3
* This file is part of XScreenSaver,
4
* Copyright (c) 1993-2004 Jamie Zawinski <jwz@jwz.org>
6
* Permission to use, copy, modify, distribute, and sell this software and its
7
* documentation for any purpose is hereby granted without fee, provided that
8
* the above copyright notice appear in all copies and that both that
9
* copyright notice and this permission notice appear in supporting
10
* documentation. No representations are made about the suitability of this
11
* software for any purpose. It is provided "as is" without express or
18
typedef struct saver_info saver_info;
20
/* Unlock states. Old pw_* equivalents in square brackets:
21
* ul_read - reading input (or ready to do so) [pw_read]
22
* ul_success - auth success, unlock the screen [pw_ok]
23
* ul_fail - authentication failed [pw_fail]
24
* ul_cancel - user cancelled auth [pw_cancel or pw_null]
25
* ul_time - timed out, user took too long [pw_time]
26
* ul_finished - user pressed enter on the current prompt, process input
28
enum unlock_state { ul_read, ul_success, ul_fail, ul_cancel, ul_time, ul_finished };
30
typedef struct screenhack screenhack;
39
RANDOM_HACKS, ONE_HACK, BLANK_ONLY, DONT_BLANK, RANDOM_HACKS_SAME
43
TEXT_DATE, TEXT_LITERAL, TEXT_FILE, TEXT_PROGRAM, TEXT_URL
49
typedef int (*auth_conv_cb_t) (
51
const struct auth_message *msg,
52
struct auth_response **resp,
55
typedef struct saver_preferences saver_preferences;
56
typedef struct saver_screen_info saver_screen_info;
57
typedef struct passwd_dialog_data passwd_dialog_data;
58
typedef struct splash_dialog_data splash_dialog_data;
61
/* This structure holds all the user-specified parameters, read from the
62
command line, the resource database, or entered through a dialog box.
64
struct saver_preferences {
66
XrmDatabase db; /* The resource database into which the
67
init file is merged, and out of which the
68
preferences are parsed. */
70
time_t init_file_date; /* The date (from stat()) of the .xscreensaver
71
file the last time this process read or
74
Bool verbose_p; /* whether to print out lots of status info */
75
Bool timestamp_p; /* whether to mark messages with a timestamp */
76
Bool capture_stderr_p; /* whether to redirect stdout/stderr */
77
Bool ignore_uninstalled_p; /* whether to avoid displaying or complaining
78
about hacks that are not on $PATH */
79
Bool debug_p; /* pay no mind to the man behind the curtain */
80
Bool xsync_p; /* whether XSynchronize has been called */
82
Bool lock_p; /* whether to lock as well as save */
84
Bool fade_p; /* whether to fade to black, if possible */
85
Bool unfade_p; /* whether to fade from black, if possible */
86
Time fade_seconds; /* how long that should take */
87
int fade_ticks; /* how many ticks should be used */
88
Bool splash_p; /* whether to do a splash screen at startup */
90
Bool install_cmap_p; /* whether we should use our own colormap
91
when using the screen's default visual. */
94
Bool quad_p; /* whether to run four savers per monitor */
97
screenhack **screenhacks; /* the programs to run */
98
int screenhacks_count;
100
saver_mode mode; /* hack-selection mode */
101
int selected_hack; /* in one_hack mode, this is the one */
103
int nice_inferior; /* nice value for subprocs */
104
int inferior_memory_limit; /* setrlimit(LIMIT_AS) value for subprocs */
106
Time initial_delay; /* how long to sleep after launch */
107
Time splash_duration; /* how long the splash screen stays up */
108
Time timeout; /* how much idle time before activation */
109
Time lock_timeout; /* how long after activation locking starts */
110
Time cycle; /* how long each hack should run */
111
Time passwd_timeout; /* how much time before pw dialog goes down */
112
Time pointer_timeout; /* how often to check mouse position */
113
Time notice_events_timeout; /* how long after window creation to select */
114
Time watchdog_timeout; /* how often to re-raise and re-blank screen */
115
int pointer_hysteresis; /* mouse motions less than N/sec are ignored */
117
Bool dpms_enabled_p; /* Whether to power down the monitor */
118
Time dpms_standby; /* how long until monitor goes black */
119
Time dpms_suspend; /* how long until monitor power-saves */
120
Time dpms_off; /* how long until monitor powers down */
122
Bool grab_desktop_p; /* These are not used by "xscreensaver" */
123
Bool grab_video_p; /* itself: they are used by the external */
124
Bool random_image_p; /* "xscreensaver-getimage" program, and set */
125
char *image_directory; /* by the "xscreensaver-demo" configurator. */
127
text_mode tmode; /* How we generate text to display. */
128
char *text_literal; /* used when tmode is TEXT_LITERAL. */
129
char *text_file; /* used when tmode is TEXT_FILE. */
130
char *text_program; /* used when tmode is TEXT_PROGRAM. */
131
char *text_url; /* used when tmode is TEXT_URL. */
133
Bool use_xidle_extension; /* which extension to use, if possible */
134
Bool use_mit_saver_extension;
135
Bool use_sgi_saver_extension;
136
Bool use_proc_interrupts;
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;
161
saver_screen_info *screens;
162
saver_screen_info *default_screen; /* ...on which dialogs will appear. */
165
/* =======================================================================
166
global connection info
167
======================================================================= */
172
/* =======================================================================
173
server extension info
174
======================================================================= */
176
Bool xinerama_p; /* Whether Xinerama is in use. */
177
Bool using_xidle_extension; /* which extension is being used. */
178
Bool using_mit_saver_extension; /* Note that `p->use_*' is the *request*, */
179
Bool using_sgi_saver_extension; /* and `si->using_*' is the *reality*. */
180
Bool using_proc_interrupts;
182
# ifdef HAVE_MIT_SAVER_EXTENSION
183
int mit_saver_ext_event_number;
184
int mit_saver_ext_error_number;
186
# ifdef HAVE_SGI_SAVER_EXTENSION
187
int sgi_saver_ext_event_number;
188
int sgi_saver_ext_error_number;
191
int randr_event_number;
192
int randr_error_number;
196
/* =======================================================================
198
======================================================================= */
200
Bool screen_blanked_p; /* Whether the saver is currently active. */
201
Window mouse_grab_window; /* Window holding our mouse grab */
202
Window keyboard_grab_window; /* Window holding our keyboard grab */
203
int mouse_grab_screen; /* The screen number the mouse grab is on */
204
int keyboard_grab_screen; /* The screen number the keyboard grab is on */
205
Bool fading_possible_p; /* Whether fading to/from black is possible. */
206
Bool throttled_p; /* Whether we should temporarily just blank
207
the screen, not run hacks. (Deprecated:
208
users should use "xset dpms force off"
210
time_t blank_time; /* The time at which the screen was blanked
211
(if currently blanked) or unblanked (if
215
/* =======================================================================
216
locking and runtime privileges
217
======================================================================= */
219
Bool locked_p; /* Whether the screen is currently locked. */
220
Bool dbox_up_p; /* Whether the demo-mode or passwd dialogs
221
are currently visible */
223
Bool locking_disabled_p; /* Sometimes locking is impossible. */
224
char *nolock_reason; /* This is why. */
226
char *orig_uid; /* What uid/gid we had at startup, before
227
discarding privileges. */
228
char *uid_message; /* Any diagnostics from our attempt to
229
discard privileges (printed only in
231
Bool dangerous_uid_p; /* Set to true if we're running as a user id
232
which is known to not be a normal, non-
235
Window passwd_dialog; /* The password dialog, if it's up. */
236
passwd_dialog_data *pw_data; /* Other info necessary to draw it. */
238
int unlock_failures; /* Counts failed login attempts while the
241
char *unlock_typeahead; /* If the screen is locked, and the user types
242
a character, we assume that it is the first
243
character of the password. It's stored here
244
for the password dialog to use to populate
247
char *user; /* The user whose session is locked. */
248
char *cached_passwd; /* Cached password, used to avoid multiple
249
prompts for password-only auth mechanisms.*/
250
enum unlock_state unlock_state;
252
auth_conv_cb_t unlock_cb; /* The function used to prompt for creds. */
253
void (*auth_finished_cb) (saver_info *si);
254
/* Called when authentication has finished,
255
regardless of success or failure.
259
/* =======================================================================
261
======================================================================= */
263
Bool demoing_p; /* Whether we are demoing a single hack
266
Window splash_dialog; /* The splash dialog, if its up. */
267
splash_dialog_data *sp_data; /* Other info necessary to draw it. */
270
/* =======================================================================
272
======================================================================= */
274
XtIntervalId lock_id; /* Timer to implement `prefs.lock_timeout' */
275
XtIntervalId cycle_id; /* Timer to implement `prefs.cycle' */
276
XtIntervalId timer_id; /* Timer to implement `prefs.timeout' */
277
XtIntervalId watchdog_id; /* Timer to implement `prefs.watchdog */
278
XtIntervalId check_pointer_timer_id; /* `prefs.pointer_timeout' */
280
XtIntervalId de_race_id; /* Timer to make sure screen un-blanks */
283
time_t last_activity_time; /* Used only when no server exts. */
284
time_t last_wall_clock_time; /* Used to detect laptop suspend. */
285
saver_screen_info *last_activity_screen;
287
Bool emergency_lock_p; /* Set when the wall clock has jumped
288
(presumably due to laptop suspend) and we
289
need to lock down right away instead of
290
waiting for the lock timer to go off. */
293
/* =======================================================================
295
======================================================================= */
297
int selection_mode; /* Set to -1 if the NEXT ClientMessage has just
298
been received; set to -2 if PREV has just
299
been received; set to N if SELECT or DEMO N
300
has been received. (This is kind of nasty.)
303
/* =======================================================================
305
======================================================================= */
307
XtIntervalId stderr_popup_timer;
311
/* This structure holds all the data that applies to the screen-specific parts
312
of the display connection; if the display has multiple screens, there will
313
be one of these for each screen.
315
struct saver_screen_info {
318
int number; /* The internal ordinal of this screen,
319
counting Xinerama rectangles as separate
321
int real_screen_number; /* The number of the underlying X screen on
322
which this rectangle lies. */
323
Screen *screen; /* The X screen in question. */
325
int x, y, width, height; /* The size and position of this rectangle
326
on its underlying X screen. */
328
Bool real_screen_p; /* This will be true of exactly one ssi per
331
Widget toplevel_shell;
333
/* =======================================================================
335
======================================================================= */
337
Window screensaver_window; /* The window that will impersonate the root,
338
when the screensaver activates. Note that
339
the window stored here may change, as we
340
destroy and recreate it on different
342
Colormap cmap; /* The colormap that goes with the window. */
343
Bool install_cmap_p; /* Whether this screen should have its own
344
colormap installed, for whichever of several
345
reasons. This is definitive (even a false
346
value here overrides prefs->install_cmap_p.)
348
Visual *current_visual; /* The visual of the window. */
349
int current_depth; /* How deep the visual (and the window) are. */
351
Visual *default_visual; /* visual to use when none other specified */
352
Visual *best_gl_visual; /* visual to use for GL hacks */
354
Window real_vroot; /* The original virtual-root window. */
355
Window real_vroot_value; /* What was in the __SWM_VROOT property. */
357
Cursor cursor; /* A blank cursor that goes with the
359
unsigned long black_pixel; /* Black, allocated from `cmap'. */
361
int blank_vp_x, blank_vp_y; /* Where the virtual-scrolling viewport was
362
when the screen went blank. We need to
363
prevent the X server from letting the mouse
364
bump the edges to scroll while the screen
365
is locked, so we reset to this when it has
366
moved, and the lock dialog is up... */
368
# ifdef HAVE_MIT_SAVER_EXTENSION
369
Window server_mit_saver_window;
373
/* =======================================================================
375
======================================================================= */
377
Colormap demo_cmap; /* The colormap that goes with the dialogs:
378
this might be the same as `cmap' so care
379
must be taken not to free it while it's
382
/* =======================================================================
384
======================================================================= */
386
int poll_mouse_last_root_x; /* Used only when no server exts. */
387
int poll_mouse_last_root_y;
388
Window poll_mouse_last_child;
389
unsigned int poll_mouse_last_mask;
390
time_t poll_mouse_last_time;
393
/* =======================================================================
395
======================================================================= */
397
int current_hack; /* Index into `prefs.screenhacks' */
402
int stderr_line_height;
403
XFontStruct *stderr_font;
405
Window stderr_overlay_window; /* Used if the server has overlay planes */
406
Colormap stderr_cmap;