http://ftp.nluug.nl/pub/os/Linux/distr/pardusrepo/sources/xscreensaver-5.02.tar.gz
[xscreensaver] / driver / types.h
1 /* types.h
2  *
3  * This file is part of XScreenSaver,
4  * Copyright (c) 1993-2004 Jamie Zawinski <jwz@jwz.org>
5  *
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 
12  * implied warranty.
13  */
14
15 #ifndef TYPES_H
16 #define TYPES_H
17
18 typedef struct saver_info saver_info;
19
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
27  */
28 enum unlock_state { ul_read, ul_success, ul_fail, ul_cancel, ul_time, ul_finished };
29
30 typedef struct screenhack screenhack;
31 struct screenhack {
32   Bool enabled_p;
33   char *visual;
34   char *name;
35   char *command;
36 };
37
38 typedef enum {
39   RANDOM_HACKS, ONE_HACK, BLANK_ONLY, DONT_BLANK, RANDOM_HACKS_SAME
40 } saver_mode;
41
42 typedef enum {
43   TEXT_DATE, TEXT_LITERAL, TEXT_FILE, TEXT_PROGRAM, TEXT_URL
44 } text_mode;
45
46 struct auth_message;
47 struct auth_response;
48
49 typedef int (*auth_conv_cb_t) (
50   int num_msg,
51   const struct auth_message *msg,
52   struct auth_response **resp,
53   saver_info *si);
54
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;
59
60
61 /* This structure holds all the user-specified parameters, read from the
62    command line, the resource database, or entered through a dialog box.
63  */
64 struct saver_preferences {
65
66   XrmDatabase db;               /* The resource database into which the
67                                    init file is merged, and out of which the
68                                    preferences are parsed. */
69
70   time_t init_file_date;        /* The date (from stat()) of the .xscreensaver
71                                    file the last time this process read or
72                                    wrote it. */
73
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 */
81
82   Bool lock_p;                  /* whether to lock as well as save */
83
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 */
89
90   Bool install_cmap_p;          /* whether we should use our own colormap
91                                    when using the screen's default visual. */
92
93 # ifdef QUAD_MODE
94   Bool quad_p;                  /* whether to run four savers per monitor */
95 # endif
96
97   screenhack **screenhacks;     /* the programs to run */
98   int screenhacks_count;
99
100   saver_mode mode;              /* hack-selection mode */
101   int selected_hack;            /* in one_hack mode, this is the one */
102
103   int nice_inferior;            /* nice value for subprocs */
104   int inferior_memory_limit;    /* setrlimit(LIMIT_AS) value for subprocs */
105
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 */
116
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 */
121
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. */
126
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.     */
132
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;
137
138   Bool getviewport_full_of_lies_p; /* XFree86 bug #421 */
139
140   char *shell;                  /* where to find /bin/sh */
141
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. */
147 };
148
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.
151
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.
155  */
156 struct saver_info {
157   char *version;
158   saver_preferences prefs;
159
160   int nscreens;
161   saver_screen_info *screens;
162   saver_screen_info *default_screen;    /* ...on which dialogs will appear. */
163
164
165   /* =======================================================================
166      global connection info
167      ======================================================================= */
168
169   XtAppContext app;
170   Display *dpy;
171
172   /* =======================================================================
173      server extension info
174      ======================================================================= */
175
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;
181
182 # ifdef HAVE_MIT_SAVER_EXTENSION
183   int mit_saver_ext_event_number;
184   int mit_saver_ext_error_number;
185 # endif
186 # ifdef HAVE_SGI_SAVER_EXTENSION
187   int sgi_saver_ext_event_number;
188   int sgi_saver_ext_error_number;
189 # endif
190 # ifdef HAVE_RANDR
191   int randr_event_number;
192   int randr_error_number;
193 # endif
194
195
196   /* =======================================================================
197      blanking
198      ======================================================================= */
199
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"
209                                    instead.) */
210   time_t blank_time;            /* The time at which the screen was blanked
211                                    (if currently blanked) or unblanked (if
212                                    not blanked.) */
213
214
215   /* =======================================================================
216      locking and runtime privileges
217      ======================================================================= */
218
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 */
222
223   Bool locking_disabled_p;      /* Sometimes locking is impossible. */
224   char *nolock_reason;          /* This is why. */
225
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
230                                    -verbose mode.) */
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-
233                                    privileged user. */
234
235   Window passwd_dialog;         /* The password dialog, if it's up. */
236   passwd_dialog_data *pw_data;  /* Other info necessary to draw it. */
237
238   int unlock_failures;          /* Counts failed login attempts while the
239                                    screen is locked. */
240
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
245                                    itself. */
246
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;
251
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.
256                                    May be NULL. */
257
258
259   /* =======================================================================
260      demoing
261      ======================================================================= */
262
263   Bool demoing_p;               /* Whether we are demoing a single hack
264                                    (without UI.) */
265
266   Window splash_dialog;         /* The splash dialog, if its up. */
267   splash_dialog_data *sp_data;  /* Other info necessary to draw it. */
268
269
270   /* =======================================================================
271      timers
272      ======================================================================= */
273
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' */
279
280   XtIntervalId de_race_id;      /* Timer to make sure screen un-blanks */
281   int de_race_ticks;
282
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;
286
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. */
291
292
293   /* =======================================================================
294      remote control
295      ======================================================================= */
296
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.)
301                                  */
302
303   /* =======================================================================
304      subprocs
305      ======================================================================= */
306
307   XtIntervalId stderr_popup_timer;
308
309 };
310
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.
314  */
315 struct saver_screen_info {
316   saver_info *global;
317
318   int number;                   /* The internal ordinal of this screen,
319                                    counting Xinerama rectangles as separate
320                                    screens. */
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. */
324
325   int x, y, width, height;      /* The size and position of this rectangle
326                                    on its underlying X screen. */
327
328   Bool real_screen_p;           /* This will be true of exactly one ssi per
329                                    X screen. */
330
331   Widget toplevel_shell;
332
333   /* =======================================================================
334      blanking
335      ======================================================================= */
336
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
341                                    visuals. */
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.)
347                                  */
348   Visual *current_visual;       /* The visual of the window. */
349   int current_depth;            /* How deep the visual (and the window) are. */
350
351   Visual *default_visual;       /* visual to use when none other specified */
352   Visual *best_gl_visual;       /* visual to use for GL hacks */
353
354   Window real_vroot;            /* The original virtual-root window. */
355   Window real_vroot_value;      /* What was in the __SWM_VROOT property. */
356
357   Cursor cursor;                /* A blank cursor that goes with the
358                                    real root window. */
359   unsigned long black_pixel;    /* Black, allocated from `cmap'. */
360
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... */
367
368 # ifdef HAVE_MIT_SAVER_EXTENSION
369   Window server_mit_saver_window;
370 # endif
371
372
373   /* =======================================================================
374      demoing
375      ======================================================================= */
376
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
380                                    still in use. */
381
382   /* =======================================================================
383      timers
384      ======================================================================= */
385
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;
391
392
393   /* =======================================================================
394      subprocs
395      ======================================================================= */
396
397   int current_hack;             /* Index into `prefs.screenhacks' */
398   pid_t pid;
399
400   int stderr_text_x;
401   int stderr_text_y;
402   int stderr_line_height;
403   XFontStruct *stderr_font;
404   GC stderr_gc;
405   Window stderr_overlay_window;    /* Used if the server has overlay planes */
406   Colormap stderr_cmap;
407 };
408
409
410 #endif