1 /* xscreensaver, Copyright (c) 1991-2018 Jamie Zawinski <jwz@jwz.org>
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
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.
22 #include <stdlib.h> /* For abort(). */
25 #if defined __FreeBSD__ || defined __MACH__ && defined __APPLE__
26 # include <sys/cdefs.h>
30 /* __dead2 is an undocumented FreeBSD-ism (and by extension, an OSX-ism),
31 normally #defined in <sys/cdefs.h>.
33 # if defined __GNUC__ || defined __clang__
34 # define __dead2 __attribute__((__noreturn__))
40 extern void jwxyz_abort(const char *fmt, ...) __dead2;
41 #define abort() jwxyz_abort("abort in %s:%d", __FUNCTION__, __LINE__)
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 *. */
51 typedef struct jwxyz_Display Display;
52 typedef struct jwxyz_Display 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;
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;
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;
97 #define XtInputReadMask (1L<<0)
98 #define XtInputWriteMask (1L<<1)
99 #define XtInputExceptMask (1L<<2)
102 #define XtIMAlternateInput 4
104 #define XtIMAll (XtIMXEvent | XtIMTimer | XtIMAlternateInput | XtIMSignal)
112 #define Window Drawable
113 #define Pixmap Drawable
115 #define XrmoptionNoArg 0
116 #define XrmoptionSepArg 1
118 #define CoordModeOrigin 0
119 #define CoordModePrevious 1
122 #define LineOnOffDash 1
123 #define LineDoubleDash 2
128 #define CapProjecting 3
136 #define FillStippled 2
137 #define FillOpaqueStippled 3
139 #define EvenOddRule 0
140 #define WindingRule 1
155 #define StaticColor 2
156 #define PseudoColor 3
158 #define DirectColor 5
164 #define DoGreen (1<<1)
165 #define DoBlue (1<<2)
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)
193 #define ButtonPress 4
194 #define ButtonRelease 5
195 #define MotionNotify 6
197 #define GraphicsExpose 13
199 #define VisibilityNotify 15
201 #define ClipByChildren 0
202 #define IncludeInferiors 1
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)
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)
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
245 #define XK_Home 0xFF50
246 #define XK_Left 0xFF51
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
266 #define XK_F10 0xFFC7
267 #define XK_F11 0xFFC8
268 #define XK_F12 0xFFC9
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 */
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 #define XDefaultScreenOfDisplay(d) (d)
315 #define XDisplayOfScreen(s) (s)
316 #define XDisplayNumberOfScreen(s) 0
317 #define XScreenNumberOfScreen(s) 0
319 extern int XDisplayWidth (Display *, int);
320 extern int XDisplayHeight (Display *, int);
321 extern int XDisplayWidthMM (Display *, int);
322 extern int XDisplayHeightMM (Display *, int);
324 unsigned long XBlackPixelOfScreen(Screen *);
325 unsigned long XWhitePixelOfScreen(Screen *);
326 unsigned long XCellsOfScreen(Screen *);
328 extern int XDrawPoint (Display *, Drawable, GC, int x, int y);
330 extern int XChangeGC (Display *, GC, unsigned long mask, XGCValues *);
332 extern int XClearArea (Display *, Window, int x, int y, int w, int h,Bool exp);
333 extern int XSetWindowBackground (Display *, Window, unsigned long);
334 extern Status XGetWindowAttributes (Display *, Window, XWindowAttributes *);
335 extern Status XGetGeometry (Display *, Drawable, Window *root_ret,
336 int *x_ret, int *y_ret,
337 unsigned int *w_ret, unsigned int *h_ret,
338 unsigned int *bw_ret, unsigned int *depth_ret);
339 extern Status XAllocColor (Display *, Colormap, XColor *);
340 extern Status XAllocColorCells (Display *, Colormap, Bool contig,
341 unsigned long *pmret, unsigned int npl,
342 unsigned long *pxret, unsigned int npx);
343 extern int XStoreColors (Display *, Colormap, XColor *, int n);
344 extern int XStoreColor (Display *, Colormap, XColor *);
345 extern Status XParseColor(Display *, Colormap, const char *spec, XColor *ret);
346 extern Status XAllocNamedColor (Display *, Colormap, char *name,
347 XColor *screen_ret, XColor *exact_ret);
348 extern int XQueryColor (Display *, Colormap, XColor *);
349 extern int XQueryColors(Display *, Colormap colormap, XColor *, int ncolors);
351 extern int XSetForeground (Display *, GC, unsigned long);
352 extern int XSetBackground (Display *, GC, unsigned long);
353 extern int XSetFunction (Display *, GC, int);
354 extern int XSetSubwindowMode (Display *, GC, int);
355 extern int XSetLineAttributes (Display *, GC, unsigned int line_width,
356 int line_style, int cap_style, int join_style);
357 extern int jwxyz_XSetAlphaAllowed (Display *, GC, Bool);
358 extern int jwxyz_XSetAntiAliasing (Display *, GC, Bool);
360 extern int XFlush (Display *);
361 extern int XSync (Display *, Bool);
362 extern int XFreeColors (Display *, Colormap, unsigned long *px, int n,
363 unsigned long planes);
364 extern int XCopyArea (Display *, Drawable src, Drawable dest, GC,
365 int src_x, int src_y,
366 unsigned int width, unsigned int height,
367 int dest_x, int dest_y);
368 extern int XCopyPlane (Display *, Drawable, Drawable, GC,
369 int src_x, int src_y,
370 unsigned width, int height,
371 int dest_x, int dest_y,
372 unsigned long plane);
374 extern int XDrawLine (Display *, Drawable, GC, int x1, int y1, int x2, int y2);
375 extern int XDrawArc (Display *, Drawable, GC, int x, int y,
376 unsigned int width, unsigned int height,
377 int angle1, int angle2);
378 extern int XFillArc (Display *, Drawable, GC, int x, int y,
379 unsigned int width, unsigned int height,
380 int angle1, int angle2);
381 extern int XDrawArcs (Display *, Drawable, GC, XArc *arcs, int narcs);
382 extern int XFillArcs (Display *, Drawable, GC, XArc *arcs, int narcs);
383 extern int XDrawRectangle (Display *, Drawable, GC, int x, int y,
384 unsigned int width, unsigned int height);
385 extern int XFillRectangle (Display *, Drawable, GC, int x, int y,
386 unsigned int width, unsigned int height);
387 extern int XFillRectangles (Display *, Drawable, GC, XRectangle *, int n);
389 extern int XDrawString (Display *, Drawable, GC, int x, int y, const char *,
391 extern int XDrawImageString (Display *, Drawable, GC, int x, int y,
392 const char *, int len);
393 extern int XDrawString16 (Display *, Drawable, GC, int x, int y,
394 const XChar2b *, int len);
396 extern Bool XQueryPointer (Display *, Window, Window *root_ret,
398 int *root_x_ret, int *root_y_ret,
399 int *win_x_ret, int *win_y_ret,
400 unsigned int *mask_ret);
401 extern int XLookupString (XKeyEvent *, char *ret, int size, KeySym *ks_ret,
403 extern KeySym XKeycodeToKeysym (Display *, KeyCode, int index);
405 extern Status XInitImage (XImage *);
406 extern XImage *XCreateImage (Display *, Visual *, unsigned int depth,
407 int format, int offset, char *data,
408 unsigned int width, unsigned int height,
409 int bitmap_pad, int bytes_per_line);
410 extern XImage *XSubImage (XImage *, int x, int y,
411 unsigned int w, unsigned int h);
413 extern unsigned long XGetPixel (XImage *, int x, int y);
414 extern int XPutPixel (XImage *, int x, int y, unsigned long);
415 extern int XDestroyImage (XImage *);
416 extern XImage *XGetImage (Display *, Drawable, int x, int y,
417 unsigned int w, unsigned int h,
418 unsigned long pm, int fmt);
419 extern Pixmap XCreatePixmapFromBitmapData (Display *, Drawable,
421 unsigned int w, unsigned int h,
425 extern XPixmapFormatValues *XListPixmapFormats (Display *, int *count_ret);
427 extern void jwxyz_draw_NSImage_or_CGImage (Display *, Drawable,
428 Bool nsimg_p, void *NSImage_arg,
429 XRectangle *geom_ret,
431 extern XImage *jwxyz_png_to_ximage (Display *, Visual *,
432 const unsigned char *, unsigned long size);
434 extern int XSetGraphicsExposures (Display *, GC, Bool);
435 extern Bool XTranslateCoordinates (Display *, Window src_w, Window dest_w,
436 int src_x, int src_y,
437 int *dest_x_ret, int *dest_y_ret,
440 extern Font XLoadFont (Display *, const char *);
441 extern XFontStruct * XQueryFont (Display *, Font);
442 extern XFontStruct * XLoadQueryFont (Display *, const char *);
443 extern int XFreeFontInfo (char **names, XFontStruct *info, int n);
444 extern int XFreeFont (Display *, XFontStruct *);
445 extern int XUnloadFont (Display *, Font);
446 extern int XTextExtents (XFontStruct *, const char *, int length,
447 int *dir_ret, int *ascent_ret, int *descent_ret,
448 XCharStruct *overall_ret);
449 extern char * jwxyz_unicode_character_name (Display *, Font, unsigned long uc);
450 extern int XTextExtents16 (XFontStruct *, const XChar2b *, int length,
451 int *dir_ret, int *ascent_ret, int *descent_ret,
452 XCharStruct *overall_ret);
453 extern int XTextWidth (XFontStruct *, const char *, int length);
454 extern int XSetFont (Display *, GC, Font);
456 extern XFontSet XCreateFontSet (Display *, char *name,
457 char ***missing_charset_list_return,
458 int *missing_charset_count_return,
459 char **def_string_return);
460 extern void XFreeFontSet (Display *, XFontSet);
461 extern void XFreeStringList (char **);
462 extern int Xutf8TextExtents (XFontSet, const char *, int num_bytes,
463 XRectangle *overall_ink_return,
464 XRectangle *overall_logical_return);
465 extern void Xutf8DrawString (Display *, Drawable, XFontSet, GC,
466 int x, int y, const char *, int num_bytes);
468 extern Pixmap XCreatePixmap (Display *, Drawable,
469 unsigned int width, unsigned int height,
471 extern int XFreePixmap (Display *, Pixmap);
473 extern char *XGetAtomName (Display *, Atom);
475 extern void set_points_list(XPoint *points, int npoints, linked_point *root);
476 extern void traverse_points_list(linked_point * root);
477 extern void draw_three_vertices(linked_point * a, Bool triangle);
478 extern double compute_edge_length(linked_point * a, linked_point * b);
479 extern double get_angle(double a, double b, double c);
480 extern Bool is_same_slope(linked_point * a);
481 extern Bool is_an_ear(linked_point * a);
482 extern Bool is_three_point_loop(linked_point * head);
484 extern int draw_arc_gl(Display *dpy, Drawable d, GC gc, int x, int y,
485 unsigned int width, unsigned int height,
486 int angle1, int angle2, Bool fill_p);
488 // Log()/Logv(), for debugging JWXYZ. Screenhacks should still use
489 // fprintf(stderr, ...).
490 extern void Log(const char *format, ...)
491 #if defined __GNUC__ || defined __clang__
492 __attribute__((format(printf, 1, 2)))
496 extern void jwxyz_logv(Bool error, const char *fmt, va_list args);
497 #define Logv(format, args) (jwxyz_logv(False, format, args))
500 extern XtAppContext XtDisplayToApplicationContext (Display *);
501 typedef void (*XtTimerCallbackProc) (XtPointer closure, XtIntervalId *);
502 typedef void (*XtInputCallbackProc) (XtPointer closure, int *fd, XtInputId *);
503 extern XtIntervalId XtAppAddTimeOut (XtAppContext, unsigned long usecs,
504 XtTimerCallbackProc, XtPointer closure);
505 extern void XtRemoveTimeOut (XtIntervalId);
506 extern XtInputId XtAppAddInput (XtAppContext, int fd, XtPointer flags,
507 XtInputCallbackProc, XtPointer closure);
508 extern void XtRemoveInput (XtInputId);
509 extern XtInputMask XtAppPending (XtAppContext);
510 extern void XtAppProcessEvent (XtAppContext, XtInputMask);
512 // Some GLX stuff that also doesn't technically belong here...
513 // from XScreenSaverGLView.m
514 extern void glXSwapBuffers (Display *, Window);
515 extern void glXMakeCurrent (Display *, Window, GLXContext);
517 // also declared in utils/visual.h
518 extern int has_writable_cells (Screen *, Visual *);
519 extern int visual_depth (Screen *, Visual *);
520 extern int visual_pixmap_depth (Screen *, Visual *);
521 extern int visual_cells (Screen *, Visual *);
522 extern int visual_class (Screen *, Visual *);
523 extern void visual_rgb_masks (Screen *screen, Visual *visual,
524 unsigned long *red_mask,
525 unsigned long *green_mask,
526 unsigned long *blue_mask);
527 extern int screen_number (Screen *);
529 // also declared in utils/grabclient.h
530 extern Bool use_subwindow_mode_p (Screen *, Window);
532 // also declared in xlockmoreI.h
533 extern void clear_gl_error (void);
534 extern void check_gl_error (const char *type);
536 // A Visual is supposed to be an opaque type, even though Xlib.h defines it.
537 // Only utils/xft.c uses this, out of necessity.
538 struct jwxyz_Visual {
539 int class; /* class of screen (monochrome, etc.) */
540 unsigned long rgba_masks[4]; /* mask values */
543 struct jwxyz_XGCValues {
544 int function; /* logical operation */
546 unsigned long plane_mask;/* plane mask */
548 unsigned long foreground;/* foreground pixel */
549 unsigned long background;/* background pixel */
550 int line_width; /* line width */
552 int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
554 int cap_style; /* CapNotLast, CapButt, CapRound, CapProjecting */
555 int join_style; /* JoinMiter, JoinRound, JoinBevel */
557 int fill_style; /* FillSolid, FillTiled,
558 FillStippled, FillOpaeueStippled */
560 int fill_rule; /* EvenOddRule, WindingRule */
562 int arc_mode; /* ArcChord, ArcPieSlice */
563 Pixmap tile; /* tile pixmap for tiling operations */
564 Pixmap stipple; /* stipple 1 plane pixmap for stipping */
565 int ts_x_origin; /* offset for tile or stipple operations */
568 Font font; /* default text font for text operations */
569 int subwindow_mode; /* ClipByChildren, IncludeInferiors */
571 Bool graphics_exposures;/* boolean, should exposures be generated */
573 int clip_x_origin; /* origin for clipping */
575 Pixmap clip_mask; /* bitmap clipping; other calls for rects */
577 int dash_offset; /* patterned/dashed line information */
581 Bool alpha_allowed_p; /* jwxyz extension: whether pixel values may have
582 a non-opaque alpha component. */
583 Bool antialias_p; /* jwxyz extension: whether Quartz should draw
584 with antialiasing. */
587 struct jwxyz_XWindowAttributes {
588 int x, y; /* location of window */
589 int width, height; /* width and height of window */
590 int border_width; /* border width of window */
591 int depth; /* depth of window */
592 Visual *visual; /* the associated visual structure */
594 Window root; /* root of screen containing window */
595 int class; /* InputOutput, InputOnly*/
596 int bit_gravity; /* one of bit gravity values */
597 int win_gravity; /* one of the window gravity values */
598 int backing_store; /* NotUseful, WhenMapped, Always */
599 unsigned long backing_planes;/* planes to be preserved if possible */
600 unsigned long backing_pixel;/* value to be used when restoring planes */
601 Bool save_under; /* boolean, should bits under be saved? */
603 Colormap colormap; /* color map to be associated with window */
605 Bool map_installed; /* boolean, is color map currently installed*/
606 int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
607 long all_event_masks; /* set of events all people have interest in*/
608 long your_event_mask; /* my event mask */
609 long do_not_propagate_mask; /* set of events that should not propagate */
610 Bool override_redirect; /* boolean value for override-redirect */
612 Screen *screen; /* back pointer to correct screen */
615 struct jwxyz_XColor {
617 unsigned short red, green, blue;
618 char flags; /* do_red, do_green, do_blue */
622 struct jwxyz_XPoint {
626 struct jwxyz_XSegment {
627 short x1, y1, x2, y2;
630 struct jwxyz_XRectangle {
632 unsigned short width, height;
637 unsigned short width, height;
638 short angle1, angle2;
642 struct jwxyz_XrmOptionDescRec {
649 struct jwxyz_XAnyEvent {
652 unsigned long serial;
659 struct jwxyz_XKeyEvent {
662 unsigned long serial;
673 unsigned int keycode;
679 struct jwxyz_XButtonEvent {
682 unsigned long serial;
701 struct jwxyz_XMotionEvent {
704 unsigned long serial;
727 XButtonEvent xbutton;
728 XMotionEvent xmotion;
731 struct jwxyz_XImage {
732 int width, height; /* size of image */
733 int xoffset; /* number of pixels offset in X direction */
734 int format; /* XYBitmap, XYPixmap, ZPixmap */
735 char *data; /* pointer to image data */
736 int byte_order; /* data byte order, LSBFirst, MSBFirst */
737 int bitmap_unit; /* quant. of scanline 8, 16, 32 */
738 int bitmap_bit_order; /* LSBFirst, MSBFirst */
739 int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */
740 int depth; /* depth of image */
741 int bytes_per_line; /* accelarator to next line */
742 int bits_per_pixel; /* bits per pixel (ZPixmap) */
743 unsigned long red_mask; /* bits in z arrangment */
744 unsigned long green_mask;
745 unsigned long blue_mask;
746 // XPointer obdata; /* hook for the object routines to hang on */
747 struct funcs { /* image manipulation routines */
749 XImage *(*create_image)(
750 Display* /* display */,
751 Visual* /* visual */,
752 unsigned int /* depth */,
756 unsigned int /* width */,
757 unsigned int /* height */,
758 int /* bitmap_pad */,
759 int /* bytes_per_line */);
760 int (*destroy_image) (XImage *);
762 unsigned long (*get_pixel) (XImage *, int, int);
763 int (*put_pixel) (XImage *, int, int, unsigned long);
765 XImage *(*sub_image) (XImage *, int, int, unsigned int, unsigned int);
766 int (*add_pixel) (XImage *, long);
771 struct jwxyz_XCharStruct {
772 short lbearing; /* origin to left edge of ink */
773 short rbearing; /* origin to right edge of ink */
774 short width; /* advance to next char's origin */
775 short ascent; /* baseline to top edge of ink */
776 short descent; /* baseline to bottom edge of ink */
778 unsigned short attributes; /* per char flags (not predefined) */
782 struct jwxyz_XFontProp {
784 unsigned long card32; /* Careful: This holds (32- or 64-bit) pointers. */
787 struct jwxyz_XFontStruct {
789 XExtData *ext_data; /* hook for extension to hang data */
791 Font fid; /* Font id for this font */
793 unsigned direction; /* hint about direction the font is painted */
795 unsigned min_char_or_byte2; /* first character */
796 unsigned max_char_or_byte2; /* last character */
798 unsigned min_byte1; /* first row that exists */
799 unsigned max_byte1; /* last row that exists */
800 Bool all_chars_exist; /* flag if all characters have non-zero size*/
802 unsigned default_char; /* char to print for undefined character */
803 int n_properties; /* how many properties there are */
804 XFontProp *properties; /* pointer to array of additional properties*/
805 XCharStruct min_bounds; /* minimum bounds over all existing char*/
806 XCharStruct max_bounds; /* maximum bounds over all existing char*/
807 XCharStruct *per_char; /* first_char to last_char information */
808 int ascent; /* log. extent above baseline for spacing */
809 int descent; /* log. descent below baseline for spacing */
812 struct jwxyz_XComposeStatus {
816 struct jwxyz_XPixmapFormatValues {
822 struct jwxyz_XChar2b {
829 Window (*root) (Display *);
830 Visual *(*visual) (Display *);
831 struct jwxyz_sources_data *(*display_sources_data) (Display *);
833 unsigned long *(*window_background) (Display *);
834 int (*draw_arc) (Display *dpy, Drawable d, GC gc, int x, int y,
835 unsigned int width, unsigned int height,
836 int angle1, int angle2, Bool fill_p);
837 void (*fill_rects) (Display *dpy, Drawable d, GC gc,
838 const XRectangle *rectangles,
839 unsigned long nrects, unsigned long pixel);
840 XGCValues *(*gc_gcv) (GC gc);
841 unsigned int (*gc_depth) (GC gc);
842 int (*draw_string) (Display *dpy, Drawable d, GC gc, int x, int y,
843 const char *str, size_t len, Bool utf8);
845 void (*copy_area) (Display *dpy, Drawable src, Drawable dst, GC gc,
846 int src_x, int src_y,
847 unsigned int width, unsigned int height,
848 int dst_x, int dst_y);
850 int (*DrawPoints) (Display *, Drawable, GC, XPoint *, int n, int mode);
851 int (*DrawSegments) (Display *, Drawable, GC, XSegment *, int n);
852 GC (*CreateGC) (Display *, Drawable, unsigned long mask, XGCValues *);
853 int (*FreeGC) (Display *, GC);
854 int (*ClearWindow) (Display *, Window);
855 int (*SetClipMask) (Display *, GC, Pixmap);
856 int (*SetClipOrigin) (Display *, GC, int x, int y);
857 int (*FillPolygon) (Display *, Drawable, GC,
858 XPoint * points, int npoints, int shape, int mode);
859 int (*DrawLines) (Display *, Drawable, GC, XPoint *, int n, int mode);
861 int (*PutImage) (Display *, Drawable, GC, XImage *,
862 int src_x, int src_y, int dest_x, int dest_y,
863 unsigned int w, unsigned int h);
864 XImage *(*GetSubImage) (Display *dpy, Drawable d, int x, int y,
865 unsigned int width, unsigned int height,
866 unsigned long plane_mask, int format,
867 XImage *dest_image, int dest_x, int dest_y);
870 #define JWXYZ_VTBL(dpy) (*(struct jwxyz_vtbl **)(dpy))
872 #define XRootWindow(dpy, screen) \
873 ((dpy) ? JWXYZ_VTBL(dpy)->root(dpy) : 0)
874 #define XDefaultVisualOfScreen(screen) \
875 ((screen) ? JWXYZ_VTBL(screen)->visual(screen) : 0)
877 #define XDrawPoints(dpy, d, gc, points, n, mode) \
878 (JWXYZ_VTBL(dpy)->DrawPoints (dpy, d, gc, points, n, mode))
879 #define XDrawSegments(dpy, d, gc, segments, n) \
880 (JWXYZ_VTBL(dpy)->DrawSegments (dpy, d, gc, segments, n))
881 #define XCreateGC(dpy, d, mask, gcv) \
882 (JWXYZ_VTBL(dpy)->CreateGC (dpy, d, mask, gcv))
883 #define XFreeGC(dpy, gc) \
884 (JWXYZ_VTBL(dpy)->FreeGC (dpy, gc))
885 #define XClearWindow(dpy, win) \
886 (JWXYZ_VTBL(dpy)->ClearWindow(dpy, win))
887 #define XSetClipMask(dpy, gc, m) \
888 (JWXYZ_VTBL(dpy)->SetClipMask (dpy, gc, m))
889 #define XSetClipOrigin(dpy, gc, x, y) \
890 (JWXYZ_VTBL(dpy)->SetClipOrigin (dpy, gc, x, y))
891 #define XFillPolygon(dpy, d, gc, points, npoints, shape, mode) \
892 (JWXYZ_VTBL(dpy)->FillPolygon (dpy, d, gc, points, npoints, shape, mode))
893 #define XDrawLines(dpy, d, gc, points, n, mode) \
894 (JWXYZ_VTBL(dpy)->DrawLines (dpy, d, gc, points, n, mode))
895 #define XPutImage(dpy, d, gc, image, src_x, src_y, dest_x, dest_y, w, h) \
896 (JWXYZ_VTBL(dpy)->PutImage (dpy, d, gc, image, src_x, src_y, \
897 dest_x, dest_y, w, h))
898 #define XGetSubImage(dpy, d, x, y, width, height, plane_mask, \
899 format, dest_image, dest_x, dest_y) \
900 (JWXYZ_VTBL(dpy)->GetSubImage (dpy, d, x, y, width, height, plane_mask, \
901 format, dest_image, dest_x, dest_y))
904 #endif /* __JWXYZ_H__ */