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