1 /* xscreensaver, Copyright (c) 1993-1997 Jamie Zawinski <jwz@netscape.com>
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_H__
13 #define __XSCREENSAVER_H__
23 extern char *progname;
24 extern char *progclass;
26 typedef struct saver_preferences saver_preferences;
27 typedef struct saver_info saver_info;
28 typedef struct saver_screen_info saver_screen_info;
32 #define countof(x) (sizeof((x))/sizeof((*x)))
36 /* This structure holds all the user-specified parameters, read from the
37 command line, the resource database, or entered through a dialog box.
39 struct saver_preferences {
41 Bool lock_p; /* whether to lock as well as save */
44 Bool fade_p; /* whether to fade to black */
45 Bool unfade_p; /* whether to fade from black */
46 int fade_seconds; /* how long that should take */
47 int fade_ticks; /* how many ticks should be used */
49 Bool install_cmap_p; /* whether we should use our own colormap
50 when using the screen's default visual. */
52 char **screenhacks; /* the programs to run */
53 int screenhacks_count;
55 int nice_inferior; /* nice value for subprocs */
57 int initial_delay; /* how long to sleep after launch */
58 Time timeout; /* how much idle time before activation */
59 Time lock_timeout; /* how long after activation locking starts */
60 Time cycle; /* how long each hack should run */
62 Time passwd_timeout; /* how much time before pw dialog goes down */
64 Time pointer_timeout; /* how often to check mouse position */
65 Time notice_events_timeout; /* how long after window creation to select */
66 Time watchdog_timeout; /* how often to re-raise and re-blank screen */
68 Bool use_xidle_extension; /* which extension to use, if possible */
69 Bool use_mit_saver_extension;
70 Bool use_sgi_saver_extension;
72 char *shell; /* where to find /bin/sh */
77 /* This structure holds all the data that applies to the program as a whole,
78 or to the non-screen-specific parts of the display connection.
82 saver_preferences prefs;
85 saver_screen_info *screens;
86 saver_screen_info *default_screen; /* ...on which dialogs will appear. */
88 /* =======================================================================
89 global connection info
90 ======================================================================= */
96 /* =======================================================================
98 ======================================================================= */
100 # ifdef HAVE_MIT_SAVER_EXTENSION
101 int mit_saver_ext_event_number;
102 int mit_saver_ext_error_number;
104 # ifdef HAVE_SGI_SAVER_EXTENSION
105 int sgi_saver_ext_event_number;
106 int sgi_saver_ext_error_number;
110 /* =======================================================================
112 ======================================================================= */
114 Bool screen_blanked_p; /* Whether the saver is currently active. */
117 /* =======================================================================
119 ======================================================================= */
121 Bool locking_disabled_p; /* Sometimes locking is impossible. */
122 char *nolock_reason; /* This is why. */
123 Bool locked_p; /* Whether the screen is currently locked. */
124 Bool dbox_up_p; /* Whether the demo-mode or passwd dialogs
125 are currently visible */
128 /* =======================================================================
130 ======================================================================= */
132 Bool demo_mode_p; /* Whether demo-mode is active */
133 char *demo_hack; /* The hack that has been selected from the
134 dialog box, which should be run next. */
137 /* =======================================================================
139 ======================================================================= */
141 XtIntervalId lock_id; /* Timer to implement `prefs.lock_timeout' */
142 XtIntervalId cycle_id; /* Timer to implement `prefs.cycle' */
143 XtIntervalId timer_id; /* Timer to implement `prefs.timeout' */
144 XtIntervalId watchdog_id; /* Timer to implement `prefs.watchdog */
145 XtIntervalId check_pointer_timer_id; /* `prefs.pointer_timeout' */
147 time_t last_activity_time; /* Used only when no server exts. */
148 saver_screen_info *last_activity_screen;
151 /* =======================================================================
153 ======================================================================= */
155 int next_mode_p; /* Set to 1 if the NEXT ClientMessage has just
156 been received; set to 2 if PREV has just
157 been received. (#### This is nasty.) */
159 /* =======================================================================
161 ======================================================================= */
163 XtIntervalId stderr_popup_timer;
168 /* This structure holds all the data that applies to the screen-specific parts
169 of the display connection; if the display has multiple screens, there will
170 be one of these for each screen.
172 struct saver_screen_info {
176 Widget toplevel_shell;
178 /* =======================================================================
180 ======================================================================= */
182 Window screensaver_window; /* The window that will impersonate the root,
183 when the screensaver activates. Note that
184 the window stored here may change, as we
185 destroy and recreate it on different
187 Colormap cmap; /* The colormap that goes with the window. */
188 Bool install_cmap_p; /* whether we should use our own colormap.
189 This can be overridden on a per-hack basis.
191 Visual *current_visual; /* The visual of the window. */
192 Visual *default_visual; /* visual to use when none other specified */
193 int current_depth; /* How deep the visual (and the window) are. */
195 Window real_vroot; /* The original virtual-root window. */
196 Window real_vroot_value; /* What was in the __SWM_VROOT property. */
198 Cursor cursor; /* A blank cursor that goes with the
200 unsigned long black_pixel; /* Black, allocated from `cmap'. */
202 # ifdef HAVE_MIT_SAVER_EXTENSION
203 Window server_mit_saver_window;
207 /* =======================================================================
209 ======================================================================= */
211 Colormap demo_cmap; /* The colormap that goes with the dialogs:
212 this might be the same as `cmap' so care
213 must be taken not to free it while it's
216 /* =======================================================================
218 ======================================================================= */
220 int poll_mouse_last_root_x; /* Used only when no server exts. */
221 int poll_mouse_last_root_y;
222 Window poll_mouse_last_child;
223 unsigned int poll_mouse_last_mask;
226 /* =======================================================================
228 ======================================================================= */
230 int current_hack; /* Index into `prefs.screenhacks' */
235 int stderr_line_height;
236 XFontStruct *stderr_font;
238 Window stderr_overlay_window; /* Used if the server has overlay planes */
239 Colormap stderr_cmap;
245 /* =======================================================================
246 server extensions and virtual roots
247 ======================================================================= */
249 extern void restore_real_vroot (saver_info *si);
250 extern void disable_builtin_screensaver (saver_info *si, Bool turn_off_p);
251 extern void ensure_no_screensaver_running (Display *, Screen *);
253 #ifdef HAVE_MIT_SAVER_EXTENSION
254 extern Bool query_mit_saver_extension (saver_info *);
256 #ifdef HAVE_SGI_SAVER_EXTENSION
257 extern Bool query_sgi_saver_extension (saver_info *);
261 /* =======================================================================
263 ======================================================================= */
265 extern void initialize_screensaver_window (saver_info *si);
266 extern void raise_window (saver_info *si,
267 Bool inhibit_fade, Bool between_hacks_p,
269 extern void blank_screen (saver_info *si);
270 extern void unblank_screen (saver_info *si);
271 extern void grab_keyboard_and_mouse (Display *, Window, Cursor);
272 extern void ungrab_keyboard_and_mouse (Display *dpy);
274 /* =======================================================================
276 ======================================================================= */
279 extern Bool unlock_p (saver_info *si);
280 extern create_passwd_dialog (Widget, Visual *, Colormap);
281 extern Bool lock_init (int argc, char **argv);
282 extern Bool passwd_valid_p (const char *typed_passwd);
285 /* =======================================================================
287 ======================================================================= */
290 extern void demo_mode (saver_info *si);
291 extern void demo_mode_restart_process (saver_info *si);
292 extern create_demo_dialog (Widget, Visual *, Colormap);
293 extern create_resources_dialog (Widget, Visual *, Colormap);
296 #if !defined(NO_LOCKING) || !defined(NO_DEMO_MODE)
297 extern void pop_up_dialog_box (Widget dialog, Widget form, int where);
298 extern void format_into_label (Widget label, const char *arg);
299 extern void steal_focus_and_colormap (Widget dialog);
303 extern void disable_motif_drag_and_drop(Widget w);
307 /* =======================================================================
309 ======================================================================= */
311 extern void start_notice_events_timer (saver_info *, Window);
312 extern void cycle_timer (XtPointer si, XtIntervalId *id);
313 extern void activate_lock_timer (XtPointer si, XtIntervalId *id);
314 extern void reset_watchdog_timer (saver_info *si, Bool on_p);
315 extern void idle_timer (XtPointer si, XtIntervalId *id);
316 extern void sleep_until_idle (saver_info *si, Bool until_idle_p);
318 /* =======================================================================
320 ======================================================================= */
322 extern Bool handle_clientmessage (saver_info *, XEvent *, Bool);
324 /* =======================================================================
326 ======================================================================= */
328 extern void init_sigchld (void);
329 extern void spawn_screenhack (saver_info *si, Bool first_time_p);
330 extern void kill_screenhack (saver_info *si);
331 extern void suspend_screenhack (saver_info *si, Bool suspend_p);
332 extern Bool screenhack_running_p (saver_info *si);
333 extern void emergency_kill_subproc (saver_info *si);
334 extern Bool select_visual (saver_screen_info *ssi, const char *visual_name);
335 extern const char *signal_name (int signal);
337 /* =======================================================================
339 ======================================================================= */
343 # define hack_uid_warn()
344 #else /* !NO_SETUID */
345 extern void hack_uid (saver_info *si);
346 extern void hack_uid_warn (saver_info *si);
347 #endif /* NO_SETUID */
349 /* =======================================================================
351 ======================================================================= */
353 extern FILE *real_stderr;
354 extern FILE *real_stdout;
355 extern void initialize_stderr (saver_info *si);
356 extern void reset_stderr (saver_screen_info *ssi);
357 extern void clear_stderr (saver_screen_info *ssi);
359 /* =======================================================================
361 ======================================================================= */
363 extern void save_argv (int argc, char **argv);
364 extern void saver_exit (saver_info *si, int status);
365 extern void restart_process (saver_info *si);
367 extern int saver_ehandler (Display *dpy, XErrorEvent *error);
368 extern int BadWindow_ehandler (Display *dpy, XErrorEvent *error);
369 extern Bool window_exists_p (Display *dpy, Window window);
370 extern char *timestring (void);
372 extern Atom XA_VROOT, XA_XSETROOT_ID;
373 extern Atom XA_SCREENSAVER_VERSION, XA_SCREENSAVER_ID;
374 extern Atom XA_SCREENSAVER_TIME;
376 #endif /* __XSCREENSAVER_H__ */