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