| 1 | /* xscreensaver, Copyright (c) 1992-2018 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 | /* Found in Don Hopkins' .plan file: |
| 13 | * |
| 14 | * The color situation is a total flying circus. The X approach to |
| 15 | * device independence is to treat everything like a MicroVax framebuffer |
| 16 | * on acid. A truely portable X application is required to act like the |
| 17 | * persistent customer in the Monty Python ``Cheese Shop'' sketch. Even |
| 18 | * the simplest applications must answer many difficult questions, like: |
| 19 | * |
| 20 | * WHAT IS YOUR DISPLAY? |
| 21 | * display = XOpenDisplay("unix:0"); |
| 22 | * WHAT IS YOUR ROOT? |
| 23 | * root = RootWindow(display, DefaultScreen(display)); |
| 24 | * AND WHAT IS YOUR WINDOW? |
| 25 | * win = XCreateSimpleWindow(display, root, 0, 0, 256, 256, 1, |
| 26 | * BlackPixel(display, DefaultScreen(display)), |
| 27 | * WhitePixel(display, DefaultScreen(display))) |
| 28 | * OH ALL RIGHT, YOU CAN GO ON. |
| 29 | * |
| 30 | * WHAT IS YOUR DISPLAY? |
| 31 | * display = XOpenDisplay("unix:0"); |
| 32 | * WHAT IS YOUR COLORMAP? |
| 33 | * cmap = DefaultColormap(display, DefaultScreen(display)); |
| 34 | * AND WHAT IS YOUR FAVORITE COLOR? |
| 35 | * favorite_color = 0; / * Black. * / |
| 36 | * / * Whoops! No, I mean: * / |
| 37 | * favorite_color = BlackPixel(display, DefaultScreen(display)); |
| 38 | * / * AAAYYYYEEEEE!! (client dumps core & falls into the chasm) * / |
| 39 | * |
| 40 | * WHAT IS YOUR DISPLAY? |
| 41 | * display = XOpenDisplay("unix:0"); |
| 42 | * WHAT IS YOUR VISUAL? |
| 43 | * struct XVisualInfo vinfo; |
| 44 | * if (XMatchVisualInfo(display, DefaultScreen(display), |
| 45 | * 8, PseudoColor, &vinfo) != 0) |
| 46 | * visual = vinfo.visual; |
| 47 | * AND WHAT IS THE NET SPEED VELOCITY OF AN XConfigureWindow REQUEST? |
| 48 | * / * Is that a SubStructureRedirectMask or a ResizeRedirectMask? * / |
| 49 | * WHAT?! HOW AM I SUPPOSED TO KNOW THAT? |
| 50 | * AAAAUUUGGGHHH!!!! (server dumps core & falls into the chasm) |
| 51 | */ |
| 52 | |
| 53 | #ifndef __SCREENHACK_I_H__ |
| 54 | #define __SCREENHACK_I_H__ |
| 55 | |
| 56 | #ifdef HAVE_CONFIG_H |
| 57 | # include "config.h" |
| 58 | #endif /* HAVE_CONFIG_H */ |
| 59 | |
| 60 | #include <stdio.h> |
| 61 | #include <stdlib.h> |
| 62 | #include <math.h> |
| 63 | #include <time.h> |
| 64 | |
| 65 | #ifdef __hpux |
| 66 | /* Which of the ten billion standards does values.h belong to? |
| 67 | What systems always have it? */ |
| 68 | # include <values.h> |
| 69 | #endif |
| 70 | |
| 71 | #ifdef HAVE_JWXYZ |
| 72 | # include "jwxyz.h" |
| 73 | # include <string.h> /* X11/Xos.h brings this in. */ |
| 74 | /* From utils/visual.c. */ |
| 75 | # define DEFAULT_VISUAL -1 |
| 76 | # define GL_VISUAL -6 |
| 77 | #else /* real X11 */ |
| 78 | # include <X11/Xlib.h> |
| 79 | # include <X11/Xutil.h> |
| 80 | # include <X11/Xresource.h> |
| 81 | # include <X11/Xos.h> |
| 82 | #endif /* !HAVE_JWXYZ */ |
| 83 | |
| 84 | #if defined(HAVE_IPHONE) || defined(HAVE_ANDROID) |
| 85 | # define HAVE_MOBILE |
| 86 | #endif |
| 87 | |
| 88 | #ifdef HAVE_ANDROID |
| 89 | /* So that hacks' debug output shows up in logcat... */ |
| 90 | # undef fprintf |
| 91 | # define fprintf(S, ...) Log(__VA_ARGS__) |
| 92 | #endif |
| 93 | |
| 94 | /* M_PI ought to have been defined in math.h, but... */ |
| 95 | #ifndef M_PI |
| 96 | # define M_PI 3.1415926535 |
| 97 | #endif |
| 98 | |
| 99 | #ifndef M_PI_2 |
| 100 | # define M_PI_2 1.5707963267 |
| 101 | #endif |
| 102 | |
| 103 | #ifndef Button6 |
| 104 | # define Button6 6 |
| 105 | # define Button7 7 |
| 106 | #endif |
| 107 | |
| 108 | #include "yarandom.h" |
| 109 | #include "usleep.h" |
| 110 | #include "resources.h" |
| 111 | #include "hsv.h" |
| 112 | #include "colors.h" |
| 113 | #include "grabscreen.h" |
| 114 | #include "visual.h" |
| 115 | #include "fps.h" |
| 116 | #include "font-retry.h" |
| 117 | |
| 118 | #ifdef HAVE_RECORD_ANIM |
| 119 | # include "recanim.h" |
| 120 | #endif |
| 121 | |
| 122 | /* Be Posixly correct */ |
| 123 | #undef bzero |
| 124 | #define bzero __ERROR_use_memset_not_bzero_in_xscreensaver__ |
| 125 | #undef bcopy |
| 126 | #define bcopy __ERROR_use_memcpy_not_bcopy_in_xscreensaver__ |
| 127 | #undef ftime |
| 128 | #define ftime __ERROR_use_gettimeofday_not_ftime_in_xscreensaver__ |
| 129 | #undef sleep |
| 130 | #define sleep __ERROR_do_not_sleep_in_xscreensaver__ |
| 131 | |
| 132 | extern Bool mono_p; |
| 133 | |
| 134 | struct xscreensaver_function_table { |
| 135 | |
| 136 | const char *progclass; |
| 137 | const char * const *defaults; |
| 138 | const XrmOptionDescRec *options; |
| 139 | |
| 140 | void (*setup_cb) (struct xscreensaver_function_table *, void *); |
| 141 | void * setup_arg; |
| 142 | |
| 143 | void * (*init_cb) (Display *, Window); |
| 144 | unsigned long (*draw_cb) (Display *, Window, void *); |
| 145 | void (*reshape_cb) (Display *, Window, void *, |
| 146 | unsigned int w, unsigned int h); |
| 147 | Bool (*event_cb) (Display *, Window, void *, XEvent *); |
| 148 | void (*free_cb) (Display *, Window, void *); |
| 149 | void (*fps_cb) (Display *, Window, fps_state *, void *); |
| 150 | void (*fps_free) (fps_state *); |
| 151 | |
| 152 | # ifndef HAVE_JWXYZ |
| 153 | Visual * (*pick_visual_hook) (Screen *); |
| 154 | Bool (*validate_visual_hook) (Screen *, const char *, Visual *); |
| 155 | # else |
| 156 | int visual; |
| 157 | # endif |
| 158 | |
| 159 | }; |
| 160 | |
| 161 | extern const char *progname; |
| 162 | |
| 163 | #endif /* __SCREENHACK_I_H__ */ |