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