1 /* xscreensaver, Copyright (c) 1992, 1993 Jamie Zawinski <jwz@lucid.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
13 * Found in Don Hopkin`s .plan file:
15 * The color situation is a total flying circus. The X approach to
16 * device independence is to treat everything like a MicroVax framebuffer
17 * on acid. A truely portable X application is required to act like the
18 * persistent customer in the Monty Python ``Cheese Shop'' sketch. Even
19 * the simplest applications must answer many difficult questions, like:
21 * WHAT IS YOUR DISPLAY?
22 * display = XOpenDisplay("unix:0");
24 * root = RootWindow(display, DefaultScreen(display));
25 * AND WHAT IS YOUR WINDOW?
26 * win = XCreateSimpleWindow(display, root, 0, 0, 256, 256, 1,
27 * BlackPixel(display, DefaultScreen(display)),
28 * WhitePixel(display, DefaultScreen(display)))
29 * OH ALL RIGHT, YOU CAN GO ON.
31 * WHAT IS YOUR DISPLAY?
32 * display = XOpenDisplay("unix:0");
33 * WHAT IS YOUR COLORMAP?
34 * cmap = DefaultColormap(display, DefaultScreen(display));
35 * AND WHAT IS YOUR FAVORITE COLOR?
36 * favorite_color = 0; /* Black. */
37 * /* Whoops! No, I mean: */
38 * favorite_color = BlackPixel(display, DefaultScreen(display));
39 * /* AAAYYYYEEEEE!! (client dumps core & falls into the chasm) */
41 * WHAT IS YOUR DISPLAY?
42 * display = XOpenDisplay("unix:0");
43 * WHAT IS YOUR VISUAL?
44 * struct XVisualInfo vinfo;
45 * if (XMatchVisualInfo(display, DefaultScreen(display),
46 * 8, PseudoColor, &vinfo) != 0)
47 * visual = vinfo.visual;
48 * AND WHAT IS THE NET SPEED VELOCITY OF AN XConfigureWindow REQUEST?
49 * /* Is that a SubStructureRedirectMask or a ResizeRedirectMask? */
50 * WHAT??! HOW AM I SUPPOSED TO KNOW THAT?
51 * AAAAUUUGGGHHH!!!! (server dumps core & falls into the chasm)
55 #ifndef _SCREENHACK_H_
56 #define _SCREENHACK_H_
63 #include <X11/Xresource.h>
68 extern char *progname;
69 extern char *progclass;
70 extern XrmDatabase db;
71 extern XrmOptionDescRec options [];
72 extern int options_size;
73 extern char *defaults [];
76 # if defined(SVR4) || defined(SYSV)
78 extern int rand (void);
79 # define random() rand()
82 extern void srand (unsigned int);
83 # define srandom(i) srand((unsigned int)(i))
85 # else /* !totally-losing-SYSV */
87 extern long random (void);
90 extern void srandom (int);
92 # endif /* !totally-losing-SYSV */
101 extern void screenhack P((Display*,Window));
103 #define usleep screenhack_usleep
105 extern void screenhack_usleep P((unsigned long));
106 extern char *get_string_resource P((char*,char*));
107 extern Bool get_boolean_resource P((char*,char*));
108 extern int get_integer_resource P((char*,char*));
109 extern double get_float_resource P((char*,char*));
110 extern unsigned int get_pixel_resource P((char*,char*,Display*,Colormap));
111 extern unsigned int get_minutes_resource P((char*,char*));
112 extern unsigned int get_seconds_resource P((char*,char*));
114 extern Visual *get_visual_resource P((Display *, char *, char *));
115 extern int get_visual_depth P((Display *, Visual *));
117 extern void hsv_to_rgb P((int,double,double,unsigned short*,
118 unsigned short*,unsigned short*));
119 extern void rgb_to_hsv P((unsigned short,unsigned short,unsigned short,
120 int*,double*,double*));
121 extern void cycle_hue P((XColor*,int));
123 extern void make_color_ramp P((int h1, double s1, double v1,
124 int h2, double s2, double v2,
125 XColor *pixels, int npixels));
127 extern Pixmap grab_screen_image P((Display *dpy, Window window, int root_p));
129 static double _frand_tmp_;
131 (_frand_tmp_ = (((double) random()) / \
132 (((double) ((unsigned int)~0)) / ((double) (f+f)))), \
133 _frand_tmp_ < 0 ? -_frand_tmp_ : _frand_tmp_)
136 #endif /* _SCREENHACK_H_ */