comparison dynamin/c/xlib.d @ 0:aa4efef0f0b1

Initial commit of code.
author Jordan Miner <jminer7@gmail.com>
date Mon, 15 Jun 2009 22:10:48 -0500
parents
children e6e201c3a439
comparison
equal deleted inserted replaced
-1:000000000000 0:aa4efef0f0b1
1 module dynamin.c.xlib;
2
3 /*
4 * A binding to at least the part of the X Window System that Dynamin uses. This
5 * binding is incomplete as it is made only for Dynamin's use.
6 */
7
8 import dynamin.c.x_types;
9
10 version(build) { pragma(link, X11); }
11
12 extern(C):
13
14 alias ubyte* XPointer;
15 alias uint XID;
16 // export these with an X prefix so they won't as easily conflict
17 alias uint XMask;
18 alias uint XAtom;
19 alias uint XVisualID;
20 alias uint XTime;
21 alias XID XWindow;
22 alias XID XDrawable;
23 alias XID XPixmap;
24 alias XID XCursor;
25 alias XID XColormap;
26 alias XID XKeySym;
27 alias ubyte XKeyCode;
28 alias int XBool;
29 alias int XStatus;
30
31 alias void XScreen;
32 alias void XDisplay;
33
34 const None = 0;
35 const ParentRelative = 1;
36 const CopyFromParent = 0;
37 const PointerWindow = 0;
38 const InputFocus = 1;
39 const PointerRoot = 1;
40 const AnyPropertyType = 0;
41 const AnyKey = 0;
42 const AnyButton = 0;
43 const AllTemporary = 0;
44 const CurrentTime = 0;
45 const NoSymbol = 0;
46
47 //{{{ display functions
48 Display* XOpenDisplay(char* display_name);
49
50 int XNextEvent(Display* display, XEvent* event_return);
51
52 int XEventsQueued(Display* display, int mode);
53
54 int XPending(Display* display);
55
56 int XPutBackEvent(Display* display, XEvent* event);
57
58 Status XSendEvent(
59 Display* display,
60 Window w,
61 Bool propagate,
62 int event_mask,
63 XEvent* event_send);
64
65 int XCloseDisplay(Display* display);
66
67 char* XDisplayString(Display* display);
68
69 int XFlush(Display* display);
70
71 int XSync(Display* display, Bool discard);
72
73 int XDisplayWidth(Display* display, int screen_number);
74
75 int XDisplayHeight(Display* display, int screen_number);
76
77 int XProtocolRevision(Display* display);
78
79 int XProtocolVersion(Display* display);
80
81 Colormap XDefaultColormap(Display* display, int screen_number);
82
83 Status XAllocColor(Display* display, Colormap colormap, XColor* screen_in_out);
84 //}}}
85
86 //{{{ window functions
87 Window XCreateSimpleWindow(
88 Display* display,
89 Window parent,
90 int x,
91 int y,
92 uint width,
93 uint height,
94 uint border_width,
95 uint border,
96 uint background);
97
98 Window XCreateWindow(
99 Display* display,
100 Window parent,
101 int x,
102 int y,
103 uint width,
104 uint height,
105 uint border_width,
106 int depth,
107 uint c_class,
108 Visual* visual,
109 uint valuemask,
110 XSetWindowAttributes* attributes);
111
112 int XDestroyWindow(Display* display, Window w);
113
114 int XClearArea(
115 Display* display,
116 Window w,
117 int x,
118 int y,
119 uint width,
120 uint height,
121 Bool exposures);
122
123 Window XRootWindow(Display* display, int screen_number);
124
125 Window XDefaultRootWindow(Display* display);
126
127 Status XQueryTree(
128 Display* display,
129 Window w,
130 Window* root_return,
131 Window* parent_return,
132 Window** children_return,
133 uint* nchildren_return);
134
135 Bool XTranslateCoordinates(
136 Display* display,
137 Window src_w,
138 Window dest_w,
139 int src_x,
140 int src_y,
141 int* dest_x_return,
142 int* dest_y_return,
143 Window* child_return);
144
145 Window XRootWindowOfScreen(Screen* screen);
146
147 Status XIconifyWindow(Display* display, Window w, int screen_number);
148
149 Status XWithdrawWindow(Display* display, Window w, int screen_number);
150
151 int XChangeProperty(
152 Display* display,
153 Window w,
154 Atom property,
155 Atom type,
156 int format,
157 int mode,
158 void* data,
159 int nelements);
160
161 Bool XCheckIfEvent(
162 Display* display,
163 XEvent* event_return,
164 Bool function(Display* display,
165 XEvent* event,
166 XPointer arg) predicate,
167 XPointer arg);
168
169 int XGetWindowProperty(
170 Display* display,
171 Window w,
172 Atom property,
173 int long_offset,
174 int long_length,
175 Bool should_delete,
176 Atom req_type,
177 Atom* actual_type_return,
178 int* actual_format_return,
179 uint* nitems_return,
180 uint* bytes_after_return,
181 void** prop_return);
182
183 int XDeleteProperty(Display* display, Window w, Atom property);
184
185 int XMapWindow(Display* display, Window w);
186
187 int XUnmapWindow(Display* display, Window w);
188
189 int XMoveWindow(Display* display, Window w, int x, int y);
190
191 int XResizeWindow(Display* display, Window w, uint width, uint height);
192
193 int XMoveResizeWindow(Display* display, Window w,
194 int x, int y, uint width, uint height);
195
196 int XSelectInput(Display* display, Window w, int event_mask);
197
198 int XReparentWindow(Display* display, Window w, Window parent, int x, int y);
199
200 int XRestackWindows(Display* display, Window* windows, int nwindows);
201
202 int XChangeWindowAttributes(
203 Display* display,
204 Window w,
205 uint valuemask,
206 XSetWindowAttributes* attributes);
207
208 Status XGetWindowAttributes(
209 Display* display,
210 Window w,
211 XWindowAttributes* window_attributes_return);
212 //}}}
213
214 //{{{ screen functions
215 int XDefaultScreen(Display* display);
216
217 Screen* XDefaultScreenOfDisplay(Display* display);
218
219 int XScreenCount(Display* display);
220
221 Screen* XScreenOfDisplay(Display* display, int screen_number);
222
223 Display* XDisplayOfScreen(Screen* screen);
224
225 int XScreenNumberOfScreen(Screen* screen);
226
227 int XWidthOfScreen(Screen* screen);
228
229 int XHeightOfScreen(Screen* screen);
230
231 int XDefaultDepthOfScreen(Screen* screen);
232
233 //}}}
234
235 //{{{ pixmap functions
236 Pixmap XCreatePixmap(Display* display, Drawable d, uint width, uint height, uint depth);
237
238 Pixmap XCreatePixmapFromBitmapData(
239 Display* display,
240 Drawable d,
241 ubyte* data,
242 uint width,
243 uint height,
244 uint fg,
245 uint bg,
246 uint depth);
247
248 int XFreePixmap(Display* display, Pixmap pixmap);
249 //}}}
250
251 //{{{ cursor functions
252 Cursor XCreatePixmapCursor(
253 Display* display,
254 Pixmap source,
255 Pixmap mask,
256 XColor* foreground_color,
257 XColor* background_color,
258 uint x,
259 uint y);
260
261 int XDefineCursor(Display* display, Window w, Cursor cursor);
262
263 int XUndefineCursor(Display* display, Window w);
264
265 int XFreeCursor(Display* display, Cursor cursor);
266
267 //}}}
268
269 //{{{ keyboard functions
270 KeyCode XKeysymToKeycode(Display* display, KeySym keysym);
271
272 KeySym XKeycodeToKeysym(
273 Display* display,
274 // if NeedWidePrototypes
275 uint keycode,
276 // else
277 //KeyCode keycode,
278 int index);
279
280 char* XKeysymToString(KeySym keysym);
281
282 KeySym XStringToKeysym(char* string);
283 //}}}
284
285 char** XListExtensions(Display* display, int* nextensions_return);
286
287 int XFreeExtensionList(char** list);
288
289 XExtCodes* XInitExtension(Display* display, char* name);
290
291 uint XBlackPixel(Display* display, int screen_number);
292
293 uint XWhitePixel(Display* display, int screen_number);
294
295 int XDefaultDepth(Display* display, int screen_number);
296
297 int XFree(void* data);
298
299 int XNoOp(Display* display);
300
301 Visual* XDefaultVisual(Display* display, int screen_number);
302
303 Visual* XDefaultVisualOfScreen(Screen* screen);
304
305 Window XGetSelectionOwner(Display* display, Atom selection);
306
307 int XSetSelectionOwner(Display* display, Atom selection, Window owner, Time time);
308
309 void XSetWMName(Display* display, Window w, XTextProperty* text_prop);
310
311 Status XSetWMProtocols(Display* display, Window w, Atom* protocols, int count);
312
313 int XConvertSelection(
314 Display* display,
315 Atom selection,
316 Atom target,
317 Atom property,
318 Window requestor,
319 Time time);
320
321 //{{{ atoms
322 Atom XInternAtom(Display* display, char* atom_name, Bool only_if_exists);
323
324 Status XInternAtoms(
325 Display* dpy,
326 char** names,
327 int count,
328 Bool onlyIfExists,
329 Atom* atoms_return);
330
331 enum : Atom {
332 XA_PRIMARY = 1,
333 XA_SECONDARY = 2,
334 XA_ARC = 3,
335 XA_ATOM = 4,
336 XA_BITMAP = 5,
337 XA_CARDINAL = 6,
338 XA_COLORMAP = 7,
339 XA_CURSOR = 8,
340 XA_CUT_BUFFER0 = 9,
341 XA_CUT_BUFFER1 = 10,
342 XA_CUT_BUFFER2 = 11,
343 XA_CUT_BUFFER3 = 12,
344 XA_CUT_BUFFER4 = 13,
345 XA_CUT_BUFFER5 = 14,
346 XA_CUT_BUFFER6 = 15,
347 XA_CUT_BUFFER7 = 16,
348 XA_DRAWABLE = 17,
349 XA_FONT = 18,
350 XA_INTEGER = 19,
351 XA_PIXMAP = 20,
352 XA_POINT = 21,
353 XA_RECTANGLE = 22,
354 XA_RESOURCE_MANAGER = 23,
355 XA_RGB_COLOR_MAP = 24,
356 XA_RGB_BEST_MAP = 25,
357 XA_RGB_BLUE_MAP = 26,
358 XA_RGB_DEFAULT_MAP = 27,
359 XA_RGB_GRAY_MAP = 28,
360 XA_RGB_GREEN_MAP = 29,
361 XA_RGB_RED_MAP = 30,
362 XA_STRING = 31,
363 XA_VISUALID = 32,
364 XA_WINDOW = 33,
365 XA_WM_COMMAND = 34,
366 XA_WM_HINTS = 35,
367 XA_WM_CLIENT_MACHINE = 36,
368 XA_WM_ICON_NAME = 37,
369 XA_WM_ICON_SIZE = 38,
370 XA_WM_NAME = 39,
371 XA_WM_NORMAL_HINTS = 40,
372 XA_WM_SIZE_HINTS = 41,
373 XA_WM_ZOOM_HINTS = 42,
374 XA_MIN_SPACE = 43,
375 XA_NORM_SPACE = 44,
376 XA_MAX_SPACE = 45,
377 XA_END_SPACE = 46,
378 XA_SUPERSCRIPT_X = 47,
379 XA_SUPERSCRIPT_Y = 48,
380 XA_SUBSCRIPT_X = 49,
381 XA_SUBSCRIPT_Y = 50,
382 XA_UNDERLINE_POSITION = 51,
383 XA_UNDERLINE_THICKNESS = 52,
384 XA_STRIKEOUT_ASCENT = 53,
385 XA_STRIKEOUT_DESCENT = 54,
386 XA_ITALIC_ANGLE = 55,
387 XA_X_HEIGHT = 56,
388 XA_QUAD_WIDTH = 57,
389 XA_WEIGHT = 58,
390 XA_POINT_SIZE = 59,
391 XA_RESOLUTION = 60,
392 XA_COPYRIGHT = 61,
393 XA_NOTICE = 62,
394 XA_FONT_NAME = 63,
395 XA_FAMILY_NAME = 64,
396 XA_FULL_NAME = 65,
397 XA_CAP_HEIGHT = 66,
398 XA_WM_CLASS = 67,
399 XA_WM_TRANSIENT_FOR = 68,
400
401 XA_LAST_PREDEFINED = 68
402 }
403 //}}}
404
405 Status XStringListToTextProperty(char** list, int count, XTextProperty* text_prop_return);
406
407 XSizeHints* XAllocSizeHints();
408
409 void XSetWMNormalHints(Display* display, Window w, XSizeHints* hints);
410
411 Status XGetWMNormalHints(
412 Display* display,
413 Window w,
414 XSizeHints* hints_return,
415 long* supplied_return);
416
417 XWMHints* XAllocWMHints();
418
419 int XSetWMHints(Display* display, Window w, XWMHints* wm_hints);
420
421 XWMHints *XGetWMHints(Display* display, Window w);
422
423 //{{{ enums
424 enum {
425 InputHint = 1 << 0,
426 StateHint = 1 << 1,
427 IconPixmapHint = 1 << 2,
428 IconWindowHint = 1 << 3,
429 IconPositionHint = 1 << 4,
430 IconMaskHint = 1 << 5,
431 WindowGroupHint = 1 << 6,
432 AllHints = InputHint | StateHint | IconPixmapHint | IconWindowHint |
433 IconPositionHint | IconMaskHint | WindowGroupHint,
434 XUrgencyHint = 1 << 8
435 }
436
437 enum {
438 WithdrawnState = 0,
439 NormalState = 1,
440 IconicState = 3
441 }
442
443 enum {
444 QueuedAlready = 0,
445 QueuedAfterReading = 1,
446 QueuedAfterFlush = 2
447 }
448
449 enum {
450 USPosition = 1 << 0,
451 USSize = 1 << 1,
452 PPosition = 1 << 2,
453 PSize = 1 << 3,
454 PMinSize = 1 << 4,
455 PMaxSize = 1 << 5,
456 PResizeInc = 1 << 6,
457 PAspect = 1 << 7,
458 PBaseSize = 1 << 8,
459 PWinGravity = 1 << 9
460 }
461
462 enum {
463 ShiftMask = 1 << 0,
464 LockMask = 1 << 1,
465 ControlMask = 1 << 2,
466 Mod1Mask = 1 << 3,
467 Mod2Mask = 1 << 4,
468 Mod3Mask = 1 << 5,
469 Mod4Mask = 1 << 6,
470 Mod5Mask = 1 << 7
471 }
472
473 enum {
474 ShiftMapIndex = 0,
475 LockMapIndex = 1,
476 ControlMapIndex = 2,
477 Mod1MapIndex = 3,
478 Mod2MapIndex = 4,
479 Mod3MapIndex = 5,
480 Mod4MapIndex = 6,
481 Mod5MapIndex = 7
482 }
483
484 enum {
485 Button1Mask = 1 << 8,
486 Button2Mask = 1 << 9,
487 Button3Mask = 1 << 10,
488 Button4Mask = 1 << 11,
489 Button5Mask = 1 << 12
490 }
491
492 enum {
493 AnyModifier = 1 << 15
494 }
495
496 enum {
497 Button1 = 1,
498 Button2 = 2,
499 Button3 = 3,
500 Button4 = 4,
501 Button5 = 5
502 }
503
504 enum {
505 NotifyNormal = 0,
506 NotifyGrab = 1,
507 NotifyUngrab = 2,
508 NotifyWhileGrabbed = 3
509 }
510
511 enum {
512 NotifyHint = 1
513 }
514
515 enum {
516 NotifyAncestor = 0,
517 NotifyVirtual = 1,
518 NotifyInferior = 2,
519 NotifyNonlinear = 3,
520 NotifyNonlinearVirtual = 4,
521 NotifyPointer = 5,
522 NotifyPointerRoot = 6,
523 NotifyDetailNone = 7
524 }
525
526 enum {
527 VisibilityUnobscured = 0,
528 VisibilityPartiallyObscured = 1,
529 VisibilityFullyObscured = 2
530 }
531
532 enum {
533 PlaceOnTop = 0,
534 PlaceOnBottom = 1
535 }
536
537 enum {
538 FamilyInternet = 0,
539 FamilyDECnet = 1,
540 FamilyChaos = 2,
541 FamilyInternet6 = 6
542 }
543
544 enum {
545 FamilyServerInterpreted = 5
546 }
547
548 enum {
549 PropertyNewValue = 0,
550 PropertyDelete = 1
551 }
552
553 enum {
554 ColormapUninstalled = 0,
555 ColormapInstalled = 1
556 }
557
558 enum {
559 GrabModeSync = 0,
560 GrabModeAsync = 1
561 }
562
563 enum {
564 GrabSuccess = 0,
565 AlreadyGrabbed = 1,
566 GrabInvalidTime = 2,
567 GrabNotViewable = 3,
568 GrabFrozen = 4
569 }
570
571 enum {
572 AsyncPointer = 0,
573 SyncPointer = 1,
574 ReplayPointer = 2,
575 AsyncKeyboard = 3,
576 SyncKeyboard = 4,
577 ReplayKeyboard = 5,
578 AsyncBoth = 6,
579 SyncBoth = 7
580 }
581
582 enum {
583 RevertToNone = None,
584 RevertToPointerRoot = PointerRoot,
585 RevertToParent = 2
586 }
587
588 enum {
589 InputOutput = 1,
590 InputOnly = 2
591 }
592
593 enum {
594 CWBackPixmap = 1 << 0,
595 CWBackPixel = 1 << 1,
596 CWBorderPixmap = 1 << 2,
597 CWBorderPixel = 1 << 3,
598 CWBitGravity = 1 << 4,
599 CWWinGravity = 1 << 5,
600 CWBackingStore = 1 << 6,
601 CWBackingPlanes = 1 << 7,
602 CWBackingPixel = 1 << 8,
603 CWOverrideRedirect = 1 << 9,
604 CWSaveUnder = 1 << 10,
605 CWEventMask = 1 << 11,
606 CWDontPropagate = 1 << 12,
607 CWColormap = 1 << 13,
608 CWCursor = 1 << 14,
609 }
610
611 enum {
612 CWX = 1 << 0,
613 CWY = 1 << 1,
614 CWWidth = 1 << 2,
615 CWHeight = 1 << 3,
616 CWBorderWidth = 1 << 4,
617 CWSibling = 1 << 5,
618 CWStackMode = 1 << 6
619 }
620
621 enum {
622 ForgetGravity = 0,
623 NorthWestGravity = 1,
624 NorthGravity = 2,
625 NorthEastGravity = 3,
626 WestGravity = 4,
627 CenterGravity = 5,
628 EastGravity = 6,
629 SouthWestGravity = 7,
630 SouthGravity = 8,
631 SouthEastGravity = 9,
632 StaticGravity = 10
633 }
634
635 enum {
636 UnmapGravity = 0
637 }
638
639 enum {
640 NotUseful = 0,
641 WhenMapped = 1,
642 Always = 2
643 }
644
645 enum {
646 IsUnmapped = 0,
647 IsUnviewable = 1,
648 IsViewable = 2
649 }
650
651 enum {
652 SetModeInsert = 0,
653 SetModeDelete = 1
654 }
655
656 enum {
657 DestroyAll = 0,
658 RetainPermanent = 1,
659 RetainTemporary = 2
660 }
661
662 enum {
663 Above = 0,
664 Below = 1,
665 TopIf = 2,
666 BottomIf = 3,
667 Opposite = 4
668 }
669
670 enum {
671 RaiseLowest = 0,
672 LowerHighest = 1
673 }
674
675 enum {
676 PropModeReplace = 0,
677 PropModePrepend = 1,
678 PropModeAppend = 2
679 }
680 //}}}
681
682 struct XSizeHints {
683 int flags;
684 int x, y;
685 int width, height;
686 int min_width, min_height;
687 int max_width, max_height;
688 int width_inc, height_inc;
689 struct _aspect {
690 int x;
691 int y;
692 }
693 _aspect min_aspect, max_aspect;
694 int base_width, base_height;
695 int win_gravity;
696 }
697
698 struct XWMHints {
699 int flags;
700 Bool input;
701 int initial_state;
702 Pixmap icon_pixmap;
703 Window icon_window;
704 int icon_x, icon_y;
705 Pixmap icon_mask;
706 XID window_group;
707 }
708
709 struct XTextProperty {
710 char* value;
711 Atom encoding;
712 int format;
713 uint nitems;
714 }
715
716 struct XColor {
717 uint pixel;
718 ushort red, green, blue;
719 ubyte flags;
720 ubyte pad;
721 }
722
723 struct Visual {
724 XExtData* ext_data;
725 VisualID visualid;
726 int c_class;
727 uint red_mask, green_mask, blue_mask;
728 int bits_per_rgb;
729 int map_entries;
730 }
731
732 struct XExtCodes {
733 int extension;
734 int major_opcode;
735 int first_event;
736 int first_error;
737 }
738
739 struct XExtData {
740 int number;
741 XExtData* next;
742 int function(XExtData* extension) free_private;
743 XPointer private_data;
744 }
745
746 struct XSetWindowAttributes {
747 Pixmap background_pixmap;
748 uint background_pixel;
749 Pixmap border_pixmap;
750 uint border_pixel;
751 int bit_gravity;
752 int win_gravity;
753 int backing_store;
754 uint backing_planes;
755 uint backing_pixel;
756 Bool save_under;
757 int event_mask;
758 int do_not_propagate_mask;
759 Bool override_redirect;
760 Colormap colormap;
761 Cursor cursor;
762 }
763
764 struct XWindowAttributes {
765 int x, y;
766 int width, height;
767 int border_width;
768 int depth;
769 Visual* visual;
770 Window root;
771 int c_class;
772 int bit_gravity;
773 int win_gravity;
774 int backing_store;
775 uint backing_planes;
776 uint backing_pixel;
777 Bool save_under;
778 Colormap colormap;
779 Bool map_installed;
780 int map_state;
781 int all_event_masks;
782 int your_event_mask;
783 int do_not_propagate_mask;
784 Bool override_redirect;
785 Screen* screen;
786 }
787
788 //{{{ events
789 struct XKeyEvent {
790 int type;
791 uint serial;
792 Bool send_event;
793 Display* display;
794 Window window;
795 Window root;
796 Window subwindow;
797 Time time;
798 int x, y;
799 int x_root, y_root;
800 uint state;
801 uint keycode;
802 Bool same_screen;
803 }
804 alias XKeyEvent XKeyPressedEvent;
805 alias XKeyEvent XKeyReleasedEvent;
806
807 struct XButtonEvent {
808 int type;
809 uint serial;
810 Bool send_event;
811 Display* display;
812 Window window;
813 Window root;
814 Window subwindow;
815 Time time;
816 int x, y;
817 int x_root, y_root;
818 uint state;
819 uint button;
820 Bool same_screen;
821 }
822 alias XButtonEvent XButtonPressedEvent;
823 alias XButtonEvent XButtonReleasedEvent;
824
825
826 struct XMotionEvent {
827 int type;
828 uint serial;
829 Bool send_event;
830 Display* display;
831 Window window;
832 Window root;
833 Window subwindow;
834 Time time;
835 int x, y;
836 int x_root, y_root;
837 uint state;
838 char is_hint;
839 Bool same_screen;
840 }
841 alias XMotionEvent XPointerMovedEvent;
842
843 struct XCrossingEvent {
844 int type;
845 uint serial;
846 Bool send_event;
847 Display* display;
848 Window window;
849 Window root;
850 Window subwindow;
851 Time time;
852 int x, y;
853 int x_root, y_root;
854 int mode;
855 int detail;
856 Bool same_screen;
857 Bool focus;
858 uint state;
859 }
860 alias XCrossingEvent XEnterWindowEvent;
861 alias XCrossingEvent XLeaveWindowEvent;
862
863 struct XFocusChangeEvent {
864 int type;
865 uint serial;
866 Bool send_event;
867 Display* display;
868 Window window;
869 int mode;
870 int detail;
871 }
872 alias XFocusChangeEvent XFocusInEvent;
873 alias XFocusChangeEvent XFocusOutEvent;
874
875 struct XKeymapEvent {
876 int type;
877 uint serial;
878 Bool send_event;
879 Display* display;
880 Window window;
881 char key_vector[32];
882 }
883
884 struct XExposeEvent {
885 int type;
886 uint serial;
887 Bool send_event;
888 Display* display;
889 Window window;
890 int x, y;
891 int width, height;
892 int count;
893 }
894
895 struct XGraphicsExposeEvent {
896 int type;
897 uint serial;
898 Bool send_event;
899 Display* display;
900 Drawable drawable;
901 int x, y;
902 int width, height;
903 int count;
904 int major_code;
905 int minor_code;
906 }
907
908 struct XNoExposeEvent {
909 int type;
910 uint serial;
911 Bool send_event;
912 Display* display;
913 Drawable drawable;
914 int major_code;
915 int minor_code;
916 }
917
918 struct XVisibilityEvent {
919 int type;
920 uint serial;
921 Bool send_event;
922 Display* display;
923 Window window;
924 int state;
925 }
926
927 struct XCreateWindowEvent {
928 int type;
929 uint serial;
930 Bool send_event;
931 Display* display;
932 Window parent;
933 Window window;
934 int x, y;
935 int width, height;
936 int border_width;
937 Bool override_redirect;
938 }
939
940 struct XDestroyWindowEvent {
941 int type;
942 uint serial;
943 Bool send_event;
944 Display* display;
945 Window event;
946 Window window;
947 }
948
949 struct XUnmapEvent {
950 int type;
951 uint serial;
952 Bool send_event;
953 Display* display;
954 Window event;
955 Window window;
956 Bool from_configure;
957 }
958
959 struct XMapEvent {
960 int type;
961 uint serial;
962 Bool send_event;
963 Display* display;
964 Window event;
965 Window window;
966 Bool override_redirect;
967 }
968
969 struct XMapRequestEvent {
970 int type;
971 uint serial;
972 Bool send_event;
973 Display* display;
974 Window parent;
975 Window window;
976 }
977
978 struct XReparentEvent {
979 int type;
980 uint serial;
981 Bool send_event;
982 Display* display;
983 Window event;
984 Window window;
985 Window parent;
986 int x, y;
987 Bool override_redirect;
988 }
989
990 struct XConfigureEvent {
991 int type;
992 uint serial;
993 Bool send_event;
994 Display* display;
995 Window event;
996 Window window;
997 int x, y;
998 int width, height;
999 int border_width;
1000 Window above;
1001 Bool override_redirect;
1002 }
1003
1004 struct XGravityEvent {
1005 int type;
1006 uint serial;
1007 Bool send_event;
1008 Display* display;
1009 Window event;
1010 Window window;
1011 int x, y;
1012 }
1013
1014 struct XResizeRequestEvent {
1015 int type;
1016 uint serial;
1017 Bool send_event;
1018 Display* display;
1019 Window window;
1020 int width, height;
1021 }
1022
1023 struct XConfigureRequestEvent {
1024 int type;
1025 uint serial;
1026 Bool send_event;
1027 Display* display;
1028 Window parent;
1029 Window window;
1030 int x, y;
1031 int width, height;
1032 int border_width;
1033 Window above;
1034 int detail;
1035 uint value_mask;
1036 }
1037
1038 struct XCirculateEvent {
1039 int type;
1040 uint serial;
1041 Bool send_event;
1042 Display* display;
1043 Window event;
1044 Window window;
1045 int place;
1046 }
1047
1048 struct XCirculateRequestEvent {
1049 int type;
1050 uint serial;
1051 Bool send_event;
1052 Display* display;
1053 Window parent;
1054 Window window;
1055 int place;
1056 }
1057
1058 struct XPropertyEvent {
1059 int type;
1060 uint serial;
1061 Bool send_event;
1062 Display* display;
1063 Window window;
1064 Atom atom;
1065 Time time;
1066 int state;
1067 }
1068
1069 struct XSelectionClearEvent {
1070 int type;
1071 uint serial;
1072 Bool send_event;
1073 Display* display;
1074 Window window;
1075 Atom selection;
1076 Time time;
1077 }
1078
1079 struct XSelectionRequestEvent {
1080 int type;
1081 uint serial;
1082 Bool send_event;
1083 Display* display;
1084 Window owner;
1085 Window requestor;
1086 Atom selection;
1087 Atom target;
1088 Atom property;
1089 Time time;
1090 }
1091
1092 struct XSelectionEvent {
1093 int type;
1094 uint serial;
1095 Bool send_event;
1096 Display* display;
1097 Window requestor;
1098 Atom selection;
1099 Atom target;
1100 Atom property;
1101 Time time;
1102 }
1103
1104 struct XColormapEvent {
1105 int type;
1106 uint serial;
1107 Bool send_event;
1108 Display* display;
1109 Window window;
1110 Colormap colormap;
1111 Bool is_new;
1112 int state;
1113 }
1114
1115 struct XClientMessageEvent {
1116 int type;
1117 uint serial;
1118 Bool send_event;
1119 Display* display;
1120 Window window;
1121 Atom message_type;
1122 int format;
1123 union _data {
1124 char[20] b;
1125 short[10] s;
1126 int[5] l;
1127 }
1128 _data data;
1129 }
1130
1131 struct XMappingEvent {
1132 int type;
1133 uint serial;
1134 Bool send_event;
1135 Display* display;
1136 Window window;
1137 int request;
1138 int first_keycode;
1139 int count;
1140 }
1141
1142 struct XErrorEvent {
1143 int type;
1144 Display* display;
1145 XID resourceid;
1146 uint serial;
1147 ubyte error_code;
1148 ubyte request_code;
1149 ubyte minor_code;
1150 }
1151
1152 struct XAnyEvent {
1153 int type;
1154 uint serial;
1155 Bool send_event;
1156 Display* display;
1157 Window window;
1158 }
1159
1160 union XEvent {
1161 int type;
1162 XAnyEvent xany;
1163 XKeyEvent xkey;
1164 XButtonEvent xbutton;
1165 XMotionEvent xmotion;
1166 XCrossingEvent xcrossing;
1167 XFocusChangeEvent xfocus;
1168 XExposeEvent xexpose;
1169 XGraphicsExposeEvent xgraphicsexpose;
1170 XNoExposeEvent xnoexpose;
1171 XVisibilityEvent xvisibility;
1172 XCreateWindowEvent xcreatewindow;
1173 XDestroyWindowEvent xdestroywindow;
1174 XUnmapEvent xunmap;
1175 XMapEvent xmap;
1176 XMapRequestEvent xmaprequest;
1177 XReparentEvent xreparent;
1178 XConfigureEvent xconfigure;
1179 XGravityEvent xgravity;
1180 XResizeRequestEvent xresizerequest;
1181 XConfigureRequestEvent xconfigurerequest;
1182 XCirculateEvent xcirculate;
1183 XCirculateRequestEvent xcirculaterequest;
1184 XPropertyEvent xproperty;
1185 XSelectionClearEvent xselectionclear;
1186 XSelectionRequestEvent xselectionrequest;
1187 XSelectionEvent xselection;
1188 XColormapEvent xcolormap;
1189 XClientMessageEvent xclient;
1190 XMappingEvent xmapping;
1191 XErrorEvent xerror;
1192 XKeymapEvent xkeymap;
1193 int pad[24];
1194 }
1195 //}}}
1196
1197 //{{{ event types
1198 enum {
1199 KeyPress = 2,
1200 KeyRelease = 3,
1201 ButtonPress = 4,
1202 ButtonRelease = 5,
1203 MotionNotify = 6,
1204 EnterNotify = 7,
1205 LeaveNotify = 8,
1206 FocusIn = 9,
1207 FocusOut = 10,
1208 KeymapNotify = 11,
1209 Expose = 12,
1210 GraphicsExpose = 13,
1211 NoExpose = 14,
1212 VisibilityNotify = 15,
1213 CreateNotify = 16,
1214 DestroyNotify = 17,
1215 UnmapNotify = 18,
1216 MapNotify = 19,
1217 MapRequest = 20,
1218 ReparentNotify = 21,
1219 ConfigureNotify = 22,
1220 ConfigureRequest = 23,
1221 GravityNotify = 24,
1222 ResizeRequest = 25,
1223 CirculateNotify = 26,
1224 CirculateRequest = 27,
1225 PropertyNotify = 28,
1226 SelectionClear = 29,
1227 SelectionRequest = 30,
1228 SelectionNotify = 31,
1229 ColormapNotify = 32,
1230 ClientMessage = 33,
1231 MappingNotify = 34,
1232 LASTEvent = 35 // must be bigger than any event #
1233 }
1234 //}}}
1235
1236 //{{{ event masks
1237 enum {
1238 NoEventMask = 0,
1239 KeyPressMask = 1 << 0,
1240 KeyReleaseMask = 1 << 1,
1241 ButtonPressMask = 1 << 2,
1242 ButtonReleaseMask = 1 << 3,
1243 EnterWindowMask = 1 << 4,
1244 LeaveWindowMask = 1 << 5,
1245 PointerMotionMask = 1 << 6,
1246 PointerMotionHintMask = 1 << 7,
1247 Button1MotionMask = 1 << 8,
1248 Button2MotionMask = 1 << 9,
1249 Button3MotionMask = 1 << 10,
1250 Button4MotionMask = 1 << 11,
1251 Button5MotionMask = 1 << 12,
1252 ButtonMotionMask = 1 << 13,
1253 KeymapStateMask = 1 << 14,
1254 ExposureMask = 1 << 15,
1255 VisibilityChangeMask = 1 << 16,
1256 StructureNotifyMask = 1 << 17,
1257 ResizeRedirectMask = 1 << 18,
1258 SubstructureNotifyMask = 1 << 19,
1259 SubstructureRedirectMask = 1 << 20,
1260 FocusChangeMask = 1 << 21,
1261 PropertyChangeMask = 1 << 22,
1262 ColormapChangeMask = 1 << 23,
1263 OwnerGrabButtonMask = 1 << 24
1264 }
1265 //}}}
1266
1267 //{{{ keys
1268 enum {
1269 XK_BackSpace = 0xFF08,
1270 XK_Tab = 0xFF09,
1271 XK_Linefeed = 0xFF0A,
1272 XK_Clear = 0xFF0B,
1273 XK_Return = 0xFF0D,
1274 XK_Pause = 0xFF13,
1275 XK_Scroll_Lock = 0xFF14,
1276 XK_Sys_Req = 0xFF15,
1277 XK_Escape = 0xFF1B,
1278 XK_Delete = 0xFFFF,
1279
1280 XK_Home = 0xFF50,
1281 XK_Left = 0xFF51,
1282 XK_Up = 0xFF52,
1283 XK_Right = 0xFF53,
1284 XK_Down = 0xFF54,
1285 XK_Prior = 0xFF55,
1286 XK_Page_Up = 0xFF55,
1287 XK_Next = 0xFF56,
1288 XK_Page_Down = 0xFF56,
1289 XK_End = 0xFF57,
1290 XK_Begin = 0xFF58,
1291
1292 XK_Select = 0xFF60,
1293 XK_Print = 0xFF61,
1294 XK_Execute = 0xFF62,
1295 XK_Insert = 0xFF63,
1296 XK_Undo = 0xFF65,
1297 XK_Redo = 0xFF66,
1298 XK_Menu = 0xFF67,
1299 XK_Find = 0xFF68,
1300 XK_Cancel = 0xFF69,
1301 XK_Help = 0xFF6A,
1302 XK_Break = 0xFF6B,
1303 XK_Mode_switch = 0xFF7E,
1304 XK_script_switch = 0xFF7E,
1305 XK_Num_Lock = 0xFF7F,
1306
1307 XK_KP_Space = 0xFF80,
1308 XK_KP_Tab = 0xFF89,
1309 XK_KP_Enter = 0xFF8D,
1310 XK_KP_F1 = 0xFF91,
1311 XK_KP_F2 = 0xFF92,
1312 XK_KP_F3 = 0xFF93,
1313 XK_KP_F4 = 0xFF94,
1314 XK_KP_Home = 0xFF95,
1315 XK_KP_Left = 0xFF96,
1316 XK_KP_Up = 0xFF97,
1317 XK_KP_Right = 0xFF98,
1318 XK_KP_Down = 0xFF99,
1319 XK_KP_Prior = 0xFF9A,
1320 XK_KP_Page_Up = 0xFF9A,
1321 XK_KP_Next = 0xFF9B,
1322 XK_KP_Page_Down = 0xFF9B,
1323 XK_KP_End = 0xFF9C,
1324 XK_KP_Begin = 0xFF9D,
1325 XK_KP_Insert = 0xFF9E,
1326 XK_KP_Delete = 0xFF9F,
1327 XK_KP_Equal = 0xFFBD,
1328 XK_KP_Multiply = 0xFFAA,
1329 XK_KP_Add = 0xFFAB,
1330 XK_KP_Separator = 0xFFAC,
1331 XK_KP_Subtract = 0xFFAD,
1332 XK_KP_Decimal = 0xFFAE,
1333 XK_KP_Divide = 0xFFAF,
1334
1335 XK_KP_0 = 0xFFB0,
1336 XK_KP_1 = 0xFFB1,
1337 XK_KP_2 = 0xFFB2,
1338 XK_KP_3 = 0xFFB3,
1339 XK_KP_4 = 0xFFB4,
1340 XK_KP_5 = 0xFFB5,
1341 XK_KP_6 = 0xFFB6,
1342 XK_KP_7 = 0xFFB7,
1343 XK_KP_8 = 0xFFB8,
1344 XK_KP_9 = 0xFFB9,
1345
1346 XK_F1 = 0xFFBE,
1347 XK_F2 = 0xFFBF,
1348 XK_F3 = 0xFFC0,
1349 XK_F4 = 0xFFC1,
1350 XK_F5 = 0xFFC2,
1351 XK_F6 = 0xFFC3,
1352 XK_F7 = 0xFFC4,
1353 XK_F8 = 0xFFC5,
1354 XK_F9 = 0xFFC6,
1355 XK_F10 = 0xFFC7,
1356 XK_F11 = 0xFFC8,
1357 XK_L1 = 0xFFC8,
1358 XK_F12 = 0xFFC9,
1359 XK_L2 = 0xFFC9,
1360 XK_F13 = 0xFFCA,
1361 XK_L3 = 0xFFCA,
1362 XK_F14 = 0xFFCB,
1363 XK_L4 = 0xFFCB,
1364 XK_F15 = 0xFFCC,
1365 XK_L5 = 0xFFCC,
1366 XK_F16 = 0xFFCD,
1367 XK_L6 = 0xFFCD,
1368 XK_F17 = 0xFFCE,
1369 XK_L7 = 0xFFCE,
1370 XK_F18 = 0xFFCF,
1371 XK_L8 = 0xFFCF,
1372 XK_F19 = 0xFFD0,
1373 XK_L9 = 0xFFD0,
1374 XK_F20 = 0xFFD1,
1375 XK_L10 = 0xFFD1,
1376 XK_F21 = 0xFFD2,
1377 XK_R1 = 0xFFD2,
1378 XK_F22 = 0xFFD3,
1379 XK_R2 = 0xFFD3,
1380 XK_F23 = 0xFFD4,
1381 XK_R3 = 0xFFD4,
1382 XK_F24 = 0xFFD5,
1383 XK_R4 = 0xFFD5,
1384 XK_F25 = 0xFFD6,
1385 XK_R5 = 0xFFD6,
1386 XK_F26 = 0xFFD7,
1387 XK_R6 = 0xFFD7,
1388 XK_F27 = 0xFFD8,
1389 XK_R7 = 0xFFD8,
1390 XK_F28 = 0xFFD9,
1391 XK_R8 = 0xFFD9,
1392 XK_F29 = 0xFFDA,
1393 XK_R9 = 0xFFDA,
1394 XK_F30 = 0xFFDB,
1395 XK_R10 = 0xFFDB,
1396 XK_F31 = 0xFFDC,
1397 XK_R11 = 0xFFDC,
1398 XK_F32 = 0xFFDD,
1399 XK_R12 = 0xFFDD,
1400 XK_F33 = 0xFFDE,
1401 XK_R13 = 0xFFDE,
1402 XK_F34 = 0xFFDF,
1403 XK_R14 = 0xFFDF,
1404 XK_F35 = 0xFFE0,
1405 XK_R15 = 0xFFE0,
1406
1407 XK_Shift_L = 0xFFE1,
1408 XK_Shift_R = 0xFFE2,
1409 XK_Control_L = 0xFFE3,
1410 XK_Control_R = 0xFFE4,
1411 XK_Caps_Lock = 0xFFE5,
1412 XK_Shift_Lock = 0xFFE6,
1413
1414 XK_Meta_L = 0xFFE7,
1415 XK_Meta_R = 0xFFE8,
1416 XK_Alt_L = 0xFFE9,
1417 XK_Alt_R = 0xFFEA,
1418 XK_Super_L = 0xFFEB,
1419 XK_Super_R = 0xFFEC,
1420 XK_Hyper_L = 0xFFED,
1421 XK_Hyper_R = 0xFFEE,
1422
1423 XK_space = 0x020,
1424 XK_exclam = 0x021,
1425 XK_quotedbl = 0x022,
1426 XK_numbersign = 0x023,
1427 XK_dollar = 0x024,
1428 XK_percent = 0x025,
1429 XK_ampersand = 0x026,
1430 XK_apostrophe = 0x027,
1431 XK_quoteright = 0x027,
1432 XK_parenleft = 0x028,
1433 XK_parenright = 0x029,
1434 XK_asterisk = 0x02A,
1435 XK_plus = 0x02B,
1436 XK_comma = 0x02C,
1437 XK_minus = 0x02D,
1438 XK_period = 0x02E,
1439 XK_slash = 0x02F,
1440 XK_0 = 0x030,
1441 XK_1 = 0x031,
1442 XK_2 = 0x032,
1443 XK_3 = 0x033,
1444 XK_4 = 0x034,
1445 XK_5 = 0x035,
1446 XK_6 = 0x036,
1447 XK_7 = 0x037,
1448 XK_8 = 0x038,
1449 XK_9 = 0x039,
1450 XK_colon = 0x03A,
1451 XK_semicolon = 0x03B,
1452 XK_less = 0x03C,
1453 XK_equal = 0x03D,
1454 XK_greater = 0x03E,
1455 XK_question = 0x03F,
1456 XK_at = 0x040,
1457 XK_A = 0x041,
1458 XK_B = 0x042,
1459 XK_C = 0x043,
1460 XK_D = 0x044,
1461 XK_E = 0x045,
1462 XK_F = 0x046,
1463 XK_G = 0x047,
1464 XK_H = 0x048,
1465 XK_I = 0x049,
1466 XK_J = 0x04A,
1467 XK_K = 0x04B,
1468 XK_L = 0x04C,
1469 XK_M = 0x04D,
1470 XK_N = 0x04E,
1471 XK_O = 0x04F,
1472 XK_P = 0x050,
1473 XK_Q = 0x051,
1474 XK_R = 0x052,
1475 XK_S = 0x053,
1476 XK_T = 0x054,
1477 XK_U = 0x055,
1478 XK_V = 0x056,
1479 XK_W = 0x057,
1480 XK_X = 0x058,
1481 XK_Y = 0x059,
1482 XK_Z = 0x05A,
1483 XK_bracketleft = 0x05B,
1484 XK_backslash = 0x05C,
1485 XK_bracketright = 0x05D,
1486 XK_asciicircum = 0x05E,
1487 XK_underscore = 0x05F,
1488 XK_grave = 0x060,
1489 XK_quoteleft = 0x060,
1490 XK_a = 0x061,
1491 XK_b = 0x062,
1492 XK_c = 0x063,
1493 XK_d = 0x064,
1494 XK_e = 0x065,
1495 XK_f = 0x066,
1496 XK_g = 0x067,
1497 XK_h = 0x068,
1498 XK_i = 0x069,
1499 XK_j = 0x06A,
1500 XK_k = 0x06B,
1501 XK_l = 0x06C,
1502 XK_m = 0x06D,
1503 XK_n = 0x06E,
1504 XK_o = 0x06F,
1505 XK_p = 0x070,
1506 XK_q = 0x071,
1507 XK_r = 0x072,
1508 XK_s = 0x073,
1509 XK_t = 0x074,
1510 XK_u = 0x075,
1511 XK_v = 0x076,
1512 XK_w = 0x077,
1513 XK_x = 0x078,
1514 XK_y = 0x079,
1515 XK_z = 0x07A,
1516 XK_braceleft = 0x07B,
1517 XK_bar = 0x07C,
1518 XK_braceright = 0x07D,
1519 XK_asciitilde = 0x07E
1520 }
1521 //}}}
1522