+#include "prefs.h"
+
+extern char *progname;
+extern char *progclass;
+
+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 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;
+ saver_preferences prefs;
+
+ int nscreens;
+ saver_screen_info *screens;
+ saver_screen_info *default_screen; /* ...on which dialogs will appear. */
+
+
+ /* =======================================================================
+ global connection info
+ ======================================================================= */
+
+ XtAppContext app;
+ Display *dpy;
+
+ /* =======================================================================
+ server extension info
+ ======================================================================= */
+
+ Bool xinerama_p; /* Whether Xinerama is in use. */
+ 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;
+# endif
+# ifdef HAVE_SGI_SAVER_EXTENSION
+ int sgi_saver_ext_event_number;
+ int sgi_saver_ext_error_number;
+# endif
+# ifdef HAVE_RANDR
+ int randr_event_number;
+ int randr_error_number;
+# endif
+
+
+ /* =======================================================================
+ blanking
+ ======================================================================= */
+
+ Bool screen_blanked_p; /* Whether the saver is currently active. */
+ Window mouse_grab_window; /* Window holding our mouse grab */
+ Window keyboard_grab_window; /* Window holding our keyboard grab */
+ int mouse_grab_screen; /* The screen number the mouse grab is on */
+ int keyboard_grab_screen; /* The screen number the keyboard grab is on */
+ Bool fading_possible_p; /* Whether fading to/from black is possible. */
+ Bool throttled_p; /* Whether we should temporarily just blank
+ the screen, not run hacks. (Deprecated:
+ users should use "xset dpms force off"
+ instead.) */
+ time_t blank_time; /* The time at which the screen was blanked
+ (if currently blanked) or unblanked (if
+ not blanked.) */
+
+
+ /* =======================================================================
+ locking and runtime privileges
+ ======================================================================= */
+
+ Bool locked_p; /* Whether the screen is currently locked. */
+ Bool dbox_up_p; /* Whether the demo-mode or passwd dialogs
+ are currently visible */
+
+ Bool locking_disabled_p; /* Sometimes locking is impossible. */
+ char *nolock_reason; /* This is why. */
+
+ char *orig_uid; /* What uid/gid we had at startup, before
+ discarding privileges. */
+ char *uid_message; /* Any diagnostics from our attempt to
+ 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. */
+
+ Window passwd_dialog; /* The password dialog, if its up. */
+ passwd_dialog_data *pw_data; /* Other info necessary to draw it. */
+
+ int unlock_failures; /* Counts failed login attempts while the
+ screen is locked. */
+
+ char *unlock_typeahead; /* If the screen is locked, and the user types
+ a character, we assume that it is the first
+ character of the password. It's stored here
+ for the password dialog to use to populate
+ itself. */
+
+
+ /* =======================================================================
+ demoing
+ ======================================================================= */
+
+ 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
+ ======================================================================= */
+
+ XtIntervalId lock_id; /* Timer to implement `prefs.lock_timeout' */
+ XtIntervalId cycle_id; /* Timer to implement `prefs.cycle' */
+ XtIntervalId timer_id; /* Timer to implement `prefs.timeout' */
+ XtIntervalId watchdog_id; /* Timer to implement `prefs.watchdog */
+ XtIntervalId check_pointer_timer_id; /* `prefs.pointer_timeout' */
+
+ XtIntervalId de_race_id; /* Timer to make sure screen un-blanks */
+ int de_race_ticks;
+
+ time_t last_activity_time; /* Used only when no server exts. */
+ time_t last_wall_clock_time; /* Used to detect laptop suspend. */
+ saver_screen_info *last_activity_screen;
+
+ Bool emergency_lock_p; /* Set when the wall clock has jumped
+ (presumably due to laptop suspend) and we
+ need to lock down right away instead of
+ waiting for the lock timer to go off. */
+
+
+ /* =======================================================================
+ remote control
+ ======================================================================= */
+
+ 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
+ ======================================================================= */
+
+ XtIntervalId stderr_popup_timer;
+
+};
+
+
+/* This structure holds all the data that applies to the screen-specific parts
+ of the display connection; if the display has multiple screens, there will
+ be one of these for each screen.
+ */
+struct saver_screen_info {
+ saver_info *global;
+
+ int number; /* The internal ordinal of this screen,
+ counting Xinerama rectangles as separate
+ screens. */
+ int real_screen_number; /* The number of the underlying X screen on
+ which this rectangle lies. */
+ Screen *screen; /* The X screen in question. */
+
+ int x, y, width, height; /* The size and position of this rectangle
+ on its underlying X screen. */
+
+ Bool real_screen_p; /* This will be true of exactly one ssi per
+ X screen. */
+
+ Widget toplevel_shell;
+
+ /* =======================================================================
+ blanking
+ ======================================================================= */
+
+ Window screensaver_window; /* The window that will impersonate the root,
+ when the screensaver activates. Note that
+ the window stored here may change, as we
+ destroy and recreate it on different
+ visuals. */
+ Colormap cmap; /* The colormap that goes with the window. */
+ 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. */
+ int current_depth; /* How deep the visual (and the window) are. */