XI2proto.h revision ea1d6981
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 aligned 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#include <stdint.h> 64 65/* make sure types have right sizes for protocol structures. */ 66#define Window uint32_t 67#define Time uint32_t 68#define Atom uint32_t 69#define Cursor uint32_t 70#define Barrier uint32_t 71 72/** 73 * XI2 Request opcodes 74 */ 75#define X_XIQueryPointer 40 76#define X_XIWarpPointer 41 77#define X_XIChangeCursor 42 78#define X_XIChangeHierarchy 43 79#define X_XISetClientPointer 44 80#define X_XIGetClientPointer 45 81#define X_XISelectEvents 46 82#define X_XIQueryVersion 47 83#define X_XIQueryDevice 48 84#define X_XISetFocus 49 85#define X_XIGetFocus 50 86#define X_XIGrabDevice 51 87#define X_XIUngrabDevice 52 88#define X_XIAllowEvents 53 89#define X_XIPassiveGrabDevice 54 90#define X_XIPassiveUngrabDevice 55 91#define X_XIListProperties 56 92#define X_XIChangeProperty 57 93#define X_XIDeleteProperty 58 94#define X_XIGetProperty 59 95#define X_XIGetSelectedEvents 60 96#define X_XIBarrierReleasePointer 61 97 98/** Number of XI requests */ 99#define XI2REQUESTS (X_XIBarrierReleasePointer - X_XIQueryPointer + 1) 100/** Number of XI2 events */ 101#define XI2EVENTS (XI_LASTEVENT + 1) 102 103/************************************************************************************* 104 * * 105 * COMMON STRUCTS * 106 * * 107 *************************************************************************************/ 108/** Fixed point 16.16 */ 109typedef int32_t FP1616; 110 111/** Fixed point 32.32 */ 112typedef struct { 113 int32_t integral; 114 uint32_t frac; 115} FP3232; 116 117/** 118 * Struct to describe a device. 119 * 120 * For a MasterPointer or a MasterKeyboard, 'attachment' specifies the 121 * paired master device. 122 * For a SlaveKeyboard or SlavePointer, 'attachment' specifies the master 123 * device this device is attached to. 124 * For a FloatingSlave, 'attachment' is undefined. 125 */ 126typedef struct { 127 uint16_t deviceid; 128 uint16_t use; /**< ::XIMasterPointer, ::XIMasterKeyboard, 129 ::XISlavePointer, ::XISlaveKeyboard, 130 ::XIFloatingSlave */ 131 uint16_t attachment; /**< Current attachment or pairing.*/ 132 uint16_t num_classes; /**< Number of classes following this struct. */ 133 uint16_t name_len; /**< Length of name in bytes. */ 134 uint8_t enabled; /**< TRUE if device is enabled. */ 135 uint8_t pad; 136} xXIDeviceInfo; 137 138/** 139 * Default template for a device class. 140 * A device class is equivalent to a device's capabilities. Multiple classes 141 * are supported per device. 142 */ 143typedef struct { 144 uint16_t type; /**< One of *class */ 145 uint16_t length; /**< Length in 4 byte units */ 146 uint16_t sourceid; /**< source device for this class */ 147 uint16_t pad; 148} xXIAnyInfo; 149 150/** 151 * Denotes button capability on a device. 152 * Struct is followed by a button bit-mask (padded to four byte chunks) and 153 * then num_buttons * Atom that names the buttons in the device-native setup 154 * (i.e. ignoring button mappings). 155 */ 156typedef struct { 157 uint16_t type; /**< Always ButtonClass */ 158 uint16_t length; /**< Length in 4 byte units */ 159 uint16_t sourceid; /**< source device for this class */ 160 uint16_t num_buttons; /**< Number of buttons provided */ 161} xXIButtonInfo; 162 163/** 164 * Denotes key capability on a device. 165 * Struct is followed by num_keys * CARD32 that lists the keycodes available 166 * on the device. 167 */ 168typedef struct { 169 uint16_t type; /**< Always KeyClass */ 170 uint16_t length; /**< Length in 4 byte units */ 171 uint16_t sourceid; /**< source device for this class */ 172 uint16_t num_keycodes; /**< Number of keys provided */ 173} xXIKeyInfo; 174 175/** 176 * Denotes an valuator capability on a device. 177 * One XIValuatorInfo describes exactly one valuator (axis) on the device. 178 */ 179typedef struct { 180 uint16_t type; /**< Always ValuatorClass */ 181 uint16_t length; /**< Length in 4 byte units */ 182 uint16_t sourceid; /**< source device for this class */ 183 uint16_t number; /**< Valuator number */ 184 Atom label; /**< Axis label */ 185 FP3232 min; /**< Min value */ 186 FP3232 max; /**< Max value */ 187 FP3232 value; /**< Last published value */ 188 uint32_t resolution; /**< Resolutions in units/m */ 189 uint8_t mode; /**< ModeRelative or ModeAbsolute */ 190 uint8_t pad1; 191 uint16_t pad2; 192} xXIValuatorInfo; 193 194/*** 195 * Denotes a scroll valuator on a device. 196 * One XIScrollInfo describes exactly one scroll valuator that must have a 197 * XIValuatorInfo struct. 198 */ 199typedef struct { 200 uint16_t type; /**< Always ValuatorClass */ 201 uint16_t length; /**< Length in 4 byte units */ 202 uint16_t sourceid; /**< source device for this class */ 203 uint16_t number; /**< Valuator number */ 204 uint16_t scroll_type; /**< ::XIScrollTypeVertical, ::XIScrollTypeHorizontal */ 205 uint16_t pad0; 206 uint32_t flags; /**< ::XIScrollFlagEmulate, ::XIScrollFlagPreferred */ 207 FP3232 increment; /**< Increment for one unit of scrolling */ 208} xXIScrollInfo; 209 210/** 211 * Denotes multitouch capability on a device. 212 */ 213typedef struct { 214 uint16_t type; /**< Always TouchClass */ 215 uint16_t length; /**< Length in 4 byte units */ 216 uint16_t sourceid; /**< source device for this class */ 217 uint8_t mode; /**< DirectTouch or DependentTouch */ 218 uint8_t num_touches; /**< Maximum number of touches (0==unlimited) */ 219} xXITouchInfo; 220 221/** 222 * Used to select for events on a given window. 223 * Struct is followed by (mask_len * CARD8), with each bit set representing 224 * the event mask for the given type. A mask bit represents an event type if 225 * (mask == (1 << type)). 226 */ 227typedef struct { 228 uint16_t deviceid; /**< Device id to select for */ 229 uint16_t mask_len; /**< Length of mask in 4 byte units */ 230} xXIEventMask; 231 232/** 233 * XKB modifier information. 234 * The effective modifier is a binary mask of base, latched, and locked 235 * modifiers. 236 */ 237typedef struct 238{ 239 uint32_t base_mods; /**< Logically pressed modifiers */ 240 uint32_t latched_mods; /**< Logically latched modifiers */ 241 uint32_t locked_mods; /**< Logically locked modifiers */ 242 uint32_t effective_mods; /**< Effective modifiers */ 243} xXIModifierInfo; 244 245/** 246 * XKB group information. 247 * The effective group is the mathematical sum of base, latched, and locked 248 * group after group wrapping is taken into account. 249 */ 250typedef struct 251{ 252 uint8_t base_group; /**< Logically "pressed" group */ 253 uint8_t latched_group; /**< Logically latched group */ 254 uint8_t locked_group; /**< Logically locked group */ 255 uint8_t effective_group; /**< Effective group */ 256} xXIGroupInfo; 257 258 259/************************************************************************************* 260 * * 261 * REQUESTS * 262 * * 263 *************************************************************************************/ 264 265/** 266 * Query the server for the supported X Input extension version. 267 */ 268 269typedef struct { 270 uint8_t reqType; /**< Input extension major code */ 271 uint8_t ReqType; /**< Always ::X_XIQueryVersion */ 272 uint16_t length; /**< Length in 4 byte units */ 273 uint16_t major_version; 274 uint16_t minor_version; 275} xXIQueryVersionReq; 276#define sz_xXIQueryVersionReq 8 277 278typedef struct { 279 uint8_t repType; /**< ::X_Reply */ 280 uint8_t RepType; /**< Always ::X_XIQueryVersion */ 281 uint16_t sequenceNumber; 282 uint32_t length; 283 uint16_t major_version; 284 uint16_t minor_version; 285 uint32_t pad1; 286 uint32_t pad2; 287 uint32_t pad3; 288 uint32_t pad4; 289 uint32_t pad5; 290} xXIQueryVersionReply; 291#define sz_xXIQueryVersionReply 32 292 293/** 294 * Query the server for information about a specific device or all input 295 * devices. 296 */ 297typedef struct { 298 uint8_t reqType; /**< Input extension major code */ 299 uint8_t ReqType; /**< Always ::X_XIQueryDevice */ 300 uint16_t length; /**< Length in 4 byte units */ 301 uint16_t deviceid; 302 uint16_t pad; 303} xXIQueryDeviceReq; 304#define sz_xXIQueryDeviceReq 8 305 306typedef struct { 307 uint8_t repType; /**< ::X_Reply */ 308 uint8_t RepType; /**< Always ::X_XIQueryDevice */ 309 uint16_t sequenceNumber; 310 uint32_t length; 311 uint16_t num_devices; 312 uint16_t pad0; 313 uint32_t pad1; 314 uint32_t pad2; 315 uint32_t pad3; 316 uint32_t pad4; 317 uint32_t pad5; 318} xXIQueryDeviceReply; 319#define sz_xXIQueryDeviceReply 32 320 321/** 322 * Select for events on a given window. 323 */ 324typedef struct { 325 uint8_t reqType; /**< Input extension major code */ 326 uint8_t ReqType; /**< Always ::X_XISelectEvents */ 327 uint16_t length; /**< Length in 4 byte units */ 328 Window win; 329 uint16_t num_masks; 330 uint16_t pad; 331} xXISelectEventsReq; 332#define sz_xXISelectEventsReq 12 333 334/** 335 * Query for selected events on a given window. 336 */ 337typedef struct { 338 uint8_t reqType; /**< Input extension major code */ 339 uint8_t ReqType; /**< Always ::X_XIGetSelectedEvents */ 340 uint16_t length; /**< Length in 4 byte units */ 341 Window win; 342} xXIGetSelectedEventsReq; 343#define sz_xXIGetSelectedEventsReq 8 344 345typedef struct { 346 uint8_t repType; /**< Input extension major opcode */ 347 uint8_t RepType; /**< Always ::X_XIGetSelectedEvents */ 348 uint16_t sequenceNumber; 349 uint32_t length; 350 uint16_t num_masks; /**< Number of xXIEventMask structs 351 trailing the reply */ 352 uint16_t pad0; 353 uint32_t pad1; 354 uint32_t pad2; 355 uint32_t pad3; 356 uint32_t pad4; 357 uint32_t pad5; 358} xXIGetSelectedEventsReply; 359#define sz_xXIGetSelectedEventsReply 32 360 361/** 362 * Query the given device's screen/window coordinates. 363 */ 364 365typedef struct { 366 uint8_t reqType; /**< Input extension major code */ 367 uint8_t ReqType; /**< Always ::X_XIQueryPointer */ 368 uint16_t length; /**< Length in 4 byte units */ 369 Window win; 370 uint16_t deviceid; 371 uint16_t pad1; 372} xXIQueryPointerReq; 373#define sz_xXIQueryPointerReq 12 374 375 376typedef struct { 377 uint8_t repType; /**< Input extension major opcode */ 378 uint8_t RepType; /**< Always ::X_XIQueryPointer */ 379 uint16_t sequenceNumber; 380 uint32_t length; 381 Window root; 382 Window child; 383 FP1616 root_x; 384 FP1616 root_y; 385 FP1616 win_x; 386 FP1616 win_y; 387 uint8_t same_screen; 388 uint8_t pad0; 389 uint16_t buttons_len; 390 xXIModifierInfo mods; 391 xXIGroupInfo group; 392} xXIQueryPointerReply; 393#define sz_xXIQueryPointerReply 56 394 395/** 396 * Warp the given device's pointer to the specified position. 397 */ 398 399typedef struct { 400 uint8_t reqType; /**< Input extension major code */ 401 uint8_t ReqType; /**< Always ::X_XIWarpPointer */ 402 uint16_t length; /**< Length in 4 byte units */ 403 Window src_win; 404 Window dst_win; 405 FP1616 src_x; 406 FP1616 src_y; 407 uint16_t src_width; 408 uint16_t src_height; 409 FP1616 dst_x; 410 FP1616 dst_y; 411 uint16_t deviceid; 412 uint16_t pad1; 413} xXIWarpPointerReq; 414#define sz_xXIWarpPointerReq 36 415 416/** 417 * Change the given device's sprite to the given cursor. 418 */ 419 420typedef struct { 421 uint8_t reqType; /**< Input extension major code */ 422 uint8_t ReqType; /**< Always ::X_XIChangeCursor */ 423 uint16_t length; /**< Length in 4 byte units */ 424 Window win; 425 Cursor cursor; 426 uint16_t deviceid; 427 uint16_t pad1; 428} xXIChangeCursorReq; 429#define sz_xXIChangeCursorReq 16 430 431/** 432 * Modify the device hierarchy. 433 */ 434 435typedef struct { 436 uint8_t reqType; /**< Input extension major code */ 437 uint8_t ReqType; /**< Always ::X_XIChangeHierarchy */ 438 uint16_t length; /**< Length in 4 byte units */ 439 uint8_t num_changes; 440 uint8_t pad0; 441 uint16_t pad1; 442} xXIChangeHierarchyReq; 443#define sz_xXIChangeHierarchyReq 8 444 445/** 446 * Generic header for any hierarchy change. 447 */ 448typedef struct { 449 uint16_t type; 450 uint16_t length; /**< Length in 4 byte units */ 451} xXIAnyHierarchyChangeInfo; 452 453/** 454 * Create a new master device. 455 * Name of new master follows struct (4-byte padded) 456 */ 457typedef struct { 458 uint16_t type; /**< Always ::XIAddMaster */ 459 uint16_t length; /**< 2 + (namelen + padding)/4 */ 460 uint16_t name_len; 461 uint8_t send_core; 462 uint8_t enable; 463} xXIAddMasterInfo; 464 465/** 466 * Delete a master device. Will automatically delete the master device paired 467 * with the given master device. 468 */ 469typedef struct { 470 uint16_t type; /**< Always ::XIRemoveMaster */ 471 uint16_t length; /**< 3 */ 472 uint16_t deviceid; 473 uint8_t return_mode; /**< ::XIAttachToMaster, ::XIFloating */ 474 uint8_t pad; 475 uint16_t return_pointer; /**< Pointer to attach slave ptr devices to */ 476 uint16_t return_keyboard; /**< keyboard to attach slave keybd devices to*/ 477} xXIRemoveMasterInfo; 478 479/** 480 * Attach an SD to a new device. 481 * NewMaster has to be of same type (pointer->pointer, keyboard->keyboard); 482 */ 483typedef struct { 484 uint16_t type; /**< Always ::XIAttachSlave */ 485 uint16_t length; /**< 2 */ 486 uint16_t deviceid; 487 uint16_t new_master; /**< id of new master device */ 488} xXIAttachSlaveInfo; 489 490/** 491 * Detach an SD from its current master device. 492 */ 493typedef struct { 494 uint16_t type; /**< Always ::XIDetachSlave */ 495 uint16_t length; /**< 2 */ 496 uint16_t deviceid; 497 uint16_t pad; 498} xXIDetachSlaveInfo; 499 500 501/** 502 * Set the window/client's ClientPointer. 503 */ 504typedef struct { 505 uint8_t reqType; 506 uint8_t ReqType; /**< Always ::X_XISetClientPointer */ 507 uint16_t length; /**< Length in 4 byte units */ 508 Window win; 509 uint16_t deviceid; 510 uint16_t pad1; 511} xXISetClientPointerReq; 512#define sz_xXISetClientPointerReq 12 513 514/** 515 * Query the given window/client's ClientPointer setting. 516 */ 517typedef struct { 518 uint8_t reqType; 519 uint8_t ReqType; /**< Always ::X_GetClientPointer */ 520 uint16_t length; /**< Length in 4 byte units */ 521 Window win; 522} xXIGetClientPointerReq; 523#define sz_xXIGetClientPointerReq 8 524 525typedef struct { 526 uint8_t repType; /**< Input extension major opcode */ 527 uint8_t RepType; /**< Always ::X_GetClientPointer */ 528 uint16_t sequenceNumber; 529 uint32_t length; 530 BOOL set; /**< client pointer is set? */ 531 uint8_t pad0; 532 uint16_t deviceid; 533 uint32_t pad1; 534 uint32_t pad2; 535 uint32_t pad3; 536 uint32_t pad4; 537 uint32_t pad5; 538} xXIGetClientPointerReply; 539#define sz_xXIGetClientPointerReply 32 540 541/** 542 * Set the input focus to the specified window. 543 */ 544typedef struct { 545 uint8_t reqType; 546 uint8_t ReqType; /**< Always ::X_XISetFocus */ 547 uint16_t length; /**< Length in 4 byte units */ 548 Window focus; 549 Time time; 550 uint16_t deviceid; 551 uint16_t pad0; 552} xXISetFocusReq; 553#define sz_xXISetFocusReq 16 554 555/** 556 * Query the current input focus. 557 */ 558typedef struct { 559 uint8_t reqType; 560 uint8_t ReqType; /**< Always ::X_XIGetDeviceFocus */ 561 uint16_t length; /**< Length in 4 byte units */ 562 uint16_t deviceid; 563 uint16_t pad0; 564} xXIGetFocusReq; 565#define sz_xXIGetFocusReq 8 566 567typedef struct { 568 uint8_t repType; /**< Input extension major opcode */ 569 uint8_t RepType; /**< Always ::X_XIGetFocus */ 570 uint16_t sequenceNumber; 571 uint32_t length; 572 Window focus; 573 uint32_t pad1; 574 uint32_t pad2; 575 uint32_t pad3; 576 uint32_t pad4; 577 uint32_t pad5; 578} xXIGetFocusReply; 579#define sz_xXIGetFocusReply 32 580 581 582/** 583 * Grab the given device. 584 */ 585typedef struct { 586 uint8_t reqType; 587 uint8_t ReqType; /**< Always ::X_XIGrabDevice */ 588 uint16_t length; /**< Length in 4 byte units */ 589 Window grab_window; 590 Time time; 591 Cursor cursor; 592 uint16_t deviceid; 593 uint8_t grab_mode; 594 uint8_t paired_device_mode; 595 uint8_t owner_events; 596 uint8_t pad; 597 uint16_t mask_len; 598} xXIGrabDeviceReq; 599#define sz_xXIGrabDeviceReq 24 600 601/** 602 * Return codes from a XIPassiveGrabDevice request. 603 */ 604typedef struct { 605 uint32_t modifiers; /**< Modifier state */ 606 uint8_t status; /**< Grab status code */ 607 uint8_t pad0; 608 uint16_t pad1; 609} xXIGrabModifierInfo; 610 611typedef struct { 612 uint8_t repType; /**< Input extension major opcode */ 613 uint8_t RepType; /**< Always ::X_XIGrabDevice */ 614 uint16_t sequenceNumber; 615 uint32_t length; 616 uint8_t status; 617 uint8_t pad0; 618 uint16_t pad1; 619 uint32_t pad2; 620 uint32_t pad3; 621 uint32_t pad4; 622 uint32_t pad5; 623 uint32_t pad6; 624} xXIGrabDeviceReply; 625#define sz_xXIGrabDeviceReply 32 626 627/** 628 * Ungrab the specified device. 629 * 630 */ 631typedef struct { 632 uint8_t reqType; 633 uint8_t ReqType; /**< Always ::X_XIUngrabDevice */ 634 uint16_t length; /**< Length in 4 byte units */ 635 Time time; 636 uint16_t deviceid; 637 uint16_t pad; 638} xXIUngrabDeviceReq; 639#define sz_xXIUngrabDeviceReq 12 640 641 642/** 643 * Allow or replay events on the specified grabbed device. 644 */ 645typedef struct { 646 uint8_t reqType; 647 uint8_t ReqType; /**< Always ::X_XIAllowEvents */ 648 uint16_t length; /**< Length in 4 byte units */ 649 Time time; 650 uint16_t deviceid; 651 uint8_t mode; 652 uint8_t pad; 653} xXIAllowEventsReq; 654#define sz_xXIAllowEventsReq 12 655 656/** 657 * Allow or replay events on the specified grabbed device. 658 * Since XI 2.2 659 */ 660typedef struct { 661 uint8_t reqType; 662 uint8_t ReqType; /**< Always ::X_XIAllowEvents */ 663 uint16_t length; /**< Length in 4 byte units */ 664 Time time; 665 uint16_t deviceid; 666 uint8_t mode; 667 uint8_t pad; 668 uint32_t touchid; /**< Since XI 2.2 */ 669 Window grab_window; /**< Since XI 2.2 */ 670} xXI2_2AllowEventsReq; 671#define sz_xXI2_2AllowEventsReq 20 672 673 674/** 675 * Passively grab the device. 676 */ 677typedef struct { 678 uint8_t reqType; 679 uint8_t ReqType; /**< Always ::X_XIPassiveGrabDevice */ 680 uint16_t length; /**< Length in 4 byte units */ 681 Time time; 682 Window grab_window; 683 Cursor cursor; 684 uint32_t detail; 685 uint16_t deviceid; 686 uint16_t num_modifiers; 687 uint16_t mask_len; 688 uint8_t grab_type; 689 uint8_t grab_mode; 690 uint8_t paired_device_mode; 691 uint8_t owner_events; 692 uint16_t pad1; 693} xXIPassiveGrabDeviceReq; 694#define sz_xXIPassiveGrabDeviceReq 32 695 696typedef struct { 697 uint8_t repType; /**< Input extension major opcode */ 698 uint8_t RepType; /**< Always ::X_XIPassiveGrabDevice */ 699 uint16_t sequenceNumber; 700 uint32_t length; 701 uint16_t num_modifiers; 702 uint16_t pad1; 703 uint32_t pad2; 704 uint32_t pad3; 705 uint32_t pad4; 706 uint32_t pad5; 707 uint32_t pad6; 708} xXIPassiveGrabDeviceReply; 709#define sz_xXIPassiveGrabDeviceReply 32 710 711/** 712 * Delete a passive grab for the given device. 713 */ 714typedef struct { 715 uint8_t reqType; 716 uint8_t ReqType; /**< Always ::X_XIPassiveUngrabDevice */ 717 uint16_t length; /**< Length in 4 byte units */ 718 Window grab_window; 719 uint32_t detail; 720 uint16_t deviceid; 721 uint16_t num_modifiers; 722 uint8_t grab_type; 723 uint8_t pad0; 724 uint16_t pad1; 725} xXIPassiveUngrabDeviceReq; 726#define sz_xXIPassiveUngrabDeviceReq 20 727 728/** 729 * List all device properties on the specified device. 730 */ 731typedef struct { 732 uint8_t reqType; 733 uint8_t ReqType; /**< Always ::X_XIListProperties */ 734 uint16_t length; /**< Length in 4 byte units */ 735 uint16_t deviceid; 736 uint16_t pad; 737} xXIListPropertiesReq; 738#define sz_xXIListPropertiesReq 8 739 740typedef struct { 741 uint8_t repType; /**< Input extension major opcode */ 742 uint8_t RepType; /**< Always ::X_XIListProperties */ 743 uint16_t sequenceNumber; 744 uint32_t length; 745 uint16_t num_properties; 746 uint16_t pad0; 747 uint32_t pad1; 748 uint32_t pad2; 749 uint32_t pad3; 750 uint32_t pad4; 751 uint32_t pad5; 752} xXIListPropertiesReply; 753#define sz_xXIListPropertiesReply 32 754 755/** 756 * Change a property on the specified device. 757 */ 758typedef struct { 759 uint8_t reqType; 760 uint8_t ReqType; /**< Always ::X_XIChangeProperty */ 761 uint16_t length; /**< Length in 4 byte units */ 762 uint16_t deviceid; 763 uint8_t mode; 764 uint8_t format; 765 Atom property; 766 Atom type; 767 uint32_t num_items; 768} xXIChangePropertyReq; 769#define sz_xXIChangePropertyReq 20 770 771/** 772 * Delete the specified property. 773 */ 774typedef struct { 775 uint8_t reqType; 776 uint8_t ReqType; /**< Always X_XIDeleteProperty */ 777 uint16_t length; /**< Length in 4 byte units */ 778 uint16_t deviceid; 779 uint16_t pad0; 780 Atom property; 781} xXIDeletePropertyReq; 782#define sz_xXIDeletePropertyReq 12 783 784/** 785 * Query the specified property's values. 786 */ 787typedef struct { 788 uint8_t reqType; 789 uint8_t ReqType; /**< Always X_XIGetProperty */ 790 uint16_t length; /**< Length in 4 byte units */ 791 uint16_t deviceid; 792#if defined(__cplusplus) || defined(c_plusplus) 793 uint8_t c_delete; 794#else 795 uint8_t delete; 796#endif 797 uint8_t pad0; 798 Atom property; 799 Atom type; 800 uint32_t offset; 801 uint32_t len; 802} xXIGetPropertyReq; 803#define sz_xXIGetPropertyReq 24 804 805typedef struct { 806 uint8_t repType; /**< Input extension major opcode */ 807 uint8_t RepType; /**< Always X_XIGetProperty */ 808 uint16_t sequenceNumber; 809 uint32_t length; 810 Atom type; 811 uint32_t bytes_after; 812 uint32_t num_items; 813 uint8_t format; 814 uint8_t pad0; 815 uint16_t pad1; 816 uint32_t pad2; 817 uint32_t pad3; 818} xXIGetPropertyReply; 819#define sz_xXIGetPropertyReply 32 820 821typedef struct { 822 uint16_t deviceid; 823 uint16_t pad; 824 Barrier barrier; 825 uint32_t eventid; 826} xXIBarrierReleasePointerInfo; 827 828typedef struct { 829 uint8_t reqType; /**< Input extension major opcode */ 830 uint8_t ReqType; /**< Always X_XIBarrierReleasePointer */ 831 uint16_t length; 832 uint32_t num_barriers; 833 /* array of xXIBarrierReleasePointerInfo */ 834} xXIBarrierReleasePointerReq; 835#define sz_xXIBarrierReleasePointerReq 8 836 837/************************************************************************************* 838 * * 839 * EVENTS * 840 * * 841 *************************************************************************************/ 842 843/** 844 * Generic XI2 event header. All XI2 events use the same header. 845 */ 846typedef struct 847{ 848 uint8_t type; 849 uint8_t extension; /**< XI extension offset */ 850 uint16_t sequenceNumber; 851 uint32_t length; 852 uint16_t evtype; 853 uint16_t deviceid; 854 Time time; 855} xXIGenericDeviceEvent; 856 857/** 858 * Device hierarchy information. 859 */ 860typedef struct 861{ 862 uint16_t deviceid; 863 uint16_t attachment; /**< ID of master or paired device */ 864 uint8_t use; /**< ::XIMasterKeyboard, 865 ::XIMasterPointer, 866 ::XISlaveKeyboard, 867 ::XISlavePointer, 868 ::XIFloatingSlave */ 869 BOOL enabled; /**< TRUE if the device is enabled */ 870 uint16_t pad; 871 uint32_t flags; /**< ::XIMasterAdded, ::XIMasterRemoved, 872 ::XISlaveAttached, ::XISlaveDetached, 873 ::XISlaveAdded, ::XISlaveRemoved, 874 ::XIDeviceEnabled, ::XIDeviceDisabled */ 875} xXIHierarchyInfo; 876 877/** 878 * The device hierarchy has been modified. This event includes the device 879 * hierarchy after the modification has been applied. 880 */ 881typedef struct 882{ 883 uint8_t type; /**< Always GenericEvent */ 884 uint8_t extension; /**< XI extension offset */ 885 uint16_t sequenceNumber; 886 uint32_t length; /**< Length in 4 byte units */ 887 uint16_t evtype; /**< ::XI_Hierarchy */ 888 uint16_t deviceid; 889 Time time; 890 uint32_t flags; /**< ::XIMasterAdded, ::XIMasterDeleted, 891 ::XISlaveAttached, ::XISlaveDetached, 892 ::XISlaveAdded, ::XISlaveRemoved, 893 ::XIDeviceEnabled, ::XIDeviceDisabled */ 894 uint16_t num_info; 895 uint16_t pad0; 896 uint32_t pad1; 897 uint32_t pad2; 898} xXIHierarchyEvent; 899 900/** 901 * A device has changed capabilities. 902 */ 903typedef struct 904{ 905 uint8_t type; /**< Always GenericEvent */ 906 uint8_t extension; /**< XI extension offset */ 907 uint16_t sequenceNumber; 908 uint32_t length; /**< Length in 4 byte units */ 909 uint16_t evtype; /**< XI_DeviceChanged */ 910 uint16_t deviceid; /**< Device that has changed */ 911 Time time; 912 uint16_t num_classes; /**< Number of classes that have changed */ 913 uint16_t sourceid; /**< Source of the new classes */ 914 uint8_t reason; /**< ::XISlaveSwitch, ::XIDeviceChange */ 915 uint8_t pad0; 916 uint16_t pad1; 917 uint32_t pad2; 918 uint32_t pad3; 919} xXIDeviceChangedEvent; 920 921/** 922 * The owner of a touch stream has passed on ownership to another client. 923 */ 924typedef struct 925{ 926 uint8_t type; /**< Always GenericEvent */ 927 uint8_t extension; /**< XI extension offset */ 928 uint16_t sequenceNumber; 929 uint32_t length; /**< Length in 4 byte units */ 930 uint16_t evtype; /**< XI_TouchOwnership */ 931 uint16_t deviceid; /**< Device that has changed */ 932 Time time; 933 uint32_t touchid; 934 Window root; 935 Window event; 936 Window child; 937/* └──────── 32 byte boundary ────────┘ */ 938 uint16_t sourceid; 939 uint16_t pad0; 940 uint32_t flags; 941 uint32_t pad1; 942 uint32_t pad2; 943} xXITouchOwnershipEvent; 944 945/** 946 * Default input event for pointer, keyboard or touch input. 947 */ 948typedef struct 949{ 950 uint8_t type; /**< Always GenericEvent */ 951 uint8_t extension; /**< XI extension offset */ 952 uint16_t sequenceNumber; 953 uint32_t length; /**< Length in 4 byte uints */ 954 uint16_t evtype; 955 uint16_t deviceid; 956 Time time; 957 uint32_t detail; /**< Keycode or button */ 958 Window root; 959 Window event; 960 Window child; 961/* └──────── 32 byte boundary ────────┘ */ 962 FP1616 root_x; /**< Always screen coords, 16.16 fixed point */ 963 FP1616 root_y; 964 FP1616 event_x; /**< Always screen coords, 16.16 fixed point */ 965 FP1616 event_y; 966 uint16_t buttons_len; /**< Len of button flags in 4 b units */ 967 uint16_t valuators_len; /**< Len of val. flags in 4 b units */ 968 uint16_t sourceid; /**< The source device */ 969 uint16_t pad0; 970 uint32_t flags; /**< ::XIKeyRepeat */ 971 xXIModifierInfo mods; 972 xXIGroupInfo group; 973} xXIDeviceEvent; 974 975 976/** 977 * Sent when an input event is generated. RawEvents include valuator 978 * information in both device-specific data (i.e. unaccelerated) and 979 * processed data (i.e. accelerated, if applicable). 980 */ 981typedef struct 982{ 983 uint8_t type; /**< Always GenericEvent */ 984 uint8_t extension; /**< XI extension offset */ 985 uint16_t sequenceNumber; 986 uint32_t length; /**< Length in 4 byte uints */ 987 uint16_t evtype; /**< ::XI_RawEvent */ 988 uint16_t deviceid; 989 Time time; 990 uint32_t detail; 991 uint16_t sourceid; /**< The source device (XI 2.1) */ 992 uint16_t valuators_len; /**< Length of trailing valuator 993 mask in 4 byte units */ 994 uint32_t flags; /**< ::XIKeyRepeat */ 995 uint32_t pad2; 996} xXIRawEvent; 997 998/** 999 * Note that the layout of root, event, child, root_x, root_y, event_x, 1000 * event_y must be identical to the xXIDeviceEvent. 1001 */ 1002typedef struct 1003{ 1004 uint8_t type; /**< Always GenericEvent */ 1005 uint8_t extension; /**< XI extension offset */ 1006 uint16_t sequenceNumber; 1007 uint32_t length; /**< Length in 4 byte uints */ 1008 uint16_t evtype; /**< ::XI_Enter */ 1009 uint16_t deviceid; 1010 Time time; 1011 uint16_t sourceid; 1012 uint8_t mode; 1013 uint8_t detail; 1014 Window root; 1015 Window event; 1016 Window child; 1017/* └──────── 32 byte boundary ────────┘ */ 1018 FP1616 root_x; 1019 FP1616 root_y; 1020 FP1616 event_x; 1021 FP1616 event_y; 1022 BOOL same_screen; 1023 BOOL focus; 1024 uint16_t buttons_len; /**< Length of trailing button mask 1025 in 4 byte units */ 1026 xXIModifierInfo mods; 1027 xXIGroupInfo group; 1028} xXIEnterEvent; 1029 1030typedef xXIEnterEvent xXILeaveEvent; 1031typedef xXIEnterEvent xXIFocusInEvent; 1032typedef xXIEnterEvent xXIFocusOutEvent; 1033 1034/** 1035 * Sent when a device property is created, modified or deleted. Does not 1036 * include property data, the client is required to query the data. 1037 */ 1038typedef struct 1039{ 1040 uint8_t type; /**< Always GenericEvent */ 1041 uint8_t extension; /**< XI extension offset */ 1042 uint16_t sequenceNumber; 1043 uint32_t length; /**< Length in 4 byte units */ 1044 uint16_t evtype; /**< ::XI_PropertyEvent */ 1045 uint16_t deviceid; 1046 Time time; 1047 Atom property; 1048 uint8_t what; /**< ::XIPropertyDeleted, 1049 ::XIPropertyCreated, 1050 ::XIPropertyMotified */ 1051 uint8_t pad0; 1052 uint16_t pad1; 1053 uint32_t pad2; 1054 uint32_t pad3; 1055} xXIPropertyEvent; 1056 1057typedef struct 1058{ 1059 uint8_t type; /**< Always GenericEvent */ 1060 uint8_t extension; /**< XI extension offset */ 1061 uint16_t sequenceNumber; 1062 uint32_t length; /**< Length in 4 byte units */ 1063 uint16_t evtype; /**< ::XI_BarrierHit or ::XI_BarrierLeave */ 1064 uint16_t deviceid; 1065 Time time; 1066 uint32_t eventid; 1067 Window root; 1068 Window event; 1069 Barrier barrier; 1070/* └──────── 32 byte boundary ────────┘ */ 1071 uint32_t dtime; 1072 uint32_t flags; /**< ::XIBarrierPointerReleased 1073 ::XIBarrierDeviceIsGrabbed */ 1074 uint16_t sourceid; 1075 int16_t pad; 1076 FP1616 root_x; 1077 FP1616 root_y; 1078 FP3232 dx; 1079 FP3232 dy; 1080} xXIBarrierEvent; 1081 1082typedef xXIBarrierEvent xXIBarrierHitEvent; 1083typedef xXIBarrierEvent xXIBarrierPointerReleasedEvent; 1084typedef xXIBarrierEvent xXIBarrierLeaveEvent; 1085 1086#undef Window 1087#undef Time 1088#undef Atom 1089#undef Cursor 1090#undef Barrier 1091 1092#endif /* _XI2PROTO_H_ */ 1093