2 * Copyright © 2009 Red Hat, Inc.
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:
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
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.
25 /* Conventions for this file:
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
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
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
46 * members of structs vertically aligned on column 16 if datatypes permit.
47 * otherwise alingned on next available 8n column.
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.
60 #include <X11/Xproto.h>
62 #include <X11/extensions/XI2.h>
64 /* make sure types have right sizes for protocol structures. */
65 #define Window uint32_t
68 #define Cursor uint32_t
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
95 /** Number of XI requests */
96 #define XI2REQUESTS (X_XIGetSelectedEvents - X_XIQueryPointer + 1)
97 /** Number of XI2 events */
98 #define XI2EVENTS (XI_LASTEVENT + 1)
100 /*************************************************************************************
104 *************************************************************************************/
105 /** Fixed point 16.16 */
106 typedef int32_t FP1616;
108 /** Fixed point 32.32 */
115 * Struct to describe a device.
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.
125 uint16_t use; /**< ::XIMasterPointer, ::XIMasterKeyboard,
126 ::XISlavePointer, ::XISlaveKeyboard,
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. */
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.
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 */
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).
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 */
160 * Denotes key capability on a device.
161 * Struct is followed by num_keys * CARD32 that lists the keycodes available
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 */
172 * Denotes an valuator capability on a device.
173 * One XIValuatorInfo describes exactly one valuator (axis) on the device.
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 */
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)).
198 uint16_t deviceid; /**< Device id to select for */
199 uint16_t mask_len; /**< Length of mask in 4 byte units */
203 * XKB modifier information.
204 * The effective modifier is a binary mask of base, latched, and locked
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 */
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.
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 */
229 /*************************************************************************************
233 *************************************************************************************/
236 * Query the server for the supported X Input extension version.
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
249 uint8_t repType; /**< ::X_Reply */
250 uint8_t RepType; /**< Always ::X_XIQueryVersion */
251 uint16_t sequenceNumber;
253 uint16_t major_version;
254 uint16_t minor_version;
260 } xXIQueryVersionReply;
261 #define sz_xXIQueryVersionReply 32
264 * Query the server for information about a specific device or all input
268 uint8_t reqType; /**< Input extension major code */
269 uint8_t ReqType; /**< Always ::X_XIQueryDevice */
270 uint16_t length; /**< Length in 4 byte units */
274 #define sz_xXIQueryDeviceReq 8
277 uint8_t repType; /**< ::X_Reply */
278 uint8_t RepType; /**< Always ::X_XIQueryDevice */
279 uint16_t sequenceNumber;
281 uint16_t num_devices;
288 } xXIQueryDeviceReply;
289 #define sz_xXIQueryDeviceReply 32
292 * Select for events on a given window.
295 uint8_t reqType; /**< Input extension major code */
296 uint8_t ReqType; /**< Always ::X_XISelectEvents */
297 uint16_t length; /**< Length in 4 byte units */
301 } xXISelectEventsReq;
302 #define sz_xXISelectEventsReq 12
305 * Query for selected events on a given window.
308 uint8_t reqType; /**< Input extension major code */
309 uint8_t ReqType; /**< Always ::X_XIGetSelectedEvents */
310 uint16_t length; /**< Length in 4 byte units */
312 } xXIGetSelectedEventsReq;
313 #define sz_xXIGetSelectedEventsReq 8
316 uint8_t repType; /**< Input extension major opcode */
317 uint8_t RepType; /**< Always ::X_XIGetSelectedEvents */
318 uint16_t sequenceNumber;
320 uint16_t num_masks; /**< Number of xXIEventMask structs
321 trailing the reply */
328 } xXIGetSelectedEventsReply;
329 #define sz_xXIGetSelectedEventsReply 32
332 * Query the given device's screen/window coordinates.
336 uint8_t reqType; /**< Input extension major code */
337 uint8_t ReqType; /**< Always ::X_XIQueryPointer */
338 uint16_t length; /**< Length in 4 byte units */
342 } xXIQueryPointerReq;
343 #define sz_xXIQueryPointerReq 12
347 uint8_t repType; /**< Input extension major opcode */
348 uint8_t RepType; /**< Always ::X_XIQueryPointer */
349 uint16_t sequenceNumber;
359 uint16_t buttons_len;
360 xXIModifierInfo mods;
362 } xXIQueryPointerReply;
363 #define sz_xXIQueryPointerReply 56
366 * Warp the given device's pointer to the specified position.
370 uint8_t reqType; /**< Input extension major code */
371 uint8_t ReqType; /**< Always ::X_XIWarpPointer */
372 uint16_t length; /**< Length in 4 byte units */
384 #define sz_xXIWarpPointerReq 36
387 * Change the given device's sprite to the given cursor.
391 uint8_t reqType; /**< Input extension major code */
392 uint8_t ReqType; /**< Always ::X_XIChangeCursor */
393 uint16_t length; /**< Length in 4 byte units */
398 } xXIChangeCursorReq;
399 #define sz_xXIChangeCursorReq 16
402 * Modify the device hierarchy.
406 uint8_t reqType; /**< Input extension major code */
407 uint8_t ReqType; /**< Always ::X_XIChangeHierarchy */
408 uint16_t length; /**< Length in 4 byte units */
412 } xXIChangeHierarchyReq;
413 #define sz_xXIChangeHierarchyReq 8
416 * Generic header for any hierarchy change.
420 uint16_t length; /**< Length in 4 byte units */
421 } xXIAnyHierarchyChangeInfo;
424 * Create a new master device.
425 * Name of new master follows struct (4-byte padded)
428 uint16_t type; /**< Always ::XIAddMaster */
429 uint16_t length; /**< 2 + (namelen + padding)/4 */
436 * Delete a master device. Will automatically delete the master device paired
437 * with the given master device.
440 uint16_t type; /**< Always ::XIRemoveMaster */
441 uint16_t length; /**< 3 */
443 uint8_t return_mode; /**< ::XIAttachToMaster, ::XIFloating */
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;
450 * Attach an SD to a new device.
451 * NewMaster has to be of same type (pointer->pointer, keyboard->keyboard);
454 uint16_t type; /**< Always ::XIAttachSlave */
455 uint16_t length; /**< 2 */
457 uint16_t new_master; /**< id of new master device */
458 } xXIAttachSlaveInfo;
461 * Detach an SD from its current master device.
464 uint16_t type; /**< Always ::XIDetachSlave */
465 uint16_t length; /**< 2 */
468 } xXIDetachSlaveInfo;
472 * Set the window/client's ClientPointer.
476 uint8_t ReqType; /**< Always ::X_XISetClientPointer */
477 uint16_t length; /**< Length in 4 byte units */
481 } xXISetClientPointerReq;
482 #define sz_xXISetClientPointerReq 12
485 * Query the given window/client's ClientPointer setting.
489 uint8_t ReqType; /**< Always ::X_GetClientPointer */
490 uint16_t length; /**< Length in 4 byte units */
492 } xXIGetClientPointerReq;
493 #define sz_xXIGetClientPointerReq 8
496 uint8_t repType; /**< Input extension major opcode */
497 uint8_t RepType; /**< Always ::X_GetClientPointer */
498 uint16_t sequenceNumber;
500 BOOL set; /**< client pointer is set? */
508 } xXIGetClientPointerReply;
509 #define sz_xXIGetClientPointerReply 32
512 * Set the input focus to the specified window.
516 uint8_t ReqType; /**< Always ::X_XISetFocus */
517 uint16_t length; /**< Length in 4 byte units */
523 #define sz_xXISetFocusReq 16
526 * Query the current input focus.
530 uint8_t ReqType; /**< Always ::X_XIGetDeviceFocus */
531 uint16_t length; /**< Length in 4 byte units */
535 #define sz_xXIGetFocusReq 8
538 uint8_t repType; /**< Input extension major opcode */
539 uint8_t RepType; /**< Always ::X_XIGetFocus */
540 uint16_t sequenceNumber;
549 #define sz_xXIGetFocusReply 32
553 * Grab the given device.
557 uint8_t ReqType; /**< Always ::X_XIGrabDevice */
558 uint16_t length; /**< Length in 4 byte units */
564 uint8_t paired_device_mode;
565 uint8_t owner_events;
569 #define sz_xXIGrabDeviceReq 24
572 * Return codes from a XIPassiveGrabDevice request.
575 uint32_t modifiers; /**< Modifier state */
576 uint8_t status; /**< Grab status code */
579 } xXIGrabModifierInfo;
582 uint8_t repType; /**< Input extension major opcode */
583 uint8_t RepType; /**< Always ::X_XIGrabDevice */
584 uint16_t sequenceNumber;
594 } xXIGrabDeviceReply;
595 #define sz_xXIGrabDeviceReply 32
598 * Ungrab the specified device.
603 uint8_t ReqType; /**< Always ::X_XIUngrabDevice */
604 uint16_t length; /**< Length in 4 byte units */
608 } xXIUngrabDeviceReq;
609 #define sz_xXIUngrabDeviceReq 12
613 * Allow or replay events on the specified grabbed device.
617 uint8_t ReqType; /**< Always ::X_XIAllowEvents */
618 uint16_t length; /**< Length in 4 byte units */
624 #define sz_xXIAllowEventsReq 12
628 * Passively grab the device.
632 uint8_t ReqType; /**< Always ::X_XIPassiveGrabDevice */
633 uint16_t length; /**< Length in 4 byte units */
639 uint16_t num_modifiers;
643 uint8_t paired_device_mode;
644 uint8_t owner_events;
646 } xXIPassiveGrabDeviceReq;
647 #define sz_xXIPassiveGrabDeviceReq 32
650 uint8_t repType; /**< Input extension major opcode */
651 uint8_t RepType; /**< Always ::X_XIPassiveGrabDevice */
652 uint16_t sequenceNumber;
654 uint16_t num_modifiers;
661 } xXIPassiveGrabDeviceReply;
662 #define sz_xXIPassiveGrabDeviceReply 32
665 * Delete a passive grab for the given device.
669 uint8_t ReqType; /**< Always ::X_XIPassiveUngrabDevice */
670 uint16_t length; /**< Length in 4 byte units */
674 uint16_t num_modifiers;
678 } xXIPassiveUngrabDeviceReq;
679 #define sz_xXIPassiveUngrabDeviceReq 20
682 * List all device properties on the specified device.
686 uint8_t ReqType; /**< Always ::X_XIListProperties */
687 uint16_t length; /**< Length in 4 byte units */
690 } xXIListPropertiesReq;
691 #define sz_xXIListPropertiesReq 8
694 uint8_t repType; /**< Input extension major opcode */
695 uint8_t RepType; /**< Always ::X_XIListProperties */
696 uint16_t sequenceNumber;
698 uint16_t num_properties;
705 } xXIListPropertiesReply;
706 #define sz_xXIListPropertiesReply 32
709 * Change a property on the specified device.
713 uint8_t ReqType; /**< Always ::X_XIChangeProperty */
714 uint16_t length; /**< Length in 4 byte units */
721 } xXIChangePropertyReq;
722 #define sz_xXIChangePropertyReq 20
725 * Delete the specified property.
729 uint8_t ReqType; /**< Always X_XIDeleteProperty */
730 uint16_t length; /**< Length in 4 byte units */
734 } xXIDeletePropertyReq;
735 #define sz_xXIDeletePropertyReq 12
738 * Query the specified property's values.
742 uint8_t ReqType; /**< Always X_XIGetProperty */
743 uint16_t length; /**< Length in 4 byte units */
745 #if defined(__cplusplus) || defined(c_plusplus)
756 #define sz_xXIGetPropertyReq 24
759 uint8_t repType; /**< Input extension major opcode */
760 uint8_t RepType; /**< Always X_XIGetProperty */
761 uint16_t sequenceNumber;
764 uint32_t bytes_after;
771 } xXIGetPropertyReply;
772 #define sz_xXIGetPropertyReply 32
774 /*************************************************************************************
778 *************************************************************************************/
781 * Generic XI2 event header. All XI2 events use the same header.
786 uint8_t extension; /**< XI extension offset */
787 uint16_t sequenceNumber;
792 } xXIGenericDeviceEvent;
795 * Device hierarchy information.
800 uint16_t attachment; /**< ID of master or paired device */
801 uint8_t use; /**< ::XIMasterKeyboard,
806 BOOL enabled; /**< TRUE if the device is enabled */
808 uint32_t flags; /**< ::XIMasterAdded, ::XIMasterRemoved,
809 ::XISlaveAttached, ::XISlaveDetached,
810 ::XISlaveAdded, ::XISlaveRemoved,
811 ::XIDeviceEnabled, ::XIDeviceDisabled */
815 * The device hierarchy has been modified. This event includes the device
816 * hierarchy after the modification has been applied.
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 */
827 uint32_t flags; /**< ::XIMasterAdded, ::XIMasterDeleted,
828 ::XISlaveAttached, ::XISlaveDetached,
829 ::XISlaveAdded, ::XISlaveRemoved,
830 ::XIDeviceEnabled, ::XIDeviceDisabled */
838 * A device has changed capabilities.
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 */
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 */
856 } xXIDeviceChangedEvent;
859 * Default input event for pointer or keyboard input.
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 */
870 uint32_t detail; /**< Keycode or button */
874 /* └──────── 32 byte boundary ────────┘ */
875 FP1616 root_x; /**< Always screen coords, 16.16 fixed point */
877 FP1616 event_x; /**< Always screen coords, 16.16 fixed point */
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 */
883 uint32_t flags; /**< ::XIKeyRepeat */
884 xXIModifierInfo mods;
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).
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 */
905 uint16_t valuators_len; /**< Length of trailing valuator
906 mask in 4 byte units */
907 uint32_t flags; /**< ::XIKeyRepeat */
912 * Note that the layout of root, event, child, root_x, root_y, event_x,
913 * event_y must be identical to the xXIDeviceEvent.
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 */
930 /* └──────── 32 byte boundary ────────┘ */
937 uint16_t buttons_len; /**< Length of trailing button mask
939 xXIModifierInfo mods;
943 typedef xXIEnterEvent xXILeaveEvent;
944 typedef xXIEnterEvent xXIFocusInEvent;
945 typedef xXIEnterEvent xXIFocusOutEvent;
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.
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 */
961 uint8_t what; /**< ::XIPropertyDeleted,
963 ::XIPropertyMotified */
976 #endif /* _XI2PROTO_H_ */