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 [];
77 # define bcopy(from,to,size) memcpy((to),(from),(size))
78 # define bzero(addr,size) memset((addr),0,(size))
80 # if defined(SVR4) || defined(SYSV)
81 extern int rand (void);
82 extern void srand (unsigned int);
83 # define random() rand()
84 # define srandom(i) srand((unsigned int)(i))
85 # else /* !totally-losing-SYSV */
86 extern long random (void);
87 extern void srandom (int);
88 # endif /* !totally-losing-SYSV */
97 extern void screenhack P((Display*,Window));
99 #define usleep screenhack_usleep
101 extern void screenhack_usleep P((unsigned long));
102 extern char *get_string_resource P((char*,char*));
103 extern Bool get_boolean_resource P((char*,char*));
104 extern int get_integer_resource P((char*,char*));
105 extern double get_float_resource P((char*,char*));
106 extern unsigned int get_pixel_resource P((char*,char*,Display*,Colormap));
107 extern unsigned int get_minutes_resource P((char*,char*));
108 extern unsigned int get_seconds_resource P((char*,char*));
110 extern Visual *get_visual_resource P((Display *, char *, char *));
111 extern int get_visual_depth P((Display *, Visual *));
113 extern void hsv_to_rgb P((int,double,double,unsigned short*,
114 unsigned short*,unsigned short*));
115 extern void rgb_to_hsv P((unsigned short,unsigned short,unsigned short,
116 int*,double*,double*));
117 extern void cycle_hue P((XColor*,int));
119 extern void make_color_ramp P((int h1, double s1, double v1,
120 int h2, double s2, double v2,
121 XColor *pixels, int npixels));
123 extern Pixmap grab_screen_image P((Display *dpy, Window window, int root_p));
125 static double _frand_tmp_;
127 (_frand_tmp_ = (((double) random()) / \
128 (((double) ((unsigned int)~0)) / ((double) (f+f)))), \
129 _frand_tmp_ < 0 ? -_frand_tmp_ : _frand_tmp_)
132 #endif /* _SCREENHACK_H_ */