09f5ea9488fa701c5dd020cf2f30cb585389b12c
[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 /* Display Power Management System (DPMS) interface. */
50 extern Bool monitor_powered_on_p (saver_info *si);
51 extern void monitor_power_on (saver_info *si);
52
53
54 /* =======================================================================
55    blanking
56    ======================================================================= */
57
58 extern Bool update_screen_layout (saver_info *si);
59 extern void initialize_screensaver_window (saver_info *si);
60 extern void initialize_screen_root_widget (saver_screen_info *ssi);
61
62 extern void raise_window (saver_info *si,
63                             Bool inhibit_fade, Bool between_hacks_p,
64                             Bool dont_clear);
65 extern Bool blank_screen (saver_info *si);
66 extern void unblank_screen (saver_info *si);
67 extern void resize_screensaver_window (saver_info *si);
68
69 extern void get_screen_viewport (saver_screen_info *ssi,
70                                  int *x_ret, int *y_ret,
71                                  int *w_ret, int *h_ret,
72                                  int target_x, int target_y,
73                                  Bool verbose_p);
74
75
76 /* =======================================================================
77    locking
78    ======================================================================= */
79
80 #ifndef NO_LOCKING
81 extern Bool unlock_p (saver_info *si);
82 extern Bool lock_priv_init (int argc, char **argv, Bool verbose_p);
83 extern Bool lock_init (int argc, char **argv, Bool verbose_p);
84 extern Bool passwd_valid_p (const char *typed_passwd, Bool verbose_p);
85 #endif /* NO_LOCKING */
86
87 extern void set_locked_p (saver_info *si, Bool locked_p);
88 extern int move_mouse_grab (saver_info *si, Window to, Cursor cursor,
89                             int to_screen_no);
90 extern int mouse_screen (saver_info *si);
91
92
93 /* =======================================================================
94    runtime privileges
95    ======================================================================= */
96
97 extern void hack_uid (saver_info *si);
98 extern void describe_uids (saver_info *si, FILE *out);
99
100 /* =======================================================================
101    demoing
102    ======================================================================= */
103
104 extern void draw_shaded_rectangle (Display *dpy, Window window,
105                                    int x, int y,
106                                    int width, int height,
107                                    int thickness,
108                                    unsigned long top_color,
109                                    unsigned long bottom_color);
110 extern int string_width (XFontStruct *font, char *s);
111
112 extern void make_splash_dialog (saver_info *si);
113 extern void handle_splash_event (saver_info *si, XEvent *e);
114
115
116 /* =======================================================================
117    timers
118    ======================================================================= */
119
120 extern void start_notice_events_timer (saver_info *, Window, Bool verbose_p);
121 extern void cycle_timer (XtPointer si, XtIntervalId *id);
122 extern void activate_lock_timer (XtPointer si, XtIntervalId *id);
123 extern void reset_watchdog_timer (saver_info *si, Bool on_p);
124 extern void idle_timer (XtPointer si, XtIntervalId *id);
125 extern void de_race_timer (XtPointer si, XtIntervalId *id);
126 extern void sleep_until_idle (saver_info *si, Bool until_idle_p);
127 extern void reset_timers (saver_info *si);
128 extern void schedule_wakeup_event (saver_info *si, Time when, Bool verbose_p);
129
130
131 /* =======================================================================
132    remote control
133    ======================================================================= */
134
135 extern Bool handle_clientmessage (saver_info *, XEvent *, Bool);
136 extern void maybe_reload_init_file (saver_info *);
137
138 /* =======================================================================
139    subprocs
140    ======================================================================= */
141
142 extern void handle_signals (saver_info *si);
143 #ifdef HAVE_SIGACTION
144  extern sigset_t block_sigchld (void);
145 #else  /* !HAVE_SIGACTION */
146  extern int block_sigchld (void);
147 #endif /* !HAVE_SIGACTION */
148 extern void unblock_sigchld (void);
149 extern void hack_environment (saver_info *si);
150 extern void hack_subproc_environment (Screen *, Window saver_window);
151 extern void init_sigchld (void);
152 extern void spawn_screenhack (saver_screen_info *ssi);
153 extern pid_t fork_and_exec (saver_screen_info *ssi, const char *command);
154 extern void kill_screenhack (saver_screen_info *ssi);
155 extern void suspend_screenhack (saver_screen_info *ssi, Bool suspend_p);
156 extern Bool screenhack_running_p (saver_info *si);
157 extern void emergency_kill_subproc (saver_info *si);
158 extern Bool select_visual (saver_screen_info *ssi, const char *visual_name);
159 extern void store_saver_status (saver_info *si);
160 extern const char *signal_name (int signal);
161
162 /* =======================================================================
163    subprocs diagnostics
164    ======================================================================= */
165
166 extern FILE *real_stderr;
167 extern FILE *real_stdout;
168 extern void stderr_log_file (saver_info *si);
169 extern void initialize_stderr (saver_info *si);
170 extern void reset_stderr (saver_screen_info *ssi);
171 extern void clear_stderr (saver_screen_info *ssi);
172 extern void shutdown_stderr (saver_info *si);
173
174
175 /* =======================================================================
176    misc
177    ======================================================================= */
178
179 extern const char *blurb (void);
180 extern void save_argv (int argc, char **argv);
181 extern void saver_exit (saver_info *si, int status, const char *core_reason);
182 extern void restart_process (saver_info *si);
183
184 extern int saver_ehandler (Display *dpy, XErrorEvent *error);
185 extern int BadWindow_ehandler (Display *dpy, XErrorEvent *error);
186 extern Bool window_exists_p (Display *dpy, Window window);
187 extern char *timestring (void);
188 extern Bool display_is_on_console_p (saver_info *si);
189 extern Visual *get_best_gl_visual (saver_info *si, Screen *screen);
190 extern void check_for_leaks (const char *where);
191 extern void describe_monitor_layout (saver_info *si);
192
193 #ifdef HAVE_XF86VMODE
194 Bool safe_XF86VidModeGetViewPort (Display *, int, int *, int *);
195 #endif /* HAVE_XF86VMODE */
196
197 extern Atom XA_VROOT, XA_XSETROOT_ID, XA_ESETROOT_PMAP_ID, XA_XROOTPMAP_ID;
198 extern Atom XA_SCREENSAVER, XA_SCREENSAVER_VERSION, XA_SCREENSAVER_ID;
199 extern Atom XA_SCREENSAVER_STATUS, XA_LOCK, XA_BLANK;
200 extern Atom XA_DEMO, XA_PREFS;
201
202 #endif /* __XSCREENSAVER_H__ */