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