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 typedef struct 157 { 158 int deviceid; 159 char *name; 160 int use; 161 int attachment; 162 Bool enabled; 163 int num_classes; 164 XIAnyClassInfo **classes; 165 } XIDeviceInfo; 166 167 typedef struct 168 { 169 int modifiers; 170 int status; 171 } XIGrabModifiers; 172 173 typedef unsigned int BarrierEventID; 174 175 typedef struct 176 { 177 int deviceid; 178 PointerBarrier barrier; 179 BarrierEventID eventid; 180 } XIBarrierReleasePointerInfo; 181 182 /** 183 * Generic XI2 event. All XI2 events have the same header. 184 */ 185 typedef struct { 186 int type; /* GenericEvent */ 187 unsigned long serial; /* # of last request processed by server */ 188 Bool send_event; /* true if this came from a SendEvent request */ 189 Display *display; /* Display the event was read from */ 190 int extension; /* XI extension offset */ 191 int evtype; 192 Time time; 193 } XIEvent; 194 195 196 typedef struct { 197 int deviceid; 198 int attachment; 199 int use; 200 Bool enabled; 201 int flags; 202 } XIHierarchyInfo; 203 204 /* 205 * Notifies the client that the device hierarchy has been changed. The client 206 * is expected to re-query the server for the device hierarchy. 207 */ 208 typedef struct { 209 int type; /* GenericEvent */ 210 unsigned long serial; /* # of last request processed by server */ 211 Bool send_event; /* true if this came from a SendEvent request */ 212 Display *display; /* Display the event was read from */ 213 int extension; /* XI extension offset */ 214 int evtype; /* XI_HierarchyChanged */ 215 Time time; 216 int flags; 217 int num_info; 218 XIHierarchyInfo *info; 219 } XIHierarchyEvent; 220 221 /* 222 * Notifies the client that the classes have been changed. This happens when 223 * the slave device that sends through the master changes. 224 */ 225 typedef struct { 226 int type; /* GenericEvent */ 227 unsigned long serial; /* # of last request processed by server */ 228 Bool send_event; /* true if this came from a SendEvent request */ 229 Display *display; /* Display the event was read from */ 230 int extension; /* XI extension offset */ 231 int evtype; /* XI_DeviceChanged */ 232 Time time; 233 int deviceid; /* id of the device that changed */ 234 int sourceid; /* Source for the new classes. */ 235 int reason; /* Reason for the change */ 236 int num_classes; 237 XIAnyClassInfo **classes; /* same as in XIDeviceInfo */ 238 } XIDeviceChangedEvent; 239 240 typedef struct { 241 int type; /* GenericEvent */ 242 unsigned long serial; /* # of last request processed by server */ 243 Bool send_event; /* true if this came from a SendEvent request */ 244 Display *display; /* Display the event was read from */ 245 int extension; /* XI extension offset */ 246 int evtype; 247 Time time; 248 int deviceid; 249 int sourceid; 250 int detail; 251 Window root; 252 Window event; 253 Window child; 254 double root_x; 255 double root_y; 256 double event_x; 257 double event_y; 258 int flags; 259 XIButtonState buttons; 260 XIValuatorState valuators; 261 XIModifierState mods; 262 XIGroupState group; 263 } XIDeviceEvent; 264 265 typedef struct { 266 int type; /* GenericEvent */ 267 unsigned long serial; /* # of last request processed by server */ 268 Bool send_event; /* true if this came from a SendEvent request */ 269 Display *display; /* Display the event was read from */ 270 int extension; /* XI extension offset */ 271 int evtype; /* XI_RawKeyPress, XI_RawKeyRelease, etc. */ 272 Time time; 273 int deviceid; 274 int sourceid; /* Bug: Always 0. https://bugs.freedesktop.org//show_bug.cgi?id=34240 */ 275 int detail; 276 int flags; 277 XIValuatorState valuators; 278 double *raw_values; 279 } XIRawEvent; 280 281 typedef struct { 282 int type; /* GenericEvent */ 283 unsigned long serial; /* # of last request processed by server */ 284 Bool send_event; /* true if this came from a SendEvent request */ 285 Display *display; /* Display the event was read from */ 286 int extension; /* XI extension offset */ 287 int evtype; 288 Time time; 289 int deviceid; 290 int sourceid; 291 int detail; 292 Window root; 293 Window event; 294 Window child; 295 double root_x; 296 double root_y; 297 double event_x; 298 double event_y; 299 int mode; 300 Bool focus; 301 Bool same_screen; 302 XIButtonState buttons; 303 XIModifierState mods; 304 XIGroupState group; 305 } XIEnterEvent; 306 307 typedef XIEnterEvent XILeaveEvent; 308 typedef XIEnterEvent XIFocusInEvent; 309 typedef XIEnterEvent XIFocusOutEvent; 310 311 typedef struct { 312 int type; /* GenericEvent */ 313 unsigned long serial; /* # of last request processed by server */ 314 Bool send_event; /* true if this came from a SendEvent request */ 315 Display *display; /* Display the event was read from */ 316 int extension; /* XI extension offset */ 317 int evtype; /* XI_PropertyEvent */ 318 Time time; 319 int deviceid; /* id of the device that changed */ 320 Atom property; 321 int what; 322 } XIPropertyEvent; 323 324 typedef struct { 325 int type; /* GenericEvent */ 326 unsigned long serial; /* # of last request processed by server */ 327 Bool send_event; /* true if this came from a SendEvent request */ 328 Display *display; /* Display the event was read from */ 329 int extension; /* XI extension offset */ 330 int evtype; 331 Time time; 332 int deviceid; 333 int sourceid; 334 unsigned int touchid; 335 Window root; 336 Window event; 337 Window child; 338 int flags; 339 } XITouchOwnershipEvent; 340 341 typedef struct { 342 int type; /* GenericEvent */ 343 unsigned long serial; /* # of last request processed by server */ 344 Bool send_event; /* true if this came from a SendEvent request */ 345 Display *display; /* Display the event was read from */ 346 int extension; /* XI extension offset */ 347 int evtype; 348 Time time; 349 int deviceid; 350 int sourceid; 351 Window event; 352 Window root; 353 double root_x; 354 double root_y; 355 double dx; 356 double dy; 357 int dtime; 358 int flags; 359 PointerBarrier barrier; 360 BarrierEventID eventid; 361 } XIBarrierEvent; 362 363 _XFUNCPROTOBEGIN 364 365 extern Bool XIQueryPointer( 366 Display* display, 367 int deviceid, 368 Window win, 369 Window* root, 370 Window* child, 371 double* root_x, 372 double* root_y, 373 double* win_x, 374 double* win_y, 375 XIButtonState *buttons, 376 XIModifierState *mods, 377 XIGroupState *group 378 ); 379 380 extern Bool XIWarpPointer( 381 Display* display, 382 int deviceid, 383 Window src_win, 384 Window dst_win, 385 double src_x, 386 double src_y, 387 unsigned int src_width, 388 unsigned int src_height, 389 double dst_x, 390 double dst_y 391 ); 392 393 extern Status XIDefineCursor( 394 Display* display, 395 int deviceid, 396 Window win, 397 Cursor cursor 398 ); 399 400 extern Status XIUndefineCursor( 401 Display* display, 402 int deviceid, 403 Window win 404 ); 405 406 extern Status XIChangeHierarchy( 407 Display* display, 408 XIAnyHierarchyChangeInfo* changes, 409 int num_changes 410 ); 411 412 extern Status XISetClientPointer( 413 Display* dpy, 414 Window win, 415 int deviceid 416 ); 417 418 extern Bool XIGetClientPointer( 419 Display* dpy, 420 Window win, 421 int* deviceid 422 ); 423 424 extern int XISelectEvents( 425 Display* dpy, 426 Window win, 427 XIEventMask *masks, 428 int num_masks 429 ); 430 431 extern XIEventMask *XIGetSelectedEvents( 432 Display* dpy, 433 Window win, 434 int *num_masks_return 435 ); 436 437 extern Status XIQueryVersion( 438 Display* dpy, 439 int* major_version_inout, 440 int* minor_version_inout 441 ); 442 443 extern XIDeviceInfo* XIQueryDevice( 444 Display* dpy, 445 int deviceid, 446 int* ndevices_return 447 ); 448 449 extern Status XISetFocus( 450 Display* dpy, 451 int deviceid, 452 Window focus, 453 Time time 454 ); 455 456 extern Status XIGetFocus( 457 Display* dpy, 458 int deviceid, 459 Window *focus_return); 460 461 extern Status XIGrabDevice( 462 Display* dpy, 463 int deviceid, 464 Window grab_window, 465 Time time, 466 Cursor cursor, 467 int grab_mode, 468 int paired_device_mode, 469 Bool owner_events, 470 XIEventMask *mask 471 ); 472 473 extern Status XIUngrabDevice( 474 Display* dpy, 475 int deviceid, 476 Time time 477 ); 478 479 extern Status XIAllowEvents( 480 Display* display, 481 int deviceid, 482 int event_mode, 483 Time time 484 ); 485 486 extern Status XIAllowTouchEvents( 487 Display* display, 488 int deviceid, 489 unsigned int touchid, 490 Window grab_window, 491 int event_mode 492 ); 493 494 extern int XIGrabButton( 495 Display* display, 496 int deviceid, 497 int button, 498 Window grab_window, 499 Cursor cursor, 500 int grab_mode, 501 int paired_device_mode, 502 int owner_events, 503 XIEventMask *mask, 504 int num_modifiers, 505 XIGrabModifiers *modifiers_inout 506 ); 507 508 extern int XIGrabKeycode( 509 Display* display, 510 int deviceid, 511 int keycode, 512 Window grab_window, 513 int grab_mode, 514 int paired_device_mode, 515 int owner_events, 516 XIEventMask *mask, 517 int num_modifiers, 518 XIGrabModifiers *modifiers_inout 519 ); 520 521 extern int XIGrabEnter( 522 Display* display, 523 int deviceid, 524 Window grab_window, 525 Cursor cursor, 526 int grab_mode, 527 int paired_device_mode, 528 int owner_events, 529 XIEventMask *mask, 530 int num_modifiers, 531 XIGrabModifiers *modifiers_inout 532 ); 533 534 extern int XIGrabFocusIn( 535 Display* display, 536 int deviceid, 537 Window grab_window, 538 int grab_mode, 539 int paired_device_mode, 540 int owner_events, 541 XIEventMask *mask, 542 int num_modifiers, 543 XIGrabModifiers *modifiers_inout 544 ); 545 546 extern int XIGrabTouchBegin( 547 Display* display, 548 int deviceid, 549 Window grab_window, 550 int owner_events, 551 XIEventMask *mask, 552 int num_modifiers, 553 XIGrabModifiers *modifiers_inout 554 ); 555 556 extern Status XIUngrabButton( 557 Display* display, 558 int deviceid, 559 int button, 560 Window grab_window, 561 int num_modifiers, 562 XIGrabModifiers *modifiers 563 ); 564 565 extern Status XIUngrabKeycode( 566 Display* display, 567 int deviceid, 568 int keycode, 569 Window grab_window, 570 int num_modifiers, 571 XIGrabModifiers *modifiers 572 ); 573 574 extern Status XIUngrabEnter( 575 Display* display, 576 int deviceid, 577 Window grab_window, 578 int num_modifiers, 579 XIGrabModifiers *modifiers 580 ); 581 582 extern Status XIUngrabFocusIn( 583 Display* display, 584 int deviceid, 585 Window grab_window, 586 int num_modifiers, 587 XIGrabModifiers *modifiers 588 ); 589 590 extern Status XIUngrabTouchBegin( 591 Display* display, 592 int deviceid, 593 Window grab_window, 594 int num_modifiers, 595 XIGrabModifiers *modifiers 596 ); 597 598 extern Atom *XIListProperties( 599 Display* display, 600 int deviceid, 601 int *num_props_return 602 ); 603 604 extern void XIChangeProperty( 605 Display* display, 606 int deviceid, 607 Atom property, 608 Atom type, 609 int format, 610 int mode, 611 unsigned char *data, 612 int num_items 613 ); 614 615 extern void 616 XIDeleteProperty( 617 Display* display, 618 int deviceid, 619 Atom property 620 ); 621 622 extern Status 623 XIGetProperty( 624 Display* display, 625 int deviceid, 626 Atom property, 627 long offset, 628 long length, 629 Bool delete_property, 630 Atom type, 631 Atom *type_return, 632 int *format_return, 633 unsigned long *num_items_return, 634 unsigned long *bytes_after_return, 635 unsigned char **data 636 ); 637 638 extern void 639 XIBarrierReleasePointers( 640 Display* display, 641 XIBarrierReleasePointerInfo *barriers, 642 int num_barriers 643 ); 644 645 extern void 646 XIBarrierReleasePointer( 647 Display* display, 648 int deviceid, 649 PointerBarrier barrier, 650 BarrierEventID eventid 651 ); 652 653 extern void XIFreeDeviceInfo(XIDeviceInfo *info); 654 655 _XFUNCPROTOEND 656 657 #endif /* XINPUT2_H */ 658