1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
#![allow(non_upper_case_globals)]

use std::os::raw::{
    c_int,
    c_uint,
    c_short,
    c_long,
    c_ulong,
    c_void,
    c_char,
    c_uchar,
};


pub type Display = _XDisplay;

pub type XID = c_ulong;
pub type Window = XID;
pub type Drawable = XID;
pub type Colormap = XID;
pub type KeySym = XID;
pub type Pixmap = XID;
pub type Cursor = XID;

pub type Time = c_ulong;
pub type XIM = *mut _XIM; 
pub type Atom = c_ulong;
pub type XEvent = _XEvent;
pub type XIC = *mut _XIC;
pub type XExtData = _XExtData;
pub type XPointer = *mut c_char;
pub type VisualID = c_ulong;
pub type XrmDatabase = *mut _XrmHashBucketRec;
pub type XKeyPressedEvent = XKeyEvent;
pub type XComposeStatus = _XComposeStatus;
pub type GC = *mut _XGC;

pub const None: u32 = 0;
pub const True: u32 = 1;
pub const False: u32 = 0;

pub const VisualIDMask: u32 = 1;

pub const CurrentTime: u32 = 0;
pub const SelectionNotify: u32 = 31;
pub const AnyPropertyType: u32 = 0;
pub const SelectionRequest: u32 = 30;
pub const PropModeReplace: u32 = 0;
pub const DestroyNotify: u32 = 17;
pub const ConfigureNotify: u32 = 22;
pub const EnterNotify: u32 = 7;
pub const LeaveNotify: u32 = 8;
pub const MotionNotify: u32 = 6;
pub const AllocNone: u32 = 0;
pub const InputOutput: u32 = 1;
pub const ClientMessage: u32 = 33;
pub const KeyPress: u32 = 2;
pub const KeyRelease: u32 = 3;
pub const ButtonPress: u32 = 4;
pub const ButtonRelease: u32 = 5;
pub const Expose: u32 = 12;

pub const CWBorderPixel: u32 = 8;
pub const CWColormap: u32 = 8192;
pub const CWEventMask: u32 = 2048;

pub const SubstructureNotifyMask: u32 = 524288;
pub const SubstructureRedirectMask: u32 = 1048576;
pub const NoEventMask: u32 = 0;

pub const ExposureMask: u32 = 32768;
pub const StructureNotifyMask: u32 = 131072;
pub const ButtonMotionMask: u32 = 8192;
pub const PointerMotionMask: u32 = 64;
pub const ButtonPressMask: u32 = 4;
pub const ButtonReleaseMask: u32 = 8;
pub const KeyPressMask: u32 = 1;
pub const KeyReleaseMask: u32 = 2;
pub const VisibilityChangeMask: u32 = 65536;
pub const FocusChangeMask: u32 = 2097152;
pub const EnterWindowMask: u32 = 16;
pub const LeaveWindowMask: u32 = 32;
pub const XBufferOverflow: i32 = -1;

pub const XIMPreeditNothing: u32 = 8;
pub const XIMStatusNothing: u32 = 1024;

pub const XNInputStyle: &'static [u8; 11usize] = b"inputStyle\0";
pub const XNClientWindow: &'static [u8; 13usize] = b"clientWindow\0";
pub const XNFocusWindow: &'static [u8; 12usize] = b"focusWindow\0";

pub const Mod1Mask: u32 = 8;
pub const ShiftMask: u32 = 1;
pub const ControlMask: u32 = 4;
pub const Mod4Mask: u32 = 64;

pub const XK_A: u32 = 65;
pub const XK_B: u32 = 66;
pub const XK_C: u32 = 67;
pub const XK_D: u32 = 68;
pub const XK_E: u32 = 69;
pub const XK_F: u32 = 70;
pub const XK_G: u32 = 71;
pub const XK_H: u32 = 72;
pub const XK_I: u32 = 73;
pub const XK_J: u32 = 74;
pub const XK_K: u32 = 75;
pub const XK_L: u32 = 76;
pub const XK_M: u32 = 77;
pub const XK_N: u32 = 78;
pub const XK_O: u32 = 79;
pub const XK_P: u32 = 80;
pub const XK_Q: u32 = 81;
pub const XK_R: u32 = 82;
pub const XK_S: u32 = 83;
pub const XK_T: u32 = 84;
pub const XK_U: u32 = 85;
pub const XK_V: u32 = 86;
pub const XK_W: u32 = 87;
pub const XK_X: u32 = 88;
pub const XK_Y: u32 = 89;
pub const XK_Z: u32 = 90;
pub const XK_a: u32 = 97;
pub const XK_b: u32 = 98;
pub const XK_c: u32 = 99;
pub const XK_d: u32 = 100;
pub const XK_e: u32 = 101;
pub const XK_f: u32 = 102;
pub const XK_g: u32 = 103;
pub const XK_h: u32 = 104;
pub const XK_i: u32 = 105;
pub const XK_j: u32 = 106;
pub const XK_k: u32 = 107;
pub const XK_l: u32 = 108;
pub const XK_m: u32 = 109;
pub const XK_n: u32 = 110;
pub const XK_o: u32 = 111;
pub const XK_p: u32 = 112;
pub const XK_q: u32 = 113;
pub const XK_r: u32 = 114;
pub const XK_s: u32 = 115;
pub const XK_t: u32 = 116;
pub const XK_u: u32 = 117;
pub const XK_v: u32 = 118;
pub const XK_w: u32 = 119;
pub const XK_x: u32 = 120;
pub const XK_y: u32 = 121;
pub const XK_z: u32 = 122;
pub const XK_0: u32 = 48;
pub const XK_1: u32 = 49;
pub const XK_2: u32 = 50;
pub const XK_3: u32 = 51;
pub const XK_4: u32 = 52;
pub const XK_5: u32 = 53;
pub const XK_6: u32 = 54;
pub const XK_7: u32 = 55;
pub const XK_8: u32 = 56;
pub const XK_9: u32 = 57;

pub const XK_Meta_L: u32 = 65511;
pub const XK_Meta_R: u32 = 65512;
pub const XK_Alt_L: u32 = 65513;
pub const XK_Alt_R: u32 = 65514;
pub const XK_Shift_L: u32 = 65505;
pub const XK_Shift_R: u32 = 65506;
pub const XK_Control_L: u32 = 65507;
pub const XK_Control_R: u32 = 65508;

pub const XK_equal: u32 = 61;
pub const XK_minus: u32 = 45;
pub const XK_bracketleft: u32 = 91;
pub const XK_bracketright: u32 = 93;
pub const XK_Return: u32 = 65293;
pub const XK_grave: u32 = 96;
pub const XK_semicolon: u32 = 59;
pub const XK_backslash: u32 = 92;
pub const XK_comma: u32 = 44;
pub const XK_slash: u32 = 47;
pub const XK_period: u32 = 46;
pub const XK_Tab: u32 = 65289;
pub const XK_ISO_Left_Tab: u32 = 65056;
pub const XK_space: u32 = 32;
pub const XK_BackSpace: u32 = 65288;
pub const XK_Escape: u32 = 65307;
pub const XK_Caps_Lock: u32 = 65509;

pub const XK_KP_Subtract: u32 = 65453;
pub const XK_KP_Decimal: u32 = 65454;
pub const XK_KP_Divide: u32 = 65455;
pub const XK_KP_Multiply: u32 = 65450;
pub const XK_KP_Add: u32 = 65451;
pub const XK_Num_Lock: u32 = 65407;
pub const XK_KP_Enter: u32 = 65421;

pub const XK_KP_0: u32 = 65456;
pub const XK_KP_1: u32 = 65457;
pub const XK_KP_2: u32 = 65458;
pub const XK_KP_3: u32 = 65459;
pub const XK_KP_4: u32 = 65460;
pub const XK_KP_5: u32 = 65461;
pub const XK_KP_6: u32 = 65462;
pub const XK_KP_7: u32 = 65463;
pub const XK_KP_8: u32 = 65464;
pub const XK_KP_9: u32 = 65465;

pub const XK_F1: u32 = 65470;
pub const XK_F2: u32 = 65471;
pub const XK_F3: u32 = 65472;
pub const XK_F4: u32 = 65473;
pub const XK_F5: u32 = 65474;
pub const XK_F6: u32 = 65475;
pub const XK_F7: u32 = 65476;
pub const XK_F8: u32 = 65477;
pub const XK_F9: u32 = 65478;
pub const XK_F10: u32 = 65479;
pub const XK_F11: u32 = 65480;
pub const XK_F12: u32 = 65481;

pub const XK_Print: u32 = 65377;
pub const XK_Home: u32 = 65360;
pub const XK_Page_Up: u32 = 65365;
pub const XK_Delete: u32 = 65535;
pub const XK_End: u32 = 65367;
pub const XK_Page_Down: u32 = 65366;
pub const XK_Left: u32 = 65361;
pub const XK_Right: u32 = 65363;
pub const XK_Down: u32 = 65364;
pub const XK_Up: u32 = 65362;
    

#[link(name = "Xcursor")]
extern "C" {
    pub fn XcursorLibraryLoadCursor(
        dpy: *mut Display,
        file: *const c_char,
    ) -> Cursor;
}

#[link(name = "X11")]
extern "C" {
    pub fn XOpenDisplay(arg1: *const c_char) -> *mut Display;
    
    pub fn XConnectionNumber(arg1: *mut Display) -> c_int;
    
    pub fn XOpenIM(
        arg1: *mut Display,
        arg2: *mut _XrmHashBucketRec,
        arg3: *mut c_char,
        arg4: *mut c_char,
    ) -> XIM;
    
    pub fn XInternAtom(
        arg1: *mut Display,
        arg2: *const c_char,
        arg3: c_int,
    ) -> Atom;
    
    pub fn XrmInitialize();
    
    pub fn XCloseIM(arg1: XIM) -> c_int;
    
    pub fn XCloseDisplay(arg1: *mut Display) -> c_int;
    
    pub fn XPending(arg1: *mut Display) -> c_int;
    
    pub fn XNextEvent(arg1: *mut Display, arg2: *mut XEvent) -> c_int;
    
    pub fn XGetWindowProperty(
        arg1: *mut Display,
        arg2: Window,
        arg3: Atom,
        arg4: c_long,
        arg5: c_long,
        arg6: c_int,
        arg7: Atom,
        arg8: *mut Atom,
        arg9: *mut c_int,
        arg10: *mut c_ulong,
        arg11: *mut c_ulong,
        arg12: *mut *mut c_uchar,
    ) -> c_int;
    
    pub fn XFree(arg1: *mut c_void) -> c_int;
    
    pub fn XChangeProperty(
        arg1: *mut Display,
        arg2: Window,
        arg3: Atom,
        arg4: Atom,
        arg5: c_int,
        arg6: c_int,
        arg7: *const c_uchar,
        arg8: c_int,
    ) -> c_int;
    
    pub fn XSendEvent(
        arg1: *mut Display,
        arg2: Window,
        arg3: c_int,
        arg4: c_long,
        arg5: *mut XEvent,
    ) -> c_int;
    
    pub fn XDefaultScreen(arg1: *mut Display) -> c_int;
    
    pub fn XRootWindow(arg1: *mut Display, arg2: c_int) -> Window;

    pub fn XGetVisualInfo(
        arg1: *mut Display,
        arg2: c_long,
        arg3: *mut XVisualInfo,
        arg4: *mut c_int,
    ) -> *mut XVisualInfo;

    pub fn XCreateColormap(
        arg1: *mut Display,
        arg2: Window,
        arg3: *mut Visual,
        arg4: c_int,
    ) -> Colormap;
    
    pub fn XCreateWindow(
        arg1: *mut Display,
        arg2: Window,
        arg3: c_int,
        arg4: c_int,
        arg5: c_uint,
        arg6: c_uint,
        arg7: c_uint,
        arg8: c_int,
        arg9: c_uint,
        arg10: *mut Visual,
        arg11: c_ulong,
        arg12: *mut XSetWindowAttributes,
    ) -> Window;
    
    pub fn XSetWMProtocols(
        arg1: *mut Display,
        arg2: Window,
        arg3: *mut Atom,
        arg4: c_int,
    ) -> c_int;
    
    pub fn XMapWindow(arg1: *mut Display, arg2: Window) -> c_int;
    
    pub fn XFlush(arg1: *mut Display) -> c_int;
    
    pub fn XStoreName(
        arg1: *mut Display,
        arg2: Window,
        arg3: *const c_char,
    ) -> c_int;
    
    pub fn XCreateIC(arg1: XIM, ...) -> XIC;
    
    pub fn XDestroyWindow(arg1: *mut Display, arg2: Window) -> c_int;
    
    pub fn XIconifyWindow(
        arg1: *mut Display,
        arg2: Window,
        arg3: c_int,
    ) -> c_int;
    
    pub fn XGetWindowAttributes(
        arg1: *mut Display,
        arg2: Window,
        arg3: *mut XWindowAttributes,
    ) -> c_int;
    
    pub fn XResourceManagerString(arg1: *mut Display) -> *mut c_char;
    
    pub fn XrmGetStringDatabase(arg1: *const c_char) -> XrmDatabase;
    
    pub fn XrmGetResource(
        arg1: XrmDatabase,
        arg2: *const c_char,
        arg3: *const c_char,
        arg4: *mut *mut c_char,
        arg5: *mut XrmValue,
    ) -> c_int;
    
    pub fn XConvertSelection(
        arg1: *mut Display,
        arg2: Atom,
        arg3: Atom,
        arg4: Atom,
        arg5: Window,
        arg6: Time,
    ) -> c_int;
    
    pub fn XSetInputFocus(
        arg1: *mut Display,
        arg2: Window,
        arg3: c_int,
        arg4: Time,
    ) -> c_int;
    
    pub fn XUngrabPointer(arg1: *mut Display, arg2: Time) -> c_int;
    
    pub fn XSetSelectionOwner(
        arg1: *mut Display,
        arg2: Atom,
        arg3: Window,
        arg4: Time,
    ) -> c_int;
    
    pub fn Xutf8LookupString(
        arg1: XIC,
        arg2: *mut XKeyPressedEvent,
        arg3: *mut c_char,
        arg4: c_int,
        arg5: *mut KeySym,
        arg6: *mut c_int,
    ) -> c_int;
    
    pub fn XDefineCursor(arg1: *mut Display, arg2: Window, arg3: Cursor) -> c_int;
    pub fn XFreeCursor(arg1: *mut Display, arg2: Cursor) -> c_int;
    pub fn XLookupString(
        arg1: *mut XKeyEvent,
        arg2: *mut c_char,
        arg3: c_int,
        arg4: *mut KeySym,
        arg5: *mut XComposeStatus,
    ) -> c_int;
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _XrmHashBucketRec {
    _unused: [u8; 0],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _XDisplay {
    _unused: [u8; 0],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _XIM {
    _unused: [u8; 0],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _XIC {
    _unused: [u8; 0],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _XComposeStatus {
    pub compose_ptr: XPointer,
    pub chars_matched: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _XExtData {
    pub number: c_int,
    pub next: *mut _XExtData,
    pub free_private: ::std::option::Option<
    unsafe extern "C" fn(extension: *mut _XExtData) -> c_int,
    >,
    pub private_data: XPointer,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XrmValue {
    pub size: c_uint,
    pub addr: XPointer,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _XGC {
    _unused: [u8; 0],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Depth {
    pub depth: c_int,
    pub nvisuals: c_int,
    pub visuals: *mut Visual,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Screen {
    pub ext_data: *mut XExtData,
    pub display: *mut _XDisplay,
    pub root: Window,
    pub width: c_int,
    pub height: c_int,
    pub mwidth: c_int,
    pub mheight: c_int,
    pub ndepths: c_int,
    pub depths: *mut Depth,
    pub root_depth: c_int,
    pub root_visual: *mut Visual,
    pub default_gc: GC,
    pub cmap: Colormap,
    pub white_pixel: c_ulong,
    pub black_pixel: c_ulong,
    pub max_maps: c_int,
    pub min_maps: c_int,
    pub backing_store: c_int,
    pub save_unders: c_int,
    pub root_input_mask: c_long,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XWindowAttributes {
    pub x: c_int,
    pub y: c_int,
    pub width: c_int,
    pub height: c_int,
    pub border_width: c_int,
    pub depth: c_int,
    pub visual: *mut Visual,
    pub root: Window,
    pub class: c_int,
    pub bit_gravity: c_int,
    pub win_gravity: c_int,
    pub backing_store: c_int,
    pub backing_planes: c_ulong,
    pub backing_pixel: c_ulong,
    pub save_under: c_int,
    pub colormap: Colormap,
    pub map_installed: c_int,
    pub map_state: c_int,
    pub all_event_masks: c_long,
    pub your_event_mask: c_long,
    pub do_not_propagate_mask: c_long,
    pub override_redirect: c_int,
    pub screen: *mut Screen,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Visual {
    pub ext_data: *mut XExtData,
    pub visualid: VisualID,
    pub class: c_int,
    pub red_mask: c_ulong,
    pub green_mask: c_ulong,
    pub blue_mask: c_ulong,
    pub bits_per_rgb: c_int,
    pub map_entries: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XSetWindowAttributes {
    pub background_pixmap: Pixmap,
    pub background_pixel: c_ulong,
    pub border_pixmap: Pixmap,
    pub border_pixel: c_ulong,
    pub bit_gravity: c_int,
    pub win_gravity: c_int,
    pub backing_store: c_int,
    pub backing_planes: c_ulong,
    pub backing_pixel: c_ulong,
    pub save_under: c_int,
    pub event_mask: c_long,
    pub do_not_propagate_mask: c_long,
    pub override_redirect: c_int,
    pub colormap: Colormap,
    pub cursor: Cursor,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XVisualInfo {
    pub visual: *mut Visual,
    pub visualid: VisualID,
    pub screen: c_int,
    pub depth: c_int,
    pub class: c_int,
    pub red_mask: c_ulong,
    pub green_mask: c_ulong,
    pub blue_mask: c_ulong,
    pub colormap_size: c_int,
    pub bits_per_rgb: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XSelectionEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub requestor: Window,
    pub selection: Atom,
    pub target: Atom,
    pub property: Atom,
    pub time: Time,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XNoExposeEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub drawable: Drawable,
    pub major_code: c_int,
    pub minor_code: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XCrossingEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub root: Window,
    pub subwindow: Window,
    pub time: Time,
    pub x: c_int,
    pub y: c_int,
    pub x_root: c_int,
    pub y_root: c_int,
    pub mode: c_int,
    pub detail: c_int,
    pub same_screen: c_int,
    pub focus: c_int,
    pub state: c_uint,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XMotionEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub root: Window,
    pub subwindow: Window,
    pub time: Time,
    pub x: c_int,
    pub y: c_int,
    pub x_root: c_int,
    pub y_root: c_int,
    pub state: c_uint,
    pub is_hint: c_char,
    pub same_screen: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XButtonEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub root: Window,
    pub subwindow: Window,
    pub time: Time,
    pub x: c_int,
    pub y: c_int,
    pub x_root: c_int,
    pub y_root: c_int,
    pub state: c_uint,
    pub button: c_uint,
    pub same_screen: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XKeyEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub root: Window,
    pub subwindow: Window,
    pub time: Time,
    pub x: c_int,
    pub y: c_int,
    pub x_root: c_int,
    pub y_root: c_int,
    pub state: c_uint,
    pub keycode: c_uint,
    pub same_screen: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XAnyEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XFocusChangeEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub mode: c_int,
    pub detail: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XExposeEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub x: c_int,
    pub y: c_int,
    pub width: c_int,
    pub height: c_int,
    pub count: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XGraphicsExposeEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub drawable: Drawable,
    pub x: c_int,
    pub y: c_int,
    pub width: c_int,
    pub height: c_int,
    pub count: c_int,
    pub major_code: c_int,
    pub minor_code: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XVisibilityEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub state: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XCreateWindowEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub parent: Window,
    pub window: Window,
    pub x: c_int,
    pub y: c_int,
    pub width: c_int,
    pub height: c_int,
    pub border_width: c_int,
    pub override_redirect: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XDestroyWindowEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub event: Window,
    pub window: Window,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XUnmapEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub event: Window,
    pub window: Window,
    pub from_configure: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XMapEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub event: Window,
    pub window: Window,
    pub override_redirect: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XMapRequestEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub parent: Window,
    pub window: Window,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XReparentEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub event: Window,
    pub window: Window,
    pub parent: Window,
    pub x: c_int,
    pub y: c_int,
    pub override_redirect: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XConfigureEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub event: Window,
    pub window: Window,
    pub x: c_int,
    pub y: c_int,
    pub width: c_int,
    pub height: c_int,
    pub border_width: c_int,
    pub above: Window,
    pub override_redirect: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XGravityEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub event: Window,
    pub window: Window,
    pub x: c_int,
    pub y: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XResizeRequestEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub width: c_int,
    pub height: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XConfigureRequestEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub parent: Window,
    pub window: Window,
    pub x: c_int,
    pub y: c_int,
    pub width: c_int,
    pub height: c_int,
    pub border_width: c_int,
    pub above: Window,
    pub detail: c_int,
    pub value_mask: c_ulong,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XCirculateEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub event: Window,
    pub window: Window,
    pub place: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XCirculateRequestEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub parent: Window,
    pub window: Window,
    pub place: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XPropertyEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub atom: Atom,
    pub time: Time,
    pub state: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XSelectionClearEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub selection: Atom,
    pub time: Time,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XSelectionRequestEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub owner: Window,
    pub requestor: Window,
    pub selection: Atom,
    pub target: Atom,
    pub property: Atom,
    pub time: Time,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XColormapEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub colormap: Colormap,
    pub new: c_int,
    pub state: c_int,
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct XClientMessageEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub message_type: Atom,
    pub format: c_int,
    pub data: XClientMessageEvent__bindgen_ty_1,
}

#[repr(C)]
#[derive(Copy, Clone)]
pub union XClientMessageEvent__bindgen_ty_1 {
    pub b: [c_char; 20usize],
    pub s: [c_short; 10usize],
    pub l: [c_long; 5usize],
    _bindgen_union_align: [u64; 5usize],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XMappingEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub request: c_int,
    pub first_keycode: c_int,
    pub count: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XErrorEvent {
    pub type_: c_int,
    pub display: *mut Display,
    pub resourceid: XID,
    pub serial: c_ulong,
    pub error_code: c_uchar,
    pub request_code: c_uchar,
    pub minor_code: c_uchar,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XKeymapEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub window: Window,
    pub key_vector: [c_char; 32usize],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XGenericEvent {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub extension: c_int,
    pub evtype: c_int,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct XGenericEventCookie {
    pub type_: c_int,
    pub serial: c_ulong,
    pub send_event: c_int,
    pub display: *mut Display,
    pub extension: c_int,
    pub evtype: c_int,
    pub cookie: c_uint,
    pub data: *mut c_void,
}

#[repr(C)]
#[derive(Copy, Clone)]
pub union _XEvent {
    pub type_: c_int,
    pub xany: XAnyEvent,
    pub xkey: XKeyEvent,
    pub xbutton: XButtonEvent,
    pub xmotion: XMotionEvent,
    pub xcrossing: XCrossingEvent,
    pub xfocus: XFocusChangeEvent,
    pub xexpose: XExposeEvent,
    pub xgraphicsexpose: XGraphicsExposeEvent,
    pub xnoexpose: XNoExposeEvent,
    pub xvisibility: XVisibilityEvent,
    pub xcreatewindow: XCreateWindowEvent,
    pub xdestroywindow: XDestroyWindowEvent,
    pub xunmap: XUnmapEvent,
    pub xmap: XMapEvent,
    pub xmaprequest: XMapRequestEvent,
    pub xreparent: XReparentEvent,
    pub xconfigure: XConfigureEvent,
    pub xgravity: XGravityEvent,
    pub xresizerequest: XResizeRequestEvent,
    pub xconfigurerequest: XConfigureRequestEvent,
    pub xcirculate: XCirculateEvent,
    pub xcirculaterequest: XCirculateRequestEvent,
    pub xproperty: XPropertyEvent,
    pub xselectionclear: XSelectionClearEvent,
    pub xselectionrequest: XSelectionRequestEvent,
    pub xselection: XSelectionEvent,
    pub xcolormap: XColormapEvent,
    pub xclient: XClientMessageEvent,
    pub xmapping: XMappingEvent,
    pub xerror: XErrorEvent,
    pub xkeymap: XKeymapEvent,
    pub xgeneric: XGenericEvent,
    pub xcookie: XGenericEventCookie,
    pub pad: [c_long; 24usize],
    _bindgen_union_align: [u64; 24usize],
}