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