summaryrefslogtreecommitdiff
path: root/XI2proto.h
blob: 14e75a7f411bf2cb763a855aba4b9ca8ffaef8c1 (plain)
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
/*
 * Copyright © 2009 Red Hat, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */

/**
 * @file XI2proto.h
 * Protocol definitions for the XI2 protocol.
 *
 * This file should not be included by clients that merely use XI2, but do not
 * need the wire protocol. Such clients should include XI2.h, or the matching
 * header from the library.
 *
 */
#ifndef _XI2PROTO_H_
#define _XI2PROTO_H_

#include <X11/Xproto.h>
#include <X11/X.h>
#include <X11/extensions/XI2.h>

/* make sure types have right sizes for protocol structures. */
#define Window  CARD32
#define Time    CARD32
#define Atom    CARD32

/* Request opcodes */
#define X_XIQueryDevicePointer          40
#define X_XIWarpDevicePointer           41
#define X_XIChangeDeviceCursor          42
#define X_XIChangeDeviceHierarchy       43
#define X_XISetClientPointer            44
#define X_XIGetClientPointer            45
#define X_XISelectEvents                46
#define X_XIQueryVersion                47
#define X_XIQueryDevice                 48
#define X_XISetDeviceFocus              49
#define X_XIGetDeviceFocus              50
#define X_XIGrabDevice                  51
#define X_XIUngrabDevice                52
#define X_XIAllowEvents                 53
#define X_XIPassiveGrabDevice           54
#define X_XIPassiveUngrabDevice         55
#define X_XIListProperties              56
#define X_XIChangeProperty              57
#define X_XIDeleteProperty              58
#define X_XIGetProperty                 59

#define XI2REQUESTS (X_XIGetProperty - X_XIQueryDevicePointer + 1)
#define XI2EVENTS   (XI_LASTEVENT + 1)

/*************************************************************************************
 *                                                                                   *
 *                               COMMON STRUCTS                                      *
 *                                                                                   *
 *************************************************************************************/
/* Fixed point 16.16 */
typedef int32_t FP1616;

/* Fixed point 32.32 */
typedef struct {
    int32_t     integral;
    uint32_t    frac;
} FP3232;

/**
 * Struct to describe a device.
 *
 * For a MasterPointer or a MasterKeyboard, 'attachment' desviced
 *
 * @see XIQueryDevices
 */
typedef struct {
    uint16_t    deviceid;
    uint16_t    use;            /**< ::MasterPointer, ::MasterKeyboard,
                                  ::SlavePointer, ::SlaveKeyboard,
                                  ::FloatingSlave */
    uint16_t    attachment;     /**< Current attachment or pairing.*/
    uint16_t    num_classes;    /**< Number of classes following this struct. */
    uint16_t    name_len;       /**< Length of name in bytes. */
    uint8_t     enabled;        /**< TRUE if device is enabled. */
    uint8_t     pad;
} xXIDeviceInfo;

/**
 * Default template for a device class.
 * A device class is equivalent to a device's capabilities. Multiple classes
 * are supported per device.
 *
 * @see XIQueryDevices
 * @see XIDeviceChangedEvent
 */
typedef struct {
    uint16_t    type;           /**< One of *class */
    uint16_t    length;         /**< Length in 4 byte units */
} xXIAnyInfo;

/**
 * Denotes button capability on a device.
 * Struct is followed by num_buttons * Atom that names the buttons in the
 * device-native setup (i.e. ignoring button mappings).
 *
 * @see XIQueryDevices
 * @see XIDeviceChangedEvent
 */
typedef struct {
    uint16_t    type;           /**< Always ButtonClass */
    uint16_t    length;         /**< Length in 4 byte units */
    uint16_t    num_buttons;    /**< Number of buttons provide */
    uint16_t    pad;
} xXIButtonInfo;

/**
 * Denotes key capability on a device.
 * Struct is followed by num_keys * CARD32 that lists the keycodes available
 * on the device.
 *
 * @see XIQueryDevices
 * @see XIDeviceChangedEvent
 */
typedef struct {
    uint16_t    type;           /**< Always KeyClass */
    uint16_t    length;         /**< Length in 4 byte units */
    uint16_t    num_keycodes;   /**< Number of keys provided */
    uint16_t    pad;
} xXIKeyInfo;

/**
 * Denotes an valuator capability on a device.
 * One XIValuatorInfo describes exactly one valuator (axis) on the device.
 *
 * @see XIQueryDevices
 * @see XIDeviceChangedEvent
 */
typedef struct {
    uint16_t    type;           /**< Always ValuatorClass       */
    uint16_t    length;         /**< Length in 4 byte units     */
    Atom        name;           /**< Valuator name              */
    FP3232      min;            /**< Min value                  */
    FP3232      max;            /**< Max value                  */
    uint32_t    resolution;     /**< Resolutions in units/m     */
    uint16_t    number;         /**< Valuator number            */
    uint8_t     mode;           /**< ModeRelative or ModeAbsolute */
    uint8_t     pad;
} xXIValuatorInfo;


/**
 * Used to select for events on a given window.
 * Struct is followed by (mask_len * CARD8), with each bit set representing
 * the event mask for the given type. A mask bit represents an event type if
 * (mask == (1 << type)).
 *
 * @see XISelectEvents
 */
typedef struct {
    uint16_t    deviceid;       /**< Device id to select for        */
    uint16_t    mask_len;       /**< Length of mask in 4 byte units */
} xXIDeviceEventMask;



typedef struct {
    uint32_t    modifiers;
    uint8_t     status;
    uint8_t     pad0;
    uint16_t    pad1;
} xXIGrabModifierInfo;

/*************************************************************************************
 *                                                                                   *
 *                                   REQUESTS                                        *
 *                                                                                   *
 *************************************************************************************/

/**********************************************************
 * XIQueryVersion.
 * Query the server for the supported X Input Extension version.
 *
 */

typedef struct {
    uint8_t     reqType;                /* input extension major code   */
    uint8_t     ReqType;                /* always X_XIQueryVersion      */
    uint16_t    length;
    uint16_t    major_version;
    uint16_t    minor_version;
} xXIQueryVersionReq;
#define sz_xXIQueryVersionReq                     8

typedef struct {
    uint8_t     repType;                /* X_Reply */
    uint8_t     RepType;                /* always X_XIQueryVersion      */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint16_t    major_version;
    uint16_t    minor_version;
    uint32_t    pad1;
    uint32_t    pad2;
    uint32_t    pad3;
    uint32_t    pad4;
    uint32_t    pad5;
} xXIQueryVersionReply;
#define sz_xXIQueryVersionReply             32

/**********************************************************
 *
 * XIQueryDevice
 * Query the server for information about a specific device or all input
 * devices.
 *
 */

typedef struct {
    uint8_t     reqType;                /* input extension major code   */
    uint8_t     ReqType;                /* always X_XIQueryDevice       */
    uint16_t    length;
    uint16_t    deviceid;
    uint16_t    pad;
} xXIQueryDeviceReq;
#define sz_xXIQueryDeviceReq                    8

typedef struct {
    uint8_t     repType;                /* X_Reply */
    uint8_t     RepType;                /* always X_XIQueryDevice       */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint16_t    num_devices;
    uint16_t    pad0;
    uint32_t    pad1;
    uint32_t    pad2;
    uint32_t    pad3;
    uint32_t    pad4;
    uint32_t    pad5;
} xXIQueryDeviceReply;
#define sz_xXIQueryDeviceReply                  32

/**********************************************************
 *
 * XISelectEvents
 *
 */
typedef struct {
    uint8_t     reqType;                /* input extension major code   */
    uint8_t     ReqType;                /* always X_XISelectEvents      */
    uint16_t    length;
    Window      window;
    uint16_t    num_masks;
    uint16_t    pad;
} xXISelectEventsReq;
#define sz_xXISelectEventsReq                  12


/**********************************************************
 *
 * QueryDevicePointer.
 *
 */

typedef struct {
    uint8_t     reqType;                /* input extension major code   */
    uint8_t     ReqType;                /* always X_QueryDevicePointer  */
    uint16_t    length;
    Window      win;
    uint16_t    deviceid;
    uint16_t    pad1;
} xXIQueryDevicePointerReq;
#define sz_xXIQueryDevicePointerReq               12


typedef struct {
    uint8_t     repType;                /* X_Reply */
    uint8_t     RepType;                /* always X_QueryDevicePointer */
    uint16_t    sequenceNumber;
    uint32_t    length;
    Window      root;
    Window      child;
    FP1616      root_x;
    FP1616      root_y;
    FP1616      win_x;
    FP1616      win_y;
    uint16_t    mask;
    uint16_t    deviceid;
    uint8_t     same_screen;
    uint8_t     pad0;
    uint16_t    pad1;
} xXIQueryDevicePointerReply;
#define sz_xXIQueryDevicePointerReply             40

/**********************************************************
 *
 * WarpDevicePointer.
 *
 */

typedef struct {
    uint8_t     reqType;        /* input extension major code   */
    uint8_t     ReqType;        /* always X_WarpDevicePointer   */
    uint16_t    length;
    Window      src_win;
    Window      dst_win;
    INT16       src_x;
    INT16       src_y;
    uint16_t    src_width;
    uint16_t    src_height;
    INT16       dst_x;
    INT16       dst_y;
    uint16_t    deviceid;
    uint16_t    pad1;
} xXIWarpDevicePointerReq;
#define sz_xXIWarpDevicePointerReq                28

/**********************************************************
 *
 * ChangeDeviceCursor.
 *
 */

typedef struct {
    uint8_t     reqType;          /* input extension major code   */
    uint8_t     ReqType;          /* always X_ChangeDeviceCursor  */
    uint16_t    length;
    Window      win;
    Cursor      cursor;
    uint16_t    deviceid;
    uint16_t    pad1;
} xXIChangeDeviceCursorReq;
#define sz_xXIChangeDeviceCursorReq               16

/**********************************************************
 *
 * ChangeDeviceHierarchy
 *
 */

typedef struct {
    uint8_t     reqType;         /* input extension major code   */
    uint8_t     ReqType;         /* always X_ChangeDeviceHierarchy */
    uint16_t    length;
    uint8_t     num_changes;
    uint8_t     pad0;
    uint16_t    pad1;
} xXIChangeDeviceHierarchyReq;
#define sz_xXIChangeDeviceHierarchyReq            8

typedef struct {
    uint16_t    type;
    uint16_t    length;         /* in 4 byte units */
} xXIAnyHierarchyChangeInfo;

/**
 * Create a new master device.
 * Name of new master follows struct (4-byte padded)
 */
typedef struct {
    uint16_t    type;           /* Always CH_CreateMasterDevice */
    uint16_t    length;         /* 2 + (namelen + padding)/4 */
    uint16_t    name_len;
    uint8_t     send_core;
    uint8_t     enable;
} xXICreateMasterInfo;

/**
 * Delete a master device. Will automatically delete the master device paired
 * with the given master device.
 */
typedef struct {
    uint16_t    type;            /* Always CH_RemoveMasterDevice */
    uint16_t    length;          /* 3 */
    uint16_t    deviceid;
    uint8_t     return_mode;     /* AttachToMaster, Floating */
    uint8_t     pad;
    uint16_t    return_pointer;  /* Pointer to attach slave ptr devices to */
    uint16_t    return_keyboard; /* keyboard to attach slave keybd devices to*/
} xXIRemoveMasterInfo;

/* Attach an SD to a new device.
 * NewMaster has to be of same type (pointer->pointer, keyboard->keyboard);
 */
typedef struct {
    uint16_t    type;           /* Always CH_AttachSlave */
    uint16_t    length;         /* 2 */
    uint16_t    deviceid;
    uint16_t    new_master;     /* id of new master device */
} xXIAttachSlaveInfo;

/* Detach an SD from its current master device.
 */
typedef struct {
    uint16_t    type;           /* Always CH_DetachSlave */
    uint16_t    length;         /* 2 */
    uint16_t    deviceid;
    uint16_t    pad;
} xXIDetachSlaveInfo;


/**********************************************************
 *
 * SetClientPointer.
 *
 */

typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_SetClientPointer */
    uint16_t    length;
    Window      win;
    uint16_t    deviceid;
    uint16_t    pad1;
} xXISetClientPointerReq;
#define sz_xXISetClientPointerReq                 12

/**********************************************************
 *
 * GetClientPointer.
 *
 */
typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_GetClientPointer */
    uint16_t    length;
    Window      win;
} xXIGetClientPointerReq;
#define sz_xXIGetClientPointerReq                 8

typedef struct {
    uint8_t     repType;                /* input extension major opcode */
    uint8_t     RepType;                /* Always X_GetClientPointer */
    uint16_t    sequenceNumber;
    uint32_t    length;
    BOOL        set;                    /* client pointer is set */
    uint8_t     pad0;
    uint16_t    deviceid;
    uint32_t    pad1;
    uint32_t    pad2;
    uint32_t    pad3;
    uint32_t    pad4;
    uint32_t    pad5;
} xXIGetClientPointerReply;
#define sz_xXIGetClientPointerReply               32

/**********************************************************
 *
 * SetDeviceFocus.
 *
 */
typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_XISetDeviceFocus */
    uint16_t    length;
    Window      focus;
    Time        time;
    uint16_t    deviceid;
    uint16_t    pad0;
} xXISetDeviceFocusReq;
#define sz_xXISetDeviceFocusReq                 16

/**********************************************************
 *
 * GetDeviceFocus.
 *
 */
typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_XIGetDeviceFocus */
    uint16_t    length;
    uint16_t    deviceid;
    uint16_t    pad0;
} xXIGetDeviceFocusReq;
#define sz_xXIGetDeviceFocusReq                 8

typedef struct {
    uint8_t     repType;                /* input extension major opcode */
    uint8_t     RepType;                /* Always X_XIGetDeviceFocus */
    uint16_t    sequenceNumber;
    uint32_t    length;
    Window      focus;
    uint32_t    pad1;
    uint32_t    pad2;
    uint32_t    pad3;
    uint32_t    pad4;
    uint32_t    pad5;
} xXIGetDeviceFocusReply;
#define sz_xXIGetDeviceFocusReply               32


/**********************************************************
 *
 * GrabDevice
 *
 */
typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_XIGrabDevice */
    uint16_t    length;
    Window      grab_window;
    Time        time;
    Cursor      cursor;
    uint16_t    deviceid;
    uint8_t     grab_mode;
    uint8_t     paired_device_mode;
    uint8_t     owner_events;
    uint8_t     pad;
    uint16_t    mask_len;
} xXIGrabDeviceReq;
#define sz_xXIGrabDeviceReq                     24

typedef struct {
    uint8_t     repType;                /* input extension major opcode */
    uint8_t     RepType;                /* Always X_XIGrabDevice */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint8_t     status;
    uint8_t     pad0;
    uint16_t    pad1;
    uint32_t    pad2;
    uint32_t    pad3;
    uint32_t    pad4;
    uint32_t    pad5;
    uint32_t    pad6;
} xXIGrabDeviceReply;
#define sz_xXIGrabDeviceReply                  32

/**********************************************************
 *
 * UngrabDevice
 *
 */
typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_XIUngrabDevice */
    uint16_t    length;
    Time        time;
    uint16_t    deviceid;
    uint16_t    pad;
} xXIUngrabDeviceReq;
#define sz_xXIUngrabDeviceReq                   12


/**********************************************************
 *
 * AllowEvents
 *
 */
typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_XIAllowEvents */
    uint16_t    length;
    Time        time;
    uint16_t    deviceid;
    uint8_t     mode;
    uint8_t     pad;
} xXIAllowEventsReq;
#define sz_xXIAllowEventsReq                   12


/**********************************************************
 *
 * PassiveGrabDevice
 *
 */
typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_XIPassiveGrabDevice */
    uint16_t    length;
    Time        time;
    Window      grab_window;
    Cursor      cursor;
    uint32_t    detail;
    uint16_t    deviceid;
    uint16_t    num_modifiers;
    uint16_t    mask_len;
    uint8_t     grab_type;
    uint8_t     grab_mode;
    uint8_t     paired_device_mode;
    uint8_t     owner_events;
    uint16_t    pad1;
} xXIPassiveGrabDeviceReq;
#define sz_xXIPassiveGrabDeviceReq              32

typedef struct {
    uint8_t     repType;                /* input extension major opcode */
    uint8_t     RepType;                /* Always X_XIPassiveGrabDevice */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint16_t    num_modifiers;
    uint16_t    pad1;
    uint32_t    pad2;
    uint32_t    pad3;
    uint32_t    pad4;
    uint32_t    pad5;
    uint32_t    pad6;
} xXIPassiveGrabDeviceReply;
#define sz_xXIPassiveGrabDeviceReply            32

typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_XIPassiveUngrabDevice */
    uint16_t    length;
    Window      grab_window;
    uint32_t    detail;
    uint16_t    deviceid;
    uint16_t    num_modifiers;
    uint8_t     grab_type;
    uint8_t     pad0;
    uint16_t    pad1;
} xXIPassiveUngrabDeviceReq;
#define sz_xXIPassiveUngrabDeviceReq            20

/**********************************************************
 *
 * XIListProperties
 *
 */
typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_XIListProperties */
    uint16_t    length;
    uint16_t    deviceid;
    uint16_t    pad;
} xXIListPropertiesReq;
#define sz_xXIListPropertiesReq                 8

typedef struct {
    uint8_t     repType;                /* input extension major opcode */
    uint8_t     RepType;                /* Always X_XIListProperties */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint16_t    num_properties;
    uint16_t    pad0;
    uint32_t    pad1;
    uint32_t    pad2;
    uint32_t    pad3;
    uint32_t    pad4;
    uint32_t    pad5;
} xXIListPropertiesReply;
#define sz_xXIListPropertiesReply               32

/**********************************************************
 *
 * XIChangeDeviceProperty
 *
 */
typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_XIChangeProperty */
    uint16_t    length;
    uint16_t    deviceid;
    uint8_t     mode;
    uint8_t     format;
    Atom        property;
    Atom        type;
    uint32_t    num_items;
} xXIChangePropertyReq;
#define sz_xXIChangePropertyReq                 20

/**********************************************************
 *
 * XIDeleteProperty
 *
 */
typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_XIDeleteProperty */
    uint16_t    length;
    uint16_t    deviceid;
    uint16_t    pad0;
    Atom        property;
} xXIDeletePropertyReq;
#define sz_xXIDeletePropertyReq                 12

/**********************************************************
 *
 * XIGetProperty
 *
 */
typedef struct {
    uint8_t     reqType;
    uint8_t     ReqType;                /* Always X_XIGetProperty */
    uint16_t    length;
    uint16_t    deviceid;
#if defined(__cplusplus) || defined(c_plusplus)
    uint8_t     c_delete;
#else
    uint8_t     delete;
#endif
    uint8_t     pad0;
    Atom        property;
    Atom        type;
    uint32_t    offset;
    uint32_t    len;
} xXIGetPropertyReq;
#define sz_xXIGetPropertyReq                    24

typedef struct {
    uint8_t     repType;                /* input extension major opcode */
    uint8_t     RepType;                /* Always X_XIGetProperty */
    uint16_t    sequenceNumber;
    uint32_t    length;
    Atom        type;
    uint32_t    bytes_after;
    uint32_t    num_items;
    uint8_t     format;
    uint8_t     pad0;
    uint16_t    pad1;
    uint32_t    pad2;
    uint32_t    pad3;
} xXIGetPropertyReply;
#define sz_xXIGetPropertyReply               32

/*************************************************************************************
 *                                                                                   *
 *                                      EVENTS                                       *
 *                                                                                   *
 *************************************************************************************/

typedef struct
{
    uint8_t     type;
    uint8_t     extension;              /* XI extension offset */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint16_t    evtype;
    uint16_t    deviceid;
    uint32_t    time;
} xXIGenericDeviceEvent;

/***********************************************************
 *  DeviceHierarchyEvent
 *
 */
typedef struct
{
    uint16_t    deviceid;
    uint16_t    attachment;
    uint8_t     use;
    BOOL        enabled;
    uint16_t    pad;
} xXIHierarchyInfo;

typedef struct
{
    uint8_t     type;                   /* always GenericEvent */
    uint8_t     extension;              /* XI extension offset */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint16_t    evtype;                 /* XI_Hierarchy */
    uint16_t    deviceid;
    uint32_t    time;
    uint32_t    flags;                  /* MasterAdded, MasterDeleted,
                                           SlaveAttached, SlaveDetached,
                                           SlaveAdded, SlaveRemoved,
                                           DeviceEnabled, DeviceDisabled */
    uint16_t    num_devices;
    uint16_t    pad0;
    uint32_t    pad1;
    uint32_t    pad2;
} xXIDeviceHierarchyEvent;

/***********************************************************
 *  DeviceChangedEvent
 *
 */

typedef struct
{
    uint8_t     type;                /* always GenericEvent */
    uint8_t     extension;           /* XI extension offset */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint16_t    evtype;              /* XI_DeviceChanged */
    uint16_t    deviceid;            /* id of master */
    uint32_t    time;
    uint16_t    num_classes;         /* classes that have changed */
    uint16_t    sourceid;            /* Source for the new classes*/
    uint8_t     reason;              /* SlaveSwitch, DeviceChange */
    uint8_t     pad0;
    uint16_t    pad1;
    uint32_t    pad2;
    uint32_t    pad3;
} xXIDeviceChangedEvent;

/***********************************************************
 *  DeviceEvent
 *
 */

typedef struct
{
    uint32_t    base_mods;
    uint32_t    latched_mods;
    uint32_t    locked_mods;
} xXIModifierInfo;

typedef struct
{
    uint8_t     base_group;
    uint8_t     latched_group;
    uint8_t     locked_group;
    uint8_t     pad0;
} xXIGroupInfo;

typedef struct
{
    uint8_t     type;                   /* always GenericEvent */
    uint8_t     extension;              /* XI extension offset */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint16_t    evtype;
    uint16_t    deviceid;
    Time        time;
    uint32_t    detail;                 /* keycode or button */
    Window      root;
    Window      event;
    Window      child;
/* └──────── 32 byte boundary ────────┘ */
    FP1616      root_x;                 /* always screen coords, 16.16 fixed point */
    FP1616      root_y;
    FP1616      event_x;                /* always screen coords, 16.16 fixed point */
    FP1616      event_y;
    uint16_t    buttons_len;            /* len of button flags in 4 b units */
    uint16_t    valuators_len;          /* len of val. flags in 4 b units */
    uint16_t    sourceid;               /* the source device */
    uint16_t    pad0;
    xXIModifierInfo     mods;
    xXIGroupInfo        group;
} xXIDeviceEvent;



/***********************************************************
 *  RawEvent
 *
 */

typedef struct
{
    uint8_t     type;                   /* always GenericEvent */
    uint8_t     extension;              /* XI extension offset */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint16_t    evtype;                 /* XI_RawEvent */
    uint16_t    deviceid;
    Time        time;
    uint32_t    detail;
    uint16_t    eventtype;              /* XI_Motion, XI_ButtonPress,
                                           XI_ButtonRelease, XI_KeyPress,
                                           XI_KeyRelease */
    uint16_t    valuators_len;
    uint32_t    pad1;
    uint32_t    pad2;
} xXIRawDeviceEvent;

/***********************************************************
 *  Enter/LeaveEvents
 *
 *  Note that the layout of root, event, child, root_x, root_y, event_x,
 *  event_y must be identical to the xXIDeviceEvent.
 *
 */

typedef struct
{
    uint8_t     type;                   /* always GenericEvent */
    uint8_t     extension;              /* XI extension offset */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint16_t    evtype;                 /* XI_Enter */
    uint16_t    deviceid;
    Time        time;
    uint16_t    sourceid;
    uint8_t     mode;
    uint8_t     detail;
    Window      root;
    Window      event;
    Window      child;
/* └──────── 32 byte boundary ────────┘ */
    FP1616      root_x;
    FP1616      root_y;
    FP1616      event_x;
    FP1616      event_y;
    BOOL        same_screen;
    BOOL        focus;
    uint16_t    buttons_len;
    xXIModifierInfo     mods;
    xXIGroupInfo        group;
} xXIEnterEvent;

typedef xXIEnterEvent xXILeaveEvent;
typedef xXIEnterEvent xXIFocusInEvent;
typedef xXIEnterEvent xXIFocusOutEvent;

/***********************************************************
 *  PropertyEvents
 *
 */

typedef struct
{
    uint8_t     type;                   /* always GenericEvent */
    uint8_t     extension;              /* XI extension offset */
    uint16_t    sequenceNumber;
    uint32_t    length;
    uint16_t    evtype;                 /* XI_PropertyEvent */
    uint16_t    deviceid;
    Time        time;
    Atom        property;
    uint8_t     what;
    uint8_t     pad0;
    uint16_t    pad1;
    uint32_t    pad2;
    uint32_t    pad3;
} xXIPropertyEvent;


#undef Window
#undef Time
#undef Atom

#endif /* _XI2PROTO_H_ */