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