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 /* Definitions used by the library and client */ 26 27 #ifndef _XINPUT2_H_ 28 #define _XINPUT2_H_ 29 30 #include <X11/Xlib.h> 31 #include <X11/extensions/XI2.h> 32 #include <X11/extensions/Xge.h> 33 #include <X11/extensions/Xfixes.h> /* PointerBarrier */ 34 35 /******************************************************************* 36 * 37 */ 38 typedef struct { 39 int type; 40 char* name; 41 Bool send_core; 42 Bool enable; 43 } XIAddMasterInfo; 44 45 typedef struct { 46 int type; 47 int deviceid; 48 int return_mode; /* AttachToMaster, Floating */ 49 int return_pointer; 50 int return_keyboard; 51 } XIRemoveMasterInfo; 52 53 typedef struct { 54 int type; 55 int deviceid; 56 int new_master; 57 } XIAttachSlaveInfo; 58 59 typedef struct { 60 int type; 61 int deviceid; 62 } XIDetachSlaveInfo; 63 64 typedef union { 65 int type; /* must be first element */ 66 XIAddMasterInfo add; 67 XIRemoveMasterInfo remove; 68 XIAttachSlaveInfo attach; 69 XIDetachSlaveInfo detach; 70 } XIAnyHierarchyChangeInfo; 71 72 typedef struct 73 { 74 int base; 75 int latched; 76 int locked; 77 int effective; 78 } XIModifierState; 79 80 typedef XIModifierState XIGroupState; 81 82 typedef struct { 83 int mask_len; 84 unsigned char *mask; 85 } XIButtonState; 86 87 typedef struct { 88 int mask_len; 89 unsigned char *mask; 90 double *values; 91 } XIValuatorState; 92 93 94 typedef struct 95 { 96 int deviceid; 97 int mask_len; 98 unsigned char* mask; 99 } XIEventMask; 100 101 typedef struct 102 { 103 int type; 104 int sourceid; 105 } XIAnyClassInfo; 106 107 typedef struct 108 { 109 int type; 110 int sourceid; 111 int num_buttons; 112 Atom *labels; 113 XIButtonState state; 114 } XIButtonClassInfo; 115 116 typedef struct 117 { 118 int type; 119 int sourceid; 120 int num_keycodes; 121 int *keycodes; 122 } XIKeyClassInfo; 123 124 typedef struct 125 { 126 int type; 127 int sourceid; 128 int number; 129 Atom label; 130 double min; 131 double max; 132 double value; 133 int resolution; 134 int mode; 135 } XIValuatorClassInfo; 136 137 /* new in XI 2.1 */ 138 typedef struct 139 { 140 int type; 141 int sourceid; 142 int number; 143 int scroll_type; 144 double increment; 145 int flags; 146 } XIScrollClassInfo; 147 148 typedef struct 149 { 150 int type; 151 int sourceid; 152 int mode; 153 int num_touches; 154 } XITouchClassInfo; 155 156 /* new in XI 2.4 */ 157 typedef struct 158 { 159 int type; 160 int sourceid; 161 int num_touches; 162 } XIGestureClassInfo; 163 164 typedef struct 165 { 166 int deviceid; 167 char *name; 168 int use; 169 int attachment; 170 Bool enabled; 171 int num_classes; 172 XIAnyClassInfo **classes; 173 } XIDeviceInfo; 174 175 typedef struct 176 { 177 int modifiers; 178 int status; 179 } XIGrabModifiers; 180 181 typedef unsigned int BarrierEventID; 182 183 typedef struct 184 { 185 int deviceid; 186 PointerBarrier barrier; 187 BarrierEventID eventid; 188 } XIBarrierReleasePointerInfo; 189 190 /** 191 * Generic XI2 event. All XI2 events have the same header. 192 */ 193 typedef struct { 194 int type; /* GenericEvent */ 195 unsigned long serial; /* # of last request processed by server */ 196 Bool send_event; /* true if this came from a SendEvent request */ 197 Display *display; /* Display the event was read from */ 198 int extension; /* XI extension offset */ 199 int evtype; 200 Time time; 201 } XIEvent; 202 203 204 typedef struct { 205 int deviceid; 206 int attachment; 207 int use; 208 Bool enabled; 209 int flags; 210 } XIHierarchyInfo; 211 212 /* 213 * Notifies the client that the device hierarchy has been changed. The client 214 * is expected to re-query the server for the device hierarchy. 215 */ 216 typedef struct { 217 int type; /* GenericEvent */ 218 unsigned long serial; /* # of last request processed by server */ 219 Bool send_event; /* true if this came from a SendEvent request */ 220 Display *display; /* Display the event was read from */ 221 int extension; /* XI extension offset */ 222 int evtype; /* XI_HierarchyChanged */ 223 Time time; 224 int flags; 225 int num_info; 226 XIHierarchyInfo *info; 227 } XIHierarchyEvent; 228 229 /* 230 * Notifies the client that the classes have been changed. This happens when 231 * the slave device that sends through the master changes. 232 */ 233 typedef struct { 234 int type; /* GenericEvent */ 235 unsigned long serial; /* # of last request processed by server */ 236 Bool send_event; /* true if this came from a SendEvent request */ 237 Display *display; /* Display the event was read from */ 238 int extension; /* XI extension offset */ 239 int evtype; /* XI_DeviceChanged */ 240 Time time; 241 int deviceid; /* id of the device that changed */ 242 int sourceid; /* Source for the new classes. */ 243 int reason; /* Reason for the change */ 244 int num_classes; 245 XIAnyClassInfo **classes; /* same as in XIDeviceInfo */ 246 } XIDeviceChangedEvent; 247 248 typedef struct { 249 int type; /* GenericEvent */ 250 unsigned long serial; /* # of last request processed by server */ 251 Bool send_event; /* true if this came from a SendEvent request */ 252 Display *display; /* Display the event was read from */ 253 int extension; /* XI extension offset */ 254 int evtype; 255 Time time; 256 int deviceid; 257 int sourceid; 258 int detail; 259 Window root; 260 Window event; 261 Window child; 262 double root_x; 263 double root_y; 264 double event_x; 265 double event_y; 266 int flags; 267 XIButtonState buttons; 268 XIValuatorState valuators; 269 XIModifierState mods; 270 XIGroupState group; 271 } XIDeviceEvent; 272 273 typedef struct { 274 int type; /* GenericEvent */ 275 unsigned long serial; /* # of last request processed by server */ 276 Bool send_event; /* true if this came from a SendEvent request */ 277 Display *display; /* Display the event was read from */ 278 int extension; /* XI extension offset */ 279 int evtype; /* XI_RawKeyPress, XI_RawKeyRelease, etc. */ 280 Time time; 281 int deviceid; 282 int sourceid; /* Bug: Always 0. https://bugs.freedesktop.org//show_bug.cgi?id=34240 */ 283 int detail; 284 int flags; 285 XIValuatorState valuators; 286 double *raw_values; 287 } XIRawEvent; 288 289 typedef struct { 290 int type; /* GenericEvent */ 291 unsigned long serial; /* # of last request processed by server */ 292 Bool send_event; /* true if this came from a SendEvent request */ 293 Display *display; /* Display the event was read from */ 294 int extension; /* XI extension offset */ 295 int evtype; 296 Time time; 297 int deviceid; 298 int sourceid; 299 int detail; 300 Window root; 301 Window event; 302 Window child; 303 double root_x; 304 double root_y; 305 double event_x; 306 double event_y; 307 int mode; 308 Bool focus; 309 Bool same_screen; 310 XIButtonState buttons; 311 XIModifierState mods; 312 XIGroupState group; 313 } XIEnterEvent; 314 315 typedef XIEnterEvent XILeaveEvent; 316 typedef XIEnterEvent XIFocusInEvent; 317 typedef XIEnterEvent XIFocusOutEvent; 318 319 typedef struct { 320 int type; /* GenericEvent */ 321 unsigned long serial; /* # of last request processed by server */ 322 Bool send_event; /* true if this came from a SendEvent request */ 323 Display *display; /* Display the event was read from */ 324 int extension; /* XI extension offset */ 325 int evtype; /* XI_PropertyEvent */ 326 Time time; 327 int deviceid; /* id of the device that changed */ 328 Atom property; 329 int what; 330 } XIPropertyEvent; 331 332 typedef struct { 333 int type; /* GenericEvent */ 334 unsigned long serial; /* # of last request processed by server */ 335 Bool send_event; /* true if this came from a SendEvent request */ 336 Display *display; /* Display the event was read from */ 337 int extension; /* XI extension offset */ 338 int evtype; 339 Time time; 340 int deviceid; 341 int sourceid; 342 unsigned int touchid; 343 Window root; 344 Window event; 345 Window child; 346 int flags; 347 } XITouchOwnershipEvent; 348 349 typedef struct { 350 int type; /* GenericEvent */ 351 unsigned long serial; /* # of last request processed by server */ 352 Bool send_event; /* true if this came from a SendEvent request */ 353 Display *display; /* Display the event was read from */ 354 int extension; /* XI extension offset */ 355 int evtype; 356 Time time; 357 int deviceid; 358 int sourceid; 359 Window event; 360 Window root; 361 double root_x; 362 double root_y; 363 double dx; 364 double dy; 365 int dtime; 366 int flags; 367 PointerBarrier barrier; 368 BarrierEventID eventid; 369 } XIBarrierEvent; 370 371 typedef struct { 372 int type; /* GenericEvent */ 373 unsigned long serial; /* # of last request processed by server */ 374 Bool send_event; /* true if this came from a SendEvent request */ 375 Display *display; /* Display the event was read from */ 376 int extension; /* XI extension offset */ 377 int evtype; 378 Time time; 379 int deviceid; 380 int sourceid; 381 int detail; 382 Window root; 383 Window event; 384 Window child; 385 double root_x; 386 double root_y; 387 double event_x; 388 double event_y; 389 double delta_x; 390 double delta_y; 391 double delta_unaccel_x; 392 double delta_unaccel_y; 393 double scale; 394 double delta_angle; 395 int flags; 396 XIModifierState mods; 397 XIGroupState group; 398 } XIGesturePinchEvent; 399 400 typedef struct { 401 int type; /* GenericEvent */ 402 unsigned long serial; /* # of last request processed by server */ 403 Bool send_event; /* true if this came from a SendEvent request */ 404 Display *display; /* Display the event was read from */ 405 int extension; /* XI extension offset */ 406 int evtype; 407 Time time; 408 int deviceid; 409 int sourceid; 410 int detail; 411 Window root; 412 Window event; 413 Window child; 414 double root_x; 415 double root_y; 416 double event_x; 417 double event_y; 418 double delta_x; 419 double delta_y; 420 double delta_unaccel_x; 421 double delta_unaccel_y; 422 int flags; 423 XIModifierState mods; 424 XIGroupState group; 425 } XIGestureSwipeEvent; 426 427 _XFUNCPROTOBEGIN 428 429 extern Bool XIQueryPointer( 430 Display* display, 431 int deviceid, 432 Window win, 433 Window* root, 434 Window* child, 435 double* root_x, 436 double* root_y, 437 double* win_x, 438 double* win_y, 439 XIButtonState *buttons, 440 XIModifierState *mods, 441 XIGroupState *group 442 ); 443 444 extern Bool XIWarpPointer( 445 Display* display, 446 int deviceid, 447 Window src_win, 448 Window dst_win, 449 double src_x, 450 double src_y, 451 unsigned int src_width, 452 unsigned int src_height, 453 double dst_x, 454 double dst_y 455 ); 456 457 extern Status XIDefineCursor( 458 Display* display, 459 int deviceid, 460 Window win, 461 Cursor cursor 462 ); 463 464 extern Status XIUndefineCursor( 465 Display* display, 466 int deviceid, 467 Window win 468 ); 469 470 extern Status XIChangeHierarchy( 471 Display* display, 472 XIAnyHierarchyChangeInfo* changes, 473 int num_changes 474 ); 475 476 extern Status XISetClientPointer( 477 Display* dpy, 478 Window win, 479 int deviceid 480 ); 481 482 extern Bool XIGetClientPointer( 483 Display* dpy, 484 Window win, 485 int* deviceid 486 ); 487 488 extern int XISelectEvents( 489 Display* dpy, 490 Window win, 491 XIEventMask *masks, 492 int num_masks 493 ); 494 495 extern XIEventMask *XIGetSelectedEvents( 496 Display* dpy, 497 Window win, 498 int *num_masks_return 499 ); 500 501 extern Status XIQueryVersion( 502 Display* dpy, 503 int* major_version_inout, 504 int* minor_version_inout 505 ); 506 507 extern XIDeviceInfo* XIQueryDevice( 508 Display* dpy, 509 int deviceid, 510 int* ndevices_return 511 ); 512 513 extern Status XISetFocus( 514 Display* dpy, 515 int deviceid, 516 Window focus, 517 Time time 518 ); 519 520 extern Status XIGetFocus( 521 Display* dpy, 522 int deviceid, 523 Window *focus_return); 524 525 extern Status XIGrabDevice( 526 Display* dpy, 527 int deviceid, 528 Window grab_window, 529 Time time, 530 Cursor cursor, 531 int grab_mode, 532 int paired_device_mode, 533 Bool owner_events, 534 XIEventMask *mask 535 ); 536 537 extern Status XIUngrabDevice( 538 Display* dpy, 539 int deviceid, 540 Time time 541 ); 542 543 extern Status XIAllowEvents( 544 Display* display, 545 int deviceid, 546 int event_mode, 547 Time time 548 ); 549 550 extern Status XIAllowTouchEvents( 551 Display* display, 552 int deviceid, 553 unsigned int touchid, 554 Window grab_window, 555 int event_mode 556 ); 557 558 extern int XIGrabButton( 559 Display* display, 560 int deviceid, 561 int button, 562 Window grab_window, 563 Cursor cursor, 564 int grab_mode, 565 int paired_device_mode, 566 int owner_events, 567 XIEventMask *mask, 568 int num_modifiers, 569 XIGrabModifiers *modifiers_inout 570 ); 571 572 extern int XIGrabKeycode( 573 Display* display, 574 int deviceid, 575 int keycode, 576 Window grab_window, 577 int grab_mode, 578 int paired_device_mode, 579 int owner_events, 580 XIEventMask *mask, 581 int num_modifiers, 582 XIGrabModifiers *modifiers_inout 583 ); 584 585 extern int XIGrabEnter( 586 Display* display, 587 int deviceid, 588 Window grab_window, 589 Cursor cursor, 590 int grab_mode, 591 int paired_device_mode, 592 int owner_events, 593 XIEventMask *mask, 594 int num_modifiers, 595 XIGrabModifiers *modifiers_inout 596 ); 597 598 extern int XIGrabFocusIn( 599 Display* display, 600 int deviceid, 601 Window grab_window, 602 int grab_mode, 603 int paired_device_mode, 604 int owner_events, 605 XIEventMask *mask, 606 int num_modifiers, 607 XIGrabModifiers *modifiers_inout 608 ); 609 610 extern int XIGrabTouchBegin( 611 Display* display, 612 int deviceid, 613 Window grab_window, 614 int owner_events, 615 XIEventMask *mask, 616 int num_modifiers, 617 XIGrabModifiers *modifiers_inout 618 ); 619 620 extern int XIGrabPinchGestureBegin( 621 Display* display, 622 int deviceid, 623 Window grab_window, 624 int grab_mode, 625 int paired_device_mode, 626 int owner_events, 627 XIEventMask *mask, 628 int num_modifiers, 629 XIGrabModifiers *modifiers_inout 630 ); 631 632 extern int XIGrabSwipeGestureBegin( 633 Display* display, 634 int deviceid, 635 Window grab_window, 636 int grab_mode, 637 int paired_device_mode, 638 int owner_events, 639 XIEventMask *mask, 640 int num_modifiers, 641 XIGrabModifiers *modifiers_inout 642 ); 643 644 extern Status XIUngrabButton( 645 Display* display, 646 int deviceid, 647 int button, 648 Window grab_window, 649 int num_modifiers, 650 XIGrabModifiers *modifiers 651 ); 652 653 extern Status XIUngrabKeycode( 654 Display* display, 655 int deviceid, 656 int keycode, 657 Window grab_window, 658 int num_modifiers, 659 XIGrabModifiers *modifiers 660 ); 661 662 extern Status XIUngrabEnter( 663 Display* display, 664 int deviceid, 665 Window grab_window, 666 int num_modifiers, 667 XIGrabModifiers *modifiers 668 ); 669 670 extern Status XIUngrabFocusIn( 671 Display* display, 672 int deviceid, 673 Window grab_window, 674 int num_modifiers, 675 XIGrabModifiers *modifiers 676 ); 677 678 extern Status XIUngrabTouchBegin( 679 Display* display, 680 int deviceid, 681 Window grab_window, 682 int num_modifiers, 683 XIGrabModifiers *modifiers 684 ); 685 686 extern Status XIUngrabPinchGestureBegin( 687 Display* display, 688 int deviceid, 689 Window grab_window, 690 int num_modifiers, 691 XIGrabModifiers *modifiers 692 ); 693 694 extern Status XIUngrabSwipeGestureBegin( 695 Display* display, 696 int deviceid, 697 Window grab_window, 698 int num_modifiers, 699 XIGrabModifiers *modifiers 700 ); 701 702 extern Atom *XIListProperties( 703 Display* display, 704 int deviceid, 705 int *num_props_return 706 ); 707 708 extern void XIChangeProperty( 709 Display* display, 710 int deviceid, 711 Atom property, 712 Atom type, 713 int format, 714 int mode, 715 unsigned char *data, 716 int num_items 717 ); 718 719 extern void 720 XIDeleteProperty( 721 Display* display, 722 int deviceid, 723 Atom property 724 ); 725 726 extern Status 727 XIGetProperty( 728 Display* display, 729 int deviceid, 730 Atom property, 731 long offset, 732 long length, 733 Bool delete_property, 734 Atom type, 735 Atom *type_return, 736 int *format_return, 737 unsigned long *num_items_return, 738 unsigned long *bytes_after_return, 739 unsigned char **data 740 ); 741 742 extern void 743 XIBarrierReleasePointers( 744 Display* display, 745 XIBarrierReleasePointerInfo *barriers, 746 int num_barriers 747 ); 748 749 extern void 750 XIBarrierReleasePointer( 751 Display* display, 752 int deviceid, 753 PointerBarrier barrier, 754 BarrierEventID eventid 755 ); 756 757 extern void XIFreeDeviceInfo(XIDeviceInfo *info); 758 759 _XFUNCPROTOEND 760 761 #endif /* XINPUT2_H */ 762