1 /* xscreensaver, Copyright (c) 1993-2011 Jamie Zawinski <jwz@jwz.org>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
12 #ifndef __XSCREENSAVER_TYPES_H__
13 #define __XSCREENSAVER_TYPES_H__
15 typedef struct saver_info saver_info;
18 ul_read, /* reading input or ready to do so */
19 ul_success, /* auth success, unlock */
20 ul_fail, /* auth fail */
21 ul_cancel, /* user cancelled auth (pw_cancel or pw_null) */
22 ul_time, /* timed out */
23 ul_finished /* user pressed enter */
26 typedef struct screenhack screenhack;
35 RANDOM_HACKS, ONE_HACK, BLANK_ONLY, DONT_BLANK, RANDOM_HACKS_SAME
39 TEXT_DATE, TEXT_LITERAL, TEXT_FILE, TEXT_PROGRAM, TEXT_URL
45 typedef int (*auth_conv_cb_t) (
47 const struct auth_message *msg,
48 struct auth_response **resp,
51 typedef struct saver_preferences saver_preferences;
52 typedef struct saver_screen_info saver_screen_info;
53 typedef struct passwd_dialog_data passwd_dialog_data;
54 typedef struct splash_dialog_data splash_dialog_data;
55 typedef struct _monitor monitor;
58 /* This structure holds all the user-specified parameters, read from the
59 command line, the resource database, or entered through a dialog box.
61 struct saver_preferences {
63 XrmDatabase db; /* The resource database into which the
64 init file is merged, and out of which the
65 preferences are parsed. */
67 time_t init_file_date; /* The date (from stat()) of the .xscreensaver
68 file the last time this process read or
71 Bool verbose_p; /* whether to print out lots of status info */
72 Bool timestamp_p; /* whether to mark messages with a timestamp */
73 Bool capture_stderr_p; /* whether to redirect stdout/stderr */
74 Bool ignore_uninstalled_p; /* whether to avoid displaying or complaining
75 about hacks that are not on $PATH */
76 Bool debug_p; /* pay no mind to the man behind the curtain */
77 Bool xsync_p; /* whether XSynchronize has been called */
79 Bool lock_p; /* whether to lock as well as save */
81 Bool fade_p; /* whether to fade to black, if possible */
82 Bool unfade_p; /* whether to fade from black, if possible */
83 Time fade_seconds; /* how long that should take */
84 int fade_ticks; /* how many ticks should be used */
85 Bool splash_p; /* whether to do a splash screen at startup */
87 Bool install_cmap_p; /* whether we should use our own colormap
88 when using the screen's default visual. */
91 Bool quad_p; /* whether to run four savers per monitor */
94 screenhack **screenhacks; /* the programs to run */
95 int screenhacks_count;
97 saver_mode mode; /* hack-selection mode */
98 int selected_hack; /* in one_hack mode, this is the one */
100 int nice_inferior; /* nice value for subprocs */
101 int inferior_memory_limit; /* setrlimit(LIMIT_AS) value for subprocs */
103 Time initial_delay; /* how long to sleep after launch */
104 Time splash_duration; /* how long the splash screen stays up */
105 Time timeout; /* how much idle time before activation */
106 Time lock_timeout; /* how long after activation locking starts */
107 Time cycle; /* how long each hack should run */
108 Time passwd_timeout; /* how much time before pw dialog goes down */
109 Time pointer_timeout; /* how often to check mouse position */
110 Time notice_events_timeout; /* how long after window creation to select */
111 Time watchdog_timeout; /* how often to re-raise and re-blank screen */
112 int pointer_hysteresis; /* mouse motions less than N/sec are ignored */
114 Bool dpms_enabled_p; /* Whether to power down the monitor */
115 Bool dpms_quickoff_p; /* Whether to power down monitor immediately
116 in "Blank Only" mode */
117 Time dpms_standby; /* how long until monitor goes black */
118 Time dpms_suspend; /* how long until monitor power-saves */
119 Time dpms_off; /* how long until monitor powers down */
121 Bool grab_desktop_p; /* These are not used by "xscreensaver" */
122 Bool grab_video_p; /* itself: they are used by the external */
123 Bool random_image_p; /* "xscreensaver-getimage" program, and set */
124 char *image_directory; /* by the "xscreensaver-demo" configurator. */
126 text_mode tmode; /* How we generate text to display. */
127 char *text_literal; /* used when tmode is TEXT_LITERAL. */
128 char *text_file; /* used when tmode is TEXT_FILE. */
129 char *text_program; /* used when tmode is TEXT_PROGRAM. */
130 char *text_url; /* used when tmode is TEXT_URL. */
132 Bool use_xidle_extension; /* which extension to use, if possible */
133 Bool use_mit_saver_extension;
134 Bool use_sgi_saver_extension;
135 Bool use_proc_interrupts;
136 Bool use_xinput_extension;
138 Bool getviewport_full_of_lies_p; /* XFree86 bug #421 */
140 char *shell; /* where to find /bin/sh */
142 char *demo_command; /* How to enter demo mode. */
143 char *prefs_command; /* How to edit preferences. */
144 char *help_url; /* Where the help document resides. */
145 char *load_url_command; /* How one loads URLs. */
146 char *new_login_command; /* Command for the "New Login" button. */
149 /* This structure holds all the data that applies to the program as a whole,
150 or to the non-screen-specific parts of the display connection.
152 The saver_preferences structure (prefs.h) holds all the user-specified
153 parameters, read from the command line, the resource database, or entered
154 through a dialog box.
158 saver_preferences prefs;
162 saver_screen_info *screens;
163 saver_screen_info *default_screen; /* ...on which dialogs will appear. */
164 monitor **monitor_layout; /* private to screens.c */
165 Visual **best_gl_visuals; /* visuals for GL hacks on screen N */
167 /* =======================================================================
168 global connection info
169 ======================================================================= */
174 /* =======================================================================
175 server extension info
176 ======================================================================= */
178 Bool using_xidle_extension; /* which extension is being used. */
179 Bool using_mit_saver_extension; /* Note that `p->use_*' is the *request*, */
180 Bool using_sgi_saver_extension; /* and `si->using_*' is the *reality*. */
181 Bool using_proc_interrupts;
183 # ifdef HAVE_MIT_SAVER_EXTENSION
184 int mit_saver_ext_event_number;
185 int mit_saver_ext_error_number;
187 # ifdef HAVE_SGI_SAVER_EXTENSION
188 int sgi_saver_ext_event_number;
189 int sgi_saver_ext_error_number;
192 int randr_event_number;
193 int randr_error_number;
194 Bool using_randr_extension;
197 Bool using_xinput_extension; /* Note that `p->use_*' is the *request*, */
198 /* and `si->using_*' is the *reality*. */
200 int xinput_ext_event_number; /* may not be used */
201 int xinput_ext_error_number;
202 int xinput_DeviceButtonPress; /* Extension device event codes. */
203 int xinput_DeviceButtonRelease; /* Assigned by server at runtime */
204 int xinput_DeviceMotionNotify;
205 struct xinput_dev_info *xinput_devices;
206 int num_xinput_devices;
209 /* =======================================================================
211 ======================================================================= */
213 Bool screen_blanked_p; /* Whether the saver is currently active. */
214 Window mouse_grab_window; /* Window holding our mouse grab */
215 Window keyboard_grab_window; /* Window holding our keyboard grab */
216 int mouse_grab_screen; /* The screen number the mouse grab is on */
217 int keyboard_grab_screen; /* The screen number the keyboard grab is on */
218 Bool fading_possible_p; /* Whether fading to/from black is possible. */
219 Bool throttled_p; /* Whether we should temporarily just blank
220 the screen, not run hacks. (Deprecated:
221 users should use "xset dpms force off"
223 time_t blank_time; /* The time at which the screen was blanked
224 (if currently blanked) or unblanked (if
228 /* =======================================================================
229 locking and runtime privileges
230 ======================================================================= */
232 Bool locked_p; /* Whether the screen is currently locked. */
233 Bool dbox_up_p; /* Whether the demo-mode or passwd dialogs
234 are currently visible */
236 Bool locking_disabled_p; /* Sometimes locking is impossible. */
237 char *nolock_reason; /* This is why. */
239 char *orig_uid; /* What uid/gid we had at startup, before
240 discarding privileges. */
241 char *uid_message; /* Any diagnostics from our attempt to
242 discard privileges (printed only in
244 Bool dangerous_uid_p; /* Set to true if we're running as a user id
245 which is known to not be a normal, non-
248 Window passwd_dialog; /* The password dialog, if it's up. */
249 passwd_dialog_data *pw_data; /* Other info necessary to draw it. */
251 int unlock_failures; /* Counts failed login attempts while the
254 char *unlock_typeahead; /* If the screen is locked, and the user types
255 a character, we assume that it is the first
256 character of the password. It's stored here
257 for the password dialog to use to populate
260 char *user; /* The user whose session is locked. */
261 char *cached_passwd; /* Cached password, used to avoid multiple
262 prompts for password-only auth mechanisms.*/
263 unlock_state unlock_state;
265 auth_conv_cb_t unlock_cb; /* The function used to prompt for creds. */
266 void (*auth_finished_cb) (saver_info *si);
267 /* Called when authentication has finished,
268 regardless of success or failure.
272 /* =======================================================================
274 ======================================================================= */
276 Bool demoing_p; /* Whether we are demoing a single hack
279 Window splash_dialog; /* The splash dialog, if its up. */
280 splash_dialog_data *sp_data; /* Other info necessary to draw it. */
283 /* =======================================================================
285 ======================================================================= */
287 XtIntervalId lock_id; /* Timer to implement `prefs.lock_timeout' */
288 XtIntervalId cycle_id; /* Timer to implement `prefs.cycle' */
289 XtIntervalId timer_id; /* Timer to implement `prefs.timeout' */
290 XtIntervalId watchdog_id; /* Timer to implement `prefs.watchdog */
291 XtIntervalId check_pointer_timer_id; /* `prefs.pointer_timeout' */
293 XtIntervalId de_race_id; /* Timer to make sure screen un-blanks */
296 time_t last_activity_time; /* Used only when no server exts. */
297 time_t last_wall_clock_time; /* Used to detect laptop suspend. */
298 saver_screen_info *last_activity_screen;
300 Bool emergency_lock_p; /* Set when the wall clock has jumped
301 (presumably due to laptop suspend) and we
302 need to lock down right away instead of
303 waiting for the lock timer to go off. */
306 /* =======================================================================
308 ======================================================================= */
310 int selection_mode; /* Set to -1 if the NEXT ClientMessage has just
311 been received; set to -2 if PREV has just
312 been received; set to N if SELECT or DEMO N
313 has been received. (This is kind of nasty.)
316 /* =======================================================================
318 ======================================================================= */
320 XtIntervalId stderr_popup_timer;
324 /* This structure holds all the data that applies to the screen-specific parts
325 of the display connection; if the display has multiple screens, there will
326 be one of these for each screen.
328 struct saver_screen_info {
331 int number; /* The internal ordinal of this screen,
332 counting Xinerama rectangles as separate
334 int real_screen_number; /* The number of the underlying X screen on
335 which this rectangle lies. */
336 Screen *screen; /* The X screen in question. */
338 int x, y, width, height; /* The size and position of this rectangle
339 on its underlying X screen. */
341 Bool real_screen_p; /* This will be true of exactly one ssi per
344 Widget toplevel_shell;
346 /* =======================================================================
348 ======================================================================= */
350 Window screensaver_window; /* The window that will impersonate the root,
351 when the screensaver activates. Note that
352 the window stored here may change, as we
353 destroy and recreate it on different
355 Colormap cmap; /* The colormap that goes with the window. */
356 Bool install_cmap_p; /* Whether this screen should have its own
357 colormap installed, for whichever of several
358 reasons. This is definitive (even a false
359 value here overrides prefs->install_cmap_p.)
361 Visual *current_visual; /* The visual of the window. */
362 int current_depth; /* How deep the visual (and the window) are. */
364 Visual *default_visual; /* visual to use when none other specified */
366 Window real_vroot; /* The original virtual-root window. */
367 Window real_vroot_value; /* What was in the __SWM_VROOT property. */
369 Cursor cursor; /* A blank cursor that goes with the
371 unsigned long black_pixel; /* Black, allocated from `cmap'. */
373 int blank_vp_x, blank_vp_y; /* Where the virtual-scrolling viewport was
374 when the screen went blank. We need to
375 prevent the X server from letting the mouse
376 bump the edges to scroll while the screen
377 is locked, so we reset to this when it has
378 moved, and the lock dialog is up... */
380 # ifdef HAVE_MIT_SAVER_EXTENSION
381 Window server_mit_saver_window;
385 /* =======================================================================
387 ======================================================================= */
389 Colormap demo_cmap; /* The colormap that goes with the dialogs:
390 this might be the same as `cmap' so care
391 must be taken not to free it while it's
394 /* =======================================================================
396 ======================================================================= */
398 int poll_mouse_last_root_x; /* Used only when no server exts. */
399 int poll_mouse_last_root_y;
400 Window poll_mouse_last_child;
401 unsigned int poll_mouse_last_mask;
402 time_t poll_mouse_last_time;
405 /* =======================================================================
407 ======================================================================= */
409 int current_hack; /* Index into `prefs.screenhacks' */
414 int stderr_line_height;
415 XFontStruct *stderr_font;
417 Window stderr_overlay_window; /* Used if the server has overlay planes */
418 Colormap stderr_cmap;
422 #endif /* __XSCREENSAVER_TYPES_H__ */