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