http://www.jwz.org/xscreensaver/xscreensaver-5.12.tar.gz
[xscreensaver] / driver / xscreensaver.h
1 /* xscreensaver, Copyright (c) 1993-2008 Jamie Zawinski <jwz@jwz.org>
2  *
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 
9  * implied warranty.
10  */
11
12 #ifndef __XSCREENSAVER_H__
13 #define __XSCREENSAVER_H__
14
15 #include <stdlib.h>
16 #ifdef HAVE_UNISTD_H
17 # include <unistd.h>
18 #endif
19
20 #include <string.h>
21 #include <stdio.h>
22
23 #ifdef HAVE_SIGACTION
24 # include <signal.h>    /* for sigset_t */
25 #endif
26
27 #include "prefs.h"
28
29 extern char *progname;
30 extern char *progclass;
31
32 #undef countof
33 #define countof(x) (sizeof((x))/sizeof((*x)))
34
35 \f
36
37 /* =======================================================================
38    server extensions and virtual roots
39    ======================================================================= */
40
41 extern Bool restore_real_vroot (saver_info *si);
42 extern void disable_builtin_screensaver (saver_info *, Bool unblank_screen_p);
43 extern Bool ensure_no_screensaver_running (Display *, Screen *);
44
45 #ifdef HAVE_PROC_INTERRUPTS
46 extern Bool query_proc_interrupts_available (saver_info *, const char **why);
47 #endif
48
49 #ifdef HAVE_XINPUT
50 extern Bool query_xinput_extension (saver_info *);
51 extern void init_xinput_extension (saver_info *si);
52 #endif
53
54 /* Display Power Management System (DPMS) interface. */
55 extern Bool monitor_powered_on_p (saver_info *si);
56 extern void monitor_power_on (saver_info *si);
57
58
59 /* =======================================================================
60    blanking
61    ======================================================================= */
62
63 extern Bool update_screen_layout (saver_info *si);
64 extern void initialize_screensaver_window (saver_info *si);
65 extern void initialize_screen_root_widget (saver_screen_info *ssi);
66
67 extern void raise_window (saver_info *si,
68                             Bool inhibit_fade, Bool between_hacks_p,
69                             Bool dont_clear);
70 extern Bool blank_screen (saver_info *si);
71 extern void unblank_screen (saver_info *si);
72 extern void resize_screensaver_window (saver_info *si);
73
74 extern void get_screen_viewport (saver_screen_info *ssi,
75                                  int *x_ret, int *y_ret,
76                                  int *w_ret, int *h_ret,
77                                  int target_x, int target_y,
78                                  Bool verbose_p);
79
80
81 /* =======================================================================
82    locking
83    ======================================================================= */
84
85 #ifndef NO_LOCKING
86 extern Bool unlock_p (saver_info *si);
87 extern Bool lock_priv_init (int argc, char **argv, Bool verbose_p);
88 extern Bool lock_init (int argc, char **argv, Bool verbose_p);
89 extern Bool passwd_valid_p (const char *typed_passwd, Bool verbose_p);
90 #endif /* NO_LOCKING */
91
92 extern void set_locked_p (saver_info *si, Bool locked_p);
93 extern int move_mouse_grab (saver_info *si, Window to, Cursor cursor,
94                             int to_screen_no);
95 extern int mouse_screen (saver_info *si);
96
97
98 /* =======================================================================
99    runtime privileges
100    ======================================================================= */
101
102 extern void hack_uid (saver_info *si);
103 extern void describe_uids (saver_info *si, FILE *out);
104
105 /* =======================================================================
106    demoing
107    ======================================================================= */
108
109 extern void draw_shaded_rectangle (Display *dpy, Window window,
110                                    int x, int y,
111                                    int width, int height,
112                                    int thickness,
113                                    unsigned long top_color,
114                                    unsigned long bottom_color);
115 extern int string_width (XFontStruct *font, char *s);
116
117 extern void make_splash_dialog (saver_info *si);
118 extern void handle_splash_event (saver_info *si, XEvent *e);
119
120
121 /* =======================================================================
122    timers
123    ======================================================================= */
124
125 extern void start_notice_events_timer (saver_info *, Window, Bool verbose_p);
126 extern void cycle_timer (XtPointer si, XtIntervalId *id);
127 extern void activate_lock_timer (XtPointer si, XtIntervalId *id);
128 extern void reset_watchdog_timer (saver_info *si, Bool on_p);
129 extern void idle_timer (XtPointer si, XtIntervalId *id);
130 extern void de_race_timer (XtPointer si, XtIntervalId *id);
131 extern void sleep_until_idle (saver_info *si, Bool until_idle_p);
132 extern void reset_timers (saver_info *si);
133 extern void schedule_wakeup_event (saver_info *si, Time when, Bool verbose_p);
134
135
136 /* =======================================================================
137    remote control
138    ======================================================================= */
139
140 extern Bool handle_clientmessage (saver_info *, XEvent *, Bool);
141 extern void maybe_reload_init_file (saver_info *);
142
143 /* =======================================================================
144    subprocs
145    ======================================================================= */
146
147 extern void handle_signals (saver_info *si);
148 #ifdef HAVE_SIGACTION
149  extern sigset_t block_sigchld (void);
150 #else  /* !HAVE_SIGACTION */
151  extern int block_sigchld (void);
152 #endif /* !HAVE_SIGACTION */
153 extern void unblock_sigchld (void);
154 extern void hack_environment (saver_info *si);
155 extern void hack_subproc_environment (Screen *, Window saver_window);
156 extern void init_sigchld (void);
157 extern void spawn_screenhack (saver_screen_info *ssi);
158 extern pid_t fork_and_exec (saver_screen_info *ssi, const char *command);
159 extern void kill_screenhack (saver_screen_info *ssi);
160 extern void suspend_screenhack (saver_screen_info *ssi, Bool suspend_p);
161 extern Bool screenhack_running_p (saver_info *si);
162 extern void emergency_kill_subproc (saver_info *si);
163 extern Bool select_visual (saver_screen_info *ssi, const char *visual_name);
164 extern void store_saver_status (saver_info *si);
165 extern const char *signal_name (int signal);
166
167 /* =======================================================================
168    subprocs diagnostics
169    ======================================================================= */
170
171 extern FILE *real_stderr;
172 extern FILE *real_stdout;
173 extern void stderr_log_file (saver_info *si);
174 extern void initialize_stderr (saver_info *si);
175 extern void reset_stderr (saver_screen_info *ssi);
176 extern void clear_stderr (saver_screen_info *ssi);
177 extern void shutdown_stderr (saver_info *si);
178
179
180 /* =======================================================================
181    misc
182    ======================================================================= */
183
184 extern const char *blurb (void);
185 extern void save_argv (int argc, char **argv);
186 extern void saver_exit (saver_info *si, int status, const char *core_reason);
187 extern void restart_process (saver_info *si);
188
189 extern int saver_ehandler (Display *dpy, XErrorEvent *error);
190 extern int BadWindow_ehandler (Display *dpy, XErrorEvent *error);
191 extern Bool window_exists_p (Display *dpy, Window window);
192 extern char *timestring (void);
193 extern Bool display_is_on_console_p (saver_info *si);
194 extern Visual *get_best_gl_visual (saver_info *si, Screen *screen);
195 extern void check_for_leaks (const char *where);
196 extern void describe_monitor_layout (saver_info *si);
197
198 #ifdef HAVE_XF86VMODE
199 Bool safe_XF86VidModeGetViewPort (Display *, int, int *, int *);
200 #endif /* HAVE_XF86VMODE */
201
202 extern Atom XA_VROOT, XA_XSETROOT_ID, XA_ESETROOT_PMAP_ID, XA_XROOTPMAP_ID;
203 extern Atom XA_SCREENSAVER, XA_SCREENSAVER_VERSION, XA_SCREENSAVER_ID;
204 extern Atom XA_SCREENSAVER_STATUS, XA_LOCK, XA_BLANK;
205 extern Atom XA_DEMO, XA_PREFS;
206
207 #endif /* __XSCREENSAVER_H__ */