From http://www.jwz.org/xscreensaver/xscreensaver-5.36.tar.gz
[xscreensaver] / jwxyz / jwxyz.h
1 /* xscreensaver, Copyright (c) 1991-2016 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 /* JWXYZ Is Not Xlib.
13
14    But it's a bunch of function definitions that bear some resemblance to
15    Xlib and that do Cocoa-ish or OpenGL-ish things that bear some resemblance
16    to the things that Xlib might have done.
17  */
18
19 #ifndef __JWXYZ_H__
20 #define __JWXYZ_H__
21
22 #include <stdlib.h> /* For abort(). */
23 #include <stdarg.h>
24
25 #if defined __FreeBSD__ || defined __MACH__ && defined __APPLE__
26 # include <sys/cdefs.h>
27 #endif
28
29 #ifndef __dead2
30 /* __dead2 is an undocumented FreeBSD-ism (and by extension, an OSX-ism),
31    normally #defined in <sys/cdefs.h>.
32  */
33 # if defined __GNUC__ || defined __clang__
34 #  define __dead2 __attribute__((__noreturn__))
35 # else
36 #  define __dead2
37 # endif
38 #endif
39
40 extern void jwxyz_abort(const char *fmt, ...) __dead2;
41 #define abort() jwxyz_abort("abort in %s:%d", __FUNCTION__, __LINE__)
42
43 typedef int Bool;
44 typedef int Status;
45 typedef void * XPointer;
46 typedef unsigned long Time;
47 typedef unsigned int KeySym;
48 typedef unsigned int KeyCode;
49 typedef unsigned int VisualID;
50 typedef unsigned long Atom; /* Must be as large as a char *. */
51
52 typedef struct jwxyz_Display            Display;
53 typedef struct jwxyz_Screen             Screen;
54 typedef struct jwxyz_Visual             Visual;
55 typedef struct jwxyz_Drawable *         Drawable;
56 typedef struct jwxyz_Colormap *         Colormap;
57 typedef struct jwxyz_GC *               GC;
58 typedef struct jwxyz_XColor             XColor;
59 typedef struct jwxyz_XGCValues          XGCValues;
60 typedef struct jwxyz_XPoint             XPoint;
61 typedef struct jwxyz_XSegment           XSegment;
62 typedef struct jwxyz_XRectangle         XRectangle;
63 typedef struct jwxyz_XArc               XArc;
64 typedef struct jwxyz_XWindowAttributes  XWindowAttributes;
65 typedef struct jwxyz_XrmOptionDescRec   XrmOptionDescRec;
66 typedef struct jwxyz_XrmDatabase *      XrmDatabase;
67 typedef struct jwxyz_XImage             XImage;
68 typedef struct jwxyz_XFontProp          XFontProp;
69 typedef struct jwxyz_XFontStruct        XFontStruct;
70 typedef struct jwxyz_Font *             Font;
71 typedef struct jwxyz_XFontSet *         XFontSet;
72 typedef struct jwxyz_XCharStruct        XCharStruct;
73 typedef struct jwxyz_XComposeStatus     XComposeStatus;
74 typedef struct jwxyz_XPixmapFormatValues XPixmapFormatValues;
75 typedef struct jwxyz_XChar2b            XChar2b;
76
77 typedef union  jwxyz_XEvent             XEvent;
78 typedef struct jwxyz_XAnyEvent          XAnyEvent;
79 typedef struct jwxyz_XKeyEvent          XKeyEvent;
80 typedef struct jwxyz_XMotionEvent       XMotionEvent;
81 typedef struct jwxyz_XButtonEvent       XButtonEvent;
82 typedef XKeyEvent                       XKeyPressedEvent;
83 typedef XKeyEvent                       XKeyReleasedEvent;
84 typedef XMotionEvent                    XPointerMovedEvent;
85 typedef XButtonEvent                    XButtonPressedEvent;
86 typedef XButtonEvent                    XButtonReleasedEvent;
87
88
89 /* Not technically Xlib... */
90 typedef struct jwxyz_GLXContext *       GLXContext;
91 typedef struct jwxyz_XtAppContext *     XtAppContext;
92 typedef struct jwxyz_XtIntervalId *     XtIntervalId;
93 typedef struct jwxyz_XtInputId *        XtInputId;
94 typedef void *                          XtPointer;
95 typedef unsigned long                   XtInputMask;
96 #define XtInputReadMask                 (1L<<0)
97 #define XtInputWriteMask                (1L<<1)
98 #define XtInputExceptMask               (1L<<2)
99 #define XtIMXEvent                      1
100 #define XtIMTimer                       2
101 #define XtIMAlternateInput              4
102 #define XtIMSignal                      8
103 #define XtIMAll (XtIMXEvent | XtIMTimer | XtIMAlternateInput | XtIMSignal)
104
105 #define True 1
106 #define TRUE 1
107 #define False 0
108 #define FALSE 0
109 #define None 0
110
111 #define Window Drawable
112 #define Pixmap Drawable
113
114 #define XrmoptionNoArg  0
115 #define XrmoptionSepArg 1
116
117 #define CoordModeOrigin         0
118 #define CoordModePrevious       1
119
120 #define LineSolid               0
121 #define LineOnOffDash           1
122 #define LineDoubleDash          2
123
124 #define CapNotLast              0
125 #define CapButt                 1
126 #define CapRound                2
127 #define CapProjecting           3
128
129 #define JoinMiter               0
130 #define JoinRound               1
131 #define JoinBevel               2
132
133 #define FillSolid               0
134 #define FillTiled               1
135 #define FillStippled            2
136 #define FillOpaqueStippled      3
137
138 #define EvenOddRule             0
139 #define WindingRule             1
140
141 #define Complex                 0
142 #define Nonconvex               1
143 #define Convex                  2
144
145 #define XYBitmap                0
146 #define XYPixmap                1
147 #define ZPixmap                 2
148
149 #define AllocNone               0
150 #define AllocAll                1
151
152 #define StaticGray              0
153 #define GrayScale               1
154 #define StaticColor             2
155 #define PseudoColor             3
156 #define TrueColor               4
157 #define DirectColor             5
158
159 #define LSBFirst                0
160 #define MSBFirst                1
161
162 #define DoRed                   (1<<0)
163 #define DoGreen                 (1<<1)
164 #define DoBlue                  (1<<2)
165
166 #define GCFunction              (1L<<0)
167 #define GCPlaneMask             (1L<<1)
168 #define GCForeground            (1L<<2)
169 #define GCBackground            (1L<<3)
170 #define GCLineWidth             (1L<<4)
171 #define GCLineStyle             (1L<<5)
172 #define GCCapStyle              (1L<<6)
173 #define GCJoinStyle             (1L<<7)
174 #define GCFillStyle             (1L<<8)
175 #define GCFillRule              (1L<<9) 
176 #define GCTile                  (1L<<10)
177 #define GCStipple               (1L<<11)
178 #define GCTileStipXOrigin       (1L<<12)
179 #define GCTileStipYOrigin       (1L<<13)
180 #define GCFont                  (1L<<14)
181 #define GCSubwindowMode         (1L<<15)
182 #define GCGraphicsExposures     (1L<<16)
183 #define GCClipXOrigin           (1L<<17)
184 #define GCClipYOrigin           (1L<<18)
185 #define GCClipMask              (1L<<19)
186 #define GCDashOffset            (1L<<20)
187 #define GCDashList              (1L<<21)
188 #define GCArcMode               (1L<<22)
189
190 #define KeyPress                2
191 #define KeyRelease              3
192 #define ButtonPress             4
193 #define ButtonRelease           5
194 #define MotionNotify            6
195 #define Expose                  12
196 #define GraphicsExpose          13
197 #define NoExpose                14
198 #define VisibilityNotify        15
199
200 #define ClipByChildren          0
201 #define IncludeInferiors        1
202
203 #define KeyPressMask            (1L<<0)
204 #define KeyReleaseMask          (1L<<1)
205 #define ButtonPressMask         (1L<<2)
206 #define ButtonReleaseMask       (1L<<3)
207 #define PointerMotionMask       (1L<<6)
208
209 #define Button1                 1
210 #define Button2                 2
211 #define Button3                 3
212 #define Button4                 4
213 #define Button5                 5
214
215 #define ShiftMask               (1<<0)
216 #define LockMask                (1<<1)
217 #define ControlMask             (1<<2)
218 #define Mod1Mask                (1<<3)
219 #define Mod2Mask                (1<<4)
220 #define Mod3Mask                (1<<5)
221 #define Mod4Mask                (1<<6)
222 #define Mod5Mask                (1<<7)
223 #define Button1Mask             (1<<8)
224 #define Button2Mask             (1<<9)
225 #define Button3Mask             (1<<10)
226 #define Button4Mask             (1<<11)
227 #define Button5Mask             (1<<12)
228
229 #define XK_Shift_L              0xFFE1
230 #define XK_Shift_R              0xFFE2
231 #define XK_Control_L            0xFFE3
232 #define XK_Control_R            0xFFE4
233 #define XK_Caps_Lock            0xFFE5
234 #define XK_Shift_Lock           0xFFE6
235 #define XK_Meta_L               0xFFE7
236 #define XK_Meta_R               0xFFE8
237 #define XK_Alt_L                0xFFE9
238 #define XK_Alt_R                0xFFEA
239 #define XK_Super_L              0xFFEB
240 #define XK_Super_R              0xFFEC
241 #define XK_Hyper_L              0xFFED
242 #define XK_Hyper_R              0xFFEE
243
244 #define XK_Home                 0xFF50
245 #define XK_Left                 0xFF51
246 #define XK_Up                   0xFF52
247 #define XK_Right                0xFF53
248 #define XK_Down                 0xFF54
249 #define XK_Prior                0xFF55
250 #define XK_Page_Up              0xFF55
251 #define XK_Next                 0xFF56
252 #define XK_Page_Down            0xFF56
253 #define XK_End                  0xFF57
254 #define XK_Begin                0xFF58
255
256 #define XK_F1                   0xFFBE
257 #define XK_F2                   0xFFBF
258 #define XK_F3                   0xFFC0
259 #define XK_F4                   0xFFC1
260 #define XK_F5                   0xFFC2
261 #define XK_F6                   0xFFC3
262 #define XK_F7                   0xFFC4
263 #define XK_F8                   0xFFC5
264 #define XK_F9                   0xFFC6
265 #define XK_F10                  0xFFC7
266 #define XK_F11                  0xFFC8
267 #define XK_F12                  0xFFC9
268
269
270 #define GXclear                 0x0             /* 0 */
271 #define GXand                   0x1             /* src AND dst */
272 // #define GXandReverse         0x2             /* src AND NOT dst */
273 #define GXcopy                  0x3             /* src */
274 // #define GXandInverted        0x4             /* NOT src AND dst */
275 // #define GXnoop               0x5             /* dst */
276 #define GXxor                   0x6             /* src XOR dst */
277 #define GXor                    0x7             /* src OR dst */
278 // #define GXnor                0x8             /* NOT src AND NOT dst */
279 // #define GXequiv              0x9             /* NOT src XOR dst */
280 // #define GXinvert             0xa             /* NOT dst */
281 // #define GXorReverse          0xb             /* src OR NOT dst */
282 // #define GXcopyInverted       0xc             /* NOT src */
283 // #define GXorInverted         0xd             /* NOT src OR dst */
284 // #define GXnand               0xe             /* NOT src OR NOT dst */
285 #define GXset                   0xf             /* 1 */
286
287 #define XA_FONT                 18
288
289 #define DefaultScreen(dpy) (0)
290 #define BlackPixelOfScreen XBlackPixelOfScreen
291 #define WhitePixelOfScreen XWhitePixelOfScreen
292 #define BlackPixel(dpy,n) BlackPixelOfScreen(ScreenOfDisplay(dpy,n))
293 #define WhitePixel(dpy,n) WhitePixelOfScreen(ScreenOfDisplay(dpy,n))
294 #define CellsOfScreen XCellsOfScreen
295 #define XFree(x) free(x)
296 #define BitmapPad(dpy) (8)
297 #define BitmapBitOrder(dpy) (MSBFirst)
298 #define ImageByteOrder(dpy) (MSBFirst)
299 #define DisplayOfScreen XDisplayOfScreen
300 #define DefaultScreenOfDisplay XDefaultScreenOfDisplay
301 #define ScreenOfDisplay(dpy,n) DefaultScreenOfDisplay(dpy)
302 #define DefaultVisualOfScreen XDefaultVisualOfScreen
303 #define DefaultColormapOfScreen(s) (0)
304 #define RootWindow XRootWindow
305 #define RootWindowOfScreen(s) RootWindow(DisplayOfScreen(s),0)
306 #define DisplayWidth XDisplayWidth
307 #define DisplayHeight XDisplayHeight
308 #define XMaxRequestSize(dpy) (65535)
309 #define XWidthOfScreen(s) (DisplayWidth(DisplayOfScreen(s),0))
310 #define XHeightOfScreen(s) (DisplayHeight(DisplayOfScreen(s),0))
311 #define XWidthMMOfScreen(s) (XDisplayWidthMM(DisplayOfScreen(s),0))
312 #define XHeightMMOfScreen(s) (XDisplayHeightMM(DisplayOfScreen(s),0))
313
314 #define ScreenCount(dpy) jwxyz_ScreenCount(dpy)
315 extern int jwxyz_ScreenCount(Display *);
316
317 extern Window XRootWindow (Display *, int screen);
318 extern Screen *XDefaultScreenOfDisplay (Display *);
319 extern Visual *XDefaultVisualOfScreen (Screen *);
320 extern Display *XDisplayOfScreen (Screen *);
321 extern int XDisplayNumberOfScreen (Screen *);
322 extern int XScreenNumberOfScreen (Screen *);
323 extern int XDisplayWidth (Display *, int);
324 extern int XDisplayHeight (Display *, int);
325 extern int XDisplayWidthMM (Display *, int);
326 extern int XDisplayHeightMM (Display *, int);
327
328 unsigned long XBlackPixelOfScreen(Screen *);
329 unsigned long XWhitePixelOfScreen(Screen *);
330 unsigned long XCellsOfScreen(Screen *);
331
332 extern int XDrawPoint (Display *, Drawable, GC, int x, int y);
333 extern int XDrawPoints (Display *, Drawable, GC, XPoint *, int n, int mode);
334 extern int XDrawSegments (Display *, Drawable, GC, XSegment *, int n);
335
336 extern GC XCreateGC (Display *, Drawable, unsigned long mask, XGCValues *);
337 extern int XChangeGC (Display *, GC, unsigned long mask, XGCValues *);
338 extern int XFreeGC (Display *, GC);
339
340 extern int XClearWindow (Display *, Window);
341 extern int XClearArea (Display *, Window, int x, int y, int w, int h,Bool exp);
342 extern int XSetWindowBackground (Display *, Window, unsigned long);
343 extern Status XGetWindowAttributes (Display *, Window, XWindowAttributes *);
344 extern Status XGetGeometry (Display *, Drawable, Window *root_ret,
345                             int *x_ret, int *y_ret, 
346                             unsigned int *w_ret, unsigned int *h_ret,
347                             unsigned int *bw_ret, unsigned int *depth_ret);
348 extern Status XAllocColor (Display *, Colormap, XColor *);
349 extern Status XAllocColorCells (Display *, Colormap, Bool contig,
350                                 unsigned long *pmret, unsigned int npl,
351                                 unsigned long *pxret, unsigned int npx);
352 extern int XStoreColors (Display *, Colormap, XColor *, int n);
353 extern int XStoreColor (Display *, Colormap, XColor *);
354 extern Status XParseColor(Display *, Colormap, const char *spec, XColor *ret);
355 extern Status XAllocNamedColor (Display *, Colormap, char *name,
356                                 XColor *screen_ret, XColor *exact_ret);
357 extern int XQueryColor (Display *, Colormap, XColor *);
358 extern int XQueryColors(Display *, Colormap colormap, XColor *, int ncolors);
359
360 extern int XSetForeground (Display *, GC, unsigned long);
361 extern int XSetBackground (Display *, GC, unsigned long);
362 extern int XSetFunction (Display *, GC, int);
363 extern int XSetSubwindowMode (Display *, GC, int);
364 extern int XSetLineAttributes (Display *, GC, unsigned int line_width,
365                                int line_style, int cap_style, int join_style);
366 extern int XSetClipMask (Display *, GC, Pixmap);
367 extern int XSetClipOrigin (Display *, GC, int x, int y);
368 extern int jwxyz_XSetAlphaAllowed (Display *, GC, Bool);
369 extern int jwxyz_XSetAntiAliasing (Display *, GC, Bool);
370
371 extern int XFlush (Display *);
372 extern int XSync (Display *, Bool);
373 extern int XFreeColors (Display *, Colormap, unsigned long *px, int n,
374                         unsigned long planes);
375 extern int XFillPolygon (Display *, Drawable, GC, 
376                          XPoint * points, int npoints, int shape, int mode);
377 extern int XCopyArea (Display *, Drawable src, Drawable dest, GC, 
378                       int src_x, int src_y, 
379                       unsigned int width, unsigned int height, 
380                       int dest_x, int dest_y);
381 extern int XCopyPlane (Display *, Drawable, Drawable, GC,
382                        int src_x, int src_y,
383                        unsigned width, int height,
384                        int dest_x, int dest_y,
385                        unsigned long plane);
386
387 extern int XDrawLine (Display *, Drawable, GC, int x1, int y1, int x2, int y2);
388 extern int XDrawLines (Display *, Drawable, GC, XPoint *, int n, int mode);
389 extern int XDrawArc (Display *, Drawable, GC, int x, int y, 
390                      unsigned int width, unsigned int height,
391                      int angle1, int angle2);
392 extern int XFillArc (Display *, Drawable, GC, int x, int y, 
393                      unsigned int width, unsigned int height,
394                      int angle1, int angle2);
395 extern int XDrawArcs (Display *, Drawable, GC, XArc *arcs, int narcs);
396 extern int XFillArcs (Display *, Drawable, GC, XArc *arcs, int narcs);
397 extern int XDrawRectangle (Display *, Drawable, GC, int x, int y, 
398                            unsigned int width, unsigned int height);
399 extern int XFillRectangle (Display *, Drawable, GC, int x, int y, 
400                            unsigned int width, unsigned int height);
401 extern int XFillRectangles (Display *, Drawable, GC, XRectangle *, int n);
402
403 extern int XDrawString (Display *, Drawable, GC, int x, int y, const char *,
404                         int len);
405 extern int XDrawImageString (Display *, Drawable, GC, int x, int y, 
406                              const char *, int len);
407 extern int XDrawString16 (Display *, Drawable, GC, int x, int y,
408                           const XChar2b *, int len);
409
410 extern Bool XQueryPointer (Display *, Window, Window *root_ret,
411                            Window *child_ret,
412                            int *root_x_ret, int *root_y_ret,
413                            int *win_x_ret, int *win_y_ret,
414                            unsigned int *mask_ret);
415 extern int XLookupString (XKeyEvent *, char *ret, int size, KeySym *ks_ret,
416                           XComposeStatus *);
417 extern KeySym XKeycodeToKeysym (Display *, KeyCode, int index);
418
419 extern Status XInitImage (XImage *);
420 extern XImage *XCreateImage (Display *, Visual *, unsigned int depth,
421                              int format, int offset, char *data,
422                              unsigned int width, unsigned int height,
423                              int bitmap_pad, int bytes_per_line);
424 extern XImage *XSubImage (XImage *, int x, int y, 
425                           unsigned int w, unsigned int h);
426
427 extern unsigned long XGetPixel (XImage *, int x, int y);
428 extern int XPutPixel (XImage *, int x, int y, unsigned long);
429 extern int XDestroyImage (XImage *);
430 extern int XPutImage (Display *, Drawable, GC, XImage *, 
431                       int src_x, int src_y, int dest_x, int dest_y,
432                       unsigned int w, unsigned int h);
433 extern XImage *XGetImage (Display *, Drawable, int x, int y,
434                           unsigned int w, unsigned int h,
435                           unsigned long pm, int fmt);
436 extern Pixmap XCreatePixmapFromBitmapData (Display *, Drawable,
437                                            const char *data,
438                                            unsigned int w, unsigned int h,
439                                            unsigned long fg,
440                                            unsigned int bg,
441                                            unsigned int depth);
442 extern XPixmapFormatValues *XListPixmapFormats (Display *, int *count_ret);
443
444 extern void jwxyz_draw_NSImage_or_CGImage (Display *, Drawable, 
445                                            Bool nsimg_p, void *NSImage_arg,
446                                            XRectangle *geom_ret, 
447                                            int exif_rotation);
448
449 extern int XSetGraphicsExposures (Display *, GC, Bool);
450 extern Bool XTranslateCoordinates (Display *, Window src_w, Window dest_w,
451                                    int src_x, int src_y,
452                                    int *dest_x_ret, int *dest_y_ret,
453                                    Window *child_ret);
454
455 extern Font XLoadFont (Display *, const char *);
456 extern XFontStruct * XQueryFont (Display *, Font);
457 extern XFontStruct * XLoadQueryFont (Display *, const char *);
458 extern int XFreeFontInfo (char **names, XFontStruct *info, int n);
459 extern int XFreeFont (Display *, XFontStruct *);
460 extern int XUnloadFont (Display *, Font);
461 extern int XTextExtents (XFontStruct *, const char *, int length,
462                          int *dir_ret, int *ascent_ret, int *descent_ret,
463                          XCharStruct *overall_ret);
464 extern char * jwxyz_unicode_character_name (Display *, Font, unsigned long uc);
465 extern int XTextExtents16 (XFontStruct *, const XChar2b *, int length,
466                            int *dir_ret, int *ascent_ret, int *descent_ret,
467                            XCharStruct *overall_ret);
468 extern int XTextWidth (XFontStruct *, const char *, int length);
469 extern int XSetFont (Display *, GC, Font);
470
471 extern XFontSet XCreateFontSet (Display *, char *name, 
472                                 char ***missing_charset_list_return,
473                                 int *missing_charset_count_return,
474                                 char **def_string_return);
475 extern void XFreeFontSet (Display *, XFontSet);
476 extern void XFreeStringList (char **);
477 extern int Xutf8TextExtents (XFontSet, const char *, int num_bytes,
478                              XRectangle *overall_ink_return,
479                              XRectangle *overall_logical_return);
480 extern void Xutf8DrawString (Display *, Drawable, XFontSet, GC,
481                              int x, int y, const char *, int num_bytes);
482 extern const char *jwxyz_nativeFontName (Font, float *size);
483
484 extern Pixmap XCreatePixmap (Display *, Drawable,
485                              unsigned int width, unsigned int height,
486                              unsigned int depth);
487 extern int XFreePixmap (Display *, Pixmap);
488
489 extern char *XGetAtomName (Display *, Atom);
490
491 // Log()/Logv(), for debugging JWXYZ. Screenhacks should still use
492 // fprintf(stderr, ...).
493 extern void Log(const char *format, ...)
494 #if defined __GNUC__ || defined __clang__
495   __attribute__((format(printf, 1, 2)))
496 #endif
497   ;
498
499 extern void jwxyz_logv(Bool error, const char *fmt, va_list args);
500 #define Logv(format, args) (jwxyz_logv(False, format, args))
501
502 // Xt timers and fds
503 extern XtAppContext XtDisplayToApplicationContext (Display *);
504 typedef void (*XtTimerCallbackProc) (XtPointer closure, XtIntervalId *);
505 typedef void (*XtInputCallbackProc) (XtPointer closure, int *fd, XtInputId *);
506 extern XtIntervalId XtAppAddTimeOut (XtAppContext, unsigned long usecs,
507                                      XtTimerCallbackProc, XtPointer closure);
508 extern void XtRemoveTimeOut (XtIntervalId);
509 extern XtInputId XtAppAddInput (XtAppContext, int fd, XtPointer flags,
510                                XtInputCallbackProc, XtPointer closure);
511 extern void XtRemoveInput (XtInputId);
512 extern XtInputMask XtAppPending (XtAppContext);
513 extern void XtAppProcessEvent (XtAppContext, XtInputMask);
514 extern struct jwxyz_sources_data *display_sources_data (Display *);
515
516 // Some GLX stuff that also doesn't technically belong here...
517 // from XScreenSaverGLView.m
518 extern void glXSwapBuffers (Display *, Window);
519 extern void glXMakeCurrent (Display *, Window, GLXContext);
520
521 // also declared in utils/visual.h
522 extern int has_writable_cells (Screen *, Visual *);
523 extern int visual_depth (Screen *, Visual *);
524 extern int visual_cells (Screen *, Visual *);
525 extern int visual_class (Screen *, Visual *);
526 extern int get_bits_per_pixel (Display *, int);
527 extern int screen_number (Screen *);
528
529 // also declared in utils/grabclient.h
530 extern Bool use_subwindow_mode_p (Screen *, Window);
531
532 // also declared in xlockmoreI.h
533 extern void clear_gl_error (void);
534 extern void check_gl_error (const char *type);
535
536 struct jwxyz_Visual {
537   VisualID visualid;    /* visual id of this visual */
538   int class;            /* class of screen (monochrome, etc.) */
539   unsigned long red_mask, green_mask, blue_mask;        /* mask values */
540   int bits_per_rgb;     /* log base 2 of distinct color values */
541 //  int map_entries;    /* color map entries */
542 };
543
544 struct jwxyz_XGCValues {
545   int function;         /* logical operation */
546 #if 0
547   unsigned long plane_mask;/* plane mask */
548 #endif
549   unsigned long foreground;/* foreground pixel */
550   unsigned long background;/* background pixel */
551   int line_width;       /* line width */
552 #if 0
553   int line_style;       /* LineSolid, LineOnOffDash, LineDoubleDash */
554 #endif
555   int cap_style;        /* CapNotLast, CapButt, CapRound, CapProjecting */
556   int join_style;       /* JoinMiter, JoinRound, JoinBevel */
557 #if 0
558   int fill_style;       /* FillSolid, FillTiled, 
559                            FillStippled, FillOpaeueStippled */
560 #endif
561   int fill_rule;        /* EvenOddRule, WindingRule */
562 #if 0
563   int arc_mode;         /* ArcChord, ArcPieSlice */
564   Pixmap tile;          /* tile pixmap for tiling operations */
565   Pixmap stipple;       /* stipple 1 plane pixmap for stipping */
566   int ts_x_origin;      /* offset for tile or stipple operations */
567   int ts_y_origin;
568 #endif
569   Font font;            /* default text font for text operations */
570   int subwindow_mode;     /* ClipByChildren, IncludeInferiors */
571 #if 0
572   Bool graphics_exposures;/* boolean, should exposures be generated */
573 #endif
574   int clip_x_origin;    /* origin for clipping */
575   int clip_y_origin;
576   Pixmap clip_mask;     /* bitmap clipping; other calls for rects */
577 #if 0
578   int dash_offset;      /* patterned/dashed line information */
579   char dashes;
580 #endif
581
582   Bool alpha_allowed_p; /* jwxyz extension: whether pixel values may have
583                            a non-opaque alpha component. */
584   Bool antialias_p;     /* jwxyz extension: whether Quartz should draw
585                            with antialiasing. */
586 };
587
588 struct jwxyz_XWindowAttributes {
589     int x, y;                   /* location of window */
590     int width, height;          /* width and height of window */
591     int border_width;           /* border width of window */
592     int depth;                  /* depth of window */
593     Visual *visual;             /* the associated visual structure */
594 #if 0
595     Window root;                /* root of screen containing window */
596     int class;                  /* InputOutput, InputOnly*/
597     int bit_gravity;            /* one of bit gravity values */
598     int win_gravity;            /* one of the window gravity values */
599     int backing_store;          /* NotUseful, WhenMapped, Always */
600     unsigned long backing_planes;/* planes to be preserved if possible */
601     unsigned long backing_pixel;/* value to be used when restoring planes */
602     Bool save_under;            /* boolean, should bits under be saved? */
603 #endif
604     Colormap colormap;          /* color map to be associated with window */
605 #if 0
606     Bool map_installed;         /* boolean, is color map currently installed*/
607     int map_state;              /* IsUnmapped, IsUnviewable, IsViewable */
608     long all_event_masks;       /* set of events all people have interest in*/
609     long your_event_mask;       /* my event mask */
610     long do_not_propagate_mask; /* set of events that should not propagate */
611     Bool override_redirect;     /* boolean value for override-redirect */
612 #endif
613     Screen *screen;             /* back pointer to correct screen */
614 };
615
616 struct jwxyz_XColor {
617   unsigned long pixel;
618   unsigned short red, green, blue;
619   char flags;  /* do_red, do_green, do_blue */
620   char pad;
621 };
622
623 struct jwxyz_XPoint {
624   short x, y;
625 };
626
627 struct jwxyz_XSegment {
628   short x1, y1, x2, y2;
629 };
630
631 struct jwxyz_XRectangle {
632   short x, y;
633   unsigned short width, height;
634 };
635
636 struct jwxyz_XArc {
637   short x, y;
638   unsigned short width, height;
639   short angle1, angle2;
640 };
641
642
643 struct jwxyz_XrmOptionDescRec {
644   char *option;
645   char *specifier;
646   int argKind;
647   void *value;
648 };
649
650 struct jwxyz_XAnyEvent {
651   int type;
652 #if 0
653   unsigned long serial;
654   Bool send_event;
655   Display *display;
656   Window window;
657 #endif
658 };
659
660 struct jwxyz_XKeyEvent {
661   int type;
662 #if 0
663   unsigned long serial;
664   Bool send_event;
665   Display *display;
666   Window window;
667   Window root;
668   Window subwindow;
669   Time time;
670   int x, y;
671   int x_root, y_root;
672 #endif
673   unsigned int state;
674   unsigned int keycode;
675 #if 0
676   Bool same_screen;
677 #endif
678 };
679
680 struct jwxyz_XButtonEvent {
681   int type;
682 #if 0
683   unsigned long serial;
684   Bool send_event;
685   Display *display;
686   Window window;
687   Window root;
688   Window subwindow;
689   Time time;
690 #endif
691   int x, y;
692 #if 0
693   int x_root, y_root;
694 #endif
695   unsigned int state;
696   unsigned int button;
697 #if 0
698   Bool same_screen;
699 #endif
700 };
701
702 struct jwxyz_XMotionEvent {
703   int type;
704 #if 0
705   unsigned long serial;
706   Bool send_event;
707   Display *display;
708   Window window;
709   Window root;
710   Window subwindow;
711   Time time;
712 #endif
713   int x, y;
714 #if 0
715   int x_root, y_root;
716 #endif
717   unsigned int state;
718 #if 0
719   char is_hint;
720   Bool same_screen;
721 #endif
722 };
723
724 union jwxyz_XEvent {
725   int type;
726   XAnyEvent xany;
727   XKeyEvent xkey;
728   XButtonEvent xbutton;
729   XMotionEvent xmotion;
730 };
731
732 struct jwxyz_XImage {
733     int width, height;          /* size of image */
734     int xoffset;                /* number of pixels offset in X direction */
735     int format;                 /* XYBitmap, XYPixmap, ZPixmap */
736     char *data;                 /* pointer to image data */
737     int byte_order;             /* data byte order, LSBFirst, MSBFirst */
738     int bitmap_unit;            /* quant. of scanline 8, 16, 32 */
739     int bitmap_bit_order;       /* LSBFirst, MSBFirst */
740     int bitmap_pad;             /* 8, 16, 32 either XY or ZPixmap */
741     int depth;                  /* depth of image */
742     int bytes_per_line;         /* accelarator to next line */
743     int bits_per_pixel;         /* bits per pixel (ZPixmap) */
744     unsigned long red_mask;     /* bits in z arrangment */
745     unsigned long green_mask;
746     unsigned long blue_mask;
747 //  XPointer obdata;            /* hook for the object routines to hang on */
748     struct funcs {              /* image manipulation routines */
749 #if 0
750       XImage *(*create_image)(
751                 Display*        /* display */,
752                 Visual*         /* visual */,
753                 unsigned int    /* depth */,
754                 int             /* format */,
755                 int             /* offset */,
756                 char*           /* data */,
757                 unsigned int    /* width */,
758                 unsigned int    /* height */,
759                 int             /* bitmap_pad */,
760                 int             /* bytes_per_line */);
761         int (*destroy_image)        (XImage *);
762 #endif
763         unsigned long (*get_pixel)  (XImage *, int, int);
764         int (*put_pixel)            (XImage *, int, int, unsigned long);
765 #if 0
766         XImage *(*sub_image)        (XImage *, int, int, unsigned int, unsigned int);
767         int (*add_pixel)            (XImage *, long);
768 #endif
769     } f;
770 };
771
772 struct jwxyz_XCharStruct {
773   short lbearing;       /* origin to left edge of ink */
774   short rbearing;       /* origin to right edge of ink */
775   short width;          /* advance to next char's origin */
776   short ascent;         /* baseline to top edge of ink */
777   short descent;        /* baseline to bottom edge of ink */
778 #if 0
779   unsigned short attributes;    /* per char flags (not predefined) */
780 #endif
781 };
782
783 struct jwxyz_XFontProp {
784   Atom          name;
785   unsigned long card32; /* Careful: This holds (32- or 64-bit) pointers. */
786 };
787
788 struct jwxyz_XFontStruct {
789 #if 0
790   XExtData      *ext_data;      /* hook for extension to hang data */
791 #endif
792   Font          fid;            /* Font id for this font */
793 #if 0
794   unsigned      direction;      /* hint about direction the font is painted */
795 #endif
796   unsigned      min_char_or_byte2;      /* first character */
797   unsigned      max_char_or_byte2;      /* last character */
798 #if 0
799   unsigned      min_byte1;      /* first row that exists */
800   unsigned      max_byte1;      /* last row that exists */
801   Bool  all_chars_exist;        /* flag if all characters have non-zero size*/
802 #endif
803   unsigned      default_char;   /* char to print for undefined character */
804   int         n_properties;   /* how many properties there are */
805   XFontProp     *properties;    /* pointer to array of additional properties*/
806   XCharStruct   min_bounds;     /* minimum bounds over all existing char*/
807   XCharStruct   max_bounds;     /* maximum bounds over all existing char*/
808   XCharStruct   *per_char;      /* first_char to last_char information */
809   int           ascent;         /* log. extent above baseline for spacing */
810   int           descent;        /* log. descent below baseline for spacing */
811 };
812
813 struct jwxyz_XComposeStatus {
814   char dummy;
815 };
816
817 struct  jwxyz_XPixmapFormatValues {
818   int depth;
819   int bits_per_pixel;
820   int scanline_pad;
821 };
822
823 struct jwxyz_XChar2b {
824   unsigned char byte1;
825   unsigned char byte2;
826 };
827
828 #endif /* __JWXYZ_H__ */