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