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>
65 /* make sure types have right sizes for protocol structures. */
66 #define Window uint32_t
69 #define Cursor uint32_t
74 #define X_XIQueryPointer 40
75 #define X_XIWarpPointer 41
76 #define X_XIChangeCursor 42
77 #define X_XIChangeHierarchy 43
78 #define X_XISetClientPointer 44
79 #define X_XIGetClientPointer 45
80 #define X_XISelectEvents 46
81 #define X_XIQueryVersion 47
82 #define X_XIQueryDevice 48
83 #define X_XISetFocus 49
84 #define X_XIGetFocus 50
85 #define X_XIGrabDevice 51
86 #define X_XIUngrabDevice 52
87 #define X_XIAllowEvents 53
88 #define X_XIPassiveGrabDevice 54
89 #define X_XIPassiveUngrabDevice 55
90 #define X_XIListProperties 56
91 #define X_XIChangeProperty 57
92 #define X_XIDeleteProperty 58
93 #define X_XIGetProperty 59
94 #define X_XIGetSelectedEvents 60
96 /** Number of XI requests */
97 #define XI2REQUESTS (X_XIGetSelectedEvents - X_XIQueryPointer + 1)
98 /** Number of XI2 events */
99 #define XI2EVENTS (XI_LASTEVENT + 1)
101 /*************************************************************************************
105 *************************************************************************************/
106 /** Fixed point 16.16 */
107 typedef int32_t FP1616;
109 /** Fixed point 32.32 */
116 * Struct to describe a device.
118 * For a MasterPointer or a MasterKeyboard, 'attachment' specifies the
119 * paired master device.
120 * For a SlaveKeyboard or SlavePointer, 'attachment' specifies the master
121 * device this device is attached to.
122 * For a FloatingSlave, 'attachment' is undefined.
126 uint16_t use; /**< ::XIMasterPointer, ::XIMasterKeyboard,
127 ::XISlavePointer, ::XISlaveKeyboard,
129 uint16_t attachment; /**< Current attachment or pairing.*/
130 uint16_t num_classes; /**< Number of classes following this struct. */
131 uint16_t name_len; /**< Length of name in bytes. */
132 uint8_t enabled; /**< TRUE if device is enabled. */
137 * Default template for a device class.
138 * A device class is equivalent to a device's capabilities. Multiple classes
139 * are supported per device.
142 uint16_t type; /**< One of *class */
143 uint16_t length; /**< Length in 4 byte units */
144 uint16_t sourceid; /**< source device for this class */
149 * Denotes button capability on a device.
150 * Struct is followed by num_buttons * Atom that names the buttons in the
151 * device-native setup (i.e. ignoring button mappings).
154 uint16_t type; /**< Always ButtonClass */
155 uint16_t length; /**< Length in 4 byte units */
156 uint16_t sourceid; /**< source device for this class */
157 uint16_t num_buttons; /**< Number of buttons provide */
161 * Denotes key capability on a device.
162 * Struct is followed by num_keys * CARD32 that lists the keycodes available
166 uint16_t type; /**< Always KeyClass */
167 uint16_t length; /**< Length in 4 byte units */
168 uint16_t sourceid; /**< source device for this class */
169 uint16_t num_keycodes; /**< Number of keys provided */
173 * Denotes an valuator capability on a device.
174 * One XIValuatorInfo describes exactly one valuator (axis) on the device.
177 uint16_t type; /**< Always ValuatorClass */
178 uint16_t length; /**< Length in 4 byte units */
179 uint16_t sourceid; /**< source device for this class */
180 uint16_t number; /**< Valuator number */
181 Atom label; /**< Axis label */
182 FP3232 min; /**< Min value */
183 FP3232 max; /**< Max value */
184 FP3232 value; /**< Last published value */
185 uint32_t resolution; /**< Resolutions in units/m */
186 uint8_t mode; /**< ModeRelative or ModeAbsolute */
192 * Denotes a scroll valuator on a device.
193 * One XIScrollInfo describes exactly one scroll valuator that must have a
194 * XIValuatorInfo struct.
197 uint16_t type; /**< Always ValuatorClass */
198 uint16_t length; /**< Length in 4 byte units */
199 uint16_t sourceid; /**< source device for this class */
200 uint16_t number; /**< Valuator number */
201 uint16_t scroll_type; /**< ::XIScrollTypeVertical, ::XIScrollTypeHorizontal */
203 uint32_t flags; /**< ::XIScrollFlagEmulate, ::XIScrollFlagPreferred */
204 FP3232 increment; /**< Increment for one unit of scrolling */
208 * Denotes multitouch capability on a device.
211 uint16_t type; /**< Always TouchClass */
212 uint16_t length; /**< Length in 4 byte units */
213 uint16_t sourceid; /**< source device for this class */
214 uint8_t mode; /**< DirectTouch or DependentTouch */
215 uint8_t num_touches; /**< Maximum number of touches (0==unlimited) */
219 * Used to select for events on a given window.
220 * Struct is followed by (mask_len * CARD8), with each bit set representing
221 * the event mask for the given type. A mask bit represents an event type if
222 * (mask == (1 << type)).
225 uint16_t deviceid; /**< Device id to select for */
226 uint16_t mask_len; /**< Length of mask in 4 byte units */
230 * XKB modifier information.
231 * The effective modifier is a binary mask of base, latched, and locked
236 uint32_t base_mods; /**< Logically pressed modifiers */
237 uint32_t latched_mods; /**< Logically latched modifiers */
238 uint32_t locked_mods; /**< Logically locked modifiers */
239 uint32_t effective_mods; /**< Effective modifiers */
243 * XKB group information.
244 * The effective group is the mathematical sum of base, latched, and locked
245 * group after group wrapping is taken into account.
249 uint8_t base_group; /**< Logically "pressed" group */
250 uint8_t latched_group; /**< Logically latched group */
251 uint8_t locked_group; /**< Logically locked group */
252 uint8_t effective_group; /**< Effective group */
256 /*************************************************************************************
260 *************************************************************************************/
263 * Query the server for the supported X Input extension version.
267 uint8_t reqType; /**< Input extension major code */
268 uint8_t ReqType; /**< Always ::X_XIQueryVersion */
269 uint16_t length; /**< Length in 4 byte units */
270 uint16_t major_version;
271 uint16_t minor_version;
272 } xXIQueryVersionReq;
273 #define sz_xXIQueryVersionReq 8
276 uint8_t repType; /**< ::X_Reply */
277 uint8_t RepType; /**< Always ::X_XIQueryVersion */
278 uint16_t sequenceNumber;
280 uint16_t major_version;
281 uint16_t minor_version;
287 } xXIQueryVersionReply;
288 #define sz_xXIQueryVersionReply 32
291 * Query the server for information about a specific device or all input
295 uint8_t reqType; /**< Input extension major code */
296 uint8_t ReqType; /**< Always ::X_XIQueryDevice */
297 uint16_t length; /**< Length in 4 byte units */
301 #define sz_xXIQueryDeviceReq 8
304 uint8_t repType; /**< ::X_Reply */
305 uint8_t RepType; /**< Always ::X_XIQueryDevice */
306 uint16_t sequenceNumber;
308 uint16_t num_devices;
315 } xXIQueryDeviceReply;
316 #define sz_xXIQueryDeviceReply 32
319 * Select for events on a given window.
322 uint8_t reqType; /**< Input extension major code */
323 uint8_t ReqType; /**< Always ::X_XISelectEvents */
324 uint16_t length; /**< Length in 4 byte units */
328 } xXISelectEventsReq;
329 #define sz_xXISelectEventsReq 12
332 * Query for selected events on a given window.
335 uint8_t reqType; /**< Input extension major code */
336 uint8_t ReqType; /**< Always ::X_XIGetSelectedEvents */
337 uint16_t length; /**< Length in 4 byte units */
339 } xXIGetSelectedEventsReq;
340 #define sz_xXIGetSelectedEventsReq 8
343 uint8_t repType; /**< Input extension major opcode */
344 uint8_t RepType; /**< Always ::X_XIGetSelectedEvents */
345 uint16_t sequenceNumber;
347 uint16_t num_masks; /**< Number of xXIEventMask structs
348 trailing the reply */
355 } xXIGetSelectedEventsReply;
356 #define sz_xXIGetSelectedEventsReply 32
359 * Query the given device's screen/window coordinates.
363 uint8_t reqType; /**< Input extension major code */
364 uint8_t ReqType; /**< Always ::X_XIQueryPointer */
365 uint16_t length; /**< Length in 4 byte units */
369 } xXIQueryPointerReq;
370 #define sz_xXIQueryPointerReq 12
374 uint8_t repType; /**< Input extension major opcode */
375 uint8_t RepType; /**< Always ::X_XIQueryPointer */
376 uint16_t sequenceNumber;
386 uint16_t buttons_len;
387 xXIModifierInfo mods;
389 } xXIQueryPointerReply;
390 #define sz_xXIQueryPointerReply 56
393 * Warp the given device's pointer to the specified position.
397 uint8_t reqType; /**< Input extension major code */
398 uint8_t ReqType; /**< Always ::X_XIWarpPointer */
399 uint16_t length; /**< Length in 4 byte units */
411 #define sz_xXIWarpPointerReq 36
414 * Change the given device's sprite to the given cursor.
418 uint8_t reqType; /**< Input extension major code */
419 uint8_t ReqType; /**< Always ::X_XIChangeCursor */
420 uint16_t length; /**< Length in 4 byte units */
425 } xXIChangeCursorReq;
426 #define sz_xXIChangeCursorReq 16
429 * Modify the device hierarchy.
433 uint8_t reqType; /**< Input extension major code */
434 uint8_t ReqType; /**< Always ::X_XIChangeHierarchy */
435 uint16_t length; /**< Length in 4 byte units */
439 } xXIChangeHierarchyReq;
440 #define sz_xXIChangeHierarchyReq 8
443 * Generic header for any hierarchy change.
447 uint16_t length; /**< Length in 4 byte units */
448 } xXIAnyHierarchyChangeInfo;
451 * Create a new master device.
452 * Name of new master follows struct (4-byte padded)
455 uint16_t type; /**< Always ::XIAddMaster */
456 uint16_t length; /**< 2 + (namelen + padding)/4 */
463 * Delete a master device. Will automatically delete the master device paired
464 * with the given master device.
467 uint16_t type; /**< Always ::XIRemoveMaster */
468 uint16_t length; /**< 3 */
470 uint8_t return_mode; /**< ::XIAttachToMaster, ::XIFloating */
472 uint16_t return_pointer; /**< Pointer to attach slave ptr devices to */
473 uint16_t return_keyboard; /**< keyboard to attach slave keybd devices to*/
474 } xXIRemoveMasterInfo;
477 * Attach an SD to a new device.
478 * NewMaster has to be of same type (pointer->pointer, keyboard->keyboard);
481 uint16_t type; /**< Always ::XIAttachSlave */
482 uint16_t length; /**< 2 */
484 uint16_t new_master; /**< id of new master device */
485 } xXIAttachSlaveInfo;
488 * Detach an SD from its current master device.
491 uint16_t type; /**< Always ::XIDetachSlave */
492 uint16_t length; /**< 2 */
495 } xXIDetachSlaveInfo;
499 * Set the window/client's ClientPointer.
503 uint8_t ReqType; /**< Always ::X_XISetClientPointer */
504 uint16_t length; /**< Length in 4 byte units */
508 } xXISetClientPointerReq;
509 #define sz_xXISetClientPointerReq 12
512 * Query the given window/client's ClientPointer setting.
516 uint8_t ReqType; /**< Always ::X_GetClientPointer */
517 uint16_t length; /**< Length in 4 byte units */
519 } xXIGetClientPointerReq;
520 #define sz_xXIGetClientPointerReq 8
523 uint8_t repType; /**< Input extension major opcode */
524 uint8_t RepType; /**< Always ::X_GetClientPointer */
525 uint16_t sequenceNumber;
527 BOOL set; /**< client pointer is set? */
535 } xXIGetClientPointerReply;
536 #define sz_xXIGetClientPointerReply 32
539 * Set the input focus to the specified window.
543 uint8_t ReqType; /**< Always ::X_XISetFocus */
544 uint16_t length; /**< Length in 4 byte units */
550 #define sz_xXISetFocusReq 16
553 * Query the current input focus.
557 uint8_t ReqType; /**< Always ::X_XIGetDeviceFocus */
558 uint16_t length; /**< Length in 4 byte units */
562 #define sz_xXIGetFocusReq 8
565 uint8_t repType; /**< Input extension major opcode */
566 uint8_t RepType; /**< Always ::X_XIGetFocus */
567 uint16_t sequenceNumber;
576 #define sz_xXIGetFocusReply 32
580 * Grab the given device.
584 uint8_t ReqType; /**< Always ::X_XIGrabDevice */
585 uint16_t length; /**< Length in 4 byte units */
591 uint8_t paired_device_mode;
592 uint8_t owner_events;
596 #define sz_xXIGrabDeviceReq 24
599 * Return codes from a XIPassiveGrabDevice request.
602 uint32_t modifiers; /**< Modifier state */
603 uint8_t status; /**< Grab status code */
606 } xXIGrabModifierInfo;
609 uint8_t repType; /**< Input extension major opcode */
610 uint8_t RepType; /**< Always ::X_XIGrabDevice */
611 uint16_t sequenceNumber;
621 } xXIGrabDeviceReply;
622 #define sz_xXIGrabDeviceReply 32
625 * Ungrab the specified device.
630 uint8_t ReqType; /**< Always ::X_XIUngrabDevice */
631 uint16_t length; /**< Length in 4 byte units */
635 } xXIUngrabDeviceReq;
636 #define sz_xXIUngrabDeviceReq 12
640 * Allow or replay events on the specified grabbed device.
644 uint8_t ReqType; /**< Always ::X_XIAllowEvents */
645 uint16_t length; /**< Length in 4 byte units */
651 #define sz_xXIAllowEventsReq 12
654 * Allow or replay events on the specified grabbed device.
659 uint8_t ReqType; /**< Always ::X_XIAllowEvents */
660 uint16_t length; /**< Length in 4 byte units */
665 uint32_t touchid; /**< Since XI 2.2 */
666 Window grab_window; /**< Since XI 2.2 */
667 } xXI2_2AllowEventsReq;
668 #define sz_xXI2_2AllowEventsReq 20
672 * Passively grab the device.
676 uint8_t ReqType; /**< Always ::X_XIPassiveGrabDevice */
677 uint16_t length; /**< Length in 4 byte units */
683 uint16_t num_modifiers;
687 uint8_t paired_device_mode;
688 uint8_t owner_events;
690 } xXIPassiveGrabDeviceReq;
691 #define sz_xXIPassiveGrabDeviceReq 32
694 uint8_t repType; /**< Input extension major opcode */
695 uint8_t RepType; /**< Always ::X_XIPassiveGrabDevice */
696 uint16_t sequenceNumber;
698 uint16_t num_modifiers;
705 } xXIPassiveGrabDeviceReply;
706 #define sz_xXIPassiveGrabDeviceReply 32
709 * Delete a passive grab for the given device.
713 uint8_t ReqType; /**< Always ::X_XIPassiveUngrabDevice */
714 uint16_t length; /**< Length in 4 byte units */
718 uint16_t num_modifiers;
722 } xXIPassiveUngrabDeviceReq;
723 #define sz_xXIPassiveUngrabDeviceReq 20
726 * List all device properties on the specified device.
730 uint8_t ReqType; /**< Always ::X_XIListProperties */
731 uint16_t length; /**< Length in 4 byte units */
734 } xXIListPropertiesReq;
735 #define sz_xXIListPropertiesReq 8
738 uint8_t repType; /**< Input extension major opcode */
739 uint8_t RepType; /**< Always ::X_XIListProperties */
740 uint16_t sequenceNumber;
742 uint16_t num_properties;
749 } xXIListPropertiesReply;
750 #define sz_xXIListPropertiesReply 32
753 * Change a property on the specified device.
757 uint8_t ReqType; /**< Always ::X_XIChangeProperty */
758 uint16_t length; /**< Length in 4 byte units */
765 } xXIChangePropertyReq;
766 #define sz_xXIChangePropertyReq 20
769 * Delete the specified property.
773 uint8_t ReqType; /**< Always X_XIDeleteProperty */
774 uint16_t length; /**< Length in 4 byte units */
778 } xXIDeletePropertyReq;
779 #define sz_xXIDeletePropertyReq 12
782 * Query the specified property's values.
786 uint8_t ReqType; /**< Always X_XIGetProperty */
787 uint16_t length; /**< Length in 4 byte units */
789 #if defined(__cplusplus) || defined(c_plusplus)
800 #define sz_xXIGetPropertyReq 24
803 uint8_t repType; /**< Input extension major opcode */
804 uint8_t RepType; /**< Always X_XIGetProperty */
805 uint16_t sequenceNumber;
808 uint32_t bytes_after;
815 } xXIGetPropertyReply;
816 #define sz_xXIGetPropertyReply 32
818 /*************************************************************************************
822 *************************************************************************************/
825 * Generic XI2 event header. All XI2 events use the same header.
830 uint8_t extension; /**< XI extension offset */
831 uint16_t sequenceNumber;
836 } xXIGenericDeviceEvent;
839 * Device hierarchy information.
844 uint16_t attachment; /**< ID of master or paired device */
845 uint8_t use; /**< ::XIMasterKeyboard,
850 BOOL enabled; /**< TRUE if the device is enabled */
852 uint32_t flags; /**< ::XIMasterAdded, ::XIMasterRemoved,
853 ::XISlaveAttached, ::XISlaveDetached,
854 ::XISlaveAdded, ::XISlaveRemoved,
855 ::XIDeviceEnabled, ::XIDeviceDisabled */
859 * The device hierarchy has been modified. This event includes the device
860 * hierarchy after the modification has been applied.
864 uint8_t type; /**< Always GenericEvent */
865 uint8_t extension; /**< XI extension offset */
866 uint16_t sequenceNumber;
867 uint32_t length; /**< Length in 4 byte units */
868 uint16_t evtype; /**< ::XI_Hierarchy */
871 uint32_t flags; /**< ::XIMasterAdded, ::XIMasterDeleted,
872 ::XISlaveAttached, ::XISlaveDetached,
873 ::XISlaveAdded, ::XISlaveRemoved,
874 ::XIDeviceEnabled, ::XIDeviceDisabled */
882 * A device has changed capabilities.
886 uint8_t type; /**< Always GenericEvent */
887 uint8_t extension; /**< XI extension offset */
888 uint16_t sequenceNumber;
889 uint32_t length; /**< Length in 4 byte units */
890 uint16_t evtype; /**< XI_DeviceChanged */
891 uint16_t deviceid; /**< Device that has changed */
893 uint16_t num_classes; /**< Number of classes that have changed */
894 uint16_t sourceid; /**< Source of the new classes */
895 uint8_t reason; /**< ::XISlaveSwitch, ::XIDeviceChange */
900 } xXIDeviceChangedEvent;
903 * The owner of a touch stream has passed on ownership to another client.
907 uint8_t type; /**< Always GenericEvent */
908 uint8_t extension; /**< XI extension offset */
909 uint16_t sequenceNumber;
910 uint32_t length; /**< Length in 4 byte units */
911 uint16_t evtype; /**< XI_TouchOwnership */
912 uint16_t deviceid; /**< Device that has changed */
918 /* └──────── 32 byte boundary ────────┘ */
924 } xXITouchOwnershipEvent;
927 * Default input event for pointer, keyboard or touch input.
931 uint8_t type; /**< Always GenericEvent */
932 uint8_t extension; /**< XI extension offset */
933 uint16_t sequenceNumber;
934 uint32_t length; /**< Length in 4 byte uints */
938 uint32_t detail; /**< Keycode or button */
942 /* └──────── 32 byte boundary ────────┘ */
943 FP1616 root_x; /**< Always screen coords, 16.16 fixed point */
945 FP1616 event_x; /**< Always screen coords, 16.16 fixed point */
947 uint16_t buttons_len; /**< Len of button flags in 4 b units */
948 uint16_t valuators_len; /**< Len of val. flags in 4 b units */
949 uint16_t sourceid; /**< The source device */
951 uint32_t flags; /**< ::XIKeyRepeat */
952 xXIModifierInfo mods;
958 * Sent when an input event is generated. RawEvents include valuator
959 * information in both device-specific data (i.e. unaccelerated) and
960 * processed data (i.e. accelerated, if applicable).
964 uint8_t type; /**< Always GenericEvent */
965 uint8_t extension; /**< XI extension offset */
966 uint16_t sequenceNumber;
967 uint32_t length; /**< Length in 4 byte uints */
968 uint16_t evtype; /**< ::XI_RawEvent */
972 uint16_t sourceid; /**< The source device (XI 2.1) */
973 uint16_t valuators_len; /**< Length of trailing valuator
974 mask in 4 byte units */
975 uint32_t flags; /**< ::XIKeyRepeat */
980 * Note that the layout of root, event, child, root_x, root_y, event_x,
981 * event_y must be identical to the xXIDeviceEvent.
985 uint8_t type; /**< Always GenericEvent */
986 uint8_t extension; /**< XI extension offset */
987 uint16_t sequenceNumber;
988 uint32_t length; /**< Length in 4 byte uints */
989 uint16_t evtype; /**< ::XI_Enter */
998 /* └──────── 32 byte boundary ────────┘ */
1005 uint16_t buttons_len; /**< Length of trailing button mask
1007 xXIModifierInfo mods;
1011 typedef xXIEnterEvent xXILeaveEvent;
1012 typedef xXIEnterEvent xXIFocusInEvent;
1013 typedef xXIEnterEvent xXIFocusOutEvent;
1016 * Sent when a device property is created, modified or deleted. Does not
1017 * include property data, the client is required to query the data.
1021 uint8_t type; /**< Always GenericEvent */
1022 uint8_t extension; /**< XI extension offset */
1023 uint16_t sequenceNumber;
1024 uint32_t length; /**< Length in 4 byte uints */
1025 uint16_t evtype; /**< ::XI_PropertyEvent */
1029 uint8_t what; /**< ::XIPropertyDeleted,
1030 ::XIPropertyCreated,
1031 ::XIPropertyMotified */
1044 #endif /* _XI2PROTO_H_ */