http://ftp.x.org/contrib/applications/xscreensaver-3.10.tar.gz
[xscreensaver] / driver / xscreensaver.h
index be5d24f755bd7297ebd6719b660e2f8616b0485a..7a61d166b2d306bf69e27af82ae6f31ba3f7942d 100644 (file)
 #include <string.h>
 #include <stdio.h>
 
+#include "prefs.h"
+
 extern char *progname;
 extern char *progclass;
 
-typedef struct saver_preferences saver_preferences;
 typedef struct saver_info saver_info;
 typedef struct saver_screen_info saver_screen_info;
-
+typedef struct passwd_dialog_data passwd_dialog_data;
+typedef struct splash_dialog_data splash_dialog_data;
 
 #undef countof
 #define countof(x) (sizeof((x))/sizeof((*x)))
 
 
 
-/* This structure holds all the user-specified parameters, read from the
-   command line, the resource database, or entered through a dialog box.
- */
-struct saver_preferences {
-  Bool verbose_p;              /* whether to print out lots of status info */
-  Bool timestamp_p;            /* whether to mark messages with a timestamp */
-  Bool debug_p;                        /* pay no mind to the man behind the curtain */
-  Bool xsync_p;                        /* whether XSynchronize has been called */
-
-  Bool lock_p;                 /* whether to lock as well as save */
-  Bool fade_p;                 /* whether to fade to black */
-  Bool unfade_p;               /* whether to fade from black */
-  int fade_seconds;            /* how long that should take */
-  int fade_ticks;              /* how many ticks should be used */
-
-  Bool install_cmap_p;         /* whether we should use our own colormap
-                                  when using the screen's default visual. */
-
-  char **screenhacks;          /* the programs to run */
-  int screenhacks_count;
-
-  int nice_inferior;           /* nice value for subprocs */
-
-  int initial_delay;           /* how long to sleep after launch */
-  Time splash_duration;                /* how long the splash screen stays up */
-  Time timeout;                        /* how much idle time before activation */
-  Time lock_timeout;           /* how long after activation locking starts */
-  Time cycle;                  /* how long each hack should run */
-#ifndef NO_LOCKING
-  Time passwd_timeout;         /* how much time before pw dialog goes down */
-#endif
-  Time pointer_timeout;                /* how often to check mouse position */
-  Time notice_events_timeout;  /* how long after window creation to select */
-  Time watchdog_timeout;       /* how often to re-raise and re-blank screen */
-
-  Bool use_xidle_extension;    /* which extension to use, if possible */
-  Bool use_mit_saver_extension;
-  Bool use_sgi_saver_extension;
-
-  char *shell;                 /* where to find /bin/sh */
-
-  char *help_url;              /* Where the help document resides. */
-  char *load_url_command;      /* How one loads URLs. */
-};
-
-
 /* This structure holds all the data that applies to the program as a whole,
    or to the non-screen-specific parts of the display connection.
+
+   The saver_preferences structure (prefs.h) holds all the user-specified
+   parameters, read from the command line, the resource database, or entered
+   through a dialog box.
  */
 struct saver_info {
   char *version;
@@ -90,18 +50,23 @@ struct saver_info {
   saver_screen_info *screens;
   saver_screen_info *default_screen;   /* ...on which dialogs will appear. */
 
+
   /* =======================================================================
      global connection info
      ======================================================================= */
 
   XtAppContext app;
   Display *dpy;
-  XrmDatabase db;
 
   /* =======================================================================
      server extension info
      ======================================================================= */
 
+  Bool using_xidle_extension;     /* which extension is being used.         */
+  Bool using_mit_saver_extension;  /* Note that `p->use_*' is the *request*, */
+  Bool using_sgi_saver_extension;  /* and `si->using_*' is the *reality*.    */
+  Bool using_proc_interrupts;
+
 # ifdef HAVE_MIT_SAVER_EXTENSION
   int mit_saver_ext_event_number;
   int mit_saver_ext_error_number;
@@ -122,7 +87,7 @@ struct saver_info {
 
 
   /* =======================================================================
-     locking and runtime priveleges
+     locking and runtime privileges
      ======================================================================= */
 
   Bool locked_p;               /* Whether the screen is currently locked. */
@@ -133,28 +98,31 @@ struct saver_info {
   char *nolock_reason;         /* This is why. */
 
   char *orig_uid;              /* What uid/gid we had at startup, before
-                                  discarding priveleges. */
+                                  discarding privileges. */
   char *uid_message;           /* Any diagnostics from our attempt to
-                                  discard priveleges (printed only in
+                                  discard privileges (printed only in
                                   -verbose mode.) */
+  Bool dangerous_uid_p;                /* Set to true if we're running as a user id
+                                  which is known to not be a normal, non-
+                                  privileged user. */
 
-  /* =======================================================================
-     demoing
-     ======================================================================= */
+  Window passwd_dialog;                /* The password dialog, if its up. */
+  passwd_dialog_data *pw_data; /* Other info necessary to draw it. */
 
-  Bool demo_mode_p;            /* Whether demo-mode is active */
-  char *demo_hack;             /* The hack that has been selected from the
-                                  dialog box, which should be run next. */
+  int unlock_failures;         /* Counts failed login attempts while the
+                                  screen is locked. */
 
 
   /* =======================================================================
-     asking questions
+     demoing
      ======================================================================= */
 
-  Bool question_up_p;          /* Whether the question dialog is currently
-                                  visible. */
-  Widget question_dialog;      /* The question dialog, if any. */
-  Widget splash_dialog;                /* The splash screen window, if any. */
+  Bool demoing_p;              /* Whether we are demoing a single hack
+                                  (without UI.) */
+
+  Window splash_dialog;                /* The splash dialog, if its up. */
+  splash_dialog_data *sp_data; /* Other info necessary to draw it. */
+
 
   /* =======================================================================
      timers
@@ -174,9 +142,11 @@ struct saver_info {
      remote control
      ======================================================================= */
 
-  int next_mode_p;             /* Set to 1 if the NEXT ClientMessage has just
-                                  been received; set to 2 if PREV has just
-                                  been received.  (#### This is nasty.) */
+  int selection_mode;          /* Set to -1 if the NEXT ClientMessage has just
+                                  been received; set to -2 if PREV has just
+                                  been received; set to N if SELECT or DEMO N
+                                  has been received.  (This is kind of nasty.)
+                                */
 
   /* =======================================================================
      subprocs
@@ -207,9 +177,11 @@ struct saver_screen_info {
                                   destroy and recreate it on different
                                   visuals. */
   Colormap cmap;               /* The colormap that goes with the window. */
-  Bool install_cmap_p;         /* whether we should use our own colormap.
-                                  This can be overridden on a per-hack basis.
-                                */
+  Bool install_cmap_p;         /* Whether this screen should have its own
+                                   colormap installed, for whichever of several
+                                   reasons.  This is definitive (even a false
+                                   value here overrides prefs->install_cmap_p.)
+                                 */
   Visual *current_visual;      /* The visual of the window. */
   Visual *default_visual;      /* visual to use when none other specified */
   int current_depth;           /* How deep the visual (and the window) are. */
@@ -269,7 +241,7 @@ struct saver_screen_info {
    ======================================================================= */
 
 extern void restore_real_vroot (saver_info *si);
-extern void disable_builtin_screensaver (saver_info *si, Bool turn_off_p);
+extern void disable_builtin_screensaver (saver_info *, Bool unblank_screen_p);
 extern Bool ensure_no_screensaver_running (Display *, Screen *);
 
 #ifdef HAVE_MIT_SAVER_EXTENSION
@@ -278,6 +250,12 @@ extern Bool query_mit_saver_extension (saver_info *);
 #ifdef HAVE_SGI_SAVER_EXTENSION
 extern Bool query_sgi_saver_extension (saver_info *);
 #endif
+#ifdef HAVE_XIDLE_EXTENSION
+extern Bool query_xidle_extension (saver_info *);
+#endif
+#ifdef HAVE_PROC_INTERRUPTS
+extern Bool query_proc_interrupts_available (saver_info *, const char **why);
+#endif
 
 /* Display Power Management System (DPMS) interface. */
 extern Bool monitor_powered_on_p (saver_info *si);
@@ -292,10 +270,8 @@ extern void initialize_screensaver_window (saver_info *si);
 extern void raise_window (saver_info *si,
                            Bool inhibit_fade, Bool between_hacks_p,
                            Bool dont_clear);
-extern void blank_screen (saver_info *si);
+extern Bool blank_screen (saver_info *si);
 extern void unblank_screen (saver_info *si);
-extern void grab_keyboard_and_mouse (saver_info *si, Window, Cursor);
-extern void ungrab_keyboard_and_mouse (saver_info *si);
 
 /* =======================================================================
    locking
@@ -303,13 +279,20 @@ extern void ungrab_keyboard_and_mouse (saver_info *si);
 
 #ifndef NO_LOCKING
 extern Bool unlock_p (saver_info *si);
-extern void create_passwd_dialog (Widget, Visual *, Colormap);
-extern Bool lock_init (int argc, char **argv);
-extern Bool passwd_valid_p (const char *typed_passwd);
-#endif
+extern Bool lock_priv_init (int argc, char **argv, Bool verbose_p);
+extern Bool lock_init (int argc, char **argv, Bool verbose_p);
+extern Bool passwd_valid_p (const char *typed_passwd, Bool verbose_p);
+
+extern void make_passwd_window (saver_info *si);
+extern void draw_passwd_window (saver_info *si);
+extern void update_passwd_window (saver_info *si, const char *printed_passwd,
+                                 float ratio);
+extern void destroy_passwd_window (saver_info *si);
+
+#endif /* NO_LOCKING */
 
 /* =======================================================================
-   runtime priveleges
+   runtime privileges
    ======================================================================= */
 
 extern void hack_uid (saver_info *si);
@@ -319,29 +302,24 @@ extern void describe_uids (saver_info *si, FILE *out);
    demoing
    ======================================================================= */
 
-#ifndef NO_DEMO_MODE
-extern void demo_mode (saver_info *si);
-extern void demo_mode_restart_process (saver_info *si);
-extern void create_demo_dialog (Widget, Visual *, Colormap);
-extern void create_resources_dialog (Widget, Visual *, Colormap);
-#endif
+extern void draw_shaded_rectangle (Display *dpy, Window window,
+                                  int x, int y,
+                                  int width, int height,
+                                  int thickness,
+                                  unsigned long top_color,
+                                  unsigned long bottom_color);
+extern int string_width (XFontStruct *font, char *s);
 
-#if !defined(NO_LOCKING) || !defined(NO_DEMO_MODE)
-extern void pop_up_dialog_box (Widget dialog, Widget form, int where);
-extern void format_into_label (Widget label, const char *arg);
-extern void steal_focus_and_colormap (Widget dialog);
-#endif
-
-extern void create_splash_dialog (Widget, Visual *, Colormap);
-extern void pop_splash_dialog (saver_info *si);
-extern void roger (Widget button, XtPointer client_data, XtPointer call_data);
+extern void make_splash_dialog (saver_info *si);
+extern void handle_splash_event (saver_info *si, XEvent *e);
+extern void skull (Display *, Window, GC, GC, int, int, int, int);
 
 
 /* =======================================================================
    timers
    ======================================================================= */
 
-extern void start_notice_events_timer (saver_info *, Window);
+extern void start_notice_events_timer (saver_info *, Window, Bool verbose_p);
 extern void cycle_timer (XtPointer si, XtIntervalId *id);
 extern void activate_lock_timer (XtPointer si, XtIntervalId *id);
 extern void reset_watchdog_timer (saver_info *si, Bool on_p);
@@ -353,12 +331,14 @@ extern void sleep_until_idle (saver_info *si, Bool until_idle_p);
    ======================================================================= */
 
 extern Bool handle_clientmessage (saver_info *, XEvent *, Bool);
+extern void maybe_reload_init_file (saver_info *);
 
 /* =======================================================================
    subprocs
    ======================================================================= */
 
 extern void hack_environment (saver_info *si);
+extern void hack_subproc_environment (saver_screen_info *ssi);
 extern void init_sigchld (void);
 extern void spawn_screenhack (saver_info *si, Bool first_time_p);
 extern void kill_screenhack (saver_info *si);
@@ -378,6 +358,7 @@ extern void initialize_stderr (saver_info *si);
 extern void reset_stderr (saver_screen_info *ssi);
 extern void clear_stderr (saver_screen_info *ssi);
 
+
 /* =======================================================================
    misc
    ======================================================================= */
@@ -391,6 +372,7 @@ extern int saver_ehandler (Display *dpy, XErrorEvent *error);
 extern int BadWindow_ehandler (Display *dpy, XErrorEvent *error);
 extern Bool window_exists_p (Display *dpy, Window window);
 extern char *timestring (void);
+extern Bool display_is_on_console_p (saver_info *si);
 
 extern Atom XA_VROOT, XA_XSETROOT_ID;
 extern Atom XA_SCREENSAVER, XA_SCREENSAVER_VERSION, XA_SCREENSAVER_ID;