]> gitweb.factorcode.org Git - factor.git/blob - extra/x11/xlib/xlib.factor
Initial import
[factor.git] / extra / x11 / xlib / xlib.factor
1 ! Copyright (C) 2005, 2006 Eduardo Cavazos
2 ! See http://factorcode.org/license.txt for BSD license.
3 !
4 ! The most popular guides to programming the X Window System are
5 ! the series from Oreilly. For programming with Xlib, there is
6 ! the reference manual and the programmers guide. However, a
7 ! lesser known manual is the free Xlib manual that comes with
8 ! the MIT X distribution. The arrangement and order of these
9 ! bindings follows the structure of the free Xlib manual. If you
10 ! add to this library and are wondering what part of the file to
11 ! modify, just find the function or data structure in the manual
12 ! and note the section.
13
14 USING: kernel arrays alien alien.c-types alien.syntax
15 math words sequences namespaces continuations ;
16 IN: x11.xlib
17
18 LIBRARY: xlib
19
20 TYPEDEF: ulong XID
21 TYPEDEF: XID Window
22 TYPEDEF: XID Drawable
23 TYPEDEF: XID Font
24 TYPEDEF: XID Pixmap
25 TYPEDEF: XID Cursor
26 TYPEDEF: XID Colormap
27 TYPEDEF: XID GContext
28 TYPEDEF: XID KeySym
29
30 TYPEDEF: ulong Atom
31
32 TYPEDEF: char* XPointer
33 TYPEDEF: void* Display*
34 TYPEDEF: void* Screen*
35 TYPEDEF: void* GC
36 TYPEDEF: void* Visual*
37 TYPEDEF: void* XExtData*
38 TYPEDEF: void* XFontProp*
39 TYPEDEF: void* XComposeStatus*
40 TYPEDEF: void* XIM
41 TYPEDEF: void* XIC
42
43 TYPEDEF: int Status
44
45 TYPEDEF: int Bool
46
47 TYPEDEF: ulong VisualID
48 TYPEDEF: ulong Time
49
50 TYPEDEF: void* Window**
51 TYPEDEF: void* Atom**
52
53 : <XID> <ulong> ; inline
54 : <Window> <XID> ; inline
55 : <Drawable> <XID> ; inline
56 : <KeySym> <XID> ; inline
57 : <Atom> <ulong> ; inline
58
59 : *XID *ulong ; inline
60 : *Window *XID ; inline
61 : *Drawable *XID ; inline
62 : *KeySym *XID ; inline
63 : *Atom *ulong ; inline
64 !
65 ! 2 - Display Functions
66 !
67
68 FUNCTION: Display* XOpenDisplay ( void* display_name ) ;
69
70 ! 2.2 Obtaining Information about the Display, Image Formats, or Screens
71
72 FUNCTION: ulong XBlackPixel ( Display* display, int screen_number ) ;
73 FUNCTION: ulong XWhitePixel ( Display* display, int screen_number ) ;
74 FUNCTION: Colormap XDefaultColormap ( Display* display, int screen_number ) ;
75 FUNCTION: int XDefaultDepth ( Display* display, int screen_number ) ;
76 FUNCTION: GC XDefaultGC ( Display* display, int screen_number ) ;
77 FUNCTION: int XDefaultScreen ( Display* display ) ;
78 FUNCTION: Window XRootWindow ( Display* display, int screen_number ) ;
79 FUNCTION: Window XDefaultRootWindow ( Display* display ) ;
80 FUNCTION: int XProtocolVersion ( Display* display ) ;
81 FUNCTION: int XProtocolRevision ( Display* display ) ;
82 FUNCTION: int XQLength ( Display* display ) ;
83 FUNCTION: int XScreenCount ( Display* display ) ;
84 FUNCTION: int XConnectionNumber ( Display* display ) ;
85
86 ! 2.5 Closing the Display
87 FUNCTION: int XCloseDisplay ( Display* display ) ;
88
89 !
90 ! 3 - Window Functions
91 !
92
93 ! 3.2 - Window Attributes
94
95 : CWBackPixmap          1 0 shift ; inline
96 : CWBackPixel           1 1 shift ; inline
97 : CWBorderPixmap        1 2 shift ; inline
98 : CWBorderPixel         1 3 shift ; inline
99 : CWBitGravity          1 4 shift ; inline
100 : CWWinGravity          1 5 shift ; inline
101 : CWBackingStore        1 6 shift ; inline
102 : CWBackingPlanes       1 7 shift ; inline
103 : CWBackingPixel        1 8 shift ; inline
104 : CWOverrideRedirect    1 9 shift ; inline
105 : CWSaveUnder           1 10 shift ; inline
106 : CWEventMask           1 11 shift ; inline
107 : CWDontPropagate       1 12 shift ; inline
108 : CWColormap            1 13 shift ; inline
109 : CWCursor              1 14 shift ; inline
110
111 C-STRUCT: XSetWindowAttributes
112         { "Pixmap" "background_pixmap" }
113         { "ulong" "background_pixel" }
114         { "Pixmap" "border_pixmap" }
115         { "ulong" "border_pixel" }
116         { "int" "bit_gravity" }
117         { "int" "win_gravity" }
118         { "int" "backing_store" }
119         { "ulong" "backing_planes" }
120         { "ulong" "backing_pixel" }
121         { "Bool" "save_under" }
122         { "long" "event_mask" }
123         { "long" "do_not_propagate_mask" }
124         { "Bool" "override_redirect" }
125         { "Colormap" "colormap" }
126         { "Cursor" "cursor" } ;
127
128 : UnmapGravity          0 ; inline
129
130 : ForgetGravity         0 ; inline
131 : NorthWestGravity      1 ; inline
132 : NorthGravity          2 ; inline
133 : NorthEastGravity      3 ; inline
134 : WestGravity           4 ; inline
135 : CenterGravity         5 ; inline
136 : EastGravity           6 ; inline
137 : SouthWestGravity      7 ; inline
138 : SouthGravity          8 ; inline
139 : SouthEastGravity      9 ; inline
140 : StaticGravity         10 ; inline
141
142 ! 3.3 - Creating Windows
143
144 FUNCTION: Window XCreateWindow ( Display* display, Window parent, int x, int y, uint width, uint height, uint border_width, int depth, uint class, Visual* visual, ulong valuemask, XSetWindowAttributes* attributes ) ;
145 FUNCTION: Window XCreateSimpleWindow ( Display* display, Window parent, int x, int y, uint width, uint height, uint border_width, ulong border, ulong background ) ;
146 FUNCTION: Status XDestroyWindow ( Display* display, Window w ) ;
147 FUNCTION: Status XMapWindow ( Display* display, Window window ) ;
148 FUNCTION: Status XMapSubwindows ( Display* display, Window window ) ;
149 FUNCTION: Status XUnmapWindow ( Display* display, Window w ) ;
150 FUNCTION: Status XUnmapSubwindows ( Display* display, Window w ) ;
151
152 ! 3.5 Mapping Windows
153
154 FUNCTION: int XMapRaised ( Display* display, Window w ) ;
155
156 ! 3.7 - Configuring Windows
157
158 : CWX                   1 0 shift ; inline
159 : CWY                   1 1 shift ; inline
160 : CWWidth               1 2 shift ; inline
161 : CWHeight              1 3 shift ; inline
162 : CWBorderWidth         1 4 shift ; inline
163 : CWSibling             1 5 shift ; inline
164 : CWStackMode           1 6 shift ; inline
165
166 C-STRUCT: XWindowChanges
167         { "int" "x" }
168         { "int" "y" }
169         { "int" "width" }
170         { "int" "height" }
171         { "int" "border_width" }
172         { "Window" "sibling" }
173         { "int" "stack_mode" } ;
174
175 FUNCTION: Status XConfigureWindow ( Display* display, Window w, uint value_mask, XWindowChanges* values ) ;
176 FUNCTION: Status XMoveWindow ( Display* display, Window w, int x, int y ) ;
177 FUNCTION: Status XResizeWindow ( Display* display, Window w, uint width, uint height ) ;
178 FUNCTION: Status XSetWindowBorderWidth ( Display* display, ulong w, uint width ) ;
179
180
181 ! 3.8 Changing Window Stacking Order
182
183 FUNCTION: Status XRaiseWindow ( Display* display, Window w ) ;
184 FUNCTION: Status XLowerWindow ( Display* display, Window w ) ;
185
186 ! 3.9 - Changing Window Attributes
187
188 FUNCTION: Status XChangeWindowAttributes (
189   Display* display, Window w, ulong valuemask, XSetWindowAttributes* attr ) ;
190 FUNCTION: Status XSetWindowBackground (
191   Display* display, Window w, ulong background_pixel ) ;
192 FUNCTION: Status XDefineCursor ( Display* display, Window w, Cursor cursor ) ;
193 FUNCTION: Status XUndefineCursor ( Display* display, Window w ) ;
194
195 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
196 ! 4 - Window Information Functions
197 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
198
199 ! 4.1 - Obtaining Window Information
200
201 FUNCTION: Status XQueryTree (
202   Display* display,
203   Window w,
204   Window* root_return,
205   Window* parent_return,
206   Window** children_return, uint* nchildren_return ) ;
207
208 C-STRUCT: XWindowAttributes
209         { "int" "x" }
210         { "int" "y" }
211         { "int" "width" }
212         { "int" " height" }
213         { "int" "border_width" }
214         { "int" "depth" }
215         { "Visual*" "visual" }
216         { "Window" "root" }
217         { "int" "class" }
218         { "int" "bit_gravity" }
219         { "int" "win_gravity" }
220         { "int" "backing_store" }
221         { "ulong" "backing_planes" }
222         { "ulong" "backing_pixel" }
223         { "Bool" "save_under" }
224         { "Colormap" "colormap" }
225         { "Bool" "map_installed" }
226         { "int" "map_state" }
227         { "long" "all_event_masks" }
228         { "long" "your_event_mask" }
229         { "long" "do_not_propagate_mask" }
230         { "Bool" "override_redirect" }
231         { "Screen*" "screen" } ;
232
233 FUNCTION: Status XGetWindowAttributes ( Display* display, Window w, XWindowAttributes* attr ) ;
234
235 : IsUnmapped            0 ; inline
236 : IsUnviewable          1 ; inline
237 : IsViewable            2 ; inline
238
239 FUNCTION: Status XGetGeometry (
240   Display* display,
241   Drawable d,
242   Window* root_return,
243   int* x_return,
244   int* y_return,
245   uint* width_return,
246   uint* height_return,
247   uint* border_width_return,
248   uint* depth_return ) ;
249
250 ! 4.2 - Translating Screen Coordinates
251
252 FUNCTION: Bool XQueryPointer ( Display* display, Window w, Window* root_return, Window* child_return, int* root_x_return, int* root_y_return, int* win_x_return, int* win_y_return, uint* mask_return ) ;
253
254 ! 4.3 - Properties and Atoms
255
256 FUNCTION: Atom XInternAtom ( Display* display, char* atom_name, Bool only_if_exists ) ;
257
258 FUNCTION: char* XGetAtomName ( Display* display, Atom atom ) ;
259
260 ! 4.4 - Obtaining and Changing Window Properties
261
262 FUNCTION: int XGetWindowProperty ( Display* display, Window w, Atom property, long long_offset, long long_length, Bool delete, Atom req_type, Atom* actual_type_return, int* actual_format_return, ulong* nitems_return, ulong* bytes_after_return, char** prop_return ) ;
263
264 FUNCTION: int XChangeProperty ( Display* display, Window w, Atom property, Atom type, int format, int mode, void* data, int nelements ) ;
265
266 ! 4.5 Selections
267
268 FUNCTION: int XSetSelectionOwner ( Display* display, Atom selection, Window owner, Time time ) ;
269
270 FUNCTION: Window XGetSelectionOwner ( Display* display, Atom selection ) ;
271
272 FUNCTION: int XConvertSelection ( Display* display, Atom selection, Atom target, Atom property, Window requestor, Time time ) ;
273
274 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
275 ! 6 - Color Management Functions
276 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
277
278 C-STRUCT: XColor
279         { "ulong" "pixel" }
280         { "ushort" "red" }
281         { "ushort" "green" }
282         { "ushort" "blue" }
283         { "char" "flags" }
284         { "char" "pad" } ;
285
286 FUNCTION: Status XLookupColor ( Display* display, Colormap colormap, char* color_name, XColor* exact_def_return, XColor* screen_def_return ) ;
287 FUNCTION: Status XAllocColor ( Display* display, Colormap colormap, XColor* screen_in_out ) ;
288 FUNCTION: Status XQueryColor ( Display* display, Colormap colormap, XColor* def_in_out ) ;
289
290 ! 6.4 Creating, Copying, and Destroying Colormaps
291
292 FUNCTION: Colormap XCreateColormap ( Display* display, Window w, Visual* visual, int alloc ) ;
293
294 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
295 ! 7 - Graphics Context Functions
296 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
297
298 : GCFunction            1 0 shift ; inline
299 : GCPlaneMask           1 1 shift ; inline
300 : GCForeground          1 2 shift ; inline
301 : GCBackground          1 3 shift ; inline
302 : GCLineWidth           1 4 shift ; inline
303 : GCLineStyle           1 5 shift ; inline
304 : GCCapStyle            1 6 shift ; inline
305 : GCJoinStyle           1 7 shift ; inline
306 : GCFillStyle           1 8 shift ; inline
307 : GCFillRule            1 9 shift ; inline
308 : GCTile                1 10 shift ; inline
309 : GCStipple             1 11 shift ; inline
310 : GCTileStipXOrigin     1 12 shift ; inline
311 : GCTileStipYOrigin     1 13 shift ; inline
312 : GCFont                1 14 shift ; inline
313 : GCSubwindowMode       1 15 shift ; inline
314 : GCGraphicsExposures   1 16 shift ; inline
315 : GCClipXOrigin         1 17 shift ; inline
316 : GCClipYOrigin         1 18 shift ; inline
317 : GCClipMask            1 19 shift ; inline
318 : GCDashOffset          1 20 shift ; inline
319 : GCDashList            1 21 shift ; inline
320 : GCArcMode             1 22 shift ; inline
321
322 : GXclear               HEX: 0 ; inline
323 : GXand                 HEX: 1 ; inline
324 : GXandReverse          HEX: 2 ; inline
325 : GXcopy                HEX: 3 ; inline
326 : GXandInverted         HEX: 4 ; inline
327 : GXnoop                HEX: 5 ; inline
328 : GXxor                 HEX: 6 ; inline
329 : GXor                  HEX: 7 ; inline
330 : GXnor                 HEX: 8 ; inline
331 : GXequiv               HEX: 9 ; inline
332 : GXinvert              HEX: a ; inline
333 : GXorReverse           HEX: b ; inline
334 : GXcopyInverted        HEX: c ; inline
335 : GXorInverted          HEX: d ; inline
336 : GXnand                HEX: e ; inline
337 : GXset                 HEX: f ; inline
338
339 C-STRUCT: XGCValues
340         { "int" "function" }
341         { "ulong" "plane_mask" }
342         { "ulong" "foreground" }
343         { "ulong" "background" }
344         { "int" "line_width" }
345         { "int" "line_style" }
346         { "int" "cap_style" }
347         { "int" "join_style" }
348         { "int" "fill_style" }
349         { "int" "fill_rule" }
350         { "int" "arc_mode" }
351         { "Pixmap" "tile" }
352         { "Pixmap" "stipple" }
353         { "int" "ts_x_origin" }
354         { "int" "ts_y_origin" }
355         { "Font" "font" }
356         { "int" "subwindow_mode" }
357         { "Bool" "graphics_exposures" }
358         { "int" "clip_x_origin" }
359         { "int" "clip_y_origin" }
360         { "Pixmap" "clip_mask" }
361         { "int" "dash_offset" }
362         { "char" "dashes" } ;
363
364 FUNCTION: GC XCreateGC ( Display* display, Window d, ulong valuemask, XGCValues* values ) ;
365 FUNCTION: int XChangeGC ( Display* display, GC gc, ulong valuemask, XGCValues* values ) ;
366 FUNCTION: Status XGetGCValues ( Display* display, GC gc, ulong valuemask, XGCValues* values_return ) ;
367 FUNCTION: Status XSetForeground ( Display* display, GC gc, ulong foreground ) ;
368 FUNCTION: Status XSetBackground ( Display* display, GC gc, ulong background ) ;
369 FUNCTION: Status XSetFunction ( Display* display, GC gc, int function ) ;
370 FUNCTION: Status XSetSubwindowMode ( Display* display, GC gc, int subwindow_mode ) ;
371
372 FUNCTION: GContext XGContextFromGC ( GC gc ) ;
373
374 FUNCTION: Status XSetFont ( Display* display, GC gc, Font font ) ;
375
376 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
377 ! 8 - Graphics Functions
378 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
379
380 FUNCTION: Status XClearWindow ( Display* display, Window w ) ;
381 FUNCTION: Status XDrawPoint ( Display* display, Drawable d, GC gc, int x, int y ) ;
382 FUNCTION: Status XDrawLine ( Display* display, Drawable d, GC gc, int x1, int y1, int x2, int y2 ) ;
383 FUNCTION: Status XDrawArc ( Display* display, Drawable d, GC gc, int x, int y, uint width, uint height, int angle1, int angle2 ) ;
384 FUNCTION: Status XFillArc ( Display* display, Drawable d, GC gc, int x, int y, uint width, uint height, int angle1, int angle2 ) ;
385
386 ! 8.5 - Font Metrics
387
388 C-STRUCT: XCharStruct
389         { "short" "lbearing" }
390         { "short" "rbearing" }
391         { "short" "width" }
392         { "short" "ascent" }
393         { "short" "descent" }
394         { "ushort" "attributes" } ;
395
396 FUNCTION: Font XLoadFont ( Display* display, char* name ) ;
397 FUNCTION: XFontStruct* XQueryFont ( Display* display, XID font_ID ) ;
398 FUNCTION: XFontStruct* XLoadQueryFont ( Display* display, char* name ) ;
399
400 C-STRUCT: XFontStruct
401         { "XExtData*" "ext_data" }
402         { "Font" "fid" }
403         { "uint" "direction" }
404         { "uint" "min_char_or_byte2" }
405         { "uint" "max_char_or_byte2" }
406         { "uint" "min_byte1" }
407         { "uint" "max_byte1" }
408         { "Bool" "all_chars_exist" }
409         { "uint" "default_char" }
410         { "int" "n_properties" }
411         { "XFontProp*" "properties" }
412         { "XCharStruct" "min_bounds" }
413         { "XCharStruct" "max_bounds" }
414         { "XCharStruct*" "per_char" }
415         { "int" "ascent" }
416         { "int" "descent" } ;
417
418 FUNCTION: int XTextWidth ( XFontStruct* font_struct, char* string, int count ) ;
419
420 ! 8.6 - Drawing Text
421
422 FUNCTION: Status XDrawString (
423         Display* display,
424         Drawable d,
425         GC gc,
426         int x,
427         int y,
428         char* string,
429         int length ) ;
430
431 !
432 ! 9 - Window and Session Manager Functions
433 !
434
435 FUNCTION: Status XReparentWindow ( Display* display, Window w, Window parent, int x, int y ) ;
436 FUNCTION: Status XAddToSaveSet ( Display* display, Window w ) ;
437 FUNCTION: Status XRemoveFromSaveSet ( Display* display, Window w ) ;
438 FUNCTION: Status XGrabServer ( Display* display ) ;
439 FUNCTION: Status XUngrabServer ( Display* display ) ;
440 FUNCTION: Status XKillClient ( Display* display, XID resource ) ;
441
442 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
443 ! 10 - Events
444 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
445
446 ! 10.3 - Event Masks
447
448 : NoEventMask                   0 ; inline
449 : KeyPressMask                  1 0 shift ; inline
450 : KeyReleaseMask                1 1 shift ; inline
451 : ButtonPressMask               1 2 shift ; inline
452 : ButtonReleaseMask             1 3 shift ; inline
453 : EnterWindowMask               1 4 shift ; inline
454 : LeaveWindowMask               1 5 shift ; inline
455 : PointerMotionMask             1 6 shift ; inline
456 : PointerMotionHintMask         1 7 shift ; inline
457 : Button1MotionMask             1 8 shift ; inline
458 : Button2MotionMask             1 9 shift ; inline
459 : Button3MotionMask             1 10 shift ; inline
460 : Button4MotionMask             1 11 shift ; inline
461 : Button5MotionMask             1 12 shift ; inline
462 : ButtonMotionMask              1 13 shift ; inline
463 : KeymapStateMask               1 14 shift ; inline
464 : ExposureMask                  1 15 shift ; inline
465 : VisibilityChangeMask          1 16 shift ; inline
466 : StructureNotifyMask           1 17 shift ; inline
467 : ResizeRedirectMask            1 18 shift ; inline
468 : SubstructureNotifyMask        1 19 shift ; inline
469 : SubstructureRedirectMask      1 20 shift ; inline
470 : FocusChangeMask               1 21 shift ; inline
471 : PropertyChangeMask            1 22 shift ; inline
472 : ColormapChangeMask            1 23 shift ; inline
473 : OwnerGrabButtonMask           1 24 shift ; inline
474
475 : KeyPress              2 ; inline
476 : KeyRelease            3 ; inline
477 : ButtonPress           4 ; inline
478 : ButtonRelease         5 ; inline
479 : MotionNotify          6 ; inline
480 : EnterNotify           7 ; inline
481 : LeaveNotify           8 ; inline
482 : FocusIn                       9 ; inline
483 : FocusOut              10 ; inline
484 : KeymapNotify          11 ; inline
485 : Expose                        12 ; inline
486 : GraphicsExpose                13 ; inline
487 : NoExpose              14 ; inline
488 : VisibilityNotify      15 ; inline
489 : CreateNotify          16 ; inline
490 : DestroyNotify         17 ; inline
491 : UnmapNotify           18 ; inline
492 : MapNotify             19 ; inline
493 : MapRequest            20 ; inline
494 : ReparentNotify                21 ; inline
495 : ConfigureNotify               22 ; inline
496 : ConfigureRequest      23 ; inline
497 : GravityNotify         24 ; inline
498 : ResizeRequest         25 ; inline
499 : CirculateNotify               26 ; inline
500 : CirculateRequest      27 ; inline
501 : PropertyNotify                28 ; inline
502 : SelectionClear                29 ; inline
503 : SelectionRequest      30 ; inline
504 : SelectionNotify               31 ; inline
505 : ColormapNotify                32 ; inline
506 : ClientMessage         33 ; inline
507 : MappingNotify         34 ; inline
508 : LASTEvent             35 ; inline
509
510 C-STRUCT: XAnyEvent
511         { "int" "type" }
512         { "ulong" "serial" }
513         { "Bool" "send_event" }
514         { "Display*" "display" }
515         { "Window" "window" } ;
516
517 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
518
519 ! 10.5 Keyboard and Pointer Events
520
521 : Button1 1 ; inline
522 : Button2 2 ; inline
523 : Button3 3 ; inline
524 : Button4 4 ; inline
525 : Button5 5 ; inline
526
527 : Button1Mask           1 8  shift ; inline
528 : Button2Mask           1 9  shift ; inline
529 : Button3Mask           1 10 shift ; inline
530 : Button4Mask           1 11 shift ; inline
531 : Button5Mask           1 12 shift ; inline
532
533 : ShiftMask     1 0 shift ; inline
534 : LockMask      1 1 shift ; inline
535 : ControlMask   1 2 shift ; inline
536 : Mod1Mask      1 3 shift ; inline
537 : Mod2Mask      1 4 shift ; inline
538 : Mod3Mask      1 5 shift ; inline
539 : Mod4Mask      1 6 shift ; inline
540 : Mod5Mask      1 7 shift ; inline
541
542 C-STRUCT: XButtonEvent
543         { "int" "type" }
544         { "ulong" "serial" }
545         { "Bool" "send_event" }
546         { "Display*" "display" }
547         { "Window" "window" }
548         { "Window" "root" }
549         { "Window" "subwindow" }
550         { "Time" "time" }
551         { "int" "x" }
552         { "int" "y" }
553         { "int" "x_root" }
554         { "int" "y_root" }
555         { "uint" "state" }
556         { "uint" "button" }
557         { "Bool" "same_screen" } ;
558
559 TYPEDEF: XButtonEvent XButtonPressedEvent
560 TYPEDEF: XButtonEvent XButtonReleasedEvent
561
562
563 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
564
565 C-STRUCT: XKeyEvent
566         { "int" "type" }
567         { "ulong" "serial" }
568         { "Bool" "send_event" }
569         { "Display*" "display" }
570         { "Window" "window" }
571         { "Window" "root" }
572         { "Window" "subwindow" }
573         { "Time" "time" }
574         { "int" "x" }
575         { "int" "y" }
576         { "int" "x_root" }
577         { "int" "y_root" }
578         { "uint" "state" }
579         { "uint" "keycode" }
580         { "Bool" "same_screen" } ;
581
582 TYPEDEF: XKeyEvent XKeyPressedEvent
583 TYPEDEF: XKeyEvent XKeyReleasedEvent
584
585 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
586
587 C-STRUCT: XMotionEvent
588         { "int" "type" }
589         { "ulong" "serial" }
590         { "Bool" "send_event" }
591         { "Display*" "display" }
592         { "Window" "window" }
593         { "Window" "root" }
594         { "Window" "subwindow" }
595         { "Time" "time" }
596         { "int" "x" }
597         { "int" "y" }
598         { "int" "x_root" }
599         { "int" "y_root" }
600         { "uint" "state" }
601         { "char" "is_hint" }
602         { "Bool" "same_screen" } ;
603
604 TYPEDEF: XMotionEvent XPointerMovedEvent
605
606 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
607
608 C-STRUCT: XCrossingEvent
609         { "int" "type" }
610         { "ulong" "serial" }
611         { "Bool" "send_event" }
612         { "Display*" "display" }
613         { "Window" "window" }
614         { "Window" "root" }
615         { "Window" "subwindow" }
616         { "Time" "time" }
617         { "int" "x" }
618         { "int" "y" }
619         { "int" "x_root" }
620         { "int" "y_root" }
621         { "int" "mode" }
622         { "int" "detail" }
623         { "Bool" "same_screen" }
624         { "Bool" "focus" }
625         { "uint" "state" } ;
626
627 TYPEDEF: XCrossingEvent XEnterWindowEvent
628 TYPEDEF: XCrossingEvent XLeaveWindowEvent
629
630 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
631
632 C-STRUCT: XFocusChangeEvent
633         { "int" "type" }
634         { "ulong" "serial" }
635         { "Bool" "send_event" }
636         { "Display*" "display" }
637         { "Window" "window" }
638         { "int" "mode" }
639         { "int" "detail" } ;
640
641 TYPEDEF: XFocusChangeEvent XFocusInEvent
642 TYPEDEF: XFocusChangeEvent XFocusOutEvent
643
644 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
645
646 C-STRUCT: XExposeEvent
647         { "int" "type" }
648         { "ulong" "serial" }
649         { "Bool" "send_event" }
650         { "Display*" "display" }
651         { "Window" "window" }
652         { "int" "x" }
653         { "int" "y" }
654         { "int" "width" }
655         { "int" "height" }
656         { "int" "count" } ;
657
658 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
659
660 C-STRUCT: XGraphicsExposeEvent
661         { "int" "type" }
662         { "ulong" "serial" }
663         { "Bool" "send_event" }
664         { "Display*" "display" }
665         { "Drawable" "drawable" }
666         { "int" "x" }
667         { "int" "y" }
668         { "int" "width" }
669         { "int" "height" }
670         { "int" "count" }
671         { "int" "major_code" }
672         { "int" "minor_code" } ;
673
674 C-STRUCT: XNoExposeEvent
675         { "int" "type" }
676         { "ulong" "serial" }
677         { "Bool" "send_event" }
678         { "Display*" "display" }
679         { "Drawable" "drawable" }
680         { "int" "major_code" }
681         { "int" "minor_code" } ;
682
683 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
684
685 C-STRUCT: XVisibilityEvent
686         { "int" "type" }
687         { "ulong" "serial" }
688         { "Bool" "send_event" }
689         { "Display*" "display" }
690         { "Window" "window" }
691         { "int" "state" } ;
692
693 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
694
695 C-STRUCT: XCreateWindowEvent
696         { "int" "type" }
697         { "ulong" "serial" }
698         { "Bool" "send_event" }
699         { "Display*" "display" }
700         { "Window" "parent" }
701         { "Window" "window" }
702         { "int" "x" }
703         { "int" "y" }
704         { "int" "width" }
705         { "int" "height" }
706         { "int" "border_width" }
707         { "Bool" "override_redirect" } ;
708
709 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
710
711 C-STRUCT: XDestroyWindowEvent
712         { "int" "type" }
713         { "ulong" "serial" }
714         { "Bool" "send_event" }
715         { "Display*" "display" }
716         { "Window" "event" }
717         { "Window" "window" } ;
718
719 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
720
721 C-STRUCT: XUnmapEvent
722         { "int" "type" }
723         { "ulong" "serial" }
724         { "Bool" "send_event" }
725         { "Display*" "display" }
726         { "Window" "event" }
727         { "Window" "window" }
728         { "Bool" "from_configure" } ;
729
730 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
731
732 C-STRUCT: XMapEvent
733         { "int" "type" }
734         { "ulong" "serial" }
735         { "Bool" "send_event" }
736         { "Display*" "display" }
737         { "Window" "event" }
738         { "Window" "window" }
739         { "Bool" "override_redirect" } ;
740
741 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
742
743 C-STRUCT: XMapRequestEvent
744         { "int" "type" }
745         { "ulong" "serial" }
746         { "Bool" "send_event" }
747         { "Display*" "display" }
748         { "Window" "parent" }
749         { "Window" "window" } ;
750
751 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
752
753 C-STRUCT: XReparentEvent
754         { "int" "type" }
755         { "ulong" "serial" }
756         { "Bool" "send_event" }
757         { "Display*" "display" }
758         { "Window" "event" }
759         { "Window" "window" }
760         { "Window" "parent" }
761         { "int" "x" }
762         { "int" "y" }
763         { "Bool" "override_redirect" } ;
764
765 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
766
767 C-STRUCT: XConfigureEvent
768         { "int" "type" }
769         { "ulong" "serial" }
770         { "Bool" "send_event" }
771         { "Display*" "display" }
772         { "Window" "event" }
773         { "Window" "window" }
774         { "int" "x" }
775         { "int" "y" }
776         { "int" "width" }
777         { "int" "height" }
778         { "int" "border_width" }
779         { "Window" "above" }
780         { "Bool" "override_redirect" } ;
781
782 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
783
784 C-STRUCT: XGravityEvent
785         { "int" "type" }
786         { "ulong" "serial" }
787         { "Bool" "send_event" }
788         { "Display*" "display" }
789         { "Window" "event" }
790         { "Window" "window" }
791         { "int" "x" }
792         { "int" "y" } ;
793
794 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
795
796 C-STRUCT: XResizeRequestEvent
797         { "int" "type" }
798         { "ulong" "serial" }
799         { "Bool" "send_event" }
800         { "Display*" "display" }
801         { "Window" "window" }
802         { "int" "width" }
803         { "int" "height" } ;
804
805 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
806
807 C-STRUCT: XConfigureRequestEvent
808         { "int" "type" }
809         { "ulong" "serial" }
810         { "Bool" "send_event" }
811         { "Display*" "display" }
812         { "Window" "parent" }
813         { "Window" "window" }
814         { "int" "x" }
815         { "int" "y" }
816         { "int" "width" }
817         { "int" "height" }
818         { "int" "border_width" }
819         { "Window" "above" }
820         { "int" "detail" }
821         { "ulong" "value_mask" } ;
822
823 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
824
825 C-STRUCT: XCirculateEvent
826         { "int" "type" }
827         { "ulong" "serial" }
828         { "Bool" "send_event" }
829         { "Display*" "display" }
830         { "Window" "event" }
831         { "Window" "window" }
832         { "int" "place" } ;
833
834 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
835
836 C-STRUCT: XCirculateRequestEvent
837         { "int" "type" }
838         { "ulong" "serial" }
839         { "Bool" "send_event" }
840         { "Display*" "display" }
841         { "Window" "parent" }
842         { "Window" "window" }
843         { "int" "place" } ;
844
845 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
846
847 C-STRUCT: XPropertyEvent
848         { "int" "type" }
849         { "ulong" "serial" }
850         { "Bool" "send_event" }
851         { "Display*" "display" }
852         { "Window" "window" }
853         { "Atom" "atom" }
854         { "Time" "time" }
855         { "int" "state" } ;
856
857 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
858
859 C-STRUCT: XSelectionClearEvent
860         { "int" "type" }
861         { "ulong" "serial" }
862         { "Bool" "send_event" }
863         { "Display*" "display" }
864         { "Window" "window" }
865         { "Atom" "selection" }
866         { "Time" "time" } ;
867
868 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
869
870 C-STRUCT: XSelectionRequestEvent
871         { "int" "type" }
872         { "ulong" "serial" }
873         { "Bool" "send_event" }
874         { "Display*" "display" }
875         { "Window" "owner" }
876         { "Window" "requestor" }
877         { "Atom" "selection" }
878         { "Atom" "target" }
879         { "Atom" "property" }
880         { "Time" "time" } ;
881
882 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
883
884 C-STRUCT: XSelectionEvent
885         { "int" "type" }
886         { "ulong" "serial" }
887         { "Bool" "send_event" }
888         { "Display*" "display" }
889         { "Window" "requestor" }
890         { "Atom" "selection" }
891         { "Atom" "target" }
892         { "Atom" "property" }
893         { "Time" "time" } ;
894
895 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
896
897 C-STRUCT: XColormapEvent
898         { "int" "type" }
899         { "ulong" "serial" }
900         { "Bool" "send_event" }
901         { "Display*" "display" }
902         { "Window" "window" }
903         { "Colormap" "colormap" }
904         { "Bool" "new" }
905         { "int" "state" } ;
906
907 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
908
909 C-STRUCT: XClientMessageEvent
910         { "int" "type" }
911         { "ulong" "serial" }
912         { "Bool" "send_event" }
913         { "Display*" "display" }
914         { "Window" "window" }
915         { "Atom" "message_type" }
916         { "int" "format" }
917         { "long" "data0" }
918         { "long" "data1" }
919         { "long" "data2" }
920         { "long" "data3" }
921         { "long" "data4" }
922 !       union {
923 !               char  b[20];
924 !               short s[10];
925 !               long  l[5];
926 !       } data;
927 ;
928
929 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
930
931 C-STRUCT: XMappingEvent
932         { "int" "type" }
933         { "ulong" "serial" }
934         { "Bool" "send_event" }
935         { "Display*" "display" }
936         { "Window" "window" }
937         { "int" "request" }
938         { "int" "first_keycode" }
939         { "int" "count" } ;
940
941 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
942
943 C-STRUCT: XErrorEvent
944         { "int" "type" }
945         { "Display*" "display" }
946         { "XID" "resourceid" }
947         { "ulong" "serial" }
948         { "uchar" "error_code" }
949         { "uchar" "request_code" }
950         { "uchar" "minor_code" } ;
951
952 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
953
954 C-STRUCT: XKeymapEvent
955         { "int" "type" }
956         { "ulong" "serial" }
957         { "Bool" "send_event" }
958         { "Display*" "display" }
959         { "Window" "window" }
960         ! char key_vector[32];
961         { "int" "pad" }
962         { "int" "pad" }
963         { "int" "pad" }
964         { "int" "pad" }
965         { "int" "pad" }
966         { "int" "pad" }
967         { "int" "pad" }
968         { "int" "pad" } ;
969
970 C-UNION: XEvent
971         "int"
972         "XAnyEvent"
973         "XKeyEvent"
974         "XButtonEvent"
975         "XMotionEvent"
976         "XCrossingEvent"
977         "XFocusChangeEvent"
978         "XExposeEvent"
979         "XGraphicsExposeEvent"
980         "XNoExposeEvent"
981         "XVisibilityEvent"
982         "XCreateWindowEvent"
983         "XDestroyWindowEvent"
984         "XUnmapEvent"
985         "XMapEvent"
986         "XMapRequestEvent"
987         "XReparentEvent"
988         "XConfigureEvent"
989         "XGravityEvent"
990         "XResizeRequestEvent"
991         "XConfigureRequestEvent"
992         "XCirculateEvent"
993         "XCirculateRequestEvent"
994         "XPropertyEvent"
995         "XSelectionClearEvent"
996         "XSelectionRequestEvent"
997         "XSelectionEvent"
998         "XColormapEvent"
999         "XClientMessageEvent"
1000         "XMappingEvent"
1001         "XErrorEvent"
1002         "XKeymapEvent"
1003         { "long" 24 } ;
1004
1005 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1006 ! 11 - Event Handling Functions
1007 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1008
1009 FUNCTION: Status XSelectInput ( Display* display, Window w, long event_mask ) ;
1010 FUNCTION: Status XFlush ( Display* display ) ;
1011 FUNCTION: Status XSync ( Display* display, int discard ) ;
1012 FUNCTION: Status XNextEvent ( Display* display, XEvent* event ) ;
1013 FUNCTION: Status XMaskEvent ( Display* display, long event_mask, XEvent* event_return ) ;
1014
1015 ! 11.3 - Event Queue Management
1016
1017 : QueuedAlready 0 ; inline
1018 : QueuedAfterReading 1 ; inline
1019 : QueuedAfterFlush 2 ; inline
1020
1021 FUNCTION: int XEventsQueued ( Display* display, int mode ) ;
1022 FUNCTION: int XPending ( Display* display ) ;
1023
1024 ! 11.6 - Sending Events to Other Applications
1025
1026 FUNCTION: Status XSendEvent ( Display* display, Window w, Bool propagate, long event_mask, XEvent* event_send ) ;
1027
1028 ! 11.8 - Handling Protocol Errors
1029
1030 FUNCTION: int XSetErrorHandler ( void* handler ) ;
1031
1032 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1033 ! 12 - Input Device Functions
1034 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1035
1036 : None 0 ; inline
1037
1038 FUNCTION: int XGrabPointer (
1039   Display* display,
1040   Window grab_window,
1041   Bool owner_events,
1042   uint event_mask,
1043   int pointer_mode,
1044   int keyboard_mode,
1045   Window confine_to,
1046   Cursor cursor,
1047   Time time ) ;
1048
1049 FUNCTION: Status XUngrabPointer ( Display* display, Time time ) ;
1050 FUNCTION: Status XChangeActivePointerGrab ( Display* display, uint event_mask, Cursor cursor, Time time ) ;
1051 FUNCTION: Status XGrabKey ( Display* display, int keycode, uint modifiers, Window grab_window, Bool owner_events, int pointer_mode, int keyboard_mode ) ;
1052 FUNCTION: Status XSetInputFocus ( Display* display, Window focus, int revert_to, Time time ) ;
1053
1054 FUNCTION: Status XGetInputFocus ( Display* display,
1055                                   Window*  focus_return,
1056                                   int*     revert_to_return ) ;
1057
1058 FUNCTION: Status XWarpPointer ( Display* display, Window src_w, Window dest_w, int src_x, int src_y, uint src_width, uint src_height, int dest_x, int dest_y ) ;
1059
1060 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1061 ! 14 - Inter-Client Communication Functions
1062 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1063
1064 ! 14.1 Client to Window Manager Communication
1065
1066 FUNCTION: Status XFetchName ( Display* display, Window w, char** window_name_return ) ;
1067 FUNCTION: Status XGetTransientForHint ( Display* display, Window w, Window* prop_window_return ) ;
1068
1069 ! 14.1.1.  Manipulating Top-Level Windows
1070
1071 FUNCTION: Status XIconifyWindow (
1072         Display* display, Window w, int screen_number ) ;
1073
1074 FUNCTION: Status XWithdrawWindow (
1075         Display* display, Window w, int screen_number ) ;
1076
1077 ! 14.1.6 - Setting and Reading the WM_HINTS Property
1078
1079 ! 17.1.7 - Setting and Reading the WM_NORMAL_HINTS Property
1080
1081 : USPosition    1 0 shift ; inline
1082 : USSize        1 1 shift ; inline
1083 : PPosition     1 2 shift ; inline
1084 : PSize         1 3 shift ; inline
1085 : PMinSize      1 4 shift ; inline
1086 : PMaxSize      1 5 shift ; inline
1087 : PResizeInc    1 6 shift ; inline
1088 : PAspect       1 7 shift ; inline
1089 : PBaseSize     1 8 shift ; inline
1090 : PWinGravity   1 9 shift ; inline
1091 : PAllHints [ PPosition PSize PMinSize PMaxSize PResizeInc PAspect ]
1092 0 [ execute bitor ] reduce ; inline
1093
1094 C-STRUCT: XSizeHints
1095     { "long" "flags" }
1096     { "int" "x" }
1097     { "int" "y" }
1098     { "int" "width" }
1099     { "int" "height" }
1100     { "int" "min_width" }
1101     { "int" "min_height" }
1102     { "int" "max_width" }
1103     { "int" "max_height" }
1104     { "int" "width_inc" }
1105     { "int" "height_inc" }
1106     { "int" "min_aspect_x" }
1107     { "int" "min_aspect_y" }
1108     { "int" "max_aspect_x" }
1109     { "int" "max_aspect_y" }
1110     { "int" "base_width" }
1111     { "int" "base_height" }
1112     { "int" "win_gravity" } ;
1113
1114 ! 14.1.10.  Setting and Reading the WM_PROTOCOLS Property
1115
1116 FUNCTION: Status XSetWMProtocols (
1117         Display* display, Window w, Atom* protocols, int count ) ;
1118
1119 FUNCTION: Status XGetWMProtocols (
1120         Display* display,
1121         Window w,
1122         Atom** protocols_return,
1123         int* count_return ) ;
1124
1125 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1126 ! 16 - Application Utility Functions
1127 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1128
1129 ! 16.1 Keyboard Utility Functions
1130
1131 FUNCTION: KeySym XLookupKeysym ( XKeyEvent* key_event, int index ) ;
1132
1133 FUNCTION: int XLookupString (
1134         XKeyEvent* event_struct,
1135         void* buffer_return,
1136         int bytes_buffer,
1137         KeySym* keysym_return,
1138         XComposeStatus* status_in_out ) ;
1139
1140 ! 16.7 Determining the Appropriate Visual Type
1141
1142 : VisualNoMask                  HEX: 0 ; inline
1143 : VisualIDMask                  HEX: 1 ; inline
1144 : VisualScreenMask              HEX: 2 ; inline
1145 : VisualDepthMask               HEX: 4 ; inline
1146 : VisualClassMask               HEX: 8 ; inline
1147 : VisualRedMaskMask             HEX: 10 ; inline
1148 : VisualGreenMaskMask           HEX: 20 ; inline
1149 : VisualBlueMaskMask            HEX: 40 ; inline
1150 : VisualColormapSizeMask        HEX: 80 ; inline
1151 : VisualBitsPerRGBMask          HEX: 100 ; inline
1152 : VisualAllMask                 HEX: 1FF ; inline
1153
1154 C-STRUCT: XVisualInfo
1155         { "Visual*" "visual" }
1156         { "VisualID" "visualid" }
1157         { "int" "screen" }
1158         { "uint" "depth" }
1159         { "int" "class" }
1160         { "ulong" "red_mask" }
1161         { "ulong" "green_mask" }
1162         { "ulong" "blue_mask" }
1163         { "int" "colormap_size" }
1164         { "int" "bits_per_rgb" } ;
1165
1166 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1167 ! Appendix D - Compatibility Functions
1168 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1169
1170 FUNCTION: Status XSetStandardProperties (
1171         Display* display,
1172         Window w,
1173         char* window_name,
1174         char* icon_name,
1175         Pixmap icon_pixmap,
1176         char** argv,
1177         int argc,
1178         XSizeHints* hints ) ;
1179
1180 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1181
1182 : XA_PRIMARY  1 ; inline
1183 : XA_SECONDARY 2 ; inline
1184 : XA_ARC 3 ; inline
1185 : XA_ATOM 4 ; inline
1186 : XA_BITMAP 5 ; inline
1187 : XA_CARDINAL 6 ; inline
1188 : XA_COLORMAP 7 ; inline
1189 : XA_CURSOR 8 ; inline
1190 : XA_CUT_BUFFER0 9 ; inline
1191 : XA_CUT_BUFFER1 10 ; inline
1192 : XA_CUT_BUFFER2 11 ; inline
1193 : XA_CUT_BUFFER3 12 ; inline
1194 : XA_CUT_BUFFER4 13 ; inline
1195 : XA_CUT_BUFFER5 14 ; inline
1196 : XA_CUT_BUFFER6 15 ; inline
1197 : XA_CUT_BUFFER7 16 ; inline
1198 : XA_DRAWABLE 17 ; inline
1199 : XA_FONT 18 ; inline
1200 : XA_INTEGER 19 ; inline
1201 : XA_PIXMAP 20 ; inline
1202 : XA_POINT 21 ; inline
1203 : XA_RECTANGLE 22 ; inline
1204 : XA_RESOURCE_MANAGER 23 ; inline
1205 : XA_RGB_COLOR_MAP 24 ; inline
1206 : XA_RGB_BEST_MAP 25 ; inline
1207 : XA_RGB_BLUE_MAP 26 ; inline
1208 : XA_RGB_DEFAULT_MAP 27 ; inline
1209 : XA_RGB_GRAY_MAP 28 ; inline
1210 : XA_RGB_GREEN_MAP 29 ; inline
1211 : XA_RGB_RED_MAP 30 ; inline
1212 : XA_STRING 31 ; inline
1213 : XA_VISUALID 32 ; inline
1214 : XA_WINDOW 33 ; inline
1215 : XA_WM_COMMAND 34 ; inline
1216 : XA_WM_HINTS 35 ; inline
1217 : XA_WM_CLIENT_MACHINE 36 ; inline
1218 : XA_WM_ICON_NAME 37 ; inline
1219 : XA_WM_ICON_SIZE 38 ; inline
1220 : XA_WM_NAME 39 ; inline
1221 : XA_WM_NORMAL_HINTS 40 ; inline
1222 : XA_WM_SIZE_HINTS 41 ; inline
1223 : XA_WM_ZOOM_HINTS 42 ; inline
1224 : XA_MIN_SPACE 43 ; inline
1225 : XA_NORM_SPACE 44 ; inline
1226 : XA_MAX_SPACE 45 ; inline
1227 : XA_END_SPACE 46 ; inline
1228 : XA_SUPERSCRIPT_X 47 ; inline
1229 : XA_SUPERSCRIPT_Y 48 ; inline
1230 : XA_SUBSCRIPT_X 49 ; inline
1231 : XA_SUBSCRIPT_Y 50 ; inline
1232 : XA_UNDERLINE_POSITION 51 ; inline
1233 : XA_UNDERLINE_THICKNESS 52 ; inline
1234 : XA_STRIKEOUT_ASCENT 53 ; inline
1235 : XA_STRIKEOUT_DESCENT 54 ; inline
1236 : XA_ITALIC_ANGLE 55 ; inline
1237 : XA_X_HEIGHT 56 ; inline
1238 : XA_QUAD_WIDTH 57 ; inline
1239 : XA_WEIGHT 58 ; inline
1240 : XA_POINT_SIZE 59 ; inline
1241 : XA_RESOLUTION 60 ; inline
1242 : XA_COPYRIGHT 61 ; inline
1243 : XA_NOTICE 62 ; inline
1244 : XA_FONT_NAME 63 ; inline
1245 : XA_FAMILY_NAME 64 ; inline
1246 : XA_FULL_NAME 65 ; inline
1247 : XA_CAP_HEIGHT 66 ; inline
1248 : XA_WM_CLASS 67 ; inline
1249 : XA_WM_TRANSIENT_FOR 68 ; inline
1250
1251 : XA_LAST_PREDEFINED 68 ; inline
1252     
1253 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1254 ! The rest of the stuff is not from the book.
1255 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1256
1257 FUNCTION: void XFree ( void* data ) ;
1258 FUNCTION: int XStoreName ( Display* display, Window w, char* window_name ) ;
1259
1260 FUNCTION: void XSetWMNormalHints ( Display* display, Window w, XSizeHints* hints ) ;
1261
1262 ! !!! INPUT METHODS
1263
1264 : XIMPreeditArea      HEX: 0001 ;
1265 : XIMPreeditCallbacks HEX: 0002 ;
1266 : XIMPreeditPosition  HEX: 0004 ;
1267 : XIMPreeditNothing   HEX: 0008 ;
1268 : XIMPreeditNone      HEX: 0010 ;
1269 : XIMStatusArea       HEX: 0100 ;
1270 : XIMStatusCallbacks  HEX: 0200 ;
1271 : XIMStatusNothing    HEX: 0400 ;
1272 : XIMStatusNone       HEX: 0800 ;
1273
1274 : XNVaNestedList "XNVaNestedList" ;
1275 : XNQueryInputStyle "queryInputStyle" ;
1276 : XNClientWindow "clientWindow" ;
1277 : XNInputStyle "inputStyle" ;
1278 : XNFocusWindow "focusWindow" ;
1279 : XNResourceName "resourceName" ;
1280 : XNResourceClass "resourceClass" ;
1281 : XNGeometryCallback "geometryCallback" ;
1282 : XNDestroyCallback "destroyCallback" ;
1283 : XNFilterEvents "filterEvents" ;
1284 : XNPreeditStartCallback "preeditStartCallback" ;
1285 : XNPreeditDoneCallback "preeditDoneCallback" ;
1286 : XNPreeditDrawCallback "preeditDrawCallback" ;
1287 : XNPreeditCaretCallback "preeditCaretCallback" ;
1288 : XNPreeditStateNotifyCallback "preeditStateNotifyCallback" ;
1289 : XNPreeditAttributes "preeditAttributes" ;
1290 : XNStatusStartCallback "statusStartCallback" ;
1291 : XNStatusDoneCallback "statusDoneCallback" ;
1292 : XNStatusDrawCallback "statusDrawCallback" ;
1293 : XNStatusAttributes "statusAttributes" ;
1294 : XNArea "area" ;
1295 : XNAreaNeeded "areaNeeded" ;
1296 : XNSpotLocation "spotLocation" ;
1297 : XNColormap "colorMap" ;
1298 : XNStdColormap "stdColorMap" ;
1299 : XNForeground "foreground" ;
1300 : XNBackground "background" ;
1301 : XNBackgroundPixmap "backgroundPixmap" ;
1302 : XNFontSet "fontSet" ;
1303 : XNLineSpace "lineSpace" ;
1304 : XNCursor "cursor" ;
1305
1306 : XNQueryIMValuesList "queryIMValuesList" ;
1307 : XNQueryICValuesList "queryICValuesList" ;
1308 : XNVisiblePosition "visiblePosition" ;
1309 : XNR6PreeditCallback "r6PreeditCallback" ;
1310 : XNStringConversionCallback "stringConversionCallback" ;
1311 : XNStringConversion "stringConversion" ;
1312 : XNResetState "resetState" ;
1313 : XNHotKey "hotKey" ;
1314 : XNHotKeyState "hotKeyState" ;
1315 : XNPreeditState "preeditState" ;
1316 : XNSeparatorofNestedList "separatorofNestedList" ;
1317
1318 : XBufferOverflow -1 ;
1319 : XLookupNone      1 ;
1320 : XLookupChars     2 ;
1321 : XLookupKeySym    3 ;
1322 : XLookupBoth      4 ;
1323
1324 FUNCTION: Bool XFilterEvent ( XEvent* event, Window w ) ;
1325
1326 FUNCTION: XIM XOpenIM ( Display* dpy, void* rdb, char* res_name, char* res_class ) ;
1327
1328 FUNCTION: Status XCloseIM ( XIM im ) ;
1329
1330 FUNCTION: XIC XCreateIC ( XIM im, char* key1, Window value1, char* key2, Window value2, char* key3, int value3, char* key4, char* value4, char* key5, char* value5, int key6 ) ;
1331
1332 FUNCTION: void XDestroyIC ( XIC ic ) ;
1333
1334 FUNCTION: void XSetICFocus ( XIC ic ) ;
1335         
1336 FUNCTION: void XUnsetICFocus ( XIC ic ) ;
1337
1338 FUNCTION: int XwcLookupString ( XIC ic, XKeyPressedEvent* event, ulong* buffer_return, int bytes_buffer, KeySym* keysym_return, Status* status_return ) ;
1339
1340 FUNCTION: int Xutf8LookupString ( XIC ic, XKeyPressedEvent* event, char* buffer_return, int bytes_buffer, KeySym* keysym_return, Status* status_return ) ;
1341
1342 SYMBOL: dpy
1343 SYMBOL: scr
1344 SYMBOL: root
1345
1346 : flush-dpy ( -- ) dpy get XFlush drop ;
1347
1348 : x-atom ( string -- atom ) dpy get swap 0 XInternAtom ;
1349
1350 : check-display
1351     [
1352         "Cannot connect to X server - check $DISPLAY" throw
1353     ] unless* ;
1354
1355 : initialize-x ( display-string -- )
1356     dup [ string>char-alien ] when
1357     XOpenDisplay check-display dpy set-global
1358     dpy get XDefaultScreen scr set-global
1359     dpy get scr get XRootWindow root set-global ;
1360
1361 : close-x ( -- ) dpy get XCloseDisplay drop ;
1362
1363 : with-x ( display-string quot -- )
1364     >r initialize-x r> [ close-x ] [ ] cleanup ;