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