summaryrefslogtreecommitdiff
path: root/XI2proto.txt
blob: 492d94faf08939401cf374ad5c54a4340bc63da9 (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
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
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562

                            The X Input Extension
                                Version 2.0

                              Peter Hutterer
                         peter.hutterer@redhat.com
                               Red Hat, Inc.



1. Introduction

The X Input Extension version 2.0 (XI2) is the second major release of the X
Input Extension.

XI2 provides a number of enhancements over version 1.5, including:
- use of XGE and GenericEvents. GenericEvents are of flexible length with a
  minimum length of 32 bytes.
- explicit device hierarchy of master and slave devices. See Section 4.
- use of multiple independent master devices (Multi-Poiner X or MPX).
- the ability for devices to change capabilities at runtime.
- raw device events

XI2's intent is to replace both core input processing and prior versions of
the X Input Extension. Historically, the majority of applications employed the
core protocol requests and events to handle user input. The core protocol does
not provide information about which device generated the event. The X Input
Extension version up to 1.5 requires the differentiation between core and
extended devices. Extended devices may not be core devices and thus cannot be
used on applications employing the core protocol. XI2 addresses both of these
issues by enabling devices to be both extended and core devices and providing
device information in each event (with the exception of core events).

                              ❧❧❧❧❧❧❧❧❧❧❧

2. Notations used in this document

Notation for requests:
┌───
    Name of request
        name of request field:       type of request field
        name of request field:       type of request field
        ▶
        name of reply field:         type of reply field
└───

Notation for events:
┌───
    Name of event
        name of field:               type of field
        name of field:               type of field
└───

Complex fields are specified in the following notation:
          name of field:                  COMPLEXFIELDTYPE
or, if multiple of these fields exist:
          name of field:                  LISTofCOMPLEXFIELDTYPE

COMPLEXFIELDTYPE:  { name of subfield:   type of subfield,
                    name of subfield:   type of subfield }

                              ❧❧❧❧❧❧❧❧❧❧❧

3. Interoperability between version 1.x and 2.0

FIXME

                              ❧❧❧❧❧❧❧❧❧❧❧

4. The Master/Slave device hierarchy

XI2 introduces a device hierarchy split up into so-called Master Devices (MD)
and Slave Devices (SD).

4.1 Master devices
An MD is a virtual device created and managed by the server. MDs may send core
events and XI events. However, an MD does not represent a physical device and
relies on SDs for event generation. MDs come in two forms: as master pointers
or as master keyboards. A master pointer is represented by a visible cursor on
the screen. A master keyboard is represented by a keyboard focus.

Each master pointer is paired with the respective master keyboard and vice
versa, and this pairing is constant for the lifetime of both input devices.
Clients can use this pairing behaviour to implement input paradigms that
require pointer and keyboard interation (e.g. SHIFT + Click).

4.2 Slave devices
An SD is usually a physical device configured in the server. SDs are not
represented by a cursor or keyboard focus and may be attached to a master
pointer or master keyboard. SDs can only be attached to any master of the same
type (e.g. a physical pointer device can be attached to any master pointer).

If an event is generated by an SD
- if the SD is attached to a master pointer, it changes the position and/or
  button state of the master pointer.
- if the SD is attached to a master keyboard, it sends events to this
  keyboard's focus window (if applicable) and/or changes the modifier state of
  this keyboard.
- if the SD is not attached to an MD ("floating"), it does not change 
  any master device. The SD has its own (invisible) sprite and its own focus.
  Both the sprite and the focus must be managed explicitly by the client
  program.

4.3 Event processing for attached slave devices

Whenever an SD changes its logical state,
- the event is delivered as an XI event to any interested clients. If the
  device is floating, event processing stops.
  Otherwise, if the device is attached,
- the master device changes its classes to reflect the SD's capabilities. All
  interested clients are notified of this device change.
- then, the event is delivered as an XI event from the MD to any interested
  clients. If the event has been delivered, event processing stops.
  Otherwise,
- the event is delivered as a core event to any interested clients.

Given that W is the event window, and P the parent window of W, event delivery
to P is only attempted if neither the XI event, nor the core event has been
delivered on W. Once an event has been delivered as either XI or core event,
event processing stops.

                              ❧❧❧❧❧❧❧❧❧❧❧
5. Data types

BUTTONMASK
        A binary mask defined as (1 << button number).
        A SETofBUTTONMASK is a binary OR of zero or more BUTTONMASK.

DEVICE { DEVICEID, AllDevices, AllMasterDevices }
        A DEVICE specifies either a DEVICEID or AllDevices or
        AllMasterDevices.

DEVICEID { CARD16 }
        A DEVICEID is a numerical ID for a device currently available in the
        server. The server may re-use a device ID after a device's removal.
        The device IDs 0 and 1 are reserved.
        AllDevices ........ 0
        AllMasterDevices .. 1

DEVICEUSE { MasterPointer, MasterKeyboard, SlavePointer,
            SlaveKeyboard, FloatingSlave }
        A DEVICEUSE field specifies the current use of a device in the MD/SD
        device hierarchy. See Section 4 for more information.

EVENTMASK
        An EVENTMASK is a binary mask defined as (1 << event type).
        A SETofEVENTMASK is a binary OR of zero or more EVENTMASK.

FP1616
        Fixed point decimal in 16.16 format as one INT16 and one CARD16.
        The INT16 contains the integral part, the CARD32 the decimal fraction
        shifted by 16.

FP3232
        Fixed point decimal in 32.32 format as one INT32 and one CARD32.
        The INT32 contains the integral part, the CARD32 the decimal fraction
        shifted by 32.

VALUATORMASK
        A binary mask defined as (1 << valuator number).
        A SETofVALUATORMASK is a binary OR of zero or more VALUATORMASK.

                              ❧❧❧❧❧❧❧❧❧❧❧
6. Errors

Errors are sent using core X error reports.

Device
        A value for a DEVICE argument does not specify a valid DEVICE.

                              ❧❧❧❧❧❧❧❧❧❧❧
7. Requests:

The server does not guarantee that the length of a reply remains constant in
future revisions of XI2. A client must always retrieve the exact length of the
protocol reply from the connection, even if the reply is longer than defined
for the XI2 version supported by the client.
Additional bytes in a request may include data supported in later versions of
XI2. Clients should ignore this data.

7.1 Requests introduced in version 2.0

    ┌───
        XIQueryVersion
        major_version:          CARD16
        minor_version:          CARD16
        ▶
        major_version:          CARD16
        minor_version:          CARD16
    └───

    The client sends the highest supported version to the server and the
    server sends the highest version it supports, but no higher than the
    requested version. Major versions changes can introduce incompatibilities
    in existing functionality, minor version changes introduce only backward
    compatible changes.  It is the clients responsibility to ensure that the
    server supports a version which is compatible with its expectations.

    major_version
        Major XI2 version.
    minor_version
        Minor XI2 version.

    If major_version is less than 2, a BadValue error occurs.

    ┌───
        XIQueryDevice
        DEVICE                  deviceid
        ▶
        num_devices:            CARD16
        deviceinfo:             LISTofDEVICEINFO
    └───

    DEVICEINFO { deviceid:              DEVICEID
                 use:                   DEVICEUSE
                 attachment:            DEVICEID
                 enabled:               BOOL
                 num_classes:           CARD16
                 name_len:              CARD16
                 name:                  LISTofCHAR8
                 classes:               LISTofCLASS }

    CLASS { BUTTONCLASS KEYCLASS, AXISCLASS }

    BUTTONCLASS { type:                 ButtonClass
                  length:               CARD16
                  num_buttons:          CARD16
                  buttons:              LISTofATOM }

    KEYCLASS    { type:                 KeyClass
                  length:               CARD16
                  num_keys:             CARD16
                  keys:                 LISTofCARD32 }

    AXISCLASS   { type:                 AxisClass
                  length:               CARD16
                  axisnumber:           CARD16
                  axisname:             ATOM
                  min:                  FP3232
                  max:                  FP3232
                  resolution:           CARD32 }

    XIQueryDevices details information about the requested input devices.

    devices
        The device to list. If 'devices' is AllDevices, all enabled and
        disabled devices are listed. If 'devices' is AllMasterDevices, all
        enabled and disabled master devices are listed. If 'devices' is a
        valid DEVICE, only this DEVICE is listed and 'num_devices' is 1.
    num_devices
        The number of 'deviceinfos' returned.

    Each 'deviceinfo' is detailed as follows:
    deviceid
        The unique ID of the device. Device IDs may get re-used when a device
        is removed.
    use
        If the device is a master pointer, 'use' is MasterPointer.
        If the device is a master keyboard, 'use' is MasterKeyboard.
        If the device is a slave pointer, 'use' is SlavePointer.
        If the device is a slave keyboard, 'use' is SlaveKeyboard.
        If the device is a floating slave, 'use' is FloatingSlave.

    attachment
        If the device is a master pointer or a master keyboard, 'attachment'
        specifies the paired master keyboard, or the paired master pointer,
        respectively.  If the device is a non-floating slave device
        'attachment' specifies the master device this device is attached to.
        If the device is a floating slave, 'attachment' is undefined.

    enabled
        Zero if the device is disabled, non-zero otherwise.
    num_classes
        Number of 'classes' provided.
    name_len
        Length of the name in bytes.
    classes
        Details the available classes provided by the device in an undefined
        order.
    name
        The device's name, padded to a multiple of 4 bytes.

    For all classes, 'type' specifies the device class. Clients are required
    to ignore unknown device classes. The 'length' field specifies the length
    of the class in 4 byte units.
    The following classes may occur only once: ButtonClass, KeyClass

    ButtonClass:
    type
        Always ButtonClass.
    length
        Length in 4 byte units.
    num_buttons
        Number of buttons provided by the device.
    buttons
        List of Atoms specifying the type of each button. An atom of None
        specifies an unnamed button. Buttons are listed in the device-native
        order and potential button mappings are ignored.

    KeyClass:
    type
        Always KeyClass.
    length
        Length in 4 byte units.
    num_keys
        Number of keycodes provided by the device.
    keys
        List of keycodes provided.

    AxisClass:
    type
        Always AxisClass.
    length
        Length in 4 byte units.
    axisnumber
        Axis number of this axis. The axis number is in device-native
        order and potential axis mappings are ignored.
    axisname
        Atom specifying the axis name. An Atom of None specifies an unnamed
        axis.
    min
        Minimum value.
    max
        Minimum value.
    resolution
        Resolution in counts/meter.
    mode
        Relative or Absolute.

    An axis in Relative mode may specify 'min' and 'max' as a hint to the
    client. If no 'min' and 'max' information is available, both must be 0.

    ┌───
        XISelectEvents
            window:         Window
            num_masks:      CARD16
            masks:          LISTofEVENTMASK

    └───

    EVENTMASK { deviceid:          DEVICE,
                mask_len:          CARD16,
                mask:              SETofEVENTMASK

    window
        The window to select the events on.
    num_masks
        Number of items in mask.
    deviceid
        Numerical deviceid, or AllDevices, or AllMasterDevices.
    mask_len
        Length of mask in 4 byte units.
    mask
        Event mask. An event mask for an event type T is defined as (1 << T).

    XISelectEvents selects for XI2 events on 'window'.

    If 'num_masks' is 0, a BadValue error occurs.

    Each 'mask' sets the (and overwrites a previous) event mask for the DEVICE
    specified through 'deviceid'. The device 'AllDevices' or
    'AllMasterDevices' is treated as a separate device by server. A client's
    event mask is the union of 'AllDevices', 'AllMasterDevices' and the
    per-device event mask.
    The removal of device from the server unsets the event masks for the
    device. If an event mask is set for AllDevices or AllMasterDevices, the
    event mask is not cleared on device removal and affects all future
    devices.

    If 'mask_len' is 0, the event mask for the given device is cleared.

    The mask for XIHierarchyEvents may only be selected for XIAllDevices.
    Setting it for any other device results in a BadValue error.

    ┌───
        XIGetSelectedEvents
            window:         Window
            ▶
            num_masks:      CARD16
            masks:          LISTofEVENTMASK
    └───


    window
        The window to select the events on.
    num_masks
        Number of items in mask.
    masks
        Selected event masks by this client.

    Masks are returned on a per-device basis, with masks for 'AllDevices' and
    'AllMasterDevices' returned separately.

    If 'num_masks' is 0, no events have been selected by this client on the
    given window.

    ┌───
        XIQueryPointer
            window:         Window
            deviceid:       DEVICEID
            ▶
            root:           Window
            child:          Window
            root_x:         FP1616
            root_y:         FP1616
            win_x:          FP1616
            win_y:          FP1616
            same_screen:    BOOL
            mods:           MODIFIERINFO
            group:          GROUPINFO
            buttons_len:    CARD16
            buttons:        SETofBUTTONMASK
    └───

    Query a master pointer device for its current position.

    root
        The root window the pointer is logically on.
    child
        The child window of 'window' that contains the pointer or None.
    root_x
    root_y
        Pointer position relative to the root window's origin.
    win_x
    win_y
        Pointer position relative to 'window' or 0 if 'same_screen' is false.
    same_screen
        TRUE if 'window' is on the same screen as the pointer.
    mods
        XKB modifier state on the paired device.
    group
        XKB group state on the paired device.
    buttons_len
        The length of 'buttons' in 4 byte units.
    buttons
        Button state.

    ┌───
        XIWarpPointer
            src_win:         Window
            dst_win:         Window
            src_x:           FP1616
            src_y:           FP1616
            src_width:       INT16
            src_height:      INT16
            dst_x:           FP1616
            dst_y:           FP1616
            deviceid:        DEVICEID
    └───

    WarpPointer moves the pointer of 'deviceid' as if the user had moved
    the pointer. WarpPointer can only be called for MasterPointer and
    FloatingSlave devices.

    src_win
       If src_window is not None, the move only takes place if src_window
       contains the pointer and the pointer is contained in the specified
       rectangle of src_window.
    dst_win
       If dst_win is None, this request moves the pointer by offsets
       'dst_x'/'dst_y' relative to the current position of the pointer. If
        dst_window is a window, this request moves the pointer to
       'dst_x'/'dst_y' relative to dst_win's origin.
    src_x
    src_y
    src_width
    src_height
       Specifies the source window rectangle.
    dst_x
    dst_y
        The relative coordinates to move the pointer if 'dst_win' is None, or
        the absolute coordinates if 'dst_win' is a window.
    deviceid
        The device to warp.

    This request cannot be used to move the pointer outside the confine-to
    window of an active pointer grab. An attempt will only move the pointer as
    far as the closest edge of the confine-to window.

    This request will generate events just as if the user had instantaneously
    moved the pointer.

    ┌───
        XIChangeCursor
            win:             Window
            cursor:          Cursor
            deviceid:        DEVICEID
    └───

    Change a master pointer's cursor on the specified window.

    window
        The window.
    cursor
        The new cursor or None.
    deviceid
        The master pointer device.

    Whenever 'device' enters a window W, the cursor shape is selected in the
    following order:
    - if the current window has a device cursor C(d) defined for 'device',
      display this cursor C(d).
    - otherwise, if the current window has a cursor C(w) defined in the core
      protocol's window attributes, display cursor C(w).
    - repeat on parent window until a cursor has been found.

    ┌───
        XIChangeHierarchy
            num_changes:     CARD8
            changes:         LISTofHIERARCHYCHANGES
    └───

    HIERARCHYCHANGE { ADDMASTER, REMOVEMASTER, ATTACHSLAVE, DETACHSLAVE }

    HIERARCHYCHANGETYPE { AddMaster, RemoveMaster, AttachSlave, DetachSlave }

    CHANGEMODE { Float, Attach }

    ADDMASTER { type:        HIERARCHYCHANGETYPE
                length:      CARD16
                name_len:    CARD16
                send_core:   BOOL
                enable:      BOOL
                name:        LISTofCHAR8 }

    REMOVEMASTER { type:            HIERARCHYCHANGETYPE
                   length:          CARD16
                   deviceid:        DEVICEID
                   return_mode:     CHANGEMODE
                   return_pointer:  DEVICEID
                   return_keyboard: DEVICEID }

    ATTACHSLAVE   { type:        HIERARCHYCHANGETYPE
                    length:      CARD16
                    deviceid:    DEVICEID
                    master:      DEVICEID }

    DETACHSLAVE { type:       HIERARCHYCHANGETYPE
                  length:     CARD16
                  deviceid:   DEVICEID }

    XIChangeHierarchy allows a client to modify the MD/SD device
    hierarchy (see Section 4).

    num_changes
        The number of changes to apply to the current hierarchy.
    changes
        The list of changes.

    The server processes the changes one by one and applies changes
    immediately. If an error occurs, processing stops at the current change
    and returns the number of successfully applied changes in the error.

    ADDMASTER creates a pair of master devices.
    type
        Always AddMaster.
    length
        Length in 4 byte units.
    name_len
        Length of 'name' in bytes.
    send_core
        TRUE if the device should send core events.
    enable
        TRUE if the device is to be enabled immediately.
    name
        The name for the new master devices. The master pointer's name is
        automatically appended with " pointer", the master keyboard's name is
        automatically appended with " keyboard".

    REMOVEMASTER removes an existing master device.
    type
        Always RemoveMaster.
    length
        Length in 4 byte units.
    deviceid
        The device to remove.
    return_mode
        Return mode for attached slave devices.
        If 'return_mode' is Float, all slave devices are set to floating.
        If 'return_mode' is Attach, slave pointers are attached to
        'return_pointer' and slave keyboards are attached to
        'return_keyboard'.
    return_pointer
    return_keyboard
        The master pointer and master keyboard to attach slave devices to, if
        'return_mode' is Attach.

    Removing a master pointer removes the paired master keyboard and vice
    versa.

    ATTACHSLAVE attaches a slave device to a given master device.
    type
        Always ChangeAttachment.
    length
        Length in 4 byte units.
    deviceid
        Deviceid of the slave device.
    master
        The new master device to attach this slave device to.

    DETACHSLAVE detaches a slave device from its current master device.
    type
        Always ChangeAttachment.
    length
        Length in 4 byte units.
    deviceid
        Deviceid of the slave device.

    ┌───
        XISetClientPointer
            win:             Window
            deviceid:        DEVICEID
    └───

    Set the ClientPointer for the client owning 'win' to the given device.

    win
         Window or client ID.
    deviceid
         The master pointer or master keyboard that acts as ClientPointer.

    Some protocol requests are ambiguous and the server has to choose a device
    to provide data for a request or a reply. By default, the server will
    choose a client's ClientPointer device to provide the data, unless the
    client currently has a grab on another device.

    ┌───
        XIGetClientPointer
            win:             Window
            ▶
            set:             BOOL
            deviceid:        DEVICEID
    └───

    Query the ClientPointer for the client owning 'win'.

    win
        The window or client ID.
    set
        TRUE if the client has an explicitly set ClientPointer.
    deviceid
        The master pointer that acts as a ClientPointer if 'set' is TRUE.

    ┌───
        XISetFocus
            focus:           Window
            deviceid:        DEVICEID
            time:            Time
    └───

    Set the focus for the given device to the given window. Future key events
    from this device are sent to this window.
    This request generates FocusIn and FocusOut events.

    focus
        A viewable window or None.
    deviceid
        The device to modify the focus window for.
    time
        Specifies the time to change the focus or CurrentTime.

    If focus is None, key events from this device are discarded until a new
    focus window is set. If focus is a viewable window, key events from this
    device are sent to this window. If the window becomes unviewable, the
    window's first viewable ancestor automatically becomes the focus window
    and FocusIn and FocusOut events are sent as if a client had changed the
    focus window.
    This is equivalent to RevertToParent in the core XSetInputFocus window.

    This request has no effect if the specified time is earlier than the
    current last-focus-change time or is later than the current X server time.
    Otherwise, the last-focus-change time is set to the specified time.

    ┌───
        XIGetFocus
            deviceid:        DEVICEID
            ▶
            focus:           Window
    └───

    Return the current focus window for the given device.

    ┌───
        XIGrabDevice
            deviceid:        DEVICEID
            grab_window:     Window
            owner_events:    BOOL
            grab_mode:       { Synchronous, Asynchronous }
            paired_device_mode: { Synchronous, Asynchronous }
            time:            TIMESTAMP or CurrentTime
            cursor:          Cursor
            mask_len:        CARD16
            masks:           SETofEVENTMASK
            ▶
            status:          Success, AlreadyGrabbed, Frozen, InvalidTime, NotViewable
    └───

    This request actively grabs control of the specified input device. Further
    input events from this device are reported only to the grabbing client.
    This request overides any previous active grab by this client for this
    device.

    deviceid
        The device to grab.
    grab_window
        Events are reported relative to the grab window.
    owner_events
        Specifies whether event will be reported normally or relative to the
        grab window.
    grab_mode
        Specifies if this device will be frozen as a result of the grab.
    paired_device_mode
        Specifies if the master device paired with this device will be frozen
        as a result of the grab.
    time
        A valid server time or CurrentTime.
    cursor
        The cursor to display for the duration of the grab or None.
    mask_len
        Length of mask in 4 byte units.
    mask
        Event mask. An event mask for an event type T is defined as (1 << T).
    status
        Success or the reason why the grab could not be established.


    The masks parameter specifies which events the client wishes to receive
    while the device is grabbed.

    If owner-events is False, input events generated from this device are
    reported with respect to grab-window, and are only reported if selected by
    being included in the event-list.  If owner-events is True, then if a
    generated event would normally be reported to this client, it is reported
    normally, otherwise the event is reported with respect to the grab-window,
    and is only reported if selected by being included in the event-list. For
    either value of owner-events, unreported events are discarded.

    If grab-mode is Asynchronous, device event processing continues normally.
    If the device is currently frozen by this client, then processing of
    device events is resumed. If grab-mode is Synchronous, the state of the
    grabbed device (as seen by means of the protocol) appears to freeze,
    and no further device events are generated by the server until the
    grabbing client issues a releasing XIAllowEvents request or until the
    device grab is released. Actual device input events are not lost while the
    device is frozen; they are simply queued for later processing.

    If the device is a slave device, the paired-device-mode is ignored.
    Otherwise, if this device is a master device and paired-device-mode is
    Asynchronous, event processing is unaffected by activation of the grab. If
    this device is a master device and paired-device-mode is Synchronous, the
    state of the master device paired with this device (as seen by means of the
    protocol) appears to freeze, and no further events are generated by the
    server until the grabbing client issues a releasing XIAllowEvents request
    or until the device grab is released. Actual events are not lost while the
    devices are frozen; they are simply queued for later processing.

    If the cursor is not None and the device is a master pointer device, the
    cursor will be displayed until the device is ungrabbed.

    This request fails and returns:
    AlreadyGrabbed: If the device is actively grabbed by some other client.
    NotViewable: If grab-window is not viewable.
    InvalidTime: If the specified time is earlier than the last-grab-time for
                 the specified device or later than the current X server time.
                 Otherwise, the last-grab-time for the specified device is set
                 to the specified time and CurrentTime is replaced by the
                 current X server time.
    Frozen: If the device is frozen by an active grab of another client.

    To release a grab of a device, use XIUngrabDevice.

    ┌───
        XIUngrabDevice
            deviceid:        DEVICEID
            time:            TIMESTAMP or CurrentTime
    └───

    This request releases the device if this client has it actively grabbed
    (from either XIGrabDevice,  XIGrabDeviceKey or XIGrabDeviceButton) and
    releases any queued events. If any devices were frozen by the grab,
    XIUngrabDevice thaws them.

    deviceid
        The device to grab.
    time
        A valid server time or CurrentTime.

    The request has no effect if the specified time is earlier
    than the last-device-grab time or is later than the current server time.
    This request generates FocusIn and FocusOut events.
    An XIUngrabDevice is performed automatically if the event window for an
    active device grab becomes not viewable.

    ┌───
        XIAllowEvents:
            deviceid:        DEVICEID
            time:            TIMESTAMP or CurrentTime
            event_mode:      { AsyncDevice, SyncDevice,
                               AsyncPairedDevice, SyncPairedDevice,
                               ReplayDevice, AsyncPair, SyncPair }
    └───

    The XIAllowEvents request releases some queued events if the client
    has caused a device to freeze.

    deviceid
        The device to grab.
    time
        A valid server time or CurrentTime.
    event_mode
        Specifies whether a device is to be thawed and events are to be
        replayed.

    The request has no effect if the specified time is earlier than the
    last-grab time of the most recent active grab for the client, or if the
    specified time is later than the current X server time.

    The following describes the processing that occurs depending on what constant
    you pass to the event-mode argument:
    AsyncDevice:
        If the specified device is frozen by the client, event processing for that
        device continues as usual. If the device is frozen multiple times  by the
        client on behalf of multiple separate grabs, AsyncDevice thaws for
        all.
        AsyncDevice has no effect if the specified device is not frozen by the
        client, but the device need not be grabbed by the client.
    SyncDevice:
        If the specified device is frozen and actively grabbed by the client,
        event processing for that device continues normally until the next
        event is reported to the client. At this time, the specified device
        again appears to freeze. However, if the reported event causes the
        grab to be released, the specified device does not freeze.
        SyncDevice has no effect if the specified device is not frozen by the
        client or is not grabbed by the client.
     ReplayDevice:
        If the specified device is actively grabbed by the client and is frozen
        as the result of an event having been sent to the client (either from
        the activation of a XIGrabButton or from a previous XIAllowEvents with
        mode SyncDevice, but not from a Grab), the grab is released and
        that event is completely reprocessed.  This time, however, the request
        ignores any passive grabs at or above (towards the root) the
        grab-window of the grab just released.
        The request has no effect if the specified device is not grabbed by
        the client or if it is not frozen as the result of an event.
     AsyncPairedDevice
        If the paired master device is frozen by the client, event processing
        for it continues as usual. If the paired device is frozen multiple
        times by the client on behalf of multiple separate grabs,
        AsyncPairedDevice thaws for all.
        AsyncPairedDevice has no effect if the device is not frozen by the
        client, but those devices need not be grabbed by the client.
        AsyncPairedDevice has no effect if deviceid specifies a slave device.
     SyncPairedDevice
        If the paired master device is frozen by the client, event processing (for
        the paired master device) continues normally until the next button or key
        event is reported to the client for the grabbed device (button event for
        the grabbed device, key or motion event for the device), at which time
        the device again appears to freeze. However, if the reported event causes
        the grab to be released, then the device does not freeze.
        SyncPairedDevice has no effect if the specified device is not grabbed
        by the client or if it is no frozen as the result of an event.
        SyncPairedDevice has no effect if deviceid specifies a slave device.
     SyncPair
        If both the device and the paired master device are frozen by the
        client, event processing (for both devices) continues normally until
        the next XIButtonPress, XIButtonRelease, XIKeyPress, or XIKeyRelease
        event is reported to the client for a grabbed device (button event for
        a pointer, key event for a keyboard), at which time the devices again
        appear to freeze. However, if the reported event causes the grab to be
        released, then the devices do not freeze (but if the other device is
        still grabbed, then a subsequent event for it will still cause both
        devices to freeze).
        SyncPair has no effect unless both the device and the paired master
        device are frozen by the client. If the device or paired master device
        is frozen twice by the client on behalf of two separate grabs,
        SyncPair thaws for both (but a subsequent freeze for SyncPair will
        only freeze each device once).
        SyncPair has no effect if deviceid specifies a slave device.
     AsyncPair
        If the device and the paired master device are frozen by the client,
        event processing for both devices continues normally. If a device is
        frozen twice by the client on behalf of two separate grabs, AsyncBoth
        thaws for both. AsyncPair has no effect unless both the device and the
        paired master device frozen by the client.
        AsyncPair has no effect if deviceid specifies a slave device.

    ┌───
        XIPassiveGrabDevice
            deviceid:        DEVICEID
            detail:          CARD32
            grab_type:       GRABTYPE
            grab_window:     Window
            cursor:          Cursor
            owner_events:    Bool
            grab_mode:       { Synchronous, Asynchronous }
            paired_device_mode: { Synchronous, Asynchronous }
            num_modifiers:   INT16
            mask_len:        CARD16
            masks:           SETofEVENTMASK
            modifiers:       CARD32 or GrabAnyModifier
            ▶
            num_modifiers_return:    INT16
            modifiers_return:        GRABMODIFIERINFO
    └───

        GRABTYPE         { GrabtypeButton, GrabtypeKeysym, GrabtypeEnter,
                           GrabTypeFocusIn}

        GRABMODIFIERINFO {   status:    Access
                             modifiers: CARD32 }

        Establish an explicit passive grab for a button or keysym
        on the specified input device.

        cursor
            The cursor to display for the duration of the grab. If grab_type
            is not GrabtypeButton, this argument is ignored.
        deviceid
            The device to establish the passive grab on.
        detail
            The button number, or key symbol to grab for.
            Must be 0 for GrabtypeEnter and GrabtypeFocusIn.
        grab_type
            The type of grab to establish.
        grab_window
            Events are reported relative to the grab window.
        grab_mode
            If grab-mode is Asynchronous, device event processing continues
            normally.  If the device is currently frozen by this client, then
            processing of device events is resumed. If grab-mode is
            Synchronous, the state of the grabbed device (as seen by means of
            the protocol) appears to freeze, and no further device events are
            generated by the server until the grabbing client issues a
            releasing XIAllowEvents request or until the device grab is
            released. Actual device input events are not lost while the device
            is frozen; they are simply queued for later processing.
        mask_len
            Length of mask in 4 byte units.
        mask
            Event mask. An event mask for an event type T is defined as (1 << T).
        modifiers
            XKB modifier state to activate this passive grab.
        num_modifiers
            Number of elements in modifiers.
        owner_events
            Specifies whether event will be reported normally or relative to the
            grab window.
        num_modifiers_return
            Number of elements in modifiers_return
        modifiers_return
            XKB modifier state that could not be grabbed.

        If owner-events is False, input events generated from this device are
        reported with respect to grab-window, and are only reported if
        selected by being included in the event-list.  If owner-events is
        True, then if a generated event would normally be reported to this
        client, it is reported normally, otherwise the event is reported
        with respect to the grab-window, and is only reported if selected
        by being included in the event-list. For either value of
        owner-events, unreported events are discarded.

        If deviceid specifies a master pointer, the modifiers of the paired
        master keyboard are used. If deviceid specifies a slave pointer
        the modifiers of the master keyboard paired with the attached master
        pointers are used. If deviceid specifies a slave keyboard, the
        modifiers of the attached master keyboard are used. Note that
        activating a grab on a slave device detaches the device from its
        master. In this case, the modifiers after activation of the grab are
        from the slave device only and may be different to the modifier state
        when the grab was triggered.

        In the future, if grab_type is GrabtypeButton or GrabtypeKeyboard, the
        device is actively grabbed if:
        - the device is not grabbed, and
        - the specified modifier keys are down, and
        - the grab_type is GrabtypeButton and the button specified in detail
          is logically pressed or the grab_type is GrabtypeKeysym and the
          keysym specified in detail is logically pressed, and
        - the grab_window contains the pointer, and
        - a passive grab on the same button/keysym + modifier
          combination does not exist on an ancestor of grab_window.

        Otherwise, if grab_type is GrabtypeEnter or GrabtypeFocusIn, the
        device is actively grabbed if:
        - the device is not actively grabbed, and
        - the specified modifier keys are down, and
        - the grab_type is GrabtypeEnter and the device's pointer has moved
          into grab_window or a descendant of grab_window, or the grab_type is
          GrabtypeFocusIn and the device's focus has been set to the
          grab_window or a descendant of grab_window,
        - a passive grab of the same grab_type + modifier combination does not
          does not exist on an ancestor of grab_window.

        A modifier of GrabAnyModifier is equivalent to issuing the request for
        all possible modifier combinations (including no modifiers). A client
        may request a grab for GrabAnyModifier and explicit modifier
        combinations in the same request.

        A GrabtypeButton or GrabtypeKeyboard grab is released when all buttons
        or keysyms are released, independent of the state of modifier keys.
        A GrabtypeEnter or GrabtypeFocusIn grab is released when the
        pointer or focus leaves the window and all of its descendants,
        independent of the state of modifier keys.
        Note that the logical state of a device (as seen by means of the
        protocol) may lag the physical state if device event processing is
        frozen.

        This request overrides all previous passive grabs by the same
        client on the same button/key/enter/focus in + modifier combinations
        on the same window.

        If some other client already has issued a XIPassiveGrabDevice request
        with the same button or keysym and modifier combination, the
        failed modifier combinations is returned in modifiers_return. If some
        other client already has issued an XIPassiveGrabDevice request of
        grab_type  XIGrabtypeEnter or XIGrabtypeFocusIn with the same
        grab_window and the same modifier combination, the failed modifier
        combinations are returned in modifiers_return. If num_modifiers_return
        is zero, all passive grabs have been successful.

        If a button grab or enter grab activates, EnterNotify and LeaveNotify
        events with mode Grab are generated as if the pointer were to suddenly
        warp from its current position some position in the grab_window.
        However, the pointer does not warp, and the pointer position is used
        as both the initial and final positions for the events.

        If a keysym grab or focus grab activates, FocusIn and FocusOut events
        with mode Grab are generated as if the focus were to change from the
        current window to the grab_window.

        If an enter or focus in grab activates, additional EnterNotify events
        with mode XIPassiveGrabNotify are generated as if the pointer or focus
        were to suddenly warp from its current position to some position in
        the grab window.  These events are sent to the grabbing client only
        and only if the grab event mask has selected for it. If such a passive
        grab deactivates, addional LeaveNotify events with mode
        XIPassiveUngrabNotify are generated and sent to the grabbing client
        before the grab deactivates.

    ┌───
        XIPassiveUngrabDevice
            deviceid:        DEVICEID
            detail:          CARD32
            grab_type:       GRABTYPE
            grab_window:     Window
            num_modifiers:   INT16
            modifiers:       MODIFIERINFO
    └───

        Release an explicit passive grab on the specified input device.

        deviceid
            The device to establish the passive grab on.
        detail
            The button number or key symbol to ungrab.
            Must be 0 for GrabtypeEnter and GrabtypeFocusIn.
        grab_type
            The type of grab to establish.
        grab_window
            Events are reported relative to the grab window.
        modifiers
            XKB modifier state to activate this passive grab.
        num_modifiers
            Number of elements in modifiers.

        This request has no effect if the client does not have a passive grab
        of the same type, same button or keysym (if applicable) and modifier
        combination on the grab_window.

    ┌───
        XIListProperties
            deviceid:        DEVICEID
            ▶
            num_properties:  INT16
            properties:      LISTofATOM
    └───

        List the properties associated with the given device.

        deviceid
            The device to list the properties for.
        num_atoms
            Number of atoms in the reply
        atoms
            All properties on the device.

    ┌───
        XIChangeProperty
            deviceid:        DEVICEID
            property:        ATOM
            type:            ATOM
            format:          { 8, 16, 32 }
            mode:            { Append, Prepend, Replace }
            num_items:       CARD32
            data:            LISTofINT8, or LISTofINT16, or LISTofINT32
    └───

        Change the given property on the given device.

        deviceid
            The device to change the property on.
        property
            The property to modify.
        type
            The property's type.
        mode
            One of Append, Prepend, or Replace
        num_items
            Number of items following this request.
        data
            Property data (nitems * format/8 bytes)

        The type is uninterpreted by the server. The format specifies whether
        the data should be viewed as a list of 8-bit, 16-bit, or 32-bit
        quantities so that the server can correctly byte-swap as necessary.

        If the mode is Replace, the previous propert y value is discarded.  If
        the mode is Prepend or Append, then the type and format must match the
        existing property value (or a Match error results). If the property is
        undefined, it is treated as defined with the correct type and format
        with zero-length data. For Prepend, the data is tacked on to the
        beginning of the existing data, and for Append, it is tacked on to the
        end of the existing data.

        The lifetime of a property is not tied to the storing client. Properties
        remain until explicitly deleted, until the device is removed, or
        until server reset.

        A property cannot be deleted by setting nitems to zero. To delete a
        property, use XIDeleteDeviceProperty.

        This request generates an XIPropertyEvent.

    ┌───
        XIDeleteProperty
            deviceid:        DEVICEID
            property:        ATOM
    └───

        Deletes the given property on the given device.

        deviceid
            The device to delete the property on.
        property
            The property to delete.

        If the property is deleted, an XIPropertyEvent is generated on the device.
        If the property does not exist, this request does nothing.

    ┌───
        XIGetProperty
            deviceid:        DEVICEID
            property:        ATOM
            type:            Atom or AnyPropertyType
            offset:          CARD32
            len:             CARD32
            delete:          BOOL
            ▶
            type:            Atom
            bytes_after:     CARD32
            num_items:       CARD32
            format:          { 8, 16, 32 }
            data:            LISTofINT8, or LISTofINT16, or LISTofINT32
    └───
        
        Get the data for the given property on the given device.

        deviceid
            The device to retrieve the property data from.
        property
            The property to retrieve the data from..
        type
            The property type to retrieve or AnyPropertyType
        offset
            The offset in 4-byte units.
        len
            Number of bytes to receive in 4-byte units.
        delete
            Delete the property after retrieving the data.
        bytes_after
            Number of unread bytes in the stored property
        num_items
            Number of items in data
        format
            8, 16, or 32
        data
            Property data (nitems * format/8 bytes)

        If the specified property does not exist for the specified device, then
        the return type is None, the format and bytes-after are zero, and the value is
        empty. The delete argument is ignored in this case. If the specified property
        exists but its type does not match the specified type, then the return
        type is the actual type of the property, the format is the actual format of the
        property (never zero), the bytes-after is the length of the property in bytes
        (even if the format is 16 or 32), and the value is empty. The delete
        argument is ignored in this case. If the specified property exists and
        either AnyPropertyType is specified or the specified type matches the actual
        type of the property, then the return type is the actual type of the property,
        the format is the actual format of the property
        (never zero), and the bytes-after and value are as follows, given:
                 N = actual length of the stored property in bytes
                    (even if the format is 16 or 32)
                 I = 4 * long-offset
                 T = N−I
                 L = MINIMUM(T, 4 * long-length)
                 A = N − (I + L)
        The returned value starts at byte index I in the property (indexing
        from 0), and its length in bytes is L. However, it is a Value error if
        offset is given such that L is negative. The value of bytes_after is A,
        giving the number of trailing unread bytes in the stored property. If
        delete is True and the bytes_after is zero, the property is also
        deleted from the device, and a XIPropertyNotify event is generated on
        the device.  
     

8. Events:

An event specifies its length in 4-byte units after the initial 32 bytes.
Future versions of the protocol may provide additional information
in the same event, thus increasing the event size. Clients are required to
always read the number of bytes specified by the event, not the size of the
event they may have been compiled against.


The following event types are available in XI2.

Version 2.0:
        HierarchyChanged
        DeviceChanged
        KeyPress
        KeyRelease
        ButtonPress
        ButtonRelease
        Motion
        RawEvent
        Enter
        Leave

All events have a set of common fields specified as EVENTHEADER.


EVENTHEADER { type:                       BYTE
              extension:                  BYTE
              sequenceNumber:             CARD16
              length:                     CARD32
              evtype:                     CARD16
              deviceid:                   DEVICEID
              time:                       Time }

    type
        Always GenericEvent.
    extension
        Always the X Input extension offset.
    sequenceNumber
        Sequence number of last request processed by the server.
    length
        Length in 4-byte units after the initial 32 bytes.
    evtype
        XI-specific event type.
    deviceid
        Numerical device id for a device.
    time
        Time in ms.


    ┌───
        HierarchyEvent:
            EVENTHEADER
            flags:                      SETofHIERARCHYMASK
            num_info:                   CARD16
            info:                       LISTofHIERARCHYINFO
    └───


    HIERARCHYMASK { MasterAdded, MasterRemoved, SlaveAttached, SlaveDetached,
                    SlaveAdded, SlaveRemoved, DeviceEnabled, DeviceDisabled }

    HIERARCHYINFO { deviceid:           DEVICEID,
                    attachment:         DEVICEID,
                    type:               DEVICEUSE
                    enabled:            BOOL
                    flags:              SETofHIERARCHYMASK}

    flags
        Set of the changes that have occured, causing this event.
    num_info
        The number of device info structs following the request.
    info:
        The current hierarchy information.

    An XIHierarchyEvent is sent whenever the device hierarchy been
    changed. The 'flags' specify all types of hierarchy modifiations that have
    occured.
    For all devices, 'info' details the hierarchy information after the
    modification of the hierarchy has occured. For each device specified with
    'deviceid':
    - if 'type' is MasterPointer or MasterKeyboard, 'attachment' decribes the
      pairing of this device.
    - if 'type' is SlavePointer or SlaveKeyboard, 'attachment' describes the
      master device this device is attached to.
    - if 'type' is FloatingSlave device, 'attachment' is undefined.

    enabled
         TRUE if the device is enabled and can send events. A disabled master
         device will not forward events from an attached, enabled slave
         device.

    Note: Multiple devices may be affected in one hierarchy change,
    'deviceid' in an XIHierarchyEvent is always the first affected
    device. Clients should ignore deviceid and instead use the 'devices' list.

    ┌───
        DeviceChangedEvent:
            EVENTHEADER
            reason:                CHANGEREASON
            source:                DEVICEID
            num_classes:           CARD16
            classes:               LISTofCLASS
    └───

    CHANGEREASON { SlaveSwitch, DeviceChange }

    A DeviceChangeEvent is sent whenever a device changes it's capabilities.
    This can happen either by a new slave device sending events through a
    master device, or by a physical device changing capabilities at runtime.

    reason
        The reason for generating this event.
        If 'reason' is SlaveSwitch, the slave device sending events through
        this device has changed and 'source' specifies the new slave device.
        A SlaveSwitch 'reason' can only occur on a master device.
        If 'reason' is DeviceChange, the device itself has changed through
        other means (e.g. a physical device change) and 'source' is
        undefined. A DeviceChange can only occur on a slave device.
    source
        The source of the new classes. Only defined in 'reason' is
        SlaveSwitch.
    num_classes
        Number of 'classes' provided.
    classes
        Details the available classes provided by the device.  The order the
        classes are provided in is undefined.

    For a detailed description of 'classes', see the XQueryInputDevice
    request.

    ┌───
        DeviceEvent:
            EVENTHEADER
            detail:                     CARD32
            root:                       Window
            event:                      Window
            child:                      Window
            root_x:                     FP1616
            root_y:                     FP1616
            event_x:                    FP1616
            event_y:                    FP1616
            buttons_len:                CARD16
            valuators_len:              CARD16
            sourceid:                   DEVICEID
            mods:                       MODIFIERINFO
            group:                      GROUPINFO
            buttons:                    SETofBUTTONMASK
            valuators:                  SETofVALUATORMASK
            axisvalues:                 LISTofFP3232
    └───

    BUTTONBIT { (1 << Button1), (1 << Button2), ... , (1 << ButtonN) }
    VALUATORBIT { (1 << 1), ( 1 << 2), ... ( 1 << n) }

    MODIFIERINFO  { base_mods:           CARD32,
                    latched_mods:        CARD32,
                    locked_mods:         CARD32}
    GROUPINFO     { base_group:          CARD8,
                    latched_group:       CARD8,
                    locked_group:        CARD8 }

    An XIDeviceEvent is generated whenever the logical state of a device
    changes in response to a button press, a button release, a motion, a key
    press or a key release.

    detail
        The button number or key code, or 0.
    root
    event
    child
        The root window, event window or subwindow, respectively. See core
        protocol specification for more detail.
    root_x
    root_y
        The position of the pointer in screen coordinates (16.16 fixed point).
    event_x
    event_y
        The position of the pointer in screen coordinates relative to the
        event window (16.16 fixed point).

    buttons_len
        The length of 'buttons' in 4 byte units.
    valuators_len
        The length of 'valuators' in 4 byte units.
    sourceid
        The source device that originally generated the event.
    mods
        XKB modifier state before the event occured.
    group
        XKB group state before the event.
    buttons
        Button state before the event.
    valuators
        Bitmask of valuators provided in 'axisvalues'.
    axisvalues
        Valuator data in device-native resolution.

    Modifier state in 'mods' is detailed as follows:
    base_mods
        XKB base modifier state.
    latched_mods
        XKB latched modifier state.
    locked_mods
        XKB locked modifier state.

    Group state in 'group' is detailed as follows:
    base_group
        XKB base group state.
    latched_group
        XKB latched group state.
    locked_group
        XKB locked group state.

    ┌───
        RawEvent
            EVENTHEADER
            eventtype:                 RAWTYPE
            detail:                    CARD32
            valuators_len:             CARD16
            valuators:                 SETofVALUATORMASK
            axisvalues:                LISTofFP3232
            axisvalues_raw:            LISTofFP3232
    └───

    RAWTYPE { Motion, KeyPress, KeyRelease, ButtonPress, ButtonRelease }

    A RawDevice event provides the information provided by the driver to the
    client. RawDevice events are only generated for slave devices and provide
    both the raw data as supplied by the driver and transformed data as used
    in the server. Transformations include, but are not limited to, axis
    clipping and acceleration.
    Transformed valuator data may be equivalent to raw data. In this case,
    both raw and transformed valuator data is provided.
    RawEvents are sent exclusively to all root windows or to the client
    that grabbed the device only.

    eventtype
        The type of event that occured on the device.
    detail
        The button number or keycode.
    valuators_len
        The length of 'valuators' in 4 byte units.
    valuators
        Bitmask of valuators provided in 'axisvalues' and 'axisvalues_raw'.
    axisvalues
        Valuator data in device-native resolution.
    axisvalues_raw
        Untransformed valuator data in device-native resolution.

    ┌───
        Enter or Leave or FocusIn or FocusOut
            EVENTHEADER
            root:               Window
            event:              Window
            child:              Window
            sourceid:           DEVICEID
            root_x:             FP1616
            root_y:             FP1616
            event_x             FP1616
            event_y:            FP1616
            mode:               NOTIFYMODE
            detail:             NOTIFYDETAIL
            same_screen:        BOOL
            focus:              BOOL
            mods:               MODIFIERINFO
            group:              GROUPINFO
            buttons_len:        CARD16
            buttons:            SETofBUTTONMASK
    └───

    NOTIFYMODE { Normal, Grab, Ungrab }
    NOTIFYDETAIL { Ancestor, Virtual, Inferior, Nonlinear, NonlinearVirtual,
                   Pointer, PointerRoot, None }

    Enter or Leave events are sent whenever a device's pointer enters or
    leaves a window.
    FocusIn or FocusOut events are sent whenever a device's focus is set to or
    away from a window.
    The enter/leave and focus in/out model is described in the core protocol
    specification, Section 11. (EnterNotify, LeaveNotify events).

    For enter and leave events, the modifier and group state is the state of
    the paired master device if the device is a master device, or the state of
    the attached master keyboard if the device is an attached slave device, or
    zero if the device is a floating slave device.

    For focus in and out events, the button state is the state of the paired
    master device if the device is a master device, or the state of the
    attached master keyboard if the device is an attached slave device, or
    zero if the device is a floating slave device.

    root
    event
    child
        The root window, event window, and child window, respectively. See the
        core protocol specification for more detail.
    sourceid
        The device that caused the pointer to move.
    root_x
    root_y
        The pointer coordinates relative to the root window.
    event_x
    event_y
        The pointer coordinates relative to the event window.
    mode
        Normal pointer motion events have mode Normal. Pseudo-motion events
        when a grab activates have mode Grab, and pseudo-motion events when a
        grab deactivates have mode Ungrab. Pseudo-motion events caused by the
        activation or deactivation of a passive enter or focus in grab have mode
        XIPassiveGrabNotify or XIPassiveUngrabNotify.
    detail
        Specifies the relation of the event window to the window the pointer
        entered or left. See the core protocol spec for details.
    same_screen
        TRUE if the event window is on the same screen as the pointer's root
        window.
    focus
        If the event window is the focus window or an inferior of the focus
        window, then focus is True. Otherwise, focus is False. This field is
        unspecified for focus in/out events.
    mods
        XKB modifier state before the event occured.
    group
        XKB group state before the event.
    buttons_len
        The length of 'buttons' in 4 byte units.
    buttons
        Button state before the event.

    ┌───
        XIPropertyEvent
            EVENTHEADER
            property:           ATOM
            what:               { PropertyCreated, PropertyDeleted, PropertyModified }
    └───

    XIPropertyEvents are sent whenever a device property is created, deleted or
    modified by a client.

    property
        The property that has been created, deleted, or modified
    what
        Specifies what has been changed.
     

                              ❧❧❧❧❧❧❧❧❧❧❧