2fd91ebf13055b585a9996d3575ec74cc0bd56e2
[framework/uifw/xorg/proto/x11proto-input.git] / XI2proto.h
1 /*
2  * Copyright © 2009 Red Hat, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  */
24
25 /* Conventions for this file:
26  * Names:
27  * structs: always typedef'd, prefixed with xXI, CamelCase
28  * struct members: lower_case_with_underscores
29  *        Exceptions: reqType, ReqType, repType, RepType, sequenceNumber are
30  *        named as such for historical reasons.
31  * request opcodes: X_XIRequestName as CamelCase
32  * defines: defines used in client applications must go in XI2.h
33  *          defines used only in protocol handling: XISOMENAME
34  *
35  * Data types: unless there is a historical name for a datatype (e.g.
36  * Window), use stdint types specifying the size of the datatype.
37  * historical data type names must be defined and undefined at the top and
38  * end of the file.
39  *
40  * General:
41  * spaces, not tabs.
42  * structs specific to a request or reply added before the request
43  *      definition. structs used in more than one request, reply or event
44  *      appended to the common structs section before the definition of the
45  *      first request.
46  * members of structs vertically aligned on column 16 if datatypes permit.
47  *      otherwise alingned on next available 8n column.
48  */
49
50 /**
51  * Protocol definitions for the XI2 protocol.
52  * This file should not be included by clients that merely use XI2, but do not
53  * need the wire protocol. Such clients should include XI2.h, or the matching
54  * header from the library.
55  *
56  */
57 #ifndef _XI2PROTO_H_
58 #define _XI2PROTO_H_
59
60 #include <X11/Xproto.h>
61 #include <X11/X.h>
62 #include <X11/extensions/XI2.h>
63
64 /* make sure types have right sizes for protocol structures. */
65 #define Window  uint32_t
66 #define Time    uint32_t
67 #define Atom    uint32_t
68 #define Cursor  uint32_t
69
70 /**
71  * XI2 Request opcodes
72  */
73 #define X_XIQueryPointer                40
74 #define X_XIWarpPointer                 41
75 #define X_XIChangeCursor                42
76 #define X_XIChangeHierarchy             43
77 #define X_XISetClientPointer            44
78 #define X_XIGetClientPointer            45
79 #define X_XISelectEvents                46
80 #define X_XIQueryVersion                47
81 #define X_XIQueryDevice                 48
82 #define X_XISetFocus                    49
83 #define X_XIGetFocus                    50
84 #define X_XIGrabDevice                  51
85 #define X_XIUngrabDevice                52
86 #define X_XIAllowEvents                 53
87 #define X_XIPassiveGrabDevice           54
88 #define X_XIPassiveUngrabDevice         55
89 #define X_XIListProperties              56
90 #define X_XIChangeProperty              57
91 #define X_XIDeleteProperty              58
92 #define X_XIGetProperty                 59
93 #define X_XIGetSelectedEvents           60
94
95 /** Number of XI requests */
96 #define XI2REQUESTS (X_XIGetSelectedEvents - X_XIQueryPointer + 1)
97 /** Number of XI2 events */
98 #define XI2EVENTS   (XI_LASTEVENT + 1)
99
100 /*************************************************************************************
101  *                                                                                   *
102  *                               COMMON STRUCTS                                      *
103  *                                                                                   *
104  *************************************************************************************/
105 /** Fixed point 16.16 */
106 typedef int32_t FP1616;
107
108 /** Fixed point 32.32 */
109 typedef struct {
110     int32_t     integral;
111     uint32_t    frac;
112 } FP3232;
113
114 /**
115  * Struct to describe a device.
116  *
117  * For a MasterPointer or a MasterKeyboard, 'attachment' specifies the
118  * paired master device.
119  * For a SlaveKeyboard or SlavePointer, 'attachment' specifies the master
120  * device this device is attached to.
121  * For a FloatingSlave, 'attachment' is undefined.
122  */
123 typedef struct {
124     uint16_t    deviceid;
125     uint16_t    use;            /**< ::XIMasterPointer, ::XIMasterKeyboard,
126                                      ::XISlavePointer, ::XISlaveKeyboard,
127                                      ::XIFloatingSlave */
128     uint16_t    attachment;     /**< Current attachment or pairing.*/
129     uint16_t    num_classes;    /**< Number of classes following this struct. */
130     uint16_t    name_len;       /**< Length of name in bytes. */
131     uint8_t     enabled;        /**< TRUE if device is enabled. */
132     uint8_t     pad;
133 } xXIDeviceInfo;
134
135 /**
136  * Default template for a device class.
137  * A device class is equivalent to a device's capabilities. Multiple classes
138  * are supported per device.
139  */
140 typedef struct {
141     uint16_t    type;           /**< One of *class */
142     uint16_t    length;         /**< Length in 4 byte units */
143     uint16_t    sourceid;       /**< source device for this class */
144     uint16_t    pad;
145 } xXIAnyInfo;
146
147 /**
148  * Denotes button capability on a device.
149  * Struct is followed by num_buttons * Atom that names the buttons in the
150  * device-native setup (i.e. ignoring button mappings).
151  */
152 typedef struct {
153     uint16_t    type;           /**< Always ButtonClass */
154     uint16_t    length;         /**< Length in 4 byte units */
155     uint16_t    sourceid;       /**< source device for this class */
156     uint16_t    num_buttons;    /**< Number of buttons provide */
157 } xXIButtonInfo;
158
159 /**
160  * Denotes key capability on a device.
161  * Struct is followed by num_keys * CARD32 that lists the keycodes available
162  * on the device.
163  */
164 typedef struct {
165     uint16_t    type;           /**< Always KeyClass */
166     uint16_t    length;         /**< Length in 4 byte units */
167     uint16_t    sourceid;       /**< source device for this class */
168     uint16_t    num_keycodes;   /**< Number of keys provided */
169 } xXIKeyInfo;
170
171 /**
172  * Denotes an valuator capability on a device.
173  * One XIValuatorInfo describes exactly one valuator (axis) on the device.
174  */
175 typedef struct {
176     uint16_t    type;           /**< Always ValuatorClass       */
177     uint16_t    length;         /**< Length in 4 byte units */
178     uint16_t    sourceid;       /**< source device for this class */
179     uint16_t    number;         /**< Valuator number            */
180     Atom        label;          /**< Axis label                 */
181     FP3232      min;            /**< Min value                  */
182     FP3232      max;            /**< Max value                  */
183     FP3232      value;          /**< Last published value       */
184     uint32_t    resolution;     /**< Resolutions in units/m     */
185     uint8_t     mode;           /**< ModeRelative or ModeAbsolute */
186     uint8_t     pad1;
187     uint16_t    pad2;
188 } xXIValuatorInfo;
189
190
191 /**
192  * Used to select for events on a given window.
193  * Struct is followed by (mask_len * CARD8), with each bit set representing
194  * the event mask for the given type. A mask bit represents an event type if
195  * (mask == (1 << type)).
196  */
197 typedef struct {
198     uint16_t    deviceid;       /**< Device id to select for        */
199     uint16_t    mask_len;       /**< Length of mask in 4 byte units */
200 } xXIEventMask;
201
202 /**
203  * XKB modifier information.
204  * The effective modifier is a binary mask of base, latched, and locked
205  * modifiers.
206  */
207 typedef struct
208 {
209     uint32_t    base_mods;              /**< Logically pressed modifiers */
210     uint32_t    latched_mods;           /**< Logically latched modifiers */
211     uint32_t    locked_mods;            /**< Logically locked modifiers */
212     uint32_t    effective_mods;         /**< Effective modifiers */
213 } xXIModifierInfo;
214
215 /**
216  * XKB group information.
217  * The effective group is the mathematical sum of base, latched, and locked
218  * group after group wrapping is taken into account.
219  */
220 typedef struct
221 {
222     uint8_t     base_group;             /**< Logically "pressed" group */
223     uint8_t     latched_group;          /**< Logically latched group */
224     uint8_t     locked_group;           /**< Logically locked group */
225     uint8_t     effective_group;        /**< Effective group */
226 } xXIGroupInfo;
227
228
229 /*************************************************************************************
230  *                                                                                   *
231  *                                   REQUESTS                                        *
232  *                                                                                   *
233  *************************************************************************************/
234
235 /**
236  * Query the server for the supported X Input extension version.
237  */
238
239 typedef struct {
240     uint8_t     reqType;                /**< Input extension major code */
241     uint8_t     ReqType;                /**< Always ::X_XIQueryVersion */
242     uint16_t    length;                 /**< Length in 4 byte units */
243     uint16_t    major_version;
244     uint16_t    minor_version;
245 } xXIQueryVersionReq;
246 #define sz_xXIQueryVersionReq                     8
247
248 typedef struct {
249     uint8_t     repType;                /**< ::X_Reply */
250     uint8_t     RepType;                /**< Always ::X_XIQueryVersion */
251     uint16_t    sequenceNumber;
252     uint32_t    length;
253     uint16_t    major_version;
254     uint16_t    minor_version;
255     uint32_t    pad1;
256     uint32_t    pad2;
257     uint32_t    pad3;
258     uint32_t    pad4;
259     uint32_t    pad5;
260 } xXIQueryVersionReply;
261 #define sz_xXIQueryVersionReply             32
262
263 /**
264  * Query the server for information about a specific device or all input
265  * devices.
266  */
267 typedef struct {
268     uint8_t     reqType;                /**< Input extension major code */
269     uint8_t     ReqType;                /**< Always ::X_XIQueryDevice */
270     uint16_t    length;                 /**< Length in 4 byte units */
271     uint16_t    deviceid;
272     uint16_t    pad;
273 } xXIQueryDeviceReq;
274 #define sz_xXIQueryDeviceReq                    8
275
276 typedef struct {
277     uint8_t     repType;                /**< ::X_Reply */
278     uint8_t     RepType;                /**< Always ::X_XIQueryDevice */
279     uint16_t    sequenceNumber;
280     uint32_t    length;
281     uint16_t    num_devices;
282     uint16_t    pad0;
283     uint32_t    pad1;
284     uint32_t    pad2;
285     uint32_t    pad3;
286     uint32_t    pad4;
287     uint32_t    pad5;
288 } xXIQueryDeviceReply;
289 #define sz_xXIQueryDeviceReply                  32
290
291 /**
292  * Select for events on a given window.
293  */
294 typedef struct {
295     uint8_t     reqType;                /**< Input extension major code */
296     uint8_t     ReqType;                /**< Always ::X_XISelectEvents */
297     uint16_t    length;                 /**< Length in 4 byte units */
298     Window      win;
299     uint16_t    num_masks;
300     uint16_t    pad;
301 } xXISelectEventsReq;
302 #define sz_xXISelectEventsReq                  12
303
304 /**
305  * Query for selected events on a given window.
306  */
307 typedef struct {
308     uint8_t     reqType;                /**< Input extension major code */
309     uint8_t     ReqType;                /**< Always ::X_XIGetSelectedEvents */
310     uint16_t    length;                 /**< Length in 4 byte units */
311     Window      win;
312 } xXIGetSelectedEventsReq;
313 #define sz_xXIGetSelectedEventsReq              8
314
315 typedef struct {
316     uint8_t     repType;                /**< Input extension major opcode */
317     uint8_t     RepType;                /**< Always ::X_XIGetSelectedEvents */
318     uint16_t    sequenceNumber;
319     uint32_t    length;
320     uint16_t    num_masks;              /**< Number of xXIEventMask structs
321                                              trailing the reply */
322     uint16_t    pad0;
323     uint32_t    pad1;
324     uint32_t    pad2;
325     uint32_t    pad3;
326     uint32_t    pad4;
327     uint32_t    pad5;
328 } xXIGetSelectedEventsReply;
329 #define sz_xXIGetSelectedEventsReply            32
330
331 /**
332  * Query the given device's screen/window coordinates.
333  */
334
335 typedef struct {
336     uint8_t     reqType;                /**< Input extension major code */
337     uint8_t     ReqType;                /**< Always ::X_XIQueryPointer */
338     uint16_t    length;                 /**< Length in 4 byte units */
339     Window      win;
340     uint16_t    deviceid;
341     uint16_t    pad1;
342 } xXIQueryPointerReq;
343 #define sz_xXIQueryPointerReq                   12
344
345
346 typedef struct {
347     uint8_t     repType;                /**< Input extension major opcode */
348     uint8_t     RepType;                /**< Always ::X_XIQueryPointer */
349     uint16_t    sequenceNumber;
350     uint32_t    length;
351     Window      root;
352     Window      child;
353     FP1616      root_x;
354     FP1616      root_y;
355     FP1616      win_x;
356     FP1616      win_y;
357     uint8_t     same_screen;
358     uint8_t     pad0;
359     uint16_t    buttons_len;
360     xXIModifierInfo mods;
361     xXIGroupInfo group;
362 } xXIQueryPointerReply;
363 #define sz_xXIQueryPointerReply                 56
364
365 /**
366  * Warp the given device's pointer to the specified position.
367  */
368
369 typedef struct {
370     uint8_t     reqType;                /**< Input extension major code */
371     uint8_t     ReqType;                /**< Always ::X_XIWarpPointer   */
372     uint16_t    length;                 /**< Length in 4 byte units */
373     Window      src_win;
374     Window      dst_win;
375     FP1616      src_x;
376     FP1616      src_y;
377     uint16_t    src_width;
378     uint16_t    src_height;
379     FP1616      dst_x;
380     FP1616      dst_y;
381     uint16_t    deviceid;
382     uint16_t    pad1;
383 } xXIWarpPointerReq;
384 #define sz_xXIWarpPointerReq                    36
385
386 /**
387  * Change the given device's sprite to the given cursor.
388  */
389
390 typedef struct {
391     uint8_t     reqType;                /**< Input extension major code */
392     uint8_t     ReqType;                /**< Always ::X_XIChangeCursor  */
393     uint16_t    length;                 /**< Length in 4 byte units */
394     Window      win;
395     Cursor      cursor;
396     uint16_t    deviceid;
397     uint16_t    pad1;
398 } xXIChangeCursorReq;
399 #define sz_xXIChangeCursorReq                           16
400
401 /**
402  * Modify the device hierarchy.
403  */
404
405 typedef struct {
406     uint8_t     reqType;                /**< Input extension major code */
407     uint8_t     ReqType;                /**< Always ::X_XIChangeHierarchy */
408     uint16_t    length;                 /**< Length in 4 byte units */
409     uint8_t     num_changes;
410     uint8_t     pad0;
411     uint16_t    pad1;
412 } xXIChangeHierarchyReq;
413 #define sz_xXIChangeHierarchyReq                        8
414
415 /**
416  * Generic header for any hierarchy change.
417  */
418 typedef struct {
419     uint16_t    type;
420     uint16_t    length;                 /**< Length in 4 byte units */
421 } xXIAnyHierarchyChangeInfo;
422
423 /**
424  * Create a new master device.
425  * Name of new master follows struct (4-byte padded)
426  */
427 typedef struct {
428     uint16_t    type;                   /**< Always ::XIAddMaster */
429     uint16_t    length;                 /**< 2 + (namelen + padding)/4 */
430     uint16_t    name_len;
431     uint8_t     send_core;
432     uint8_t     enable;
433 } xXIAddMasterInfo;
434
435 /**
436  * Delete a master device. Will automatically delete the master device paired
437  * with the given master device.
438  */
439 typedef struct {
440     uint16_t    type;            /**< Always ::XIRemoveMaster */
441     uint16_t    length;          /**< 3 */
442     uint16_t    deviceid;
443     uint8_t     return_mode;     /**< ::XIAttachToMaster, ::XIFloating */
444     uint8_t     pad;
445     uint16_t    return_pointer;  /**< Pointer to attach slave ptr devices to */
446     uint16_t    return_keyboard; /**< keyboard to attach slave keybd devices to*/
447 } xXIRemoveMasterInfo;
448
449 /**
450  * Attach an SD to a new device.
451  * NewMaster has to be of same type (pointer->pointer, keyboard->keyboard);
452  */
453 typedef struct {
454     uint16_t    type;           /**< Always ::XIAttachSlave */
455     uint16_t    length;         /**< 2 */
456     uint16_t    deviceid;
457     uint16_t    new_master;     /**< id of new master device */
458 } xXIAttachSlaveInfo;
459
460 /**
461  * Detach an SD from its current master device.
462  */
463 typedef struct {
464     uint16_t    type;           /**< Always ::XIDetachSlave */
465     uint16_t    length;         /**< 2 */
466     uint16_t    deviceid;
467     uint16_t    pad;
468 } xXIDetachSlaveInfo;
469
470
471 /**
472  * Set the window/client's ClientPointer.
473  */
474 typedef struct {
475     uint8_t     reqType;
476     uint8_t     ReqType;                /**< Always ::X_XISetClientPointer */
477     uint16_t    length;                 /**< Length in 4 byte units */
478     Window      win;
479     uint16_t    deviceid;
480     uint16_t    pad1;
481 } xXISetClientPointerReq;
482 #define sz_xXISetClientPointerReq                 12
483
484 /**
485  * Query the given window/client's ClientPointer setting.
486  */
487 typedef struct {
488     uint8_t     reqType;
489     uint8_t     ReqType;                /**< Always ::X_GetClientPointer */
490     uint16_t    length;                 /**< Length in 4 byte units */
491     Window      win;
492 } xXIGetClientPointerReq;
493 #define sz_xXIGetClientPointerReq                 8
494
495 typedef struct {
496     uint8_t     repType;                /**< Input extension major opcode */
497     uint8_t     RepType;                /**< Always ::X_GetClientPointer */
498     uint16_t    sequenceNumber;
499     uint32_t    length;
500     BOOL        set;                    /**< client pointer is set? */
501     uint8_t     pad0;
502     uint16_t    deviceid;
503     uint32_t    pad1;
504     uint32_t    pad2;
505     uint32_t    pad3;
506     uint32_t    pad4;
507     uint32_t    pad5;
508 } xXIGetClientPointerReply;
509 #define sz_xXIGetClientPointerReply               32
510
511 /**
512  * Set the input focus to the specified window.
513  */
514 typedef struct {
515     uint8_t     reqType;
516     uint8_t     ReqType;                /**< Always ::X_XISetFocus */
517     uint16_t    length;                 /**< Length in 4 byte units */
518     Window      focus;
519     Time        time;
520     uint16_t    deviceid;
521     uint16_t    pad0;
522 } xXISetFocusReq;
523 #define sz_xXISetFocusReq                       16
524
525 /**
526  * Query the current input focus.
527  */
528 typedef struct {
529     uint8_t     reqType;
530     uint8_t     ReqType;                /**< Always ::X_XIGetDeviceFocus */
531     uint16_t    length;                 /**< Length in 4 byte units */
532     uint16_t    deviceid;
533     uint16_t    pad0;
534 } xXIGetFocusReq;
535 #define sz_xXIGetFocusReq                       8
536
537 typedef struct {
538     uint8_t     repType;                /**< Input extension major opcode */
539     uint8_t     RepType;                /**< Always ::X_XIGetFocus */
540     uint16_t    sequenceNumber;
541     uint32_t    length;
542     Window      focus;
543     uint32_t    pad1;
544     uint32_t    pad2;
545     uint32_t    pad3;
546     uint32_t    pad4;
547     uint32_t    pad5;
548 } xXIGetFocusReply;
549 #define sz_xXIGetFocusReply                     32
550
551
552 /**
553  * Grab the given device.
554  */
555 typedef struct {
556     uint8_t     reqType;
557     uint8_t     ReqType;                /**< Always ::X_XIGrabDevice */
558     uint16_t    length;                 /**< Length in 4 byte units */
559     Window      grab_window;
560     Time        time;
561     Cursor      cursor;
562     uint16_t    deviceid;
563     uint8_t     grab_mode;
564     uint8_t     paired_device_mode;
565     uint8_t     owner_events;
566     uint8_t     pad;
567     uint16_t    mask_len;
568 } xXIGrabDeviceReq;
569 #define sz_xXIGrabDeviceReq                     24
570
571 /**
572  * Return codes from a XIPassiveGrabDevice request.
573  */
574 typedef struct {
575     uint32_t    modifiers;              /**< Modifier state */
576     uint8_t     status;                 /**< Grab status code */
577     uint8_t     pad0;
578     uint16_t    pad1;
579 } xXIGrabModifierInfo;
580
581 typedef struct {
582     uint8_t     repType;                /**< Input extension major opcode */
583     uint8_t     RepType;                /**< Always ::X_XIGrabDevice */
584     uint16_t    sequenceNumber;
585     uint32_t    length;
586     uint8_t     status;
587     uint8_t     pad0;
588     uint16_t    pad1;
589     uint32_t    pad2;
590     uint32_t    pad3;
591     uint32_t    pad4;
592     uint32_t    pad5;
593     uint32_t    pad6;
594 } xXIGrabDeviceReply;
595 #define sz_xXIGrabDeviceReply                  32
596
597 /**
598  * Ungrab the specified device.
599  *
600  */
601 typedef struct {
602     uint8_t     reqType;
603     uint8_t     ReqType;                /**< Always ::X_XIUngrabDevice */
604     uint16_t    length;                 /**< Length in 4 byte units */
605     Time        time;
606     uint16_t    deviceid;
607     uint16_t    pad;
608 } xXIUngrabDeviceReq;
609 #define sz_xXIUngrabDeviceReq                   12
610
611
612 /**
613  * Allow or replay events on the specified grabbed device.
614  */
615 typedef struct {
616     uint8_t     reqType;
617     uint8_t     ReqType;                /**< Always ::X_XIAllowEvents */
618     uint16_t    length;                 /**< Length in 4 byte units */
619     Time        time;
620     uint16_t    deviceid;
621     uint8_t     mode;
622     uint8_t     pad;
623 } xXIAllowEventsReq;
624 #define sz_xXIAllowEventsReq                   12
625
626
627 /**
628  * Passively grab the device.
629  */
630 typedef struct {
631     uint8_t     reqType;
632     uint8_t     ReqType;                /**< Always ::X_XIPassiveGrabDevice */
633     uint16_t    length;                 /**< Length in 4 byte units */
634     Time        time;
635     Window      grab_window;
636     Cursor      cursor;
637     uint32_t    detail;
638     uint16_t    deviceid;
639     uint16_t    num_modifiers;
640     uint16_t    mask_len;
641     uint8_t     grab_type;
642     uint8_t     grab_mode;
643     uint8_t     paired_device_mode;
644     uint8_t     owner_events;
645     uint16_t    pad1;
646 } xXIPassiveGrabDeviceReq;
647 #define sz_xXIPassiveGrabDeviceReq              32
648
649 typedef struct {
650     uint8_t     repType;                /**< Input extension major opcode */
651     uint8_t     RepType;                /**< Always ::X_XIPassiveGrabDevice */
652     uint16_t    sequenceNumber;
653     uint32_t    length;
654     uint16_t    num_modifiers;
655     uint16_t    pad1;
656     uint32_t    pad2;
657     uint32_t    pad3;
658     uint32_t    pad4;
659     uint32_t    pad5;
660     uint32_t    pad6;
661 } xXIPassiveGrabDeviceReply;
662 #define sz_xXIPassiveGrabDeviceReply            32
663
664 /**
665  * Delete a passive grab for the given device.
666  */
667 typedef struct {
668     uint8_t     reqType;
669     uint8_t     ReqType;                /**< Always ::X_XIPassiveUngrabDevice */
670     uint16_t    length;                 /**< Length in 4 byte units */
671     Window      grab_window;
672     uint32_t    detail;
673     uint16_t    deviceid;
674     uint16_t    num_modifiers;
675     uint8_t     grab_type;
676     uint8_t     pad0;
677     uint16_t    pad1;
678 } xXIPassiveUngrabDeviceReq;
679 #define sz_xXIPassiveUngrabDeviceReq            20
680
681 /**
682  * List all device properties on the specified device.
683  */
684 typedef struct {
685     uint8_t     reqType;
686     uint8_t     ReqType;                /**< Always ::X_XIListProperties */
687     uint16_t    length;                 /**< Length in 4 byte units */
688     uint16_t    deviceid;
689     uint16_t    pad;
690 } xXIListPropertiesReq;
691 #define sz_xXIListPropertiesReq                 8
692
693 typedef struct {
694     uint8_t     repType;                /**< Input extension major opcode */
695     uint8_t     RepType;                /**< Always ::X_XIListProperties */
696     uint16_t    sequenceNumber;
697     uint32_t    length;
698     uint16_t    num_properties;
699     uint16_t    pad0;
700     uint32_t    pad1;
701     uint32_t    pad2;
702     uint32_t    pad3;
703     uint32_t    pad4;
704     uint32_t    pad5;
705 } xXIListPropertiesReply;
706 #define sz_xXIListPropertiesReply               32
707
708 /**
709  * Change a property on the specified device.
710  */
711 typedef struct {
712     uint8_t     reqType;
713     uint8_t     ReqType;                /**< Always ::X_XIChangeProperty */
714     uint16_t    length;                 /**< Length in 4 byte units */
715     uint16_t    deviceid;
716     uint8_t     mode;
717     uint8_t     format;
718     Atom        property;
719     Atom        type;
720     uint32_t    num_items;
721 } xXIChangePropertyReq;
722 #define sz_xXIChangePropertyReq                 20
723
724 /**
725  * Delete the specified property.
726  */
727 typedef struct {
728     uint8_t     reqType;
729     uint8_t     ReqType;                /**< Always X_XIDeleteProperty */
730     uint16_t    length;                 /**< Length in 4 byte units */
731     uint16_t    deviceid;
732     uint16_t    pad0;
733     Atom        property;
734 } xXIDeletePropertyReq;
735 #define sz_xXIDeletePropertyReq                 12
736
737 /**
738  * Query the specified property's values.
739  */
740 typedef struct {
741     uint8_t     reqType;
742     uint8_t     ReqType;                /**< Always X_XIGetProperty */
743     uint16_t    length;                 /**< Length in 4 byte units */
744     uint16_t    deviceid;
745 #if defined(__cplusplus) || defined(c_plusplus)
746     uint8_t     c_delete;
747 #else
748     uint8_t     delete;
749 #endif
750     uint8_t     pad0;
751     Atom        property;
752     Atom        type;
753     uint32_t    offset;
754     uint32_t    len;
755 } xXIGetPropertyReq;
756 #define sz_xXIGetPropertyReq                    24
757
758 typedef struct {
759     uint8_t     repType;                /**< Input extension major opcode */
760     uint8_t     RepType;                /**< Always X_XIGetProperty */
761     uint16_t    sequenceNumber;
762     uint32_t    length;
763     Atom        type;
764     uint32_t    bytes_after;
765     uint32_t    num_items;
766     uint8_t     format;
767     uint8_t     pad0;
768     uint16_t    pad1;
769     uint32_t    pad2;
770     uint32_t    pad3;
771 } xXIGetPropertyReply;
772 #define sz_xXIGetPropertyReply               32
773
774 /*************************************************************************************
775  *                                                                                   *
776  *                                      EVENTS                                       *
777  *                                                                                   *
778  *************************************************************************************/
779
780 /**
781  * Generic XI2 event header. All XI2 events use the same header.
782  */
783 typedef struct
784 {
785     uint8_t     type;
786     uint8_t     extension;              /**< XI extension offset */
787     uint16_t    sequenceNumber;
788     uint32_t    length;
789     uint16_t    evtype;
790     uint16_t    deviceid;
791     Time        time;
792 } xXIGenericDeviceEvent;
793
794 /**
795  * Device hierarchy information.
796  */
797 typedef struct
798 {
799     uint16_t    deviceid;
800     uint16_t    attachment;             /**< ID of master or paired device */
801     uint8_t     use;                    /**< ::XIMasterKeyboard,
802                                              ::XIMasterPointer,
803                                              ::XISlaveKeyboard,
804                                              ::XISlavePointer,
805                                              ::XIFloatingSlave */
806     BOOL        enabled;                /**< TRUE if the device is enabled */
807     uint16_t    pad;
808     uint32_t    flags;                  /**< ::XIMasterAdded, ::XIMasterRemoved,
809                                              ::XISlaveAttached, ::XISlaveDetached,
810                                              ::XISlaveAdded, ::XISlaveRemoved,
811                                              ::XIDeviceEnabled, ::XIDeviceDisabled */
812 } xXIHierarchyInfo;
813
814 /**
815  * The device hierarchy has been modified. This event includes the device
816  * hierarchy after the modification has been applied.
817  */
818 typedef struct
819 {
820     uint8_t     type;                   /**< Always GenericEvent */
821     uint8_t     extension;              /**< XI extension offset */
822     uint16_t    sequenceNumber;
823     uint32_t    length;                 /**< Length in 4 byte units */
824     uint16_t    evtype;                 /**< ::XI_Hierarchy */
825     uint16_t    deviceid;
826     Time        time;
827     uint32_t    flags;                  /**< ::XIMasterAdded, ::XIMasterDeleted,
828                                              ::XISlaveAttached, ::XISlaveDetached,
829                                              ::XISlaveAdded, ::XISlaveRemoved,
830                                              ::XIDeviceEnabled, ::XIDeviceDisabled */
831     uint16_t    num_info;
832     uint16_t    pad0;
833     uint32_t    pad1;
834     uint32_t    pad2;
835 } xXIHierarchyEvent;
836
837 /**
838  * A device has changed capabilities.
839  */
840 typedef struct
841 {
842     uint8_t     type;                   /**< Always GenericEvent */
843     uint8_t     extension;              /**< XI extension offset */
844     uint16_t    sequenceNumber;
845     uint32_t    length;                 /**< Length in 4 byte units */
846     uint16_t    evtype;                 /**< XI_DeviceChanged */
847     uint16_t    deviceid;               /**< Device that has changed */
848     Time        time;
849     uint16_t    num_classes;            /**< Number of classes that have changed */
850     uint16_t    sourceid;               /**< Source of the new classes */
851     uint8_t     reason;                 /**< ::XISlaveSwitch, ::XIDeviceChange */
852     uint8_t     pad0;
853     uint16_t    pad1;
854     uint32_t    pad2;
855     uint32_t    pad3;
856 } xXIDeviceChangedEvent;
857
858 /**
859  * Default input event for pointer or keyboard input.
860  */
861 typedef struct
862 {
863     uint8_t     type;                   /**< Always GenericEvent */
864     uint8_t     extension;              /**< XI extension offset */
865     uint16_t    sequenceNumber;
866     uint32_t    length;                 /**< Length in 4 byte uints */
867     uint16_t    evtype;
868     uint16_t    deviceid;
869     Time        time;
870     uint32_t    detail;                 /**< Keycode or button */
871     Window      root;
872     Window      event;
873     Window      child;
874 /* └──────── 32 byte boundary ────────┘ */
875     FP1616      root_x;                 /**< Always screen coords, 16.16 fixed point */
876     FP1616      root_y;
877     FP1616      event_x;                /**< Always screen coords, 16.16 fixed point */
878     FP1616      event_y;
879     uint16_t    buttons_len;            /**< Len of button flags in 4 b units */
880     uint16_t    valuators_len;          /**< Len of val. flags in 4 b units */
881     uint16_t    sourceid;               /**< The source device */
882     uint16_t    pad0;
883     uint32_t    flags;                  /**< ::XIKeyRepeat */
884     xXIModifierInfo     mods;
885     xXIGroupInfo        group;
886 } xXIDeviceEvent;
887
888
889 /**
890  * Sent when an input event is generated. RawEvents include valuator
891  * information in both device-specific data (i.e. unaccelerated) and
892  * processed data (i.e. accelerated, if applicable).
893  */
894 typedef struct
895 {
896     uint8_t     type;                   /**< Always GenericEvent */
897     uint8_t     extension;              /**< XI extension offset */
898     uint16_t    sequenceNumber;
899     uint32_t    length;                 /**< Length in 4 byte uints */
900     uint16_t    evtype;                 /**< ::XI_RawEvent */
901     uint16_t    deviceid;
902     Time        time;
903     uint32_t    detail;
904     uint16_t    pad0;
905     uint16_t    valuators_len;          /**< Length of trailing valuator
906                                              mask in 4 byte units */
907     uint32_t    flags;                  /**< ::XIKeyRepeat */
908     uint32_t    pad2;
909 } xXIRawEvent;
910
911 /**
912  * Note that the layout of root, event, child, root_x, root_y, event_x,
913  * event_y must be identical to the xXIDeviceEvent.
914  */
915 typedef struct
916 {
917     uint8_t     type;                   /**< Always GenericEvent */
918     uint8_t     extension;              /**< XI extension offset */
919     uint16_t    sequenceNumber;
920     uint32_t    length;                 /**< Length in 4 byte uints */
921     uint16_t    evtype;                 /**< ::XI_Enter */
922     uint16_t    deviceid;
923     Time        time;
924     uint16_t    sourceid;
925     uint8_t     mode;
926     uint8_t     detail;
927     Window      root;
928     Window      event;
929     Window      child;
930 /* └──────── 32 byte boundary ────────┘ */
931     FP1616      root_x;
932     FP1616      root_y;
933     FP1616      event_x;
934     FP1616      event_y;
935     BOOL        same_screen;
936     BOOL        focus;
937     uint16_t    buttons_len;            /**< Length of trailing button mask
938                                              in 4 byte units */
939     xXIModifierInfo     mods;
940     xXIGroupInfo        group;
941 } xXIEnterEvent;
942
943 typedef xXIEnterEvent xXILeaveEvent;
944 typedef xXIEnterEvent xXIFocusInEvent;
945 typedef xXIEnterEvent xXIFocusOutEvent;
946
947 /**
948  * Sent when a device property is created, modified or deleted. Does not
949  * include property data, the client is required to query the data.
950  */
951 typedef struct
952 {
953     uint8_t     type;                   /**< Always GenericEvent */
954     uint8_t     extension;              /**< XI extension offset */
955     uint16_t    sequenceNumber;
956     uint32_t    length;                 /**< Length in 4 byte uints */
957     uint16_t    evtype;                 /**< ::XI_PropertyEvent */
958     uint16_t    deviceid;
959     Time        time;
960     Atom        property;
961     uint8_t     what;                   /**< ::XIPropertyDeleted,
962                                              ::XIPropertyCreated,
963                                              ::XIPropertyMotified */
964     uint8_t     pad0;
965     uint16_t    pad1;
966     uint32_t    pad2;
967     uint32_t    pad3;
968 } xXIPropertyEvent;
969
970
971 #undef Window
972 #undef Time
973 #undef Atom
974 #undef Cursor
975
976 #endif /* _XI2PROTO_H_ */