library.xml revision 37eb1ca1
1<chapter><title>Input Extension</title> 2<sect1 id="Input_Extension_Overview"> 3<title>Overview</title> 4<!-- .XS --> 5<!-- (SN Input Extension Overview --> 6<!-- .XE --> 7<para> 8<!-- .LP --> 9This document describes an extension to 10the X11 server. The purpose of this extension is to support the use 11of additional input devices beyond the pointer and keyboard devices 12defined by the core X protocol. This first section gives an overview 13of the input extension. The following sections correspond to 14chapters 9, 10, and 11, ``Window and Session Manager Functions'', 15``Events'', and ``Event Handling Functions'' of the 16``Xlib - C Language Interface'' manual 17and describe how to use the input device extension. 18</para> 19<sect2 id="Design_Approach"> 20<title>Design Approach</title> 21<!-- .XS --> 22<!-- (SN Design Approach --> 23<!-- .XE --> 24<para> 25<!-- .LP --> 26The design approach of the extension is to define functions 27and events analogous to the core functions and events. 28This allows extension input devices and events to be individually 29distinguishable from each other and from the core input devices and events. 30These functions and events make use of a device identifier and support the 31reporting of <emphasis remap='I'>n</emphasis>-dimensional motion data as well as other data that 32is not currently reportable via the core input events. 33</para> 34</sect2> 35<sect2 id="Core_Input_Devices"> 36<title>Core Input Devices</title> 37<!-- .XS --> 38<!-- (SN Core Input Devices --> 39<!-- .XE --> 40<para> 41<!-- .LP --> 42The X server core protocol supports two input devices: a pointer and a 43keyboard. The pointer device has two major functions. 44First, it may be used to generate motion information 45that client programs can detect. Second, it may also be used to indicate the 46current location and focus of the X keyboard. To accomplish this, the server 47echoes a cursor at the current position of the X pointer. Unless the X 48keyboard has been explicitly focused, this cursor also shows the current 49location and focus of the X keyboard. 50</para> 51<para> 52<!-- .LP --> 53The X keyboard is used to generate input that client programs can detect. 54</para> 55<para> 56<!-- .LP --> 57The X keyboard and X pointer are referred to in this document as 58the <emphasis remap='I'>core devices</emphasis>, and the input 59events they generate 60<function>( KeyPress ,</function> 61<function>KeyRelease ,</function> 62<function>ButtonPress ,</function> 63<function>ButtonRelease ,</function> 64and 65<function>MotionNotify )</function> 66are known as the <emphasis remap='I'>core input events</emphasis>. All other 67input devices are referred to as <emphasis remap='I'>extension input devices</emphasis>, and the 68input events they generate are referred to as <emphasis remap='I'>extension input events</emphasis>. 69<!-- .NT --> 70This input extension does not change the behavior or functionality of the 71core input devices, core events, or core protocol requests, with the 72exception of the core grab requests. These requests may affect the 73synchronization of events from extension devices. See the explanation 74in the section titled ``Event Synchronization and Core Grabs.'' 75<!-- .NE --> 76</para> 77<para> 78<!-- .LP --> 79Selection of the physical devices to be initially used by the server as the 80core devices is left implementation dependent. Functions are defined that 81allow client programs to change which physical devices are used as the 82core devices. 83</para> 84</sect2> 85<sect2 id="Extension_Input_Devices"> 86<title>Extension Input Devices</title> 87<!-- .XS --> 88<!-- (SN Extension Input Devices --> 89<!-- .XE --> 90<para> 91<!-- .LP --> 92The input extension controls access to input devices other than the X keyboard 93and X pointer. It allows client programs to select input from these devices 94independently 95from each other and independently from the core devices. Input events from 96these devices are of extension types 97<function>( DeviceKeyPress ,</function> 98<function>DeviceKeyRelease ,</function> 99<function>DeviceButtonPress ,</function> 100<function>DeviceButtonRelease ,</function> 101<function>DeviceMotionNotify ,</function> 102and so on) and contain 103a device identifier so that events of the same type coming from different 104input devices can be distinguished. 105</para> 106<para> 107<!-- .LP --> 108Extension input events are not limited in size by the size of the server 10932-byte wire events. Extension input events 110may be constructed by the server sending as many 111wire-sized events as necessary to return the information required for 112that event. 113The library event reformatting routines 114are responsible for combining these into one or more client XEvents. 115</para> 116<para> 117<!-- .LP --> 118Any input device that generates key, button, or motion data may be used as 119an extension input device. 120Extension input devices may have zero or more keys, zero or more buttons, 121and may report zero or more axes of motion. Motion may be reported 122as relative movements from a previous position or as an absolute 123position. All valuators reporting motion information for a given 124extension input device must report the same kind of motion information 125(absolute or relative). 126</para> 127<para> 128<!-- .LP --> 129This extension is designed to accommodate new types of input devices that 130may be added in the future. The protocol requests that refer to 131specific characteristics of input devices organize that information 132by <emphasis remap='I'>input device classes</emphasis>. Server implementors may add new 133classes of input devices without changing the protocol requests. 134</para> 135<para> 136<!-- .LP --> 137All extension input 138devices are treated like the core X keyboard in determining their location 139and focus. The server does not track the location of these devices on an 140individual basis and, therefore, 141does not echo a cursor to indicate their current location. 142Instead, their location is determined by the location of the core X pointer. 143Like the core X keyboard, some may be explicitly focused. If they are 144not explicitly focused, their focus 145is determined by the location of the core X pointer. 146</para> 147<sect3 id="Input_Device_Classes"> 148<title>Input Device Classes</title> 149<!-- .XS --> 150<!-- (SN Input Device Classes --> 151<!-- .XE --> 152<para> 153<!-- .LP --> 154Some of the input extension requests divide input devices into classes 155based on their functionality. This is intended to allow new classes of input 156devices to be defined at a later time without changing the semantics of 157these functions. The following input device classes are currently 158defined: 159<variablelist> 160 <varlistentry> 161 <term>KEY</term> 162 <listitem> 163 <para> 164The device reports key events. 165 </para> 166 </listitem> 167 </varlistentry> 168 <varlistentry> 169 <term>BUTTON</term> 170 <listitem> 171 <para> 172The device reports button events. 173 </para> 174 </listitem> 175 </varlistentry> 176 <varlistentry> 177 <term>VALUATOR</term> 178 <listitem> 179 <para> 180The device reports valuator data in motion events. 181 </para> 182 </listitem> 183 </varlistentry> 184 <varlistentry> 185 <term>PROXIMITY</term> 186 <listitem> 187 <para> 188The device reports proximity events. 189 </para> 190 </listitem> 191 </varlistentry> 192 <varlistentry> 193 <term>FOCUS</term> 194 <listitem> 195 <para> 196The device can be focused. 197 </para> 198 </listitem> 199 </varlistentry> 200 <varlistentry> 201 <term>FEEDBACK</term> 202 <listitem> 203 <para> 204The device supports feedbacks. 205 </para> 206 </listitem> 207 </varlistentry> 208</variablelist> 209</para> 210<para> 211<!-- .LP --> 212Additional classes may be added in the future. 213Functions that support multiple input classes, such as the 214<function>XListInputDevices</function> 215function that lists all available input devices, 216organize the data they return by input class. Client programs that 217use these functions should not access data unless it matches a 218class defined at the time those clients were compiled. In this way, 219new classes can be added without forcing existing clients that use 220these functions to be recompiled. 221</para> 222</sect3> 223</sect2> 224<sect2 id="Using_Extension_Input_Devices"> 225<title>Using Extension Input Devices</title> 226<!-- .XS --> 227<!-- (SN Using Extension Input Devices --> 228<!-- .XE --> 229<para> 230<!-- .LP --> 231A client that wishes to access an input device does so through the library 232functions defined in the following sections. A typical sequence of requests 233that a client would make is as follows: 234</para> 235<itemizedlist> 236 <listitem> 237 <para> 238<function>XListInputDevices</function> 239- lists all of the available input devices. From the 240information returned by this request, determine whether the desired input 241device is attached to the server. For a description of the 242<function>XListInputDevices</function> 243request, see the section entitled ``Listing Available Devices.'' 244 </para> 245 </listitem> 246 <listitem> 247 <para> 248<function>XOpenDevice</function> 249- requests that the server open the device for access by this client. 250This request returns an 251<function>XDevice</function> 252structure that is used 253by most other input extension requests to identify the specified device. 254For a description of the 255<function>XOpenDevice</function> 256request, see the section entitled ``Enabling and Disabling Extension Devices.'' 257 </para> 258 </listitem> 259 <listitem> 260 <para> 261Determine the event types and event classes needed to select the desired 262input extension events, and identify them when they are received. 263This is done via macros whose name corresponds to the desired event, for 264example, 265<function>DeviceKeyPress .</function> 266For a description of these macros, 267see the section entitled ``Selecting Extension Device Events.'' 268 </para> 269 </listitem> 270 <listitem> 271 <para> 272<function>XSelectExtensionEvent</function> 273- selects the desired events from the server. 274For a description of the 275<function>XSelextExtensionEvent</function> 276request, see the section entitled ``Selecting Extension Device Events.'' 277 </para> 278 </listitem> 279 <listitem> 280 <para> 281<function>XNextEvent</function> 282- receives the next available event. This is the core 283<function>XNextEvent</function> 284function provided by the standard X libarary. 285 </para> 286 </listitem> 287</itemizedlist> 288<para> 289<!-- .LP --> 290Other requests are defined to grab and focus extension devices, to 291change their key, button, or modifier mappings, to control the 292propagation of input extension events, to get motion history from an 293extension device, and to send input extension events to another client. 294These functions are described in the following sections. 295</para> 296</sect2> 297</sect1> 298<sect1 id="Library_Extension_Requests"> 299<title>Library Extension Requests</title> 300<!-- .XS --> 301<!-- (SN Library Extension Requests --> 302<!-- .XE --> 303<para> 304<!-- .LP --> 305Extension input devices are accessed by client programs through the 306use of new protocol requests. 307The following requests are provided as extensions to Xlib. Constants 308and structures referenced by these functions may be found in the 309files <function><X11/extensions/XI.h></function> and <function><X11/extensions/XInput.h></function>, 310which are attached to this document as 311Appendix A.<!-- xref --> 312</para> 313<para> 314<!-- .LP --> 315The library will return <function>NoSuchExtension</function> if an extension request 316is made to a server that does not support the input extension. 317</para> 318<para> 319<!-- .LP --> 320Input extension requests cannot be used to access the X keyboard and 321X pointer devices. 322</para> 323<sect2 id="Window_Manager_Functions"> 324<title>Window Manager Functions</title> 325<!-- .XS --> 326<!-- (SN Window Manager Functions --> 327<!-- .XE --> 328<para> 329<!-- .LP --> 330This section discusses the following X Input Extension Window Manager topics: 331</para> 332<itemizedlist> 333 <listitem> 334 <para> 335Changing the core devices 336 </para> 337 </listitem> 338 <listitem> 339 <para> 340Event synchronization and core grabs 341 </para> 342 </listitem> 343 <listitem> 344 <para> 345Extension active grabs 346 </para> 347 </listitem> 348 <listitem> 349 <para> 350Passively grabbing a key 351 </para> 352 </listitem> 353 <listitem> 354 <para> 355Passively grabbing a button 356 </para> 357 </listitem> 358 <listitem> 359 <para> 360Thawing a device 361 </para> 362 </listitem> 363 <listitem> 364 <para> 365Controlling device focus 366 </para> 367 </listitem> 368 <listitem> 369 <para> 370Controlling device feedback 371 </para> 372 </listitem> 373 <listitem> 374 <para> 375Ringing a bell on an input device 376 </para> 377 </listitem> 378 <listitem> 379 <para> 380Controlling device encoding 381 </para> 382 </listitem> 383 <listitem> 384 <para> 385Controlling button mapping 386 </para> 387 </listitem> 388 <listitem> 389 <para> 390Obtaining the state of a device 391 </para> 392 </listitem> 393</itemizedlist> 394<sect3 id="Changing_the_Core_Devices"> 395<title>Changing the Core Devices</title> 396<!-- .XS --> 397<!-- (SN Changing the Core Devices --> 398<!-- .XE --> 399 400<para> 401<!-- .LP --> 402These functions are provided to change which physical device is used 403as the X pointer or X keyboard. 404</para> 405<!-- .NT --> 406<note><para> 407Using these functions may change the characteristics of the core devices. 408The new pointer device may have a different number of buttons from the 409old one, or the new keyboard device may have a different number of 410keys or report a different range of keycodes. Client programs may be 411running that depend on those characteristics. For example, a client 412program could allocate an array based on the number of buttons on the 413pointer device and then use the button numbers received in button events 414as indices into that array. Changing the core devices could cause 415such client programs to behave improperly or to terminate abnormally 416if they ignore the 417<function>ChangeDeviceNotify</function> 418event generated by these requests. 419</para></note> 420<!-- .NE --> 421 422<para> 423<!-- .LP --> 424These functions change the X keyboard or X pointer device and generate an 425<function>XChangeDeviceNotify</function> 426event and a 427<function>MappingNotify</function> 428event. 429The specified device becomes the 430new X keyboard or X pointer device. The location of the core device 431does not change as a result of this request. 432</para> 433<para> 434<!-- .LP --> 435These requests fail and return 436<function>AlreadyGrabbed</function> 437if either the specified 438device or the core device it would replace are grabbed by some other client. 439They fail and return 440<function>GrabFrozen</function> 441if either device is frozen by the active grab of another client. 442</para> 443<para> 444<!-- .LP --> 445These requests fail with a 446<function>BadDevice</function> 447error if the specified device is invalid, has not previously been opened via 448<function>XOpenDevice ,</function> 449or is 450not supported as a core device by the server implementation. 451</para> 452<para> 453<!-- .LP --> 454Once the device has successfully replaced one of the core devices, it 455is treated as a core device until it is in turn replaced by another 456<function>ChangeDevice</function> 457request or until the server terminates. The termination 458of the client that changed the device will not cause it to change back. 459Attempts to use the 460<function>XCloseDevice</function> 461request to close the new core device will fail with a 462<function>BadDevice</function> 463error. 464<!-- .sp --> 465</para> 466<para> 467<!-- .LP --> 468To change which physical device is used as the X keyboard, use the 469<function>XChangeKeyboardDevice</function> 470function. 471The specified device must support input class 472<function>Keys</function> 473(as reported in the 474<function>ListInputDevices</function> 475request) or the request will fail with a 476<function>BadMatch</function> 477error. 478</para> 479<para> 480<!-- .LP --> 481<!-- .sM --> 482<funcsynopsis> 483<funcprototype> 484 <funcdef>int <function> XChangeKeyboardDevice</function></funcdef> 485 <paramdef>Display<parameter> *display</parameter></paramdef> 486 <paramdef>XDevice<parameter> *device</parameter></paramdef> 487</funcprototype> 488</funcsynopsis> 489<!-- .FN --> 490<variablelist> 491 <varlistentry> 492 <term> 493 <emphasis remap='I'>display</emphasis> 494 </term> 495 <listitem> 496 <para> 497Specifies the connection to the X server. 498 </para> 499 </listitem> 500 </varlistentry> 501 <varlistentry> 502 <term> 503 <emphasis remap='I'>device</emphasis> 504 </term> 505 <listitem> 506 <para> 507Specifies the desired device. 508 </para> 509 </listitem> 510 </varlistentry> 511</variablelist> 512</para> 513<para> 514<!-- .LP --> 515<!-- .eM --> 516If no error occurs, 517<function>XChangeKeyboardDevice</function> 518returns 519<function>Success .</function> 520A 521<function>ChangeDeviceNotify</function> 522event with the request field set to 523<function>NewKeyboard</function> 524is sent to all clients selecting that event. 525A 526<function>MappingNotify</function> 527event with the request field set to 528<function>MappingKeyboard</function> 529is sent to all clients. 530The requested device becomes the X keyboard, and the old keyboard becomes 531available as an extension input device. 532The focus state of the new keyboard is the same as 533the focus state of the old X keyboard. 534</para> 535<para> 536<!-- .LP --> 537<function>XChangeKeyboardDevice</function> 538can generate 539<function>AlreadyGrabbed ,</function> 540<function>BadDevice ,</function> 541<function>BadMatch ,</function> 542and 543<function>GrabFrozen</function> 544errors. 545<!-- .sp --> 546</para> 547<para> 548<!-- .LP --> 549To change which physical device is used as the X pointer, 550use the 551<function>XChangePointerDevice</function> 552function. 553The specified device must support input class 554<function>Valuators</function> 555(as reported in the 556<function>XListInputDevices</function> 557request) and report at least two axes of motion, 558or the request will fail with a 559<function>BadMatch</function> 560error. 561If the specified device reports more than two axes, the two specified in 562the xaxis and yaxis arguments will be used. Data from other 563valuators on the device will be ignored. 564</para> 565<para> 566<!-- .LP --> 567If the specified device reports absolute positional information, and the 568server implementation does not allow such a device to be used as the 569X pointer, the request will fail with a 570<function>BadDevice</function> 571error. 572<!-- .sM --> 573<funcsynopsis> 574<funcprototype> 575 <funcdef>int <function> XChangePointerDevice</function></funcdef> 576 <paramdef>Display<parameter> *display</parameter></paramdef> 577 <paramdef>XDevice<parameter> *device</parameter></paramdef> 578 <paramdef>int<parameter> xaxis</parameter></paramdef> 579 <paramdef>int<parameter> yaxis</parameter></paramdef> 580</funcprototype> 581</funcsynopsis> 582<!-- .FN --> 583<variablelist> 584 <varlistentry> 585 <term> 586 <emphasis remap='I'>display</emphasis> 587 </term> 588 <listitem> 589 <para> 590Specifies the connection to the X server. 591 </para> 592 </listitem> 593 </varlistentry> 594 <varlistentry> 595 <term> 596 <emphasis remap='I'>device</emphasis> 597 </term> 598 <listitem> 599 <para> 600Specifies the desired device. 601 </para> 602 </listitem> 603 </varlistentry> 604 <varlistentry> 605 <term> 606 <emphasis remap='I'>xaxis</emphasis> 607 </term> 608 <listitem> 609 <para> 610Specifies the zero-based index of the axis to be used as the x-axis of the 611pointer device. 612 </para> 613 </listitem> 614 </varlistentry> 615 <varlistentry> 616 <term> 617 <emphasis remap='I'>yaxis</emphasis> 618 </term> 619 <listitem> 620 <para> 621Specifies the zero-based index of the axis to be used as the y-axis of the 622pointer device. 623 </para> 624 </listitem> 625 </varlistentry> 626</variablelist> 627</para> 628<para> 629<!-- .LP --> 630<!-- .eM --> 631If no error occurs, 632<function>XChangePointerDevice</function> 633returns 634<function>Success .</function> 635A 636<function>ChangeDeviceNotify</function> 637event with the request field set to 638<function>NewPointer</function> 639is sent to all clients selecting that event. 640A 641<function>MappingNotify</function> 642event with the request field set to 643<function>MappingPointer</function> 644is sent to all clients. 645The requested device becomes the X pointer, and the old pointer becomes 646available as an extension input device. 647</para> 648<para> 649<!-- .LP --> 650<function>XChangePointerDevice</function> 651can generate 652<function>AlreadyGrabbed ,</function> 653<function>BadDevice ,</function> 654<function>BadMatch ,</function> 655and 656<function>GrabFrozen</function> 657errors. 658</para> 659</sect3> 660<sect3 id="Event_Synchronization_and_Core_Grabs"> 661<title>Event Synchronization and Core Grabs</title> 662<!-- .XS --> 663<!-- (SN Event Synchronization and Core Grabs --> 664<!-- .XE --> 665<para> 666<!-- .LP --> 667Implementation of the input extension requires an extension of the 668meaning of event synchronization for the core grab requests. This is 669necessary in order to allow window managers to freeze all input devices 670with a single request. 671</para> 672<para> 673<!-- .LP --> 674The core grab requests require a pointer_mode and keyboard_mode 675argument. The meaning of these modes is changed by the input extension. 676For the 677<function>XGrabPointer</function> 678and 679<function>XGrabButton</function> 680requests, pointer_mode controls synchronization of the pointer device, 681and keyboard_mode controls the synchronization of all other input devices. 682For the 683<function>XGrabKeyboard</function> 684and 685<function>XGrabKey</function> 686requests, pointer_mode controls the synchronization 687of all input devices, except the X keyboard, while keyboard_mode controls 688the synchronization of the keyboard. When using one of the core grab 689requests, the synchronization of extension devices 690is controlled by the mode specified for the device not being grabbed. 691</para> 692</sect3> 693<sect3 id="Extension_Active_Grabs"> 694<title>Extension Active Grabs</title> 695<!-- .XS --> 696<!-- (SN Extension Active Grabs --> 697<!-- .XE --> 698<para> 699<!-- .LP --> 700Active grabs of 701extension devices are supported via the 702<function>XGrabDevice</function> 703function in the same way that core devices are grabbed using the core 704<function>XGrabKeyboard</function> 705function, except that an extension input device 706is passed as a function parameter. 707The 708<function>XUngrabDevice</function> 709function allows a previous active grab for an extension device to be released. 710</para> 711<para> 712<!-- .LP --> 713Passive grabs of buttons and keys on extension devices are supported 714via the 715<function>XGrabDeviceButton</function> 716and 717<function>XGrabDeviceKey</function> 718functions. 719These passive grabs are released via the 720<function>XUngrabDeviceKey</function> 721and 722<function>XUngrabDeviceButton</function> 723functions. 724<!-- .sp --> 725</para> 726<para> 727<!-- .LP --> 728To grab an extension device, use the 729<function>XGrabDevice</function> 730function. 731The device must have previously been opened using the 732<function>XOpenDevice</function> 733function. 734<!-- .sM --> 735<funcsynopsis> 736<funcprototype> 737 <funcdef>int <function> XGrabDevice</function></funcdef> 738 <paramdef>Display<parameter> *display</parameter></paramdef> 739 <paramdef>XDevice<parameter> *device</parameter></paramdef> 740 <paramdef>Window<parameter> grab_window</parameter></paramdef> 741 <paramdef>Bool<parameter> owner_events</parameter></paramdef> 742 <paramdef>int<parameter> event_count</parameter></paramdef> 743 <paramdef>XEventClass<parameter> *event_list</parameter></paramdef> 744 <paramdef>int<parameter> this_device_mode</parameter></paramdef> 745 <paramdef>int<parameter> other_device_mode</parameter></paramdef> 746 <paramdef>Time<parameter> time</parameter></paramdef> 747</funcprototype> 748</funcsynopsis> 749<!-- .FN --> 750<variablelist> 751 <varlistentry> 752 <term> 753 "<emphasis remap='I'>display</emphasis>" 754 </term> 755 <listitem> 756 <para> 757Specifies the connection to the X server. 758 </para> 759 </listitem> 760 </varlistentry> 761 <varlistentry> 762 <term> 763 <emphasis remap='I'>device</emphasis> 764 </term> 765 <listitem> 766 <para> 767Specifies the desired device. 768 </para> 769 </listitem> 770 </varlistentry> 771 <varlistentry> 772 <term> 773 <emphasis remap='I'>grab_window</emphasis> 774 </term> 775 <listitem> 776 <para> 777Specifies the ID of a window associated with the device specified above. 778 </para> 779 </listitem> 780 </varlistentry> 781 <varlistentry> 782 <term> 783 <emphasis remap='I'>owner_events</emphasis> 784 </term> 785 <listitem> 786 <para> 787Specifies a boolean value of either 788<function>True</function> 789or 790<function>False .</function> 791 </para> 792 </listitem> 793 </varlistentry> 794 <varlistentry> 795 <term> 796 <emphasis remap='I'>event_count</emphasis> 797 </term> 798 <listitem> 799 <para> 800Specifies the number of elements in the event_list array. 801 </para> 802 </listitem> 803 </varlistentry> 804 <varlistentry> 805 <term> 806 <emphasis remap='I'>event_list</emphasis> 807 </term> 808 <listitem> 809 <para> 810Specifies a pointer to a list of event classes that indicate which events 811the client wishes to receive. 812These event classes must have been obtained 813using the device being grabbed. 814 </para> 815 </listitem> 816 </varlistentry> 817 <varlistentry> 818 <term> 819 <emphasis remap='I'>this_device_mode</emphasis> 820 </term> 821 <listitem> 822 <para> 823Controls further processing of events from this device. You can pass one 824of these constants: 825<function>GrabModeSync</function> 826or 827<function>GrabModeAsync .</function> 828 </para> 829 </listitem> 830 </varlistentry> 831 <varlistentry> 832 <term> 833 <emphasis remap='I'>other_device_mode</emphasis> 834 </term> 835 <listitem> 836 <para> 837Controls further processing of events from all other devices. You can pass one 838of these constants: 839<function>GrabModeSync</function> 840or 841<function>GrabModeAsync .</function> 842 </para> 843 </listitem> 844 </varlistentry> 845 <varlistentry> 846 <term> 847 <emphasis remap='I'>time</emphasis> 848 </term> 849 <listitem> 850 <para> 851Specifies the time. This may be either a timestamp expressed in 852milliseconds or 853<function>CurrentTime .</function> 854 </para> 855 </listitem> 856 </varlistentry> 857</variablelist> 858</para> 859<para> 860<!-- .LP --> 861<!-- .eM --> 862<function>XGrabDevice</function> 863actively grabs an extension input device and generates 864<function>DeviceFocusIn</function> 865and 866<function>DeviceFocusOut</function> 867events. 868Further input events from this device are reported only to the grabbing client. 869This function overrides any previous active grab by this client for this device. 870</para> 871<para> 872<!-- .LP --> 873The event_list parameter is a pointer to a list of event classes. This list 874indicates which events the client wishes to receive while the grab is active. 875If owner_events is 876<function>False ,</function> 877input events from this device are reported with respect to 878grab_window and are reported only if specified in event_list. 879If owner_events is 880<function>True ,</function> 881then if a generated event would normally be reported to this client, 882it is reported normally. 883Otherwise, the event is reported with respect to the grab_window and is only 884reported if specified in event_list. 885</para> 886<para> 887<!-- .LP --> 888The this_device_mode argument controls the further processing 889of events from this device, and the other_device_mode argument controls 890the further processing of input events from all other devices. 891</para> 892<itemizedlist> 893 <listitem> 894 <para> 895If the this_device_mode argument is 896<function>GrabModeAsync ,</function> 897device event processing continues 898normally; if the device is currently frozen by this client, then 899processing of device events is resumed. 900If the this_device_mode argument is 901<function>GrabModeSync ,</function> 902the state of the grabbed device 903(as seen by client applications) appears to freeze, 904and no further device events are generated by the server until the 905grabbing client issues a releasing 906<function>XAllowDeviceEvents</function> 907call or until the device grab is released. 908Actual device input events are not lost while the device is frozen; they are 909simply queued for later processing. 910 </para> 911 </listitem> 912 <listitem> 913 <para> 914If the other_device_mode is 915<function>GrabModeAsync ,</function> 916event processing from other input devices is unaffected 917by activation of the grab. 918If other_device_mode is 919<function>GrabModeSync ,</function> 920the state of all devices except the grabbed device 921(as seen by client applications) appears to freeze, and no further 922events are generated by the server until the grabbing client issues a 923releasing 924<function>XAllowEvents</function> 925or 926<function>XAllowDeviceEvents</function> 927call or until the device grab is released. 928Actual events are not lost 929while the other devices are frozen; they are simply queued for later 930processing. 931 </para> 932 </listitem> 933</itemizedlist> 934<para> 935<!-- .LP --> 936<function>XGrabDevice</function> 937fails on the following conditions: 938</para> 939<itemizedlist> 940 <listitem> 941 <para> 942If the device is actively grabbed by some other client, it returns 943<function>AlreadyGrabbed .</function> 944 </para> 945 </listitem> 946 <listitem> 947 <para> 948If grab_window is not viewable, it returns 949<function>GrabNotViewable .</function> 950 </para> 951 </listitem> 952 <listitem> 953 <para> 954If the specified time is earlier 955than the last-grab-time for the specified device 956or later than the current X server time, it returns 957<function>GrabInvalidTime .</function> 958Otherwise, 959the last-grab-time for the specified device is set 960to the specified time and 961<function>CurrentTime</function> 962is replaced by the current X server time. 963 </para> 964 </listitem> 965 <listitem> 966 <para> 967If the device is frozen by an active grab of another client, it returns 968<function>GrabFrozen .</function> 969 </para> 970 </listitem> 971</itemizedlist> 972<para> 973<!-- .LP --> 974If a grabbed device is closed by a client while an active grab by that 975client is in effect, that active grab will be released. 976Any passive grabs established by that client will be released. 977If the device is frozen only by an active grab 978of the requesting client, it is thawed. 979</para> 980<para> 981<!-- .LP --> 982<function>XGrabDevice</function> 983can generate 984<function>BadClass ,</function> 985<function>BadDevice ,</function> 986<function>BadValue ,</function> 987and 988<function>BadWindow</function> 989errors. 990<!-- .sp --> 991</para> 992<para> 993<!-- .LP --> 994To release a grab of an extension device, use the 995<function>XUngrabDevice</function> 996function. 997</para> 998<para> 999<!-- .LP --> 1000<!-- .sM --> 1001<funcsynopsis> 1002<funcprototype> 1003 <funcdef>int <function> XUngrabDevice</function></funcdef> 1004 <paramdef>Display<parameter> *display</parameter></paramdef> 1005 <paramdef>XDevice<parameter> *device</parameter></paramdef> 1006 <paramdef>Time<parameter> time</parameter></paramdef> 1007</funcprototype> 1008</funcsynopsis> 1009<!-- .FN --> 1010<variablelist> 1011 <varlistentry> 1012 <term> 1013 <emphasis remap='I'>display</emphasis> 1014 </term> 1015 <listitem> 1016 <para> 1017Specifies the connection to the X server. 1018 </para> 1019 </listitem> 1020 </varlistentry> 1021 <varlistentry> 1022 <term> 1023 <emphasis remap='I'>device</emphasis> 1024 </term> 1025 <listitem> 1026 <para> 1027Specifies the desired device. 1028 </para> 1029 </listitem> 1030 </varlistentry> 1031 <varlistentry> 1032 <term> 1033 <emphasis remap='I'>time</emphasis> 1034 </term> 1035 <listitem> 1036 <para> 1037Specifies the time. This may be either a timestamp expressed in 1038milliseconds, or 1039<function>CurrentTime .</function> 1040 </para> 1041 </listitem> 1042 </varlistentry> 1043</variablelist> 1044</para> 1045<para> 1046<!-- .LP --> 1047<!-- .eM --> 1048<function>XUngrabDevice</function> 1049allows a client to release an extension input device and any 1050queued events if this client has it grabbed from either 1051<function>XGrabDevice</function> 1052or 1053<function>XGrabDeviceKey .</function> 1054If any other devices are frozen by the grab, 1055<function>XUngrabDevice</function> 1056thaws them. 1057This function does not release the device and any 1058queued events if the specified time is earlier than the last-device-grab 1059time or is later than the current X server time. It also generates 1060<function>DeviceFocusIn</function> 1061and 1062<function>DeviceFocusOut</function> 1063events. The X server automatically performs an 1064<function>XUngrabDevice</function> 1065if the event window for an active device grab becomes not viewable 1066or if the client terminates without releasing the grab. 1067</para> 1068<para> 1069<!-- .LP --> 1070<function>XUngrabDevice</function> 1071can generate 1072<function>BadDevice</function> 1073errors. 1074</para> 1075</sect3> 1076<sect3 id="Passively_Grabbing_a_Key"> 1077<title>Passively Grabbing a Key</title> 1078<!-- .XS --> 1079<!-- (SN Passively Grabbing a Key --> 1080<!-- .XE --> 1081<para> 1082<!-- .LP --> 1083To passively grab a single key on an extension device, use 1084<function>XGrabDeviceKey .</function> 1085That device must have previously been opened using the 1086<function>XOpenDevice</function> 1087function, or the request will fail with a 1088<function>BadDevice</function> 1089error. 1090If the specified device does not support input class 1091<function>Keys ,</function> 1092the request will fail with a 1093<function>BadMatch</function> 1094error. 1095<!-- .sM --> 1096<funcsynopsis> 1097<funcprototype> 1098 <funcdef>int <function> XGrabDeviceKey</function></funcdef> 1099 <paramdef>Display<parameter> *display</parameter></paramdef> 1100 <paramdef>XDevice<parameter> *device</parameter></paramdef> 1101 <paramdef>int<parameter> keycode</parameter></paramdef> 1102 <paramdef>unsignedint<parameter> modifiers</parameter></paramdef> 1103 <paramdef>XDevice<parameter> *modifier_device</parameter></paramdef> 1104 <paramdef>Window<parameter> grab_window</parameter></paramdef> 1105 <paramdef>Bool<parameter> owner_events</parameter></paramdef> 1106 <paramdef>int<parameter> event_count</parameter></paramdef> 1107 <paramdef>XEventClass<parameter> *event_list</parameter></paramdef> 1108 <paramdef>int<parameter> this_device_mode</parameter></paramdef> 1109 <paramdef>int<parameter> other_device_mode</parameter></paramdef> 1110</funcprototype> 1111</funcsynopsis> 1112<!-- .FN --> 1113<variablelist> 1114 <varlistentry> 1115 <term> 1116 <emphasis remap='I'>display</emphasis> 1117 </term> 1118 <listitem> 1119 <para> 1120Specifies the connection to the X server. 1121 </para> 1122 </listitem> 1123 </varlistentry> 1124 <varlistentry> 1125 <term> 1126 <emphasis remap='I'>device</emphasis> 1127 </term> 1128 <listitem> 1129 <para> 1130Specifies the desired device. 1131 </para> 1132 </listitem> 1133 </varlistentry> 1134 <varlistentry> 1135 <term> 1136 <emphasis remap='I'>keycode</emphasis> 1137 </term> 1138 <listitem> 1139 <para> 1140Specifies the keycode of the key that is to be grabbed. You can pass 1141either the keycode or 1142<function>AnyKey .</function> 1143 </para> 1144 </listitem> 1145 </varlistentry> 1146 <varlistentry> 1147 <term> 1148 <emphasis remap='I'>modifiers</emphasis> 1149 </term> 1150 <listitem> 1151 <para> 1152Specifies the set of keymasks. This mask is the bitwise inclusive OR 1153of these keymask bits: 1154<function>ShiftMask ,</function> 1155<function>LockMask ,</function> 1156<function>ControlMask ,</function> 1157<function>Mod1Mask ,</function> 1158<function>Mod2Mask ,</function> 1159<function>Mod3Mask ,</function> 1160<function>Mod4Mask ,</function> 1161and 1162<function>Mod5Mask .</function> 1163 </para> 1164 </listitem> 1165 </varlistentry> 1166 <varlistentry> 1167 <term> 1168 1169 </term> 1170 <listitem> 1171 <para> 1172You can also pass 1173<function>AnyModifier ,</function> 1174which is equivalent to issuing the grab key request 1175for all possible modifier combinations (including the combination 1176of no modifiers). 1177 </para> 1178 </listitem> 1179 </varlistentry> 1180 <varlistentry> 1181 <term> 1182 <emphasis remap='I'>modifier_device</emphasis> 1183 </term> 1184 <listitem> 1185 <para> 1186Specifies the device whose modifiers are to be used. If NULL is 1187specified, the core X keyboard is used as the modifier_device. 1188 </para> 1189 </listitem> 1190 </varlistentry> 1191 <varlistentry> 1192 <term> 1193 <emphasis remap='I'>grab_window</emphasis> 1194 </term> 1195 <listitem> 1196 <para> 1197Specifies the ID of a window associated with the device specified above. 1198 </para> 1199 </listitem> 1200 </varlistentry> 1201 <varlistentry> 1202 <term> 1203 <emphasis remap='I'>owner_events</emphasis> 1204 </term> 1205 <listitem> 1206 <para> 1207Specifies a boolean value of either 1208<function>True</function> 1209or 1210<function>False .</function> 1211 </para> 1212 </listitem> 1213 </varlistentry> 1214 <varlistentry> 1215 <term> 1216 <emphasis remap='I'>event_count</emphasis> 1217 </term> 1218 <listitem> 1219 <para> 1220Specifies the number of elements in the event_list array. 1221 </para> 1222 </listitem> 1223 </varlistentry> 1224 <varlistentry> 1225 <term> 1226 <emphasis remap='I'>event_list</emphasis> 1227 </term> 1228 <listitem> 1229 <para> 1230Specifies a pointer to a list of event classes that indicate which events 1231the client wishes to receive. 1232 </para> 1233 </listitem> 1234 </varlistentry> 1235 <varlistentry> 1236 <term> 1237 <emphasis remap='I'>this_device_mode</emphasis> 1238 </term> 1239 <listitem> 1240 <para> 1241Controls further processing of events from this device. 1242You can pass one of these constants: 1243<function>GrabModeSync</function> 1244or 1245<function>GrabModeAsync .</function> 1246 </para> 1247 </listitem> 1248 </varlistentry> 1249 <varlistentry> 1250 <term> 1251 <emphasis remap='I'>other_device_mode</emphasis> 1252 </term> 1253 <listitem> 1254 <para> 1255Controls further processing of events from all other devices. 1256You can pass one of these constants: 1257<function>GrabModeSync</function> 1258or 1259<function>GrabModeAsync .</function> 1260 </para> 1261 </listitem> 1262 </varlistentry> 1263</variablelist> 1264</para> 1265<para> 1266<!-- .LP --> 1267<!-- .eM --> 1268<function>XGrabDeviceKey</function> 1269is analogous to the core 1270<function>XGrabKey</function> 1271function. It creates an 1272explicit passive grab for a key on an extension device. 1273The 1274<function>XGrabDeviceKey</function> 1275function establishes a passive grab on a device. 1276Consequently, in the future, 1277</para> 1278<itemizedlist> 1279 <listitem> 1280 <para> 1281IF the device is not grabbed and the specified key, 1282which itself can be a modifier key, is logically pressed 1283when the specified modifier keys logically are down on the specified 1284modifier device (and no other keys are down), 1285 </para> 1286 </listitem> 1287 <listitem> 1288 <para> 1289AND no other modifier keys logically are down, 1290 </para> 1291 </listitem> 1292 <listitem> 1293 <para> 1294AND EITHER the grab window is an ancestor of (or is) the focus window 1295or the grab window is a descendent of the focus window and contains the pointer, 1296 </para> 1297 </listitem> 1298 <listitem> 1299 <para> 1300AND a passive grab on the same device and key combination does not exist on any 1301ancestor of the grab window, 1302 </para> 1303 </listitem> 1304 <listitem> 1305 <para> 1306THEN the device is actively grabbed, as for 1307<function>XGrabDevice ,</function> 1308the last-device-grab time is set to the time at which the key was pressed 1309(as transmitted in the 1310<function>DeviceKeyPress</function> 1311event), and the 1312<function>DeviceKeyPress</function> 1313event is reported. 1314 </para> 1315 </listitem> 1316</itemizedlist> 1317<para> 1318<!-- .LP --> 1319The interpretation of the remaining arguments is as for 1320<function>XGrabDevice .</function> 1321The active grab is terminated automatically when the logical state of the 1322device has the specified key released 1323(independent of the logical state of the modifier keys). 1324</para> 1325<para> 1326<!-- .LP --> 1327Note that the logical state of a device (as seen by means of the X protocol) 1328may lag the physical state if device event processing is frozen. 1329</para> 1330<para> 1331<!-- .LP --> 1332A modifier of 1333<function>AnyModifier</function> 1334is equivalent to issuing the request for all 1335possible modifier combinations (including the combination of no modifiers). 1336It is not required that all modifiers specified have 1337currently assigned keycodes. 1338A key of 1339<function>AnyKey</function> 1340is equivalent to issuing 1341the request for all possible keycodes. Otherwise, the key must be in 1342the range specified by min_keycode and max_keycode in the 1343information returned by the 1344<function>XListInputDevices</function> 1345function. 1346If it is not within that range, 1347<function>XGrabDeviceKey</function> 1348generates a 1349<function>BadValue</function> 1350error. 1351</para> 1352<para> 1353<!-- .LP --> 1354<function>XGrabDeviceKey</function> 1355generates a 1356<function>BadAccess</function> 1357error if some other client has issued a 1358<function>XGrabDeviceKey</function> 1359with the same device and key combination on the same window. 1360When using 1361<function>AnyModifier</function> 1362or 1363<function>AnyKey ,</function> 1364the request fails completely and the X server generates a 1365<function>BadAccess</function> 1366error, and no grabs are established if there is a conflicting grab 1367for any combination. 1368</para> 1369<para> 1370<!-- .LP --> 1371<function>XGrabDeviceKey</function> 1372returns 1373<function>Success</function> 1374upon successful completion of the request. 1375</para> 1376<para> 1377<!-- .LP --> 1378<function>XGrabDeviceKey</function> 1379can generate 1380<function>BadAccess ,</function> 1381<function>BadClass ,</function> 1382<function>BadDevice ,</function> 1383<function>BadMatch ,</function> 1384<function>BadValue ,</function> 1385and 1386<function>BadWindow</function> 1387errors. 1388<!-- .sp --> 1389</para> 1390<para> 1391<!-- .LP --> 1392To release a passive grab of a single key on an extension device, use 1393<function>XUngrabDeviceKey .</function> 1394<!-- .sM --> 1395<funcsynopsis> 1396<funcprototype> 1397 <funcdef>int <function> XUngrabDeviceKey</function></funcdef> 1398 <paramdef>Display<parameter> *display</parameter></paramdef> 1399 <paramdef>XDevice<parameter> *device</parameter></paramdef> 1400 <paramdef>int<parameter> keycode</parameter></paramdef> 1401 <paramdef>unsignedint<parameter> modifiers</parameter></paramdef> 1402 <paramdef>XDevice<parameter> *modifier_device</parameter></paramdef> 1403 <paramdef>Window<parameter> ungrab_window</parameter></paramdef> 1404</funcprototype> 1405</funcsynopsis> 1406<!-- .FN --> 1407<variablelist> 1408 <varlistentry> 1409 <term> 1410 <emphasis remap='I'>display</emphasis> 1411 </term> 1412 <listitem> 1413 <para> 1414Specifies the connection to the X server. 1415 </para> 1416 </listitem> 1417 </varlistentry> 1418 <varlistentry> 1419 <term> 1420 <emphasis remap='I'>device</emphasis> 1421 </term> 1422 <listitem> 1423 <para> 1424Specifies the desired device. 1425 </para> 1426 </listitem> 1427 </varlistentry> 1428 <varlistentry> 1429 <term> 1430 <emphasis remap='I'>keycode</emphasis> 1431 </term> 1432 <listitem> 1433 <para> 1434Specifies the keycode of the key that is to be ungrabbed. You can pass 1435either the keycode or 1436<function>AnyKey .</function> 1437 </para> 1438 </listitem> 1439 </varlistentry> 1440 <varlistentry> 1441 <term> 1442 <emphasis remap='I'>modifiers</emphasis> 1443 </term> 1444 <listitem> 1445 <para> 1446Specifies the set of keymasks. This mask is the bitwise inclusive OR 1447of these keymask bits: 1448<function>ShiftMask ,</function> 1449<function>LockMask ,</function> 1450<function>ControlMask , </function> 1451<function>Mod1Mask ,</function> 1452<function>Mod2Mask ,</function> 1453<function>Mod3Mask ,</function> 1454<function>Mod4Mask ,</function> 1455and 1456<function>Mod5Mask .</function> 1457 </para> 1458 </listitem> 1459 </varlistentry> 1460 <varlistentry> 1461 <term> 1462 1463 </term> 1464 <listitem> 1465 <para> 1466You can also pass 1467<function>AnyModifier ,</function> 1468which is equivalent to issuing the ungrab key 1469request for all possible modifier combinations (including the combination 1470of no modifiers). 1471 </para> 1472 </listitem> 1473 </varlistentry> 1474 <varlistentry> 1475 <term> 1476 <emphasis remap='I'>modifier_device</emphasis> 1477 </term> 1478 <listitem> 1479 <para> 1480Specifies the device whose modifiers are to be used. If NULL is 1481specified, the core X keyboard is used as the modifier_device. 1482 </para> 1483 </listitem> 1484 </varlistentry> 1485 <varlistentry> 1486 <term> 1487 <emphasis remap='I'>ungrab_window</emphasis> 1488 </term> 1489 <listitem> 1490 <para> 1491Specifies the ID of a window associated with the device specified above. 1492 </para> 1493 </listitem> 1494 </varlistentry> 1495</variablelist> 1496</para> 1497<para> 1498<!-- .LP --> 1499<!-- .eM --> 1500<function>XUngrabDeviceKey</function> 1501is analogous to the core 1502<function>XUngrabKey</function> 1503function. It releases an explicit passive grab for a key 1504on an extension input device. 1505</para> 1506<para> 1507<!-- .LP --> 1508<function>XUngrabDeviceKey</function> 1509can generate 1510<function>BadAlloc ,</function> 1511<function>BadDevice ,</function> 1512<function>BadMatch ,</function> 1513<function>BadValue ,</function> 1514and 1515<function>BadWindow</function> 1516errors. 1517</para> 1518</sect3> 1519<sect3 id="Passively_Grabbing_a_Button"> 1520<title>Passively Grabbing a Button</title> 1521<!-- .XS --> 1522<!-- (SN Passively Grabbing a Button --> 1523<!-- .XE --> 1524<para> 1525<!-- .LP --> 1526To establish a passive grab for a single button on an extension device, use 1527<function>XGrabDeviceButton .</function> 1528The specified device must have previously been opened using the 1529<function>XOpenDevice</function> 1530function, or the request will fail with a 1531<function>BadDevice</function> 1532error. If the specified device does not support input class 1533<function>Buttons ,</function> 1534the request will fail with a 1535<function>BadMatch</function> 1536error. 1537<!-- .sM --> 1538<funcsynopsis> 1539<funcprototype> 1540 <funcdef>int <function> XGrabDeviceButton</function></funcdef> 1541 <paramdef>Display<parameter> *display</parameter></paramdef> 1542 <paramdef>XDevice<parameter> *device</parameter></paramdef> 1543 <paramdef>unsignedint<parameter> button</parameter></paramdef> 1544 <paramdef>unsignedint<parameter> modifiers</parameter></paramdef> 1545 <paramdef>XDevice*modifier_device<parameter> </parameter></paramdef> 1546 <paramdef>Window<parameter> grab_window</parameter></paramdef> 1547 <paramdef>Bool<parameter> owner_events</parameter></paramdef> 1548 <paramdef>int<parameter> event_count</parameter></paramdef> 1549 <paramdef>XEventClass<parameter> *event_list</parameter></paramdef> 1550 <paramdef>int<parameter> this_device_mode</parameter></paramdef> 1551 <paramdef>int<parameter> other_device_mode</parameter></paramdef> 1552</funcprototype> 1553</funcsynopsis> 1554<!-- .FN --> 1555<variablelist> 1556 <varlistentry> 1557 <term> 1558 <emphasis remap='I'>display</emphasis> 1559 </term> 1560 <listitem> 1561 <para> 1562Specifies the connection to the X server. 1563 </para> 1564 </listitem> 1565 </varlistentry> 1566 <varlistentry> 1567 <term> 1568 <emphasis remap='I'>device</emphasis> 1569 </term> 1570 <listitem> 1571 <para> 1572Specifies the desired device. 1573 </para> 1574 </listitem> 1575 </varlistentry> 1576 <varlistentry> 1577 <term> 1578 <emphasis remap='I'>button</emphasis> 1579 </term> 1580 <listitem> 1581 <para> 1582Specifies the code of the button that is to be grabbed. You can pass 1583either the button or 1584<function>AnyButton .</function> 1585 </para> 1586 </listitem> 1587 </varlistentry> 1588 <varlistentry> 1589 <term> 1590 <emphasis remap='I'>modifiers</emphasis> 1591 </term> 1592 <listitem> 1593 <para> 1594Specifies the set of keymasks. This mask is the bitwise inclusive OR 1595of these keymask bits: 1596<function>ShiftMask ,</function> 1597<function>LockMask ,</function> 1598<function>ControlMask , </function> 1599<function>Mod1Mask ,</function> 1600<function>Mod2Mask ,</function> 1601<function>Mod3Mask ,</function> 1602<function>Mod4Mask ,</function> 1603and 1604<function>Mod5Mask .</function> 1605 </para> 1606 </listitem> 1607 </varlistentry> 1608 <varlistentry> 1609 <term> 1610 1611 </term> 1612 <listitem> 1613 <para> 1614You can also pass 1615<function>AnyModifier ,</function> 1616which is equivalent to issuing the grab request 1617for all possible modifier combinations (including the combination 1618of no modifiers). 1619 </para> 1620 </listitem> 1621 </varlistentry> 1622 <varlistentry> 1623 <term> 1624 <emphasis remap='I'>modifier_device</emphasis> 1625 </term> 1626 <listitem> 1627 <para> 1628Specifies the device whose modifiers are to be used. If NULL is 1629specified, the core X keyboard is used as the modifier_device. 1630 </para> 1631 </listitem> 1632 </varlistentry> 1633 <varlistentry> 1634 <term> 1635 <emphasis remap='I'>grab_window</emphasis> 1636 </term> 1637 <listitem> 1638 <para> 1639Specifies the ID of a window associated with the device specified above. 1640 </para> 1641 </listitem> 1642 </varlistentry> 1643 <varlistentry> 1644 <term> 1645 <emphasis remap='I'>owner_events</emphasis> 1646 </term> 1647 <listitem> 1648 <para> 1649Specifies a boolean value of either 1650<function>True</function> 1651or 1652<function>False .</function> 1653 </para> 1654 </listitem> 1655 </varlistentry> 1656 <varlistentry> 1657 <term> 1658 <emphasis remap='I'>event_count</emphasis> 1659 </term> 1660 <listitem> 1661 <para> 1662Specifies the number of elements in the event_list array. 1663 </para> 1664 </listitem> 1665 </varlistentry> 1666 <varlistentry> 1667 <term> 1668 <emphasis remap='I'>event_list</emphasis> 1669 </term> 1670 <listitem> 1671 <para> 1672Specifies a list of event classes that indicates which device events are to be 1673reported to the client. 1674 </para> 1675 </listitem> 1676 </varlistentry> 1677 <varlistentry> 1678 <term> 1679 <emphasis remap='I'>this_device_mode</emphasis> 1680 </term> 1681 <listitem> 1682 <para> 1683Controls further processing of events from this device. You can pass one 1684of these constants: 1685<function>GrabModeSync</function> 1686or 1687<function>GrabModeAsync .</function> 1688 </para> 1689 </listitem> 1690 </varlistentry> 1691 <varlistentry> 1692 <term> 1693 <emphasis remap='I'>other_device_mode</emphasis> 1694 </term> 1695 <listitem> 1696 <para> 1697Controls further processing of events from all other devices. You can pass one 1698of these constants: 1699<function>GrabModeSync</function> 1700or 1701<function>GrabModeAsync .</function> 1702 </para> 1703 </listitem> 1704 </varlistentry> 1705</variablelist> 1706</para> 1707<para> 1708<!-- .LP --> 1709<!-- .eM --> 1710<function>XGrabDeviceButton </function> 1711is analogous to the core 1712<function>XGrabButton</function> 1713function. 1714It creates an explicit passive grab for a button on an extension input device. 1715Because the server does not track extension devices, 1716no cursor is specified with this request. 1717For the same reason, there is no confine_to parameter. 1718The device must have previously been opened using the 1719<function>XOpenDevice</function> 1720function. 1721</para> 1722<para> 1723<!-- .LP --> 1724The 1725<function>XGrabDeviceButton</function> 1726function establishes a passive grab on a device. 1727Consequently, in the future, 1728</para> 1729<itemizedlist> 1730 <listitem> 1731 <para> 1732IF the device is not grabbed and the specified button is logically pressed 1733when the specified modifier keys logically are down 1734(and no other buttons or modifier keys are down), 1735 </para> 1736 </listitem> 1737 <listitem> 1738 <para> 1739AND EITHER the grab window is an ancestor of (or is) the focus window 1740OR the grab window is a descendent of the focus window and contains the pointer, 1741 </para> 1742 </listitem> 1743 <listitem> 1744 <para> 1745AND a passive grab on the same device and button/key combination does not 1746exist on any ancestor of the grab window, 1747 </para> 1748 </listitem> 1749 <listitem> 1750 <para> 1751THEN the device is actively grabbed, as for 1752<function>XGrabDevice ,</function> 1753the last-grab time is set to the time at which the button was pressed 1754(as transmitted in the 1755<function>DeviceButtonPress</function> 1756event), and the 1757<function>DeviceButtonPress</function> 1758event is reported. 1759 </para> 1760 </listitem> 1761</itemizedlist> 1762<para> 1763<!-- .LP --> 1764The interpretation of the remaining arguments is as for 1765<function>XGrabDevice .</function> 1766The active grab is terminated automatically when logical state of the 1767device has all buttons released (independent of the logical state of 1768the modifier keys). 1769</para> 1770<para> 1771<!-- .LP --> 1772Note that the logical state of a device (as seen by means of the X protocol) 1773may lag the physical state if device event processing is frozen. 1774</para> 1775<para> 1776<!-- .LP --> 1777A modifier of 1778<function>AnyModifier</function> 1779is equivalent to issuing the request for all 1780possible modifier combinations (including the combination of no 1781modifiers). 1782It is not required that all modifiers specified have 1783currently assigned keycodes. 1784A button of 1785<function>AnyButton</function> 1786is equivalent to issuing 1787the request for all possible buttons. 1788Otherwise, it is not required that the 1789specified button be assigned to a physical button. 1790</para> 1791<para> 1792<!-- .LP --> 1793<function>XGrabDeviceButton</function> 1794generates a 1795<function>BadAccess</function> 1796error if some other client has issued a 1797<function>XGrabDeviceButton</function> 1798with the same device and button combination on the same window. 1799When using 1800<function>AnyModifier</function> 1801or 1802<function>AnyButton ,</function> 1803the request fails completely and the X server generates a 1804<function>BadAccess</function> 1805error and no grabs are 1806established if there is a conflicting grab for any combination. 1807</para> 1808<para> 1809<!-- .LP --> 1810<function>XGrabDeviceButton</function> 1811can generate 1812<function>BadAccess , </function> 1813<function>BadClass ,</function> 1814<function>BadDevice ,</function> 1815<function>BadMatch ,</function> 1816<function>BadValue ,</function> 1817and 1818<function>BadWindow</function> 1819errors. 1820<!-- .sp --> 1821</para> 1822<para> 1823<!-- .LP --> 1824To release a passive grab of a button on an extension device, use 1825<function>XUngrabDeviceButton .</function> 1826<!-- .sM --> 1827<funcsynopsis> 1828<funcprototype> 1829 <funcdef>int <function> XUngrabDeviceButton</function></funcdef> 1830 <paramdef>Display<parameter> *display</parameter></paramdef> 1831 <paramdef>XDevice<parameter> *device</parameter></paramdef> 1832 <paramdef>unsignedint<parameter> button</parameter></paramdef> 1833 <paramdef>unsignedint<parameter> modifiers</parameter></paramdef> 1834 <paramdef>XDevice<parameter> *modifier_device</parameter></paramdef> 1835 <paramdef>Window<parameter> ungrab_window</parameter></paramdef> 1836</funcprototype> 1837</funcsynopsis> 1838<!-- .FN --> 1839<variablelist> 1840 <varlistentry> 1841 <term> 1842 <emphasis remap='I'>display</emphasis> 1843 </term> 1844 <listitem> 1845 <para> 1846Specifies the connection to the X server. 1847 </para> 1848 </listitem> 1849 </varlistentry> 1850 <varlistentry> 1851 <term> 1852 <emphasis remap='I'>device</emphasis> 1853 </term> 1854 <listitem> 1855 <para> 1856Specifies the desired device. 1857 </para> 1858 </listitem> 1859 </varlistentry> 1860 <varlistentry> 1861 <term> 1862 <emphasis remap='I'>button</emphasis> 1863 </term> 1864 <listitem> 1865 <para> 1866Specifies the code of the button that is to be ungrabbed. You can pass 1867either a button or 1868<function>AnyButton .</function> 1869 </para> 1870 </listitem> 1871 </varlistentry> 1872 <varlistentry> 1873 <term> 1874 <emphasis remap='I'>modifiers</emphasis> 1875 </term> 1876 <listitem> 1877 <para> 1878Specifies the set of keymasks. This mask is the bitwise inclusive OR 1879of these keymask bits: 1880<function>ShiftMask ,</function> 1881<function>LockMask ,</function> 1882<function>ControlMask , </function> 1883<function>Mod1Mask ,</function> 1884<function>Mod2Mask ,</function> 1885<function>Mod3Mask ,</function> 1886<function>Mod4Mask ,</function> 1887and 1888<function>Mod5Mask .</function> 1889 </para> 1890 </listitem> 1891 </varlistentry> 1892 <varlistentry> 1893 <term> 1894 1895 </term> 1896 <listitem> 1897 <para> 1898You can also pass 1899<function>AnyModifier ,</function> 1900which is equivalent to issuing the ungrab key 1901request for all possible modifier combinations (including the combination 1902of no modifiers). 1903 </para> 1904 </listitem> 1905 </varlistentry> 1906 <varlistentry> 1907 <term> 1908 <emphasis remap='I'>modifier_device</emphasis> 1909 </term> 1910 <listitem> 1911 <para> 1912Specifies the device whose modifiers are to be used. If NULL is 1913specified, the core X keyboard is used as the modifier_device. 1914 </para> 1915 </listitem> 1916 </varlistentry> 1917 <varlistentry> 1918 <term> 1919 <emphasis remap='I'>ungrab_window</emphasis> 1920 </term> 1921 <listitem> 1922 <para> 1923Specifies the ID of a window associated with the device specified above. 1924 </para> 1925 </listitem> 1926 </varlistentry> 1927</variablelist> 1928</para> 1929<para> 1930<!-- .LP --> 1931<!-- .eM --> 1932<function>XUngrabDeviceButton </function> 1933is analogous to the core 1934<function>XUngrabButton</function> 1935function. It releases an explicit passive grab for a button 1936on an extension device. 1937That device must have previously been opened using the 1938<function>XOpenDevice</function> 1939function, or a 1940<function>BadDevice</function> 1941error will result. 1942</para> 1943<para> 1944<!-- .LP --> 1945A modifier of 1946<function>AnyModifier</function> 1947is equivalent to issuing the request for all 1948possible modifier combinations (including the combination of no 1949modifiers). 1950</para> 1951<para> 1952<!-- .LP --> 1953<function>XUngrabDeviceButton </function> 1954can generate 1955<function>BadAlloc , </function> 1956<function>BadDevice ,</function> 1957<function>BadMatch ,</function> 1958<function>BadValue ,</function> 1959and 1960<function>BadWindow</function> 1961errors. 1962</para> 1963</sect3> 1964<sect3 id="Thawing_a_Device"> 1965<title>Thawing a Device</title> 1966<!-- .XS --> 1967<!-- (SN Thawing a Device --> 1968<!-- .XE --> 1969<para> 1970<!-- .LP --> 1971To allow further events to be processed when a device has been frozen, use 1972<function>XAllowDeviceEvents .</function> 1973<!-- .sM --> 1974<funcsynopsis> 1975<funcprototype> 1976 <funcdef>int <function> XAllowDeviceEvents</function></funcdef> 1977 <paramdef>Display<parameter> *display</parameter></paramdef> 1978 <paramdef>XDevice<parameter> *device</parameter></paramdef> 1979 <paramdef>int<parameter> event_mode</parameter></paramdef> 1980 <paramdef>Time<parameter> time</parameter></paramdef> 1981</funcprototype> 1982</funcsynopsis> 1983<!-- .FN --> 1984<variablelist> 1985 <varlistentry> 1986 <term> 1987 <emphasis remap='I'>display</emphasis> 1988 </term> 1989 <listitem> 1990 <para> 1991Specifies the connection to the X server. 1992 </para> 1993 </listitem> 1994 </varlistentry> 1995 <varlistentry> 1996 <term> 1997 <emphasis remap='I'>device</emphasis> 1998 </term> 1999 <listitem> 2000 <para> 2001Specifies the desired device. 2002 </para> 2003 </listitem> 2004 </varlistentry> 2005 <varlistentry> 2006 <term> 2007 <emphasis remap='I'>event_mode</emphasis> 2008 </term> 2009 <listitem> 2010 <para> 2011Specifies the event mode. You can pass one of these constants: 2012<function>AsyncThisDevice ,</function> 2013<function>SyncThisDevice ,</function> 2014<function>AsyncOtherDevices ,</function> 2015<function>ReplayThisDevice ,</function> 2016<function>AsyncAll ,</function> 2017or 2018<function>SyncAll .</function> 2019 </para> 2020 </listitem> 2021 </varlistentry> 2022 <varlistentry> 2023 <term> 2024 <emphasis remap='I'>time</emphasis> 2025 </term> 2026 <listitem> 2027 <para> 2028Specifies the time. This may be either a timestamp expressed in 2029milliseconds, or 2030<function>CurrentTime .</function> 2031 </para> 2032 </listitem> 2033 </varlistentry> 2034</variablelist> 2035</para> 2036<para> 2037<!-- .LP --> 2038<!-- .eM --> 2039<function>XAllowDeviceEvents</function> 2040releases some queued events if the client has caused a device to freeze. 2041It has no effect if the specified time is earlier than the last-grab 2042time of the most recent active grab for the client and device, 2043or if the specified time is later than the current X server time. 2044The following describes the processing that occurs depending on what constant 2045you pass to the event_mode argument: 2046</para> 2047<itemizedlist> 2048 <listitem> 2049 <para> 2050<function>AsyncThisDevice</function> 2051 </para> 2052 </listitem> 2053 <listitem> 2054 <para> 2055If the specified device is frozen by the client, event processing for that 2056continues as usual. If the device is frozen multiple times by the client on 2057behalf of multiple separate grabs, 2058<function>AsyncThisDevice</function> 2059thaws for all. 2060<function>AsyncThisDevice</function> 2061has no effect if the specified device is not frozen by the 2062client, but the device need not be grabbed by the client. 2063 </para> 2064 </listitem> 2065 <listitem> 2066 <para> 2067<function>SyncThisDevice</function> 2068 </para> 2069 </listitem> 2070 <listitem> 2071 <para> 2072If the specified device is frozen and actively grabbed by the client, 2073event processing for that device continues normally until the next 2074key or button event is reported to the client. 2075At this time, 2076the specified device again appears to freeze. 2077However, if the reported event causes the grab to be released, 2078the specified device does not freeze. 2079<function>SyncThisDevice</function> 2080has no effect if the specified device is not frozen by the client 2081or is not grabbed by the client. 2082 </para> 2083 </listitem> 2084 <listitem> 2085 <para> 2086<function>ReplayThisDevice</function> 2087 </para> 2088 </listitem> 2089 <listitem> 2090 <para> 2091If the specified device is actively grabbed by the client 2092and is frozen as the result of an event having been sent to the client 2093(either from the activation of a 2094<function>GrabDeviceButton</function> 2095or from a previous 2096<function>AllowDeviceEvents</function> 2097with mode 2098<function>SyncThisDevice , </function> 2099but not from a 2100<function>Grab ),</function> 2101the grab is released and that event is completely reprocessed. 2102This time, however, the request ignores any passive grabs at or above 2103(toward the root) the grab-window of the grab just released. 2104The request has no effect if the specified device is not grabbed by the client 2105or if it is not frozen as the result of an event. 2106 </para> 2107 </listitem> 2108 <listitem> 2109 <para> 2110<function>AsyncOtherDevices</function> 2111 </para> 2112 </listitem> 2113 <listitem> 2114 <para> 2115If the remaining devices are frozen by the client, 2116event processing for them continues as usual. 2117If the other devices are frozen multiple times by the client on behalf of 2118multiple separate grabs, 2119<function>AsyncOtherDevices</function> 2120``thaws'' for all. 2121<function>AsyncOtherDevices</function> 2122has no effect if the devices are not frozen by the client, 2123but those devices need not be grabbed by the client. 2124 </para> 2125 </listitem> 2126 <listitem> 2127 <para> 2128<function>SyncAll</function> 2129 </para> 2130 </listitem> 2131 <listitem> 2132 <para> 2133If all devices are frozen by the client, 2134event processing (for all devices) continues normally until the next 2135button or key event is reported 2136to the client for a grabbed device, 2137at which time the devices again appear to 2138freeze. However, if the reported event causes the grab to be released, 2139then the devices do not freeze (but if any device is still 2140grabbed, then a subsequent event for it will still cause all devices 2141to freeze). 2142<function>SyncAll</function> 2143has no effect unless all devices are frozen by the client. 2144If any device is frozen twice 2145by the client on behalf of two separate grabs, 2146<function>SyncAll</function> 2147"thaws" for both (but a subsequent freeze for 2148<function>SyncAll</function> 2149will freeze each device only once). 2150 </para> 2151 </listitem> 2152 <listitem> 2153 <para> 2154<function>AsyncAll</function> 2155 </para> 2156 </listitem> 2157 <listitem> 2158 <para> 2159If all devices are frozen by the 2160client, event processing (for all devices) continues normally. 2161If any device is frozen multiple times by the client on behalf of multiple 2162separate grabs, 2163<function>AsyncAll</function> 2164``thaws ''for all. 2165If any device is frozen twice by the client on behalf of two separate grabs, 2166<function>AsyncAll</function> 2167``thaws'' for both. 2168<function>AsyncAll</function> 2169has no effect unless all devices are frozen by the client. 2170 </para> 2171 </listitem> 2172</itemizedlist> 2173<para> 2174<!-- .LP --> 2175<function>AsyncThisDevice ,</function> 2176<function>SyncThisDevice ,</function> 2177and 2178<function>ReplayThisDevice </function> 2179have no effect on the processing of events from the remaining devices. 2180<function>AsyncOtherDevices</function> 2181has no effect on the processing of events from the specified device. 2182When the event_mode is 2183<function>SyncAll</function> 2184or 2185<function>AsyncAll ,</function> 2186the device parameter is ignored. 2187</para> 2188<para> 2189<!-- .LP --> 2190It is possible for several grabs of different devices (by the same 2191or different clients) to be active simultaneously. 2192If a device is frozen on behalf of any grab, 2193no event processing is performed for the device. 2194It is possible for a single device to be frozen because of several grabs. 2195In this case, 2196the freeze must be released on behalf of each grab before events can 2197again be processed. 2198</para> 2199<para> 2200<!-- .LP --> 2201<function>XAllowDeviceEvents</function> 2202can generate 2203<function>BadDevice</function> 2204and 2205<function>BadValue</function> 2206errors. 2207</para> 2208</sect3> 2209<sect3 id="Controlling_Device_Focus"> 2210<title>Controlling Device Focus</title> 2211<!-- .XS --> 2212<!-- (SN Controlling Device Focus --> 2213<!-- .XE --> 2214<para> 2215<!-- .LP --> 2216The current focus window for an extension input device can be 2217determined using the 2218<function>XGetDeviceFocus</function> 2219function. 2220Extension devices are focused using the 2221<function>XSetDeviceFocus</function> 2222function in the same way that the keyboard is focused using the core 2223<function>XSetInputFocus</function> 2224function, except that a device ID is passed as 2225a function parameter. One additional focus state, 2226<function>FollowKeyboard ,</function> 2227is provided for extension devices. 2228</para> 2229<para> 2230<!-- .LP --> 2231To get the current focus state, revert state, 2232and focus time of an extension device, use 2233<function>XGetDeviceFocus .</function> 2234<!-- .sM --> 2235<funcsynopsis> 2236<funcprototype> 2237 <funcdef>int <function> XGetDeviceFocus</function></funcdef> 2238 <paramdef>Display<parameter> *display</parameter></paramdef> 2239 <paramdef>XDevice<parameter> *device</parameter></paramdef> 2240 <paramdef>Window<parameter> *focus_return</parameter></paramdef> 2241 <paramdef>int<parameter> *revert_to_return</parameter></paramdef> 2242 <paramdef>Time<parameter> *focus_time_return</parameter></paramdef> 2243</funcprototype> 2244</funcsynopsis> 2245<!-- .FN --> 2246<variablelist> 2247 <varlistentry> 2248 <term> 2249 <emphasis remap='I'>display</emphasis> 2250 </term> 2251 <listitem> 2252 <para> 2253Specifies the connection to the X server. 2254 </para> 2255 </listitem> 2256 </varlistentry> 2257 <varlistentry> 2258 <term> 2259 <emphasis remap='I'>device</emphasis> 2260 </term> 2261 <listitem> 2262 <para> 2263Specifies the desired device. 2264 </para> 2265 </listitem> 2266 </varlistentry> 2267 <varlistentry> 2268 <term> 2269 <emphasis remap='I'>focus_return</emphasis> 2270 </term> 2271 <listitem> 2272 <para> 2273Specifies the address of a variable into which the server can return the ID of 2274the window that contains the device focus or one of the constants 2275<function>None ,</function> 2276<function>PointerRoot ,</function> 2277or 2278<function>FollowKeyboard . </function> 2279 </para> 2280 </listitem> 2281 </varlistentry> 2282 <varlistentry> 2283 <term> 2284 <emphasis remap='I'>revert_to_return</emphasis> 2285 </term> 2286 <listitem> 2287 <para> 2288Specifies the address of a variable into which the server can 2289return the current revert_to status for the device. 2290 </para> 2291 </listitem> 2292 </varlistentry> 2293 <varlistentry> 2294 <term> 2295 <emphasis remap='I'>focus_time_return</emphasis> 2296 </term> 2297 <listitem> 2298 <para> 2299Specifies the address of a variable into which the server can 2300return the focus time last set for the device. 2301 </para> 2302 </listitem> 2303 </varlistentry> 2304</variablelist> 2305</para> 2306<para> 2307<!-- .LP --> 2308<!-- .eM --> 2309<function>XGetDeviceFocus</function> 2310returns the focus state, the revert-to state, 2311and the last-focus-time for an extension input device. 2312</para> 2313<para> 2314<!-- .LP --> 2315<function>XGetDeviceFocus</function> 2316can generate 2317<function>BadDevice</function> 2318and 2319<function>BadMatch</function> 2320errors. 2321<!-- .sp --> 2322</para> 2323<para> 2324<!-- .LP --> 2325To set the focus of an extension device, use 2326<function>XSetDeviceFocus .</function> 2327<!-- .sM --> 2328<funcsynopsis> 2329<funcprototype> 2330 <funcdef>int <function> XSetDeviceFocus</function></funcdef> 2331 <paramdef>Display<parameter> *display</parameter></paramdef> 2332 <paramdef>XDevice<parameter> *device</parameter></paramdef> 2333 <paramdef>Window<parameter> focus</parameter></paramdef> 2334 <paramdef>int<parameter> revert_to</parameter></paramdef> 2335 <paramdef>Time<parameter> time</parameter></paramdef> 2336</funcprototype> 2337</funcsynopsis> 2338<!-- .FN --> 2339<variablelist> 2340 <varlistentry> 2341 <term> 2342 <emphasis remap='I'>display</emphasis> 2343 </term> 2344 <listitem> 2345 <para> 2346Specifies the connection to the X server. 2347 </para> 2348 </listitem> 2349 </varlistentry> 2350 <varlistentry> 2351 <term> 2352 <emphasis remap='I'>device</emphasis> 2353 </term> 2354 <listitem> 2355 <para> 2356Specifies the desired device. 2357 </para> 2358 </listitem> 2359 </varlistentry> 2360 <varlistentry> 2361 <term> 2362 <emphasis remap='I'>focus</emphasis> 2363 </term> 2364 <listitem> 2365 <para> 2366Specifies the ID of the window to which the device's focus should be set. 2367This may be a window ID, or 2368<function>PointerRoot ,</function> 2369<function>FollowKeyboard ,</function> 2370or 2371<function>None .</function> 2372 </para> 2373 </listitem> 2374 </varlistentry> 2375 <varlistentry> 2376 <term> 2377 <emphasis remap='I'>revert_to</emphasis> 2378 </term> 2379 <listitem> 2380 <para> 2381Specifies to which window the focus of the device should revert 2382if the focus window becomes not viewable. One of the following 2383constants may be passed: 2384<function>RevertToParent ,</function> 2385<function>RevertToPointerRoot ,</function> 2386<function>RevertToNone ,</function> 2387or 2388<function>RevertToFollowKeyboard .</function> 2389 </para> 2390 </listitem> 2391 </varlistentry> 2392 <varlistentry> 2393 <term> 2394 <emphasis remap='I'>time</emphasis> 2395 </term> 2396 <listitem> 2397 <para> 2398Specifies the time. You can pass either a timestamp, expressed in 2399milliseconds, or 2400<function>CurrentTime .</function> 2401 </para> 2402 </listitem> 2403 </varlistentry> 2404</variablelist> 2405</para> 2406<para> 2407<!-- .LP --> 2408<!-- .eM --> 2409<function>XSetDeviceFocus</function> 2410changes the focus for an extension input device and the 2411last-focus-change-time. It has no effect if the specified 2412time is earlier than the last-focus-change-time or is later than the 2413current X server time. Otherwise, the last-focus-change-time is set to the 2414specified time. 2415This function causes the X server to generate 2416<function>DeviceFocusIn</function> 2417and 2418<function>DeviceFocusOut</function> 2419events. 2420</para> 2421<para> 2422<!-- .LP --> 2423The action taken by the server when this function is requested depends 2424on the value of the focus argument: 2425</para> 2426<itemizedlist> 2427 <listitem> 2428 <para> 2429If the focus argument is 2430<function>None ,</function> 2431all input events from this device will be discarded until a new focus window 2432is set. In this case, the revert_to argument is ignored. 2433 </para> 2434 </listitem> 2435 <listitem> 2436 <para> 2437If the focus argument is a window ID, it becomes the focus 2438window of the device. If an input event from the device would normally 2439be reported to this window or to one of its inferiors, the event is 2440reported normally. Otherwise, the event is reported relative to the focus 2441window. 2442 </para> 2443 </listitem> 2444 <listitem> 2445 <para> 2446If the focus argument is 2447<function>PointerRoot ,</function> 2448the focus window is dynamically taken to be the root window 2449of whatever screen the pointer is on at each input event. 2450In this case, the revert_to argument is ignored. 2451 </para> 2452 </listitem> 2453 <listitem> 2454 <para> 2455If the focus argument is 2456<function>FollowKeyboard , </function> 2457the focus window is dynamically taken to be the same as the focus 2458of the X keyboard at each input event. 2459 </para> 2460 </listitem> 2461</itemizedlist> 2462<para> 2463<!-- .LP --> 2464The specified focus window must be viewable at the time 2465<function>XSetDeviceFocus</function> 2466is called. Otherwise, it generates a 2467<function>BadMatch</function> 2468error. 2469If the focus window later becomes not viewable, 2470the X server evaluates the revert_to argument 2471to determine the new focus window. 2472</para> 2473<itemizedlist> 2474 <listitem> 2475 <para> 2476If the revert_to argument is 2477<function>RevertToParent ,</function> 2478the focus reverts to the parent (or the closest viewable ancestor), 2479and the new revert_to value is taken to be 2480<function>RevertToNone . </function> 2481 </para> 2482 </listitem> 2483 <listitem> 2484 <para> 2485If the revert_to argument is 2486<function>RevertToPointerRoot ,</function> 2487<function>RevertToFollowKeyboard ,</function> 2488or 2489<function>RevertToNone ,</function> 2490the focus reverts to that value. 2491 </para> 2492 </listitem> 2493</itemizedlist> 2494<para> 2495<!-- .LP --> 2496When the focus reverts, 2497the X server generates 2498<function>DeviceFocusIn</function> 2499and 2500<function>DeviceFocusOut</function> 2501events, but the last-focus-change time is not affected. 2502</para> 2503<para> 2504<!-- .LP --> 2505<function>XSetDeviceFocus</function> 2506can generate 2507<function>BadDevice ,</function> 2508<function>BadMatch , </function> 2509<function>BadValue ,</function> 2510and 2511<function>BadWindow</function> 2512errors. 2513</para> 2514</sect3> 2515<sect3 id="Controlling_Device_Feedback"> 2516<title>Controlling Device Feedback</title> 2517<!-- .XS --> 2518<!-- (SN Controlling Device Feedback --> 2519<!-- .XE --> 2520<para> 2521<!-- .LP --> 2522To determine the current feedback settings of an extension input device, use 2523<function>XGetFeedbackControl .</function> 2524<!-- .sM --> 2525<funcsynopsis> 2526<funcprototype> 2527 <funcdef>XFeedbackState * <function> XGetFeedbackControl</function></funcdef> 2528 <paramdef>Display<parameter> *display</parameter></paramdef> 2529 <paramdef>XDevice<parameter> *device</parameter></paramdef> 2530 <paramdef>int<parameter> *num_feedbacks_return</parameter></paramdef> 2531</funcprototype> 2532</funcsynopsis> 2533<!-- .FN --> 2534<variablelist> 2535 <varlistentry> 2536 <term> 2537 <emphasis remap='I'>display</emphasis> 2538 </term> 2539 <listitem> 2540 <para> 2541Specifies the connection to the X server. 2542 </para> 2543 </listitem> 2544 </varlistentry> 2545 <varlistentry> 2546 <term> 2547 <emphasis remap='I'>device</emphasis> 2548 </term> 2549 <listitem> 2550 <para> 2551Specifies the desired device. 2552 </para> 2553 </listitem> 2554 </varlistentry> 2555 <varlistentry> 2556 <term> 2557 <emphasis remap='I'>num_feedbacks_return</emphasis> 2558 </term> 2559 <listitem> 2560 <para> 2561Returns the number of feedbacks supported by the device. 2562 </para> 2563 </listitem> 2564 </varlistentry> 2565</variablelist> 2566</para> 2567<para> 2568<!-- .LP --> 2569<!-- .eM --> 2570<function>XGetFeedbackControl</function> 2571returns a list of 2572<function>FeedbackState</function> 2573structures that describe the feedbacks supported by the specified device. 2574There is an 2575<function>XFeedbackState</function> 2576structure for each class of feedback. These are of 2577variable length, but the first three members are common to all. 2578</para> 2579<para> 2580<!-- .LP --> 2581<!-- .sM --> 2582<literallayout class="monospaced"> 2583<!-- .TA .5i --> 2584<!-- .ta .5i --> 2585typedef struct { 2586 XID class; 2587 int length; 2588 XID id; 2589} XFeedbackState; 2590</literallayout> 2591</para> 2592<para> 2593<!-- .LP --> 2594<!-- .eM --> 2595The common members are as follows: 2596</para> 2597<itemizedlist> 2598 <listitem> 2599 <para> 2600The class member identifies the class of feedback. 2601It may be compared to constants defined in the file 2602<function>< X11/extensions/XI.h >.</function> 2603Currently defined feedback constants include: 2604<function>KbdFeedbackClass , </function> 2605<function>PtrFeedbackClass ,</function> 2606<function>StringFeedbackClass ,</function> 2607<function>IntegerFeedbackClass , </function> 2608<function>LedFeedbackClass ,</function> 2609and 2610<function>BellFeedbackClass .</function> 2611 </para> 2612 </listitem> 2613 <listitem> 2614 <para> 2615The length member specifies the length of the 2616<function>FeedbackState</function> 2617structure and can be used by clients to traverse the list. 2618 </para> 2619 </listitem> 2620 <listitem> 2621 <para> 2622The id member uniquely identifies a feedback for a given device and class. 2623This allows a device to support more than one feedback of the same class. 2624Other feedbacks of other classes or devices may have the same ID. 2625<!-- .sp --> 2626 </para> 2627 </listitem> 2628</itemizedlist> 2629<para> 2630<!-- .LP --> 2631Those feedbacks equivalent to those 2632supported by the core keyboard are reported in class 2633<function>KbdFeedback</function> 2634using the 2635<function>XKbdFeedbackState</function> 2636structure, which is defined as follows: 2637</para> 2638<para> 2639<!-- .LP --> 2640<!-- .sM --> 2641<literallayout class="monospaced"> 2642<!-- .TA .5i --> 2643<!-- .ta .5i --> 2644typedef struct { 2645 XID class; 2646 int length; 2647 XID id; 2648 int click; 2649 int percent; 2650 int pitch; 2651 int duration; 2652 int led_mask; 2653 int global_auto_repeat; 2654 char auto_repeats[32]; 2655} XKbdFeedbackState; 2656</literallayout> 2657</para> 2658<para> 2659<!-- .LP --> 2660<!-- .eM --> 2661The additional members of the 2662<function>XKbdFeedbackState</function> 2663structure report the current state of the feedback: 2664</para> 2665<itemizedlist> 2666 <listitem> 2667 <para> 2668The click member specifies the key-click volume and has a value in the range 26690 (off) to 100 (loud). 2670 </para> 2671 </listitem> 2672 <listitem> 2673 <para> 2674The percent member specifies the bell volume and has a value in the range 26750 (off) to 100 (loud). 2676 </para> 2677 </listitem> 2678 <listitem> 2679 <para> 2680The pitch member specifies the bell pitch in Hz. The range of the value is 2681implementation-dependent. 2682 </para> 2683 </listitem> 2684 <listitem> 2685 <para> 2686The duration member specifies the duration in milliseconds of the bell. 2687 </para> 2688 </listitem> 2689 <listitem> 2690 <para> 2691The led_mask member is a bit mask that describes the current state of up to 269232 LEDs. A value of 1 in a bit indicates that the corresponding LED is on. 2693 </para> 2694 </listitem> 2695 <listitem> 2696 <para> 2697The global_auto_repeat member has a value of 2698<function>AutoRepeatModeOn</function> 2699or 2700<function>AutoRepeatModeOff .</function> 2701 </para> 2702 </listitem> 2703 <listitem> 2704 <para> 2705The auto_repeats member is a bit vector. Each bit set to 1 indicates 2706that auto-repeat is enabled for the corresponding key. The vector is 2707represented as 32 bytes. Byte N (from 0) contains the bits for keys 27088N to 8N + 7, with the least significant bit in the byte representing 2709key 8N. 2710<!-- .sp --> 2711 </para> 2712 </listitem> 2713</itemizedlist> 2714<para> 2715<!-- .LP --> 2716Those feedbacks equivalent to those 2717supported by the core pointer are reported in class 2718<function>PtrFeedback</function> 2719using the 2720<function>XPtrFeedbackState</function> 2721structure, which is defined as follows: 2722</para> 2723<para> 2724<!-- .LP --> 2725<!-- .sM --> 2726<literallayout class="monospaced"> 2727<!-- .TA .5i --> 2728<!-- .ta .5i --> 2729typedef struct { 2730 XID class; 2731 int length; 2732 XID id; 2733 int accelNum; 2734 int accelDenom; 2735 int threshold; 2736} XPtrFeedbackState; 2737</literallayout> 2738</para> 2739<para> 2740<!-- .LP --> 2741<!-- .eM --> 2742The additional members of the 2743<function>XPtrFeedbackState</function> 2744structure report the current state of the feedback: 2745</para> 2746<itemizedlist> 2747 <listitem> 2748 <para> 2749The accelNum member returns the numerator for the acceleration multiplier. 2750 </para> 2751 </listitem> 2752 <listitem> 2753 <para> 2754The accelDenom member returns the denominator for the acceleration multiplier. 2755 </para> 2756 </listitem> 2757 <listitem> 2758 <para> 2759The accelDenom member returns the threshold for the acceleration. 2760<!-- .sp --> 2761 </para> 2762 </listitem> 2763</itemizedlist> 2764<para> 2765<!-- .LP --> 2766Integer feedbacks are those capable of displaying integer numbers 2767and reported via the 2768<function>XIntegerFeedbackState</function> 2769structure. 2770The minimum and maximum values that they can display are reported. 2771</para> 2772<para> 2773<!-- .LP --> 2774<!-- .sM --> 2775<literallayout class="monospaced"> 2776<!-- .TA .5i --> 2777<!-- .ta .5i --> 2778typedef struct { 2779 XID class; 2780 int length; 2781 XID id; 2782 int resolution; 2783 int minVal; 2784 int maxVal; 2785} XIntegerFeedbackState; 2786</literallayout> 2787</para> 2788<para> 2789<!-- .LP --> 2790<!-- .eM --> 2791The additional members of the 2792<function>XIntegerFeedbackState</function> 2793structure report the capabilities of the feedback: 2794</para> 2795<itemizedlist> 2796 <listitem> 2797 <para> 2798The resolution member specifies the number of digits that the feedback 2799can display. 2800 </para> 2801 </listitem> 2802 <listitem> 2803 <para> 2804The minVal member specifies the minimum value that the feedback can display. 2805 </para> 2806 </listitem> 2807 <listitem> 2808 <para> 2809The maxVal specifies the maximum value that the feedback can display. 2810<!-- .sp --> 2811 </para> 2812 </listitem> 2813</itemizedlist> 2814<para> 2815<!-- .LP --> 2816String feedbacks are those that can display character information 2817and are reported via the 2818<function>XStringFeedbackState</function> 2819structure. 2820Clients set these feedbacks by passing a list of 2821<function>KeySyms</function> 2822to be displayed. 2823The 2824<function>XGetFeedbackControl</function> 2825function returns the 2826set of key symbols that the feedback can display, as well as the 2827maximum number of symbols that can be displayed. 2828The 2829<function>XStringFeedbackState</function> 2830structure is defined as follows: 2831</para> 2832<para> 2833<!-- .LP --> 2834<!-- .sM --> 2835<literallayout class="monospaced"> 2836<!-- .TA .5i --> 2837<!-- .ta .5i --> 2838typedef struct { 2839 XID class; 2840 int length; 2841 XID id; 2842 int max_symbols; 2843 int num_syms_supported; 2844 KeySym *syms_supported; 2845} XStringFeedbackState; 2846</literallayout> 2847</para> 2848<para> 2849<!-- .LP --> 2850<!-- .eM --> 2851The additional members of the 2852<function>XStringFeedbackState</function> 2853structure report the capabilities of the feedback: 2854</para> 2855<itemizedlist> 2856 <listitem> 2857 <para> 2858The max_symbols member specifies the maximum number of symbols 2859that can be displayed. 2860 </para> 2861 </listitem> 2862 <listitem> 2863 <para> 2864The syms_supported member is a pointer to the list of supported symbols. 2865 </para> 2866 </listitem> 2867 <listitem> 2868 <para> 2869The num_syms_supported member specifies the length of the list of supported symbols. 2870<!-- .sp --> 2871 </para> 2872 </listitem> 2873</itemizedlist> 2874<para> 2875<!-- .LP --> 2876Bell feedbacks are those that can generate a sound 2877and are reported via the 2878<function>XBellFeedbackState</function> 2879structure. 2880Some implementations may support a bell as part of a 2881<function>KbdFeedback</function> 2882feedback. Class 2883<function>BellFeedback</function> 2884is provided for implementations that do not choose to do 2885so and for devices that support multiple feedbacks that can produce sound. 2886The meaning of the members is the same as that of the corresponding fields in 2887the 2888<function>XKbdFeedbackState</function> 2889structure. 2890</para> 2891<para> 2892<!-- .LP --> 2893<!-- .sM --> 2894<literallayout class="monospaced"> 2895<!-- .TA .5i --> 2896<!-- .ta .5i --> 2897typedef struct { 2898 XID class; 2899 int length; 2900 XID id; 2901 int percent; 2902 int pitch; 2903 int duration; 2904} XBellFeedbackState; 2905</literallayout> 2906</para> 2907<para> 2908<!-- .LP --> 2909<!-- .eM --> 2910Led feedbacks are those that can generate a light and are reported via the 2911<function>XLedFeedbackState</function> 2912structure. 2913Up to 32 lights per feedback are supported. 2914Each bit in led_mask 2915corresponds to one supported light, and the corresponding bit in led_values 2916indicates whether that light is currently on (1) or off (0). 2917Some implementations may support leds as part of a 2918<function>KbdFeedback</function> 2919feedback. 2920Class 2921<function>LedFeedback</function> 2922is provided for implementations that do not choose to do 2923so and for devices that support multiple led feedbacks. 2924</para> 2925<para> 2926<!-- .LP --> 2927<!-- .sM --> 2928<literallayout class="monospaced"> 2929<!-- .TA .5i --> 2930<!-- .ta .5i --> 2931typedef struct { 2932 XID class; 2933 int length; 2934 XID id; 2935 Mask led_values; 2936 Mask led_mask; 2937} XLedFeedbackState; 2938</literallayout> 2939</para> 2940<para> 2941<!-- .LP --> 2942<!-- .eM --> 2943<function>XGetFeedbackControl</function> 2944can generate 2945<function>BadDevice</function> 2946and 2947<function>BadMatch</function> 2948errors. 2949<!-- .sp --> 2950</para> 2951<para> 2952<!-- .LP --> 2953To free the information returned by the 2954<function>XGetFeedbackControl</function> 2955function, use 2956<function>XFreeFeedbackList .</function> 2957<!-- .sM --> 2958<funcsynopsis> 2959<funcprototype> 2960 <funcdef>void <function> XFreeFeedbackList</function></funcdef> 2961 <paramdef>XFeedbackState<parameter> *list</parameter></paramdef> 2962</funcprototype> 2963</funcsynopsis> 2964<!-- .FN --> 2965<variablelist> 2966 <varlistentry> 2967 <term> 2968 <emphasis remap='I'>list</emphasis> 2969 </term> 2970 <listitem> 2971 <para> 2972Specifies the pointer to the 2973<function>XFeedbackState</function> 2974structure returned by 2975a previous call to 2976<function>XGetFeedbackControl .</function> 2977 </para> 2978 </listitem> 2979 </varlistentry> 2980</variablelist> 2981</para> 2982<para> 2983<!-- .LP --> 2984<!-- .eM --> 2985<function>XFreeFeedbackList</function> 2986frees the list of feedback control information. 2987<!-- .sp --> 2988</para> 2989<para> 2990<!-- .LP --> 2991To change the settings of a feedback on an extension device, use 2992<function>XChangeFeedbackControl .</function> 2993This function modifies the current control values of the specified feedback 2994using information passed in the appropriate 2995<function>XFeedbackControl</function> 2996structure for the feedback. 2997Which values are modified depends on the valuemask passed. 2998<!-- .sM --> 2999<funcsynopsis> 3000<funcprototype> 3001 <funcdef>int <function> XChangeFeedbackControl</function></funcdef> 3002 <paramdef>Display<parameter> *display</parameter></paramdef> 3003 <paramdef>XDevice<parameter> *device</parameter></paramdef> 3004 <paramdef>unsignedlong<parameter> valuemask</parameter></paramdef> 3005 <paramdef>XFeedbackControl<parameter> *value</parameter></paramdef> 3006</funcprototype> 3007</funcsynopsis> 3008<!-- .FN --> 3009<variablelist> 3010 <varlistentry> 3011 <term> 3012 <emphasis remap='I'>display</emphasis> 3013 </term> 3014 <listitem> 3015 <para> 3016Specifies the connection to the X server. 3017 </para> 3018 </listitem> 3019 </varlistentry> 3020 <varlistentry> 3021 <term> 3022 <emphasis remap='I'>device</emphasis> 3023 </term> 3024 <listitem> 3025 <para> 3026Specifies the desired device. 3027 </para> 3028 </listitem> 3029 </varlistentry> 3030 <varlistentry> 3031 <term> 3032 <emphasis remap='I'>valuemask</emphasis> 3033 </term> 3034 <listitem> 3035 <para> 3036Specifies one value for each bit in the mask (least to most significant 3037bit). The values are associated with the feedbacks for the specified 3038device. 3039 </para> 3040 </listitem> 3041 </varlistentry> 3042 <varlistentry> 3043 <term> 3044 <emphasis remap='I'>value</emphasis> 3045 </term> 3046 <listitem> 3047 <para> 3048Specifies a pointer to the 3049<function>XFeedbackControl</function> 3050structure. 3051 </para> 3052 </listitem> 3053 </varlistentry> 3054</variablelist> 3055</para> 3056<para> 3057<!-- .LP --> 3058<!-- .eM --> 3059<function>XChangeFeedbackControl</function> 3060controls the device characteristics described by the 3061<function>XFeedbackControl</function> 3062structure. 3063There is an 3064<function>XFeedbackControl</function> 3065structure for each class of feedback. 3066These are of variable length, but the first 3067three members are common to all and are as follows: 3068</para> 3069<para> 3070<!-- .LP --> 3071<!-- .sM --> 3072<literallayout class="monospaced"> 3073<!-- .TA .5i --> 3074<!-- .ta .5i --> 3075typedef struct { 3076 XID class; 3077 int length; 3078 XID id; 3079} XFeedbackControl; 3080</literallayout> 3081</para> 3082<para> 3083<!-- .LP --> 3084<!-- .eM --> 3085Feedback class 3086<function>KbdFeedback</function> 3087controls feedbacks equivalent to those provided by the core keyboard using the 3088<function>KbdFeedbackControl</function> 3089structure, which is defined as follows:. 3090</para> 3091<para> 3092<!-- .LP --> 3093<!-- .sM --> 3094<literallayout class="monospaced"> 3095<!-- .TA .5i --> 3096<!-- .ta .5i --> 3097typedef struct { 3098 XID class; 3099 int length; 3100 XID id; 3101 int click; 3102 int percent; 3103 int pitch; 3104 int duration; 3105 int led_mask; 3106 int led_value; 3107 int key; 3108 int auto_repeat_mode; 3109} XKbdFeedbackControl; 3110</literallayout> 3111</para> 3112<para> 3113<!-- .LP --> 3114<!-- .eM --> 3115This class controls the device characteristics described by the 3116<function>XKbdFeedbackControl</function> 3117structure. These include the key_click_percent, 3118global_auto_repeat, and individual key auto-repeat. Valid modes 3119are 3120<function>AutoRepeatModeOn ,</function> 3121<function>AutoRepeatModeOff ,</function> 3122and 3123<function>AutoRepeatModeDefault .</function> 3124</para> 3125<para> 3126<!-- .LP --> 3127Valid masks are as follows: 3128<!-- .sM --> 3129</para> 3130 3131<literallayout class="monospaced"> 3132 3133#define DvKeyClickPercent (1><<0) 3134#define DvPercent (1><<0) 3135#define DvPitch (1><<0) 3136#define DvDuration (1><<0) 3137#define DvLed (1><<0) 3138#define DvLedMode (1><<0) 3139#define DvKey (1><<0) 3140#define DvAutoRepeatMode (1><<0) 3141</literallayout> 3142 3143<para> 3144<!-- .LP --> 3145Feedback class 3146<function>PtrFeedback</function> 3147controls feedbacks equivalent to those provided by the core pointer using the 3148<function>PtrFeedbackControl</function> 3149structure, which is defined as follows: 3150</para> 3151<para> 3152<!-- .LP --> 3153<!-- .sM --> 3154<literallayout class="monospaced"> 3155<!-- .TA .5i --> 3156<!-- .ta .5i --> 3157typedef struct { 3158 XID class; 3159 int length; 3160 XID id; 3161 int accelNum; 3162 int accelDenom; 3163 int threshold; 3164} XPtrFeedbackControl; 3165</literallayout> 3166</para> 3167<para> 3168<!-- .LP --> 3169<!-- .eM --> 3170Which values are modified depends on the valuemask passed. 3171</para> 3172<para> 3173<!-- .LP --> 3174Valid masks are as follows: 3175<!-- .sM --> 3176</para> 3177 3178<literallayout class="monospaced"> 3179#define DvAccelnum (1L<<0) 3180#define DvAccelDenom (1L<<1) 3181#define DvThreshold (1L<<2) 3182</literallayout> 3183 3184 3185<para> 3186<!-- .LP --> 3187<!-- .eM --> 3188The acceleration, expressed as a fraction, is a multiplier for movement. 3189For example, 3190specifying 3/1 means that the device moves three times as fast as normal. 3191The fraction may be rounded arbitrarily by the X server. 3192Acceleration takes effect only if the device moves more than threshold pixels at 3193once and applies only to the amount beyond the value in the threshold argument. 3194Setting a value to -1 restores the default. 3195The values of the accelNumerator and threshold fields must be nonzero for 3196the pointer values to be set. 3197Otherwise, the parameters will be unchanged. 3198Negative values generate a 3199<function>BadValue</function> 3200error, as does a zero value 3201for the accelDenominator field. 3202</para> 3203<para> 3204<!-- .LP --> 3205This request fails with a 3206<function>BadMatch</function> 3207error if the specified device is not currently reporting relative motion. 3208If a device that is capable of reporting both relative and absolute motion 3209has its mode changed from 3210<function>Relative</function> 3211to 3212<function>Absolute</function> 3213by an 3214<function>XSetDeviceMode</function> 3215request, valuator control values 3216will be ignored by the server while the device is in that mode. 3217</para> 3218<para> 3219<!-- .LP --> 3220Feedback class 3221<function>IntegerFeedback</function> 3222controls integer feedbacks displayed on input devices and are 3223reported via the 3224<function>IntegerFeedbackControl</function> 3225structure, which is defined as follows: 3226</para> 3227<para> 3228<!-- .LP --> 3229<!-- .sM --> 3230<literallayout class="monospaced"> 3231<!-- .TA .5i --> 3232<!-- .ta .5i --> 3233typedef struct { 3234 XID class; 3235 int length; 3236 XID id; 3237 int int_to_display; 3238} XIntegerFeedbackControl; 3239</literallayout> 3240</para> 3241<para> 3242<!-- .LP --> 3243<!-- .eM --> 3244Valid masks are as follows: 3245<!-- .sM --> 3246</para> 3247 3248<literallayout class="monospaced"> 3249 3250#define DvInteger (1L<<0) 3251</literallayout> 3252 3253<para> 3254<!-- .LP --> 3255<!-- .eM --> 3256Feedback class 3257<function>StringFeedback</function> 3258controls string feedbacks displayed on input devices 3259and reported via the 3260<function>StringFeedbackControl</function> 3261structure, which is defined as follows: 3262</para> 3263<para> 3264<!-- .LP --> 3265<!-- .sM --> 3266<literallayout class="monospaced"> 3267<!-- .TA .5i --> 3268<!-- .ta .5i --> 3269typedef struct { 3270 XID class; 3271 int length; 3272 XID id; 3273 int num_keysyms; 3274 KeySym *syms_to_display; 3275} XStringFeedbackControl; 3276</literallayout> 3277</para> 3278<para> 3279<!-- .LP --> 3280<!-- .eM --> 3281Valid masks are as follows: 3282<!-- .sM --> 3283</para> 3284<literallayout class="monospaced"> 3285 3286#define DvString (1L<<0) 3287</literallayout> 3288 3289<para> 3290<!-- .LP --> 3291<!-- .eM --> 3292Feedback class 3293<function>BellFeedback</function> 3294controls a bell on an input device and is reported via the 3295<function>BellFeedbackControl</function> 3296structure, which is defined as follows: 3297</para> 3298<para> 3299<!-- .LP --> 3300<!-- .sM --> 3301<literallayout class="monospaced"> 3302<!-- .TA .5i --> 3303<!-- .ta .5i --> 3304typedef struct { 3305 XID class; 3306 int length; 3307 XID id; 3308 int percent; 3309 int pitch; 3310 int duration; 3311} XBellFeedbackControl; 3312</literallayout> 3313</para> 3314<para> 3315<!-- .LP --> 3316<!-- .eM --> 3317Valid masks are as follows: 3318<!-- .sM --> 3319</para> 3320 3321 3322<literallayout class="monospaced"> 3323 3324#define DvPercent (1L<<1) 3325#define DvPitch (1L<<2) 3326#define DvDuration (1L<<3) 3327</literallayout> 3328 3329<para> 3330<!-- .LP --> 3331<!-- .eM --> 3332Feedback class 3333<function>LedFeedback</function> 3334controls lights on an input device and are reported via the 3335<function>LedFeedbackControl</function> 3336structure, which is defined as follows: 3337</para> 3338<para> 3339<!-- .LP --> 3340<!-- .sM --> 3341<literallayout class="monospaced"> 3342<!-- .TA .5i --> 3343<!-- .ta .5i --> 3344typedef struct { 3345 XID class; 3346 int length; 3347 XID id; 3348 int led_mask; 3349 int led_values; 3350} XLedFeedbackControl; 3351</literallayout> 3352</para> 3353<para> 3354<!-- .LP --> 3355<!-- .eM --> 3356Valid masks are as follows: 3357<!-- .sM --> 3358</para> 3359 3360<literallayout class="monospaced"> 3361 3362#define DvLed (1L<<4) 3363#define DvLedMode (1L<<5) 3364</literallayout> 3365 3366<para> 3367<!-- .LP --> 3368<!-- .eM --> 3369<function>XChangeFeedbackControl</function> 3370can generate 3371<function>BadDevice ,</function> 3372<function>BadFeedBack ,</function> 3373<function>BadMatch ,</function> 3374and 3375<function>BadValue</function> 3376errors. 3377</para> 3378</sect3> 3379<sect3 id="Ringing_a_Bell_on_an_Input_Device"> 3380<title>Ringing a Bell on an Input Device</title> 3381<!-- .XS --> 3382<!-- (SN Ringing a Bell on an Input Device --> 3383<!-- .XE --> 3384<para> 3385<!-- .LP --> 3386To ring a bell on an extension input device, use 3387<function>XDeviceBell .</function> 3388<!-- .sM --> 3389<funcsynopsis> 3390<funcprototype> 3391 <funcdef>int <function> XDeviceBell</function></funcdef> 3392 <paramdef>Display<parameter> *display</parameter></paramdef> 3393 <paramdef>XDevice<parameter> *device</parameter></paramdef> 3394 <paramdef>XIDfeedbackclass,<parameter> feedbackid</parameter></paramdef> 3395 <paramdef>int<parameter> percent</parameter></paramdef> 3396</funcprototype> 3397</funcsynopsis> 3398<!-- .FN --> 3399<variablelist> 3400 <varlistentry> 3401 <term> 3402 <emphasis remap='I'>display</emphasis> 3403 </term> 3404 <listitem> 3405 <para> 3406Specifies the connection to the X server. 3407 </para> 3408 </listitem> 3409 </varlistentry> 3410 <varlistentry> 3411 <term> 3412 <emphasis remap='I'>device</emphasis> 3413 </term> 3414 <listitem> 3415 <para> 3416Specifies the desired device. 3417 </para> 3418 </listitem> 3419 </varlistentry> 3420 <varlistentry> 3421 <term> 3422 <emphasis remap='I'>feedbackclass</emphasis> 3423 </term> 3424 <listitem> 3425 <para> 3426Specifies the feedbackclass. Valid values are 3427<function>KbdFeedbackClass</function> 3428and 3429<function>BellFeedbackClass .</function> 3430 </para> 3431 </listitem> 3432 </varlistentry> 3433 <varlistentry> 3434 <term> 3435 <emphasis remap='I'>feedbackid</emphasis> 3436 </term> 3437 <listitem> 3438 <para> 3439Specifies the ID of the feedback that has the bell. 3440 </para> 3441 </listitem> 3442 </varlistentry> 3443 <varlistentry> 3444 <term> 3445 <emphasis remap='I'>percent</emphasis> 3446 </term> 3447 <listitem> 3448 <para> 3449Specifies the volume in the range -100 (quiet) to 100 percent (loud). 3450 </para> 3451 </listitem> 3452 </varlistentry> 3453</variablelist> 3454</para> 3455<para> 3456<!-- .LP --> 3457<!-- .eM --> 3458<function>XDeviceBell</function> 3459is analogous to the core 3460<function>XBell</function> 3461function. It rings the specified bell on the specified input device feedback, 3462using the specified volume. 3463The specified volume is relative to the base volume for the feedback. 3464If the value for the percent argument is not in the range -100 to 100 3465inclusive, a 3466<function>BadValue</function> 3467error results. 3468The volume at which the bell rings when the percent argument is nonnegative is: 3469</para> 3470<para> 3471<!-- .LP --> 3472<literallayout class="monospaced"> 3473 base - [(base * percent) / 100] + percent 3474</literallayout> 3475</para> 3476<para> 3477<!-- .LP --> 3478The volume at which the bell rings 3479when the percent argument is negative is: 3480</para> 3481<para> 3482<!-- .LP --> 3483<literallayout class="monospaced"> 3484 base + [(base * percent) / 100] 3485</literallayout> 3486</para> 3487<para> 3488<!-- .LP --> 3489To change the base volume of the bell, use 3490<function>XChangeFeedbackControl .</function> 3491</para> 3492<para> 3493<!-- .LP --> 3494<function>XDeviceBell</function> 3495can generate 3496<function>BadDevice</function> 3497and 3498<function>BadValue</function> 3499errors. 3500</para> 3501</sect3> 3502<sect3 id="Controlling_Device_Encoding"> 3503<title>Controlling Device Encoding</title> 3504<!-- .XS --> 3505<!-- (SN Controlling Device Encoding --> 3506<!-- .XE --> 3507<para> 3508<!-- .LP --> 3509To get the key mapping of an extension device that supports input class 3510<function>Keys ,</function> 3511use 3512<function>XGetDeviceKeyMapping .</function> 3513<!-- .sM --> 3514<funcsynopsis> 3515<funcprototype> 3516 <funcdef>KeySym * <function> XGetDeviceKeyMapping</function></funcdef> 3517 <paramdef>Display<parameter> *display</parameter></paramdef> 3518 <paramdef>XDevice<parameter> *device</parameter></paramdef> 3519 <paramdef>KeyCode<parameter> first_keycode_wanted</parameter></paramdef> 3520 <paramdef>int<parameter> keycode_count</parameter></paramdef> 3521 <paramdef>int<parameter> *keysyms_per_keycode_return</parameter></paramdef> 3522</funcprototype> 3523</funcsynopsis> 3524<!-- .FN --> 3525<variablelist> 3526 <varlistentry> 3527 <term> 3528 <emphasis remap='I'>display</emphasis> 3529 </term> 3530 <listitem> 3531 <para> 3532Specifies the connection to the X server. 3533 </para> 3534 </listitem> 3535 </varlistentry> 3536 <varlistentry> 3537 <term> 3538 <emphasis remap='I'>device</emphasis> 3539 </term> 3540 <listitem> 3541 <para> 3542Specifies the desired device. 3543 </para> 3544 </listitem> 3545 </varlistentry> 3546 <varlistentry> 3547 <term> 3548 <emphasis remap='I'>first_keycode_wanted</emphasis> 3549 </term> 3550 <listitem> 3551 <para> 3552Specifies the first keycode that is to be returned. 3553 </para> 3554 </listitem> 3555 </varlistentry> 3556 <varlistentry> 3557 <term> 3558 <emphasis remap='I'>keycode_count</emphasis> 3559 </term> 3560 <listitem> 3561 <para> 3562Specifies the number of keycodes that are to be returned. 3563 </para> 3564 </listitem> 3565 </varlistentry> 3566 <varlistentry> 3567 <term> 3568 <emphasis remap='I'>keysyms_per_keycode_return</emphasis> 3569 </term> 3570 <listitem> 3571 <para> 3572Returns the number of keysyms per keycode. 3573 </para> 3574 </listitem> 3575 </varlistentry> 3576</variablelist> 3577</para> 3578<para> 3579<!-- .LP --> 3580<!-- .eM --> 3581<function>XGetDeviceKeyMapping </function> 3582is analogous to the core 3583<function>XGetKeyboardMapping</function> 3584function. 3585It returns the symbols for the specified number of keycodes for the 3586specified extension device. 3587</para> 3588<para> 3589<!-- .LP --> 3590<function>XGetDeviceKeyMapping </function> 3591returns the symbols for the 3592specified number of keycodes for the 3593specified extension device, starting with the specified keycode. 3594The first_keycode_wanted must be greater than or equal to 3595min-keycode as returned 3596by the 3597<function>XListInputDevices</function> 3598request (else a 3599<function>BadValue</function> 3600error results). The following value: 3601<literallayout class="monospaced"> 3602first_keycode_wanted + keycode_count - 1 3603</literallayout> 3604</para> 3605<para> 3606<!-- .LP --> 3607must be less than or equal to max-keycode as returned 3608by the 3609<function>XListInputDevices</function> 3610request (else a 3611<function>BadValue</function> 3612error results). 3613</para> 3614<para> 3615<!-- .LP --> 3616The number of elements in the keysyms list is as follows: 3617<literallayout class="monospaced"> 3618keycode_count * keysyms_per_keycode_return 3619</literallayout> 3620And KEYSYM number N (counting from zero) for keycode K has an index 3621(counting from zero), in keysyms, of the following: 3622<literallayout class="monospaced"> 3623(K - first_keycode_wanted) * keysyms_per_keycode_return + N 3624</literallayout> 3625</para> 3626<para> 3627<!-- .LP --> 3628The keysyms_per_keycode_return value is chosen arbitrarily by the server 3629to be large enough to report all requested symbols. 3630A special KEYSYM value of 3631<function>NoSymbol</function> 3632is used to fill in unused elements for individual keycodes. 3633</para> 3634<para> 3635<!-- .LP --> 3636To free the data returned by this function, use 3637<function>XFree .</function> 3638</para> 3639<para> 3640<!-- .LP --> 3641If the specified device has not first been opened by this client via 3642<function>XOpenDevice ,</function> 3643this request will fail with a 3644<function>BadDevice</function> 3645error. 3646If that device does not support input class 3647<function>Keys ,</function> 3648this request will fail with a 3649<function>BadMatch</function> 3650error. 3651</para> 3652<para> 3653<!-- .LP --> 3654<function>XGetDeviceKeyMapping </function> 3655can generate 3656<function>BadDevice ,</function> 3657<function>BadMatch ,</function> 3658and 3659<function>BadValue</function> 3660errors. 3661<!-- .sp --> 3662</para> 3663<para> 3664<!-- .LP --> 3665To change the keyboard mapping of an extension device that supports input class 3666<function>Keys ,</function> 3667use 3668<function>XChangeDeviceKeyMapping .</function> 3669<!-- .sM --> 3670<funcsynopsis> 3671<funcprototype> 3672 <funcdef>int <function> XChangeDeviceKeyMapping</function></funcdef> 3673 <paramdef>Display<parameter> *display</parameter></paramdef> 3674 <paramdef>XDevice<parameter> *device</parameter></paramdef> 3675 <paramdef>int<parameter> first_keycode</parameter></paramdef> 3676 <paramdef>int<parameter> keysyms_per_keycode</parameter></paramdef> 3677 <paramdef>KeySym<parameter> *keysyms</parameter></paramdef> 3678 <paramdef>int<parameter> num_codes</parameter></paramdef> 3679</funcprototype> 3680</funcsynopsis> 3681<!-- .FN --> 3682<variablelist> 3683 <varlistentry> 3684 <term> 3685 <emphasis remap='I'>display</emphasis> 3686 </term> 3687 <listitem> 3688 <para> 3689Specifies the connection to the X server. 3690 </para> 3691 </listitem> 3692 </varlistentry> 3693 <varlistentry> 3694 <term> 3695 <emphasis remap='I'>device</emphasis> 3696 </term> 3697 <listitem> 3698 <para> 3699Specifies the desired device. 3700 </para> 3701 </listitem> 3702 </varlistentry> 3703 <varlistentry> 3704 <term> 3705 <emphasis remap='I'>first_keycode</emphasis> 3706 </term> 3707 <listitem> 3708 <para> 3709Specifies the first keycode that is to be changed. 3710 </para> 3711 </listitem> 3712 </varlistentry> 3713 <varlistentry> 3714 <term> 3715 <emphasis remap='I'>keysyms_per_keycode</emphasis> 3716 </term> 3717 <listitem> 3718 <para> 3719Specifies the keysyms that are to be used. 3720 </para> 3721 </listitem> 3722 </varlistentry> 3723 <varlistentry> 3724 <term> 3725 <emphasis remap='I'>keysyms</emphasis> 3726 </term> 3727 <listitem> 3728 <para> 3729Specifies a pointer to an array of keysyms. 3730 </para> 3731 </listitem> 3732 </varlistentry> 3733 <varlistentry> 3734 <term> 3735 <emphasis remap='I'>num_codes</emphasis> 3736 </term> 3737 <listitem> 3738 <para> 3739Specifies the number of keycodes that are to be changed. 3740 </para> 3741 </listitem> 3742 </varlistentry> 3743</variablelist> 3744</para> 3745<para> 3746<!-- .LP --> 3747<!-- .eM --> 3748<function>XChangeDeviceKeyMapping</function> 3749is analogous to the core 3750<function>XChangeKeyboardMapping</function> 3751function. 3752It defines the symbols for the specified number of keycodes for the 3753specified extension keyboard device. 3754</para> 3755<para> 3756<!-- .LP --> 3757If the specified device has not first been opened by this client via 3758<function>XOpenDevice ,</function> 3759this request will fail with a 3760<function>BadDevice</function> 3761error. 3762If the specified device does not support input class 3763<function>Keys ,</function> 3764this request will fail with a 3765<function>BadMatch</function> 3766error. 3767</para> 3768<para> 3769<!-- .LP --> 3770The number of elements in the keysyms list must be a multiple of 3771keysyms_per_keycode. Otherwise, 3772<function>XChangeDeviceKeyMapping</function> 3773generates a 3774<function>BadLength</function> 3775error. 3776The specified first_keycode must be greater than or equal to 3777the min_keycode value returned by the 3778<function>ListInputDevices</function> 3779request, or this request will fail with a 3780<function>BadValue</function> 3781error. In addition, if the following expression is not less than 3782the max_keycode value returned by the 3783<function>ListInputDevices</function> 3784request, the request will fail with a 3785<function>BadValue</function> 3786error: 3787<literallayout class="monospaced"> 3788 first_keycode + (num_codes / keysyms_per_keycode) - 1 3789</literallayout> 3790</para> 3791<para> 3792<!-- .LP --> 3793<function>XChangeDeviceKeyMapping</function> 3794can generate 3795<function>BadAlloc ,</function> 3796<function>BadDevice ,</function> 3797<function>BadMatch ,</function> 3798and 3799<function>BadValue</function> 3800errors. 3801<!-- .sp --> 3802</para> 3803<para> 3804<!-- .LP --> 3805To obtain the keycodes that are used as modifiers on an 3806extension device that supports input class 3807<function>Keys ,</function> 3808use 3809<function>XGetDeviceModifierMapping .</function> 3810<!-- .sM --> 3811<funcsynopsis> 3812<funcprototype> 3813 <funcdef>XModifierKeymap * <function> XGetDeviceModifierMapping</function></funcdef> 3814 <paramdef>Display<parameter> *display</parameter></paramdef> 3815 <paramdef>XDevice<parameter> *device</parameter></paramdef> 3816</funcprototype> 3817</funcsynopsis> 3818<!-- .FN --> 3819<variablelist> 3820 <varlistentry> 3821 <term> 3822 <emphasis remap='I'>display</emphasis> 3823 </term> 3824 <listitem> 3825 <para> 3826Specifies the connection to the X server. 3827 </para> 3828 </listitem> 3829 </varlistentry> 3830 <varlistentry> 3831 <term> 3832 <emphasis remap='I'>device</emphasis> 3833 </term> 3834 <listitem> 3835 <para> 3836Specifies the desired device. 3837 </para> 3838 </listitem> 3839 </varlistentry> 3840</variablelist> 3841</para> 3842<para> 3843<!-- .LP --> 3844<!-- .eM --> 3845<function>XGetDeviceModifierMapping</function> 3846is analogous to the core 3847<function>XGetModifierMapping</function> 3848function. 3849The 3850<function>XGetDeviceModifierMapping</function> 3851function returns a newly created 3852<function>XModifierKeymap</function> 3853structure that contains the keys being used as 3854modifiers for the specified device. 3855The structure should be freed after use with 3856<function>XFreeModifierMapping .</function> 3857If only zero values appear in the set for any modifier, 3858that modifier is disabled. 3859</para> 3860<para> 3861<!-- .LP --> 3862<function>XGetDeviceModifierMapping</function> 3863can generate 3864<function>BadDevice</function> 3865and 3866<function>BadMatch</function> 3867errors. 3868<!-- .sp --> 3869</para> 3870<para> 3871<!-- .LP --> 3872To set which keycodes are to be used as modifiers for an extension device, use 3873<function>XSetDeviceModifierMapping .</function> 3874<!-- .sM --> 3875<funcsynopsis> 3876<funcprototype> 3877 <funcdef>int <function> XSetDeviceModifierMapping</function></funcdef> 3878 <paramdef>Display<parameter> *display</parameter></paramdef> 3879 <paramdef>XDevice<parameter> *device</parameter></paramdef> 3880 <paramdef>XModifierKeymap<parameter> *modmap</parameter></paramdef> 3881</funcprototype> 3882</funcsynopsis> 3883<!-- .FN --> 3884<variablelist> 3885 <varlistentry> 3886 <term> 3887 <emphasis remap='I'>display</emphasis> 3888 </term> 3889 <listitem> 3890 <para> 3891Specifies the connection to the X server. 3892 </para> 3893 </listitem> 3894 </varlistentry> 3895 <varlistentry> 3896 <term> 3897 <emphasis remap='I'>device</emphasis> 3898 </term> 3899 <listitem> 3900 <para> 3901Specifies the desired device. 3902 </para> 3903 </listitem> 3904 </varlistentry> 3905 <varlistentry> 3906 <term> 3907 <emphasis remap='I'>modmap</emphasis> 3908 </term> 3909 <listitem> 3910 <para> 3911Specifies a pointer to the 3912<function>XModifierKeymap</function> 3913structure. 3914 </para> 3915 </listitem> 3916 </varlistentry> 3917</variablelist> 3918</para> 3919<para> 3920<!-- .LP --> 3921<!-- .eM --> 3922<function>XSetDeviceModifierMapping</function> 3923is analogous to the core 3924<function>XSetModifierMapping</function> 3925function. 3926The 3927<function>XSetDeviceModifierMapping</function> 3928function specifies the keycodes of the keys, if any, 3929that are to be used as modifiers. A zero value means 3930that no key should be used. No two arguments can have the same nonzero 3931keycode value. Otherwise, 3932<function>XSetDeviceModifierMapping</function> 3933generates a 3934<function>BadValue</function> 3935error. 3936There are eight modifiers, and the modifiermap member of the 3937<function>XModifierKeymap</function> 3938structure contains eight sets of max_keypermod 3939keycodes, one for each modifier in the order 3940<function>Shift ,</function> 3941<function>Lock ,</function> 3942<function>Control ,</function> 3943<function>Mod1 ,</function> 3944<function>Mod2 ,</function> 3945<function>Mod3 ,</function> 3946<function>Mod4 ,</function> 3947and 3948<function>Mod5 .</function> 3949Only nonzero keycodes have meaning in each set, and zero keycodes 3950are ignored. 3951In addition, all of the nonzero keycodes must be in the range specified by 3952min_keycode and max_keycode reported by the 3953<function>XListInputDevices</function> 3954function. 3955Otherwise, 3956<function>XSetModifierMapping</function> 3957generates a 3958<function>BadValue</function> 3959error. 3960No keycode may appear twice in the entire map. 3961Otherwise, it generates a 3962<function>BadValue</function> 3963error. 3964</para> 3965<para> 3966<!-- .LP --> 3967A X server can impose restrictions on how modifiers can be changed, 3968for example, 3969if certain keys do not generate up transitions in hardware or if multiple 3970modifier keys are not supported. 3971If some such restriction is violated, 3972the status reply is 3973<function>MappingFailed ,</function> 3974and none of the modifiers are changed. 3975If the new keycodes specified for a modifier differ from those 3976currently defined and any (current or new) keys for that modifier are 3977in the logically down state, 3978the status reply is 3979<function>MappingBusy , </function> 3980and none of the modifiers are changed. 3981<function>XSetModifierMapping</function> 3982generates a 3983<function>DeviceMappingNotify</function> 3984event on a 3985<function>MappingSuccess</function> 3986status. 3987</para> 3988<para> 3989<!-- .LP --> 3990<function>XSetDeviceModifierMapping</function> 3991can generate 3992<function>BadAlloc ,</function> 3993<function>BadDevice ,</function> 3994<function>BadMatch ,</function> 3995and 3996<function>BadValue</function> 3997errors. 3998</para> 3999</sect3> 4000<sect3 id="Controlling_Button_Mapping"> 4001<title>Controlling Button Mapping</title> 4002<!-- .XS --> 4003<!-- (SN Controlling Button Mapping --> 4004<!-- .XE --> 4005<para> 4006<!-- .LP --> 4007To set the mapping of the buttons on an extension device, use 4008<function>XSetDeviceButtonMapping .</function> 4009<!-- .sM --> 4010<funcsynopsis> 4011<funcprototype> 4012 <funcdef>int <function> XSetDeviceButtonMapping</function></funcdef> 4013 <paramdef>Display<parameter> *display</parameter></paramdef> 4014 <paramdef>XDevice<parameter> *device</parameter></paramdef> 4015 <paramdef>unsignedchar<parameter> map[]</parameter></paramdef> 4016 <paramdef>int<parameter> nmap</parameter></paramdef> 4017</funcprototype> 4018</funcsynopsis> 4019<!-- .FN --> 4020<variablelist> 4021 <varlistentry> 4022 <term> 4023 <emphasis remap='I'>display</emphasis> 4024 </term> 4025 <listitem> 4026 <para> 4027Specifies the connection to the X server. 4028 </para> 4029 </listitem> 4030 </varlistentry> 4031 <varlistentry> 4032 <term> 4033 <emphasis remap='I'>device</emphasis> 4034 </term> 4035 <listitem> 4036 <para> 4037Specifies the desired device. 4038 </para> 4039 </listitem> 4040 </varlistentry> 4041 <varlistentry> 4042 <term> 4043 <emphasis remap='I'>map</emphasis> 4044 </term> 4045 <listitem> 4046 <para> 4047Specifies the mapping list. 4048 </para> 4049 </listitem> 4050 </varlistentry> 4051 <varlistentry> 4052 <term> 4053 <emphasis remap='I'>nmap</emphasis> 4054 </term> 4055 <listitem> 4056 <para> 4057Specifies the number of items in the mapping list. 4058 </para> 4059 </listitem> 4060 </varlistentry> 4061</variablelist> 4062</para> 4063<para> 4064<!-- .LP --> 4065<!-- .eM --> 4066<function>XSetDeviceButtonMapping</function> 4067sets the mapping of the buttons on an extension device. 4068If it succeeds, the X server generates a 4069<function>DeviceMappingNotify</function> 4070event, and 4071<function>XSetDeviceButtonMapping</function> 4072returns 4073<function>MappingSuccess .</function> 4074Elements of the list are indexed starting from one. 4075The length of the list must be the same as 4076<function>XGetDeviceButtonMapping</function> 4077would return, or a 4078<function>BadValue</function> 4079error results. 4080The index is a button number, and the element of the list 4081defines the effective number. 4082A zero element disables a button, and elements are not restricted in 4083value by the number of physical buttons. 4084However, no two elements can have the same nonzero value, or a 4085<function>BadValue</function> 4086error results. 4087If any of the buttons to be altered are logically in the down state, 4088<function>XSetDeviceButtonMapping</function> 4089returns 4090<function>MappingBusy ,</function> 4091and the mapping is not changed. 4092</para> 4093<para> 4094<!-- .LP --> 4095<function>XSetDeviceButtonMapping</function> 4096can generate 4097<function>BadDevice ,</function> 4098<function>BadMatch ,</function> 4099and 4100<function>BadValue</function> 4101errors. 4102<!-- .sp --> 4103</para> 4104<para> 4105<!-- .LP --> 4106To get the button mapping, use 4107<function>XGetDeviceButtonMapping .</function> 4108<!-- .sM --> 4109<funcsynopsis> 4110<funcprototype> 4111 <funcdef>int <function> XGetDeviceButtonMapping</function></funcdef> 4112 <paramdef>Display<parameter> *display</parameter></paramdef> 4113 <paramdef>XDevice<parameter> *device</parameter></paramdef> 4114 <paramdef>unsignedchar<parameter> map_return[]</parameter></paramdef> 4115 <paramdef>int<parameter> nmap</parameter></paramdef> 4116</funcprototype> 4117</funcsynopsis> 4118<!-- .FN --> 4119<variablelist> 4120 <varlistentry> 4121 <term> 4122 <emphasis remap='I'>display</emphasis> 4123 </term> 4124 <listitem> 4125 <para> 4126Specifies the connection to the X server. 4127 </para> 4128 </listitem> 4129 </varlistentry> 4130 <varlistentry> 4131 <term> 4132 <emphasis remap='I'>device</emphasis> 4133 </term> 4134 <listitem> 4135 <para> 4136Specifies the desired device. 4137 </para> 4138 </listitem> 4139 </varlistentry> 4140 <varlistentry> 4141 <term> 4142 <emphasis remap='I'>map_return</emphasis> 4143 </term> 4144 <listitem> 4145 <para> 4146Specifies the mapping list. 4147 </para> 4148 </listitem> 4149 </varlistentry> 4150 <varlistentry> 4151 <term> 4152 <emphasis remap='I'>nmap</emphasis> 4153 </term> 4154 <listitem> 4155 <para> 4156Specifies the number of items in the mapping list. 4157 </para> 4158 </listitem> 4159 </varlistentry> 4160</variablelist> 4161</para> 4162<para> 4163<!-- .LP --> 4164<!-- .eM --> 4165<function>XGetDeviceButtonMapping</function> 4166returns the current mapping of the specified extension device. 4167Elements of the list are indexed starting from one. 4168<function>XGetDeviceButtonMapping</function> 4169returns the number of physical buttons actually on the pointer. 4170The nominal mapping for the buttons is the identity mapping: map[i]=i. 4171The nmap argument specifies the length of the array where the button 4172mapping is returned, and only the first nmap elements are returned 4173in map_return. 4174</para> 4175<para> 4176<!-- .LP --> 4177<function>XGetDeviceButtonMapping</function> 4178can generate 4179<function>BadDevice</function> 4180and 4181<function>BadMatch</function> 4182errors. 4183</para> 4184</sect3> 4185<sect3 id="Obtaining_the_State_of_a_Device"> 4186<title>Obtaining the State of a Device</title> 4187<!-- .XS --> 4188<!-- (SN Obtaining the State of a Device --> 4189<!-- .XE --> 4190<para> 4191<!-- .LP --> 4192To obtain information that describes the state of the keys, buttons, and 4193valuators of an extension device, use 4194<function>XQueryDeviceState .</function> 4195<!-- .sM --> 4196<funcsynopsis> 4197<funcprototype> 4198 <funcdef>XDeviceState * <function> XQueryDeviceState</function></funcdef> 4199 <paramdef>Display<parameter> *display</parameter></paramdef> 4200 <paramdef>XDevice<parameter> *device</parameter></paramdef> 4201</funcprototype> 4202</funcsynopsis> 4203<!-- .FN --> 4204<variablelist> 4205 <varlistentry> 4206 <term> 4207 <emphasis remap='I'>display</emphasis> 4208 </term> 4209 <listitem> 4210 <para> 4211Specifies the connection to the X server. 4212 </para> 4213 </listitem> 4214 </varlistentry> 4215 <varlistentry> 4216 <term> 4217 <emphasis remap='I'>device</emphasis> 4218 </term> 4219 <listitem> 4220 <para> 4221Specifies the desired device. 4222 </para> 4223 </listitem> 4224 </varlistentry> 4225</variablelist> 4226</para> 4227<para> 4228<!-- .LP --> 4229<!-- .eM --> 4230<function>XQueryDeviceState</function> 4231returns a pointer to an 4232<function>XDeviceState</function> 4233structure, which points to a list of 4234structures that describe the state of the keys, buttons, and valuators 4235on the device: 4236</para> 4237<para> 4238<!-- .LP --> 4239<!-- .sM --> 4240<literallayout class="monospaced"> 4241<!-- .TA .5i --> 4242<!-- .ta .5i --> 4243typedef struct { 4244 XID device_id; 4245 int num_classes; 4246 XInputClass *data; 4247} XDeviceState; 4248</literallayout> 4249</para> 4250<para> 4251<!-- .LP --> 4252<!-- .eM --> 4253The structures are of variable length, but the first 4254two members are common to all and are as follows: 4255</para> 4256<para> 4257<!-- .LP --> 4258<!-- .sM --> 4259<literallayout class="monospaced"> 4260<!-- .TA .5i --> 4261<!-- .ta .5i --> 4262typedef struct { 4263 unsigned char class; 4264 unsigned char length; 4265} XInputClass; 4266</literallayout> 4267</para> 4268<para> 4269<!-- .LP --> 4270<!-- .eM --> 4271The class member contains a class identifier. This identifier can be 4272compared with constants defined in the file 4273<function>< X11/extensions/XI.h >.</function> 4274Currently defined constants are: 4275<function>KeyClass ,</function> 4276<function>ButtonClass ,</function> 4277and 4278<function>ValuatorClass .</function> 4279</para> 4280<para> 4281<!-- .LP --> 4282The length member contains the length of the structure and can be used 4283by clients to traverse the list. 4284</para> 4285<para> 4286<!-- .LP --> 4287The 4288<function>XValuatorState</function> 4289structure describes the current state of the valuators 4290on the device. 4291The num_valuators member contains the number of valuators 4292on the device. 4293The mode member is a mask whose bits report the data mode 4294and other state information for the device. 4295The following bits are currently defined: 4296<literallayout class="monospaced"> 4297<!-- .TA .5i 1.5i 2.5i --> 4298<!-- .ta .5i 1.5i 2.5i --> 4299 DeviceMode 1 << 0 Relative = 0, Absolute = 1 4300 ProximityState 1 << 1 InProximity = 0, OutOfProximity = 1 4301</literallayout> 4302The valuators member contains a pointer to an array of integers that 4303describe the current value of the valuators. 4304If the mode is 4305<function>Relative ,</function> 4306these values are undefined. 4307</para> 4308<para> 4309<!-- .LP --> 4310<!-- .sM --> 4311<literallayout class="monospaced"> 4312<!-- .TA .5i --> 4313<!-- .ta .5i --> 4314typedef struct { 4315 unsigned char class; 4316 unsigned char length; 4317 unsigned char num_valuators; 4318 unsigned char mode; 4319 int *valuators; 4320} XValuatorState; 4321</literallayout> 4322</para> 4323<para> 4324<!-- .LP --> 4325<!-- .eM --> 4326The 4327<function>XKeyState</function> 4328structure describes the current state of the keys 4329on the device. Byte N (from 0) contains the 4330bits for key 8N to 8N + 7 with the least significant bit in the 4331byte representing key 8N. 4332</para> 4333<para> 4334<!-- .LP --> 4335<!-- .sM --> 4336<literallayout class="monospaced"> 4337<!-- .TA .5i --> 4338<!-- .ta .5i --> 4339typedef struct { 4340 unsigned char class; 4341 unsigned char length; 4342 short num_keys; 4343 char keys[32]; 4344} XKeyState; 4345</literallayout> 4346</para> 4347<para> 4348<!-- .LP --> 4349<!-- .eM --> 4350The 4351<function>XButtonState</function> 4352structure describes the current state of the buttons 4353on the device. Byte N (from 0) contains the bits for button 8N to 8N + 7 4354with the least significant bit in the 4355byte representing button 8N. 4356</para> 4357<para> 4358<!-- .LP --> 4359<!-- .sM --> 4360<literallayout class="monospaced"> 4361<!-- .TA .5i --> 4362<!-- .ta .5i --> 4363typedef struct { 4364 unsigned char class; 4365 unsigned char length; 4366 short num_buttons; 4367 char buttons[32]; 4368} XButtonState; 4369</literallayout> 4370</para> 4371<para> 4372<!-- .LP --> 4373<!-- .eM --> 4374<function>XQueryDeviceState</function> 4375can generate 4376<function>BadDevice</function> 4377errors. 4378<!-- .sp --> 4379</para> 4380<para> 4381<!-- .LP --> 4382To free the data returned by this function, use 4383<function>XFreeDeviceState .</function> 4384<!-- .sM --> 4385<funcsynopsis> 4386<funcprototype> 4387 <funcdef>void <function> XFreeDeviceState</function></funcdef> 4388 <paramdef>XDeviceState<parameter> *state</parameter></paramdef> 4389</funcprototype> 4390</funcsynopsis> 4391<!-- .FN --> 4392<variablelist> 4393 <varlistentry> 4394 <term> 4395 <emphasis remap='I'>state</emphasis> 4396 </term> 4397 <listitem> 4398 <para> 4399Specifies the pointer to the 4400<function>XDeviceState</function> 4401data returned by a previous call to 4402<function>XQueryDeviceState .</function> 4403 </para> 4404 </listitem> 4405 </varlistentry> 4406</variablelist> 4407</para> 4408<para> 4409<!-- .LP --> 4410<!-- .eM --> 4411<function>XFreeDeviceState</function> 4412frees the device state data. 4413</para> 4414</sect3> 4415</sect2> 4416<sect2 id="Events"> 4417<title>Events</title> 4418<!-- .XS --> 4419<!-- (SN Events --> 4420<!-- .XE --> 4421<para> 4422<!-- .LP --> 4423The input extension creates input events analogous to the core input events. 4424These extension input events are generated by manipulating one of the 4425extension input devices. 4426The remainder of this section discusses the following X Input Extension 4427event topics: 4428</para> 4429<itemizedlist> 4430 <listitem> 4431 <para> 4432Event types 4433 </para> 4434 </listitem> 4435 <listitem> 4436 <para> 4437Event classes 4438 </para> 4439 </listitem> 4440 <listitem> 4441 <para> 4442Event structures 4443 </para> 4444 </listitem> 4445</itemizedlist> 4446<sect3 id="Event_Types"> 4447<title>Event Types</title> 4448<!-- .XS --> 4449<!-- (SN Event Types --> 4450<!-- .XE --> 4451<para> 4452<!-- .LP --> 4453Event types are integer numbers that a client can use to determine what 4454kind of event it has received. The client compares the type field of 4455the event structure with known event types to make this determination. 4456</para> 4457<para> 4458<!-- .LP --> 4459The core input event types are constants and are defined in the header file 4460<function>< X11/X.h >.</function> 4461Extension event types are not constants. Instead, they 4462are dynamically allocated by the extension's request to the X server 4463when the extension is initialized. Because of this, extension event 4464types must be obtained by the client from the server. 4465</para> 4466<para> 4467<!-- .LP --> 4468The client program determines the event type for an extension event by using 4469the information returned by the 4470<function>XOpenDevice</function> 4471request. 4472This type can then be used for comparison with the type field 4473of events received by the client. 4474</para> 4475<para> 4476<!-- .LP --> 4477Extension events propagate up the window hierarchy in the same manner 4478as core events. If a window is not interested in an extension event, 4479it usually propagates to the closest ancestor that is interested, 4480unless the dont_propagate list prohibits it. 4481Grabs of extension devices may alter the set of windows that receive a particular 4482extension event. 4483</para> 4484<para> 4485<!-- .LP --> 4486The following table lists the event category and its associated event 4487type or types. 4488</para> 4489 4490<informaltable> 4491 <tgroup cols='2' align='center'> 4492 <colspec colname='c1'/> 4493 <colspec colname='c2'/> 4494 <thead> 4495 <row> 4496 <entry>Event Category</entry> 4497 <entry>Event Type</entry> 4498 </row> 4499 </thead> 4500 <tbody> 4501 <row> 4502 <entry>Device key</entry> 4503 <entry><function>DeviceKeyPress</function></entry> 4504 </row> 4505 <row> 4506 <entry></entry> 4507 <entry><function>DeviceKeyRelease</function></entry> 4508 </row> 4509 <row> 4510 <entry>Device motion</entry> 4511 <entry><function>DeviceButtonPress</function></entry> 4512 </row> 4513 <row> 4514 <entry></entry> 4515 <entry><function>DeviceButtonRelease</function></entry> 4516 </row> 4517 <row> 4518 <entry></entry> 4519 <entry><function>DeviceMotionNotify</function></entry> 4520 </row> 4521 <row> 4522 <entry>Device input focus</entry> 4523 <entry><function>DeviceFocusIn</function></entry> 4524 </row> 4525 <row> 4526 <entry></entry> 4527 <entry><function>DeviceFocusOut</function></entry> 4528 </row> 4529 <row> 4530 <entry>Device state notification</entry> 4531 <entry><function>DeviceStateNotify</function></entry> 4532 </row> 4533 <row> 4534 <entry>Device proximity</entry> 4535 <entry><function>ProximityIn</function></entry> 4536 </row> 4537 <row> 4538 <entry></entry> 4539 <entry><function>ProximityOut</function></entry> 4540 </row> 4541 <row> 4542 <entry>Device mapping</entry> 4543 <entry><function>DeviceMappingNotify</function></entry> 4544 </row> 4545 <row> 4546 <entry>Device change</entry> 4547 <entry><function>ChangeDeviceNotify</function></entry> 4548 </row> 4549 </tbody> 4550 </tgroup> 4551</informaltable> 4552 4553</sect3> 4554<sect3 id="Event_Classes"> 4555<title>Event Classes</title> 4556<!-- .XS --> 4557<!-- (SN Event Classes --> 4558<!-- .XE --> 4559<para> 4560<!-- .LP --> 4561Event classes are integer numbers that are used in the same way as the 4562core event masks. They are used by a client program to indicate to the 4563server which events that client program wishes to receive. 4564</para> 4565<para> 4566<!-- .LP --> 4567The core input event masks are constants and are defined in the header file 4568<function>< X11/X.h >.</function> 4569Extension event classes are not constants. Instead, they are dynamically 4570allocated by the extension's request to the X server 4571when the extension is initialized. Because of this, extension event 4572classes must be obtained by the client from the server. 4573</para> 4574<para> 4575<!-- .LP --> 4576The event class for an extension event and device is obtained from 4577information returned by the 4578<function>XOpenDevice</function> 4579function. 4580This class can then be used in an 4581<function>XSelectExtensionEvent</function> 4582request to ask that events of that type from that device be sent to 4583the client program. 4584</para> 4585<para> 4586<!-- .LP --> 4587For 4588<function>DeviceButtonPress</function> 4589events, the client may specify whether 4590or not an implicit passive grab should be done when the button is 4591pressed. If the client wants to guarantee that it will receive a 4592<function>DeviceButtonRelease</function> 4593event for each 4594<function>DeviceButtonPress</function> 4595event it receives, it should specify the 4596<function>DeviceButtonPressGrab</function> 4597class in addition to the 4598<function>DeviceButtonPress</function> 4599class. 4600This restricts the client in that only one client at a time 4601may request 4602<function>DeviceButtonPress</function> 4603events from the same device and 4604window if any client specifies this class. 4605</para> 4606<para> 4607<!-- .LP --> 4608If any client has specified the 4609<function>DeviceButtonPressGrab</function> 4610class, any requests by any other client that specify the same device 4611and window and specify either 4612<function>DeviceButtonPress</function> 4613or 4614<function>DeviceButtonPressGrab</function> 4615will cause an 4616<function>Access</function> 4617error to be generated. 4618</para> 4619<para> 4620<!-- .LP --> 4621If only the 4622<function>DeviceButtonPress</function> 4623class is specified, no implicit passive grab will be done when a button 4624is pressed on the device. 4625Multiple clients may use this class to specify the same device and 4626window combination. 4627</para> 4628<para> 4629<!-- .LP --> 4630The client may also select 4631<function>DeviceMotion</function> 4632events only when a button is down. 4633It does this by specifying the event classes 4634<function>DeviceButton1Motion</function> 4635through 4636<function>DeviceButton5Motion . </function> 4637An input device will support only 4638as many button motion classes as it has buttons. 4639</para> 4640</sect3> 4641<sect3 id="Event_Structures"> 4642<title>Event Structures</title> 4643<!-- .XS --> 4644<!-- (SN Event Structures --> 4645<!-- .XE --> 4646<para> 4647<!-- .LP --> 4648Each extension event type has a corresponding structure declared in 4649<function>< X11/extensions/XInput.h >.</function> 4650All event structures have the following common members: 4651<variablelist> 4652 <varlistentry> 4653 <term> 4654 type 4655 </term> 4656 <listitem> 4657 <para> 4658Set to the event type number that uniquely identifies it. For example, 4659when the X server reports a 4660<function>DeviceKeyPress</function> 4661event to a client application, it sends an 4662<function>XDeviceKeyPressEvent</function> 4663structure. 4664 </para> 4665 </listitem> 4666 </varlistentry> 4667 <varlistentry> 4668 <term> 4669 serial 4670 </term> 4671 <listitem> 4672 <para> 4673Set from the serial number reported in the protocol but expanded from the 467416-bit least significant bits to a full 32-bit value. 4675 </para> 4676 </listitem> 4677 </varlistentry> 4678 <varlistentry> 4679 <term> 4680 send_event 4681 </term> 4682 <listitem> 4683 <para> 4684Set to 4685<function>True</function> 4686if the event came from an 4687<function>XSendEvent</function> 4688request. 4689 </para> 4690 </listitem> 4691 </varlistentry> 4692 <varlistentry> 4693 <term> 4694 display 4695 </term> 4696 <listitem> 4697 <para> 4698Set to a pointer to a structure that defines the display 4699on which the event was read. 4700 </para> 4701 </listitem> 4702 </varlistentry> 4703</variablelist> 4704</para> 4705<para> 4706<!-- .LP --> 4707Extension event structures report the current position of the X pointer. 4708In addition, if the device reports motion data and is reporting absolute data, 4709the current value of any valuators the device contains is also reported. 4710</para> 4711<sect4 id="Device_Key_Events"> 4712<title>Device Key Events</title> 4713<!-- .XS --> 4714<!-- (SN Device Key Events --> 4715<!-- .XE --> 4716<para> 4717<!-- .LP --> 4718Key events from extension devices contain all the information that is 4719contained in a key event from the X keyboard. In addition, they contain 4720a device ID and report the current value of any valuators on the device, 4721if that device is reporting absolute data. 4722If data for more than six valuators is being reported, more than one 4723key event will be sent. 4724The axes_count member contains the number of axes that are being 4725reported. The server sends as many of these events as are 4726needed to report the device data. Each event contains the total number 4727of axes reported in the axes_count member and the first axis reported 4728in the current event in the first_axis member. 4729If the device supports input class 4730<function>Valuators , </function> 4731but is not reporting absolute mode data, 4732the axes_count member contains zero (0). 4733</para> 4734<para> 4735<!-- .LP --> 4736The location reported in 4737the x, y and x_root, y_root members is the location of the core X pointer. 4738</para> 4739<para> 4740<!-- .LP --> 4741The 4742<function>XDeviceKeyEvent</function> 4743structure is defined as follows: 4744</para> 4745<para> 4746<!-- .LP --> 4747<!-- .sM --> 4748<literallayout class="monospaced"> 4749<!-- .TA .5i 3i --> 4750<!-- .ta .5i 3i --> 4751typedef struct { 4752 int type; /* of event */ 4753 unsigned long serial; /* # of last request processed */ 4754 Bool send_event; /* true if from SendEvent request */ 4755 Display *display; /* Display the event was read from */ 4756 Window window; /* "event" window reported relative to */ 4757 XID deviceid; 4758 Window root; /* root window event occurred on */ 4759 Window subwindow; /* child window */ 4760 Time time; /* milliseconds */ 4761 int x, y; /* x, y coordinates in event window */ 4762 int x_root; /* coordinates relative to root */ 4763 int y_root; /* coordinates relative to root */ 4764 unsigned int state; /* key or button mask */ 4765 unsigned int keycode; /* detail */ 4766 Bool same_screen; /* same screen flag */ 4767 unsigned int device_state; /* device key or button mask */ 4768 unsigned char axes_count; 4769 unsigned char first_axis; 4770 int axis_data[6]; 4771} XDeviceKeyEvent; 4772 4773typedef XDeviceKeyEvent XDeviceKeyPressedEvent; 4774typedef XDeviceKeyEvent XDeviceKeyReleasedEvent; 4775</literallayout> 4776<!-- .eM --> 4777</para> 4778</sect4> 4779<sect4 id="Device_Button_Events"> 4780<title>Device Button Events</title> 4781<!-- .XS --> 4782<!-- (SN Device Button Events --> 4783<!-- .XE --> 4784<para> 4785<!-- .LP --> 4786Button events from extension devices contain all the information that is 4787contained in a button event from the X pointer. In addition, they contain 4788a device ID and report the current value of any valuators on the device 4789if that device is reporting absolute data. 4790If data for more than six valuators is being reported, more than one 4791button event may be sent. 4792The axes_count member contains the number of axes that are being 4793reported. The server sends as many of these events as are 4794needed to report the device data. Each event contains the total number 4795of axes reported in the axes_count member and the first axis reported 4796in the current event in the first_axis member. 4797If the device supports input class 4798<function>Valuators , </function> 4799but is not reporting absolute mode data, 4800the axes_count member contains zero (0). 4801</para> 4802<para> 4803<!-- .LP --> 4804The location reported in 4805the x, y and x_root, y_root members is the location of the core X pointer. 4806</para> 4807<para> 4808<!-- .LP --> 4809<!-- .sM --> 4810<literallayout class="monospaced"> 4811<!-- .TA .5i 3i --> 4812<!-- .ta .5i 3i --> 4813typedef struct { 4814 int type; /* of event */ 4815 unsigned long serial; /* # of last request processed by server */ 4816 Bool send_event; /* true if from a SendEvent request */ 4817 Display *display; /* Display the event was read from */ 4818 Window window; /* "event" window reported relative to */ 4819 XID deviceid; 4820 Window root; /* root window that the event occurred on */ 4821 Window subwindow; /* child window */ 4822 Time time; /* milliseconds */ 4823 int x, y; /* x, y coordinates in event window */ 4824 int x_root; /* coordinates relative to root */ 4825 int y_root; /* coordinates relative to root */ 4826 unsigned int state; /* key or button mask */ 4827 unsigned int button; /* detail */ 4828 Bool same_screen; /* same screen flag */ 4829 unsigned int device_state; /* device key or button mask */ 4830 unsigned char axes_count; 4831 unsigned char first_axis; 4832 int axis_data[6]; 4833} XDeviceButtonEvent; 4834 4835typedef XDeviceButtonEvent XDeviceButtonPressedEvent; 4836typedef XDeviceButtonEvent XDeviceButtonReleasedEvent; 4837</literallayout> 4838<!-- .eM --> 4839</para> 4840</sect4> 4841<sect4 id="Device_Motion_Events"> 4842<title>Device Motion Events</title> 4843<!-- .XS --> 4844<!-- (SN Device Motion Events --> 4845<!-- .XE --> 4846<para> 4847<!-- .LP --> 4848Motion events from extension devices contain all the information that is 4849contained in a motion event from the X pointer. In addition, they contain 4850a device ID and report the current value of any valuators on the device. 4851</para> 4852<para> 4853<!-- .LP --> 4854The location reported in 4855the x, y and x_root, y_root members is the location of the core X pointer, 4856and so is 2-dimensional. 4857</para> 4858<para> 4859<!-- .LP --> 4860Extension motion devices may report motion data for a variable number of 4861axes. 4862The axes_count member contains the number of axes that are being 4863reported. The server sends as many of these events as are 4864needed to report the device data. Each event contains the total number 4865of axes reported in the axes_count member and the first axis reported 4866in the current event in the first_axis member. 4867</para> 4868<para> 4869<!-- .LP --> 4870<!-- .sM --> 4871<literallayout class="monospaced"> 4872<!-- .TA .5i 3i --> 4873<!-- .ta .5i 3i --> 4874typedef struct { 4875 int type; /* of event */ 4876 unsigned long serial; /* # of last request processed by server */ 4877 Bool send_event; /* true if from a SendEvent request */ 4878 Display *display; /* Display the event was read from */ 4879 Window window; /* "event" window reported relative to */ 4880 XID deviceid; 4881 Window root; /* root window that the event occurred on */ 4882 Window subwindow; /* child window */ 4883 Time time; /* milliseconds */ 4884 int x, y; /* x, y coordinates in event window */ 4885 int x_root; /* coordinates relative to root */ 4886 int y_root; /* coordinates relative to root */ 4887 unsigned int state; /* key or button mask */ 4888 char is_hint; /* detail */ 4889 Bool same_screen; /* same screen flag */ 4890 unsigned int device_state; /* device key or button mask */ 4891 unsigned char axes_count; 4892 unsigned char first_axis; 4893 int axis_data[6]; 4894} XDeviceMotionEvent; 4895</literallayout> 4896<!-- .eM --> 4897</para> 4898</sect4> 4899<sect4 id="Device_Focus_Events"> 4900<title>Device Focus Events</title> 4901<!-- .XS --> 4902<!-- (SN Device Focus Events --> 4903<!-- .XE --> 4904<para> 4905<!-- .LP --> 4906These events are equivalent to the core focus events. 4907They contain the same information, with the addition 4908of a device ID to identify which device has had a focus change, 4909and a timestamp. 4910</para> 4911<para> 4912<!-- .LP --> 4913<function>DeviceFocusIn</function> 4914and 4915<function>DeviceFocusOut</function> 4916events are generated for 4917focus changes of extension devices in the same manner as core focus 4918events are generated. 4919</para> 4920<para> 4921<!-- .LP --> 4922<!-- .sM --> 4923<literallayout class="monospaced"> 4924<!-- .TA .5i 2.5i --> 4925<!-- .ta .5i 2.5i --> 4926typedef struct { 4927 int type; /* of event */ 4928 unsigned long serial; /* # of last request processed by server */ 4929 Bool send_event; /* true if this came from a SendEvent request */ 4930 Display *display; /* Display the event was read from */ 4931 Window window; /* "event" window it is reported relative to */ 4932 XID deviceid; 4933 int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */ 4934 int detail; 4935 /* 4936 * NotifyAncestor, NotifyVirtual, NotifyInferior, 4937 * NotifyNonLinear,NotifyNonLinearVirtual, NotifyPointer, 4938 * NotifyPointerRoot, NotifyDetailNone 4939 */ 4940 Time time; 4941} XDeviceFocusChangeEvent; 4942 4943typedef XDeviceFocusChangeEvent XDeviceFocusInEvent; 4944typedef XDeviceFocusChangeEvent XDeviceFocusOutEvent; 4945</literallayout> 4946<!-- .eM --> 4947</para> 4948</sect4> 4949<sect4 id="Device_StateNotify_Event"> 4950<title>Device StateNotify Event</title> 4951<!-- .XS --> 4952<!-- (SN Device StateNotify Event --> 4953<!-- .XE --> 4954<para> 4955<!-- .LP --> 4956This event is analogous to the core keymap event but 4957reports the current state of the device for each 4958input class that it supports. 4959It is generated after every 4960<function>DeviceFocusIn</function> 4961event and 4962<function>EnterNotify</function> 4963event and is delivered to clients who have selected 4964<function>XDeviceStateNotify</function> 4965events. 4966</para> 4967<para> 4968<!-- .LP --> 4969If the device supports input class 4970<function>Valuators ,</function> 4971the mode member in the 4972<function>XValuatorStatus</function> 4973structure is a bitmask that reports the device mode, 4974proximity state, and other state information. 4975The following bits are currently defined: 4976<literallayout class="monospaced"> 4977<!-- .TA .5i 1.5i --> 4978<!-- .ta .5i 1.5i --> 4979 0x01 Relative = 0, Absolute = 1 4980 0x02 InProximity = 0, OutOfProximity = 1 4981</literallayout> 4982</para> 4983<para> 4984<!-- .LP --> 4985If the device supports more valuators than can be reported in a single 4986<function>XEvent ,</function> 4987multiple 4988<function>XDeviceStateNotify</function> 4989events will be generated. 4990</para> 4991<para> 4992<!-- .LP --> 4993<!-- .sM --> 4994<literallayout class="monospaced"> 4995<!-- .TA .5i 3i --> 4996<!-- .ta .5i 3i --> 4997typedef struct { 4998 unsigned char class; 4999 unsigned char length; 5000} XInputClass; 5001 5002typedef struct { 5003 int type; 5004 unsigned long serial; /* # of last request processed by server */ 5005 Bool send_event; /* true if this came from a SendEvent request */ 5006 Display *display; /* Display the event was read from */ 5007 Window window; 5008 XID deviceid; 5009 Time time; 5010 int num_classes; 5011 char data[64]; 5012} XDeviceStateNotifyEvent; 5013 5014typedef struct { 5015 unsigned char class; 5016 unsigned char length; 5017 unsigned char num_valuators; 5018 unsigned char mode; 5019 int valuators[6]; 5020} XValuatorStatus; 5021 5022typedef struct { 5023 unsigned char class; 5024 unsigned char length; 5025 short num_keys; 5026 char keys[32]; 5027} XKeyStatus; 5028 5029typedef struct { 5030 unsigned char class; 5031 unsigned char length; 5032 short num_buttons; 5033 char buttons[32]; 5034} XButtonStatus; 5035</literallayout> 5036<!-- .eM --> 5037</para> 5038</sect4> 5039<sect4 id="Device_Mapping_Event"> 5040<title>Device Mapping Event</title> 5041<!-- .XS --> 5042<!-- (SN Device Mapping Event --> 5043<!-- .XE --> 5044<para> 5045<!-- .LP --> 5046This event is equivalent to the core 5047<function>MappingNotify</function> 5048event. 5049It notifies client programs when the mapping of keys, 5050modifiers, or buttons on an extension device has changed. 5051</para> 5052<para> 5053<!-- .LP --> 5054<!-- .sM --> 5055<literallayout class="monospaced"> 5056<!-- .TA .5i 3i --> 5057<!-- .ta .5i 3i --> 5058typedef struct { 5059 int type; 5060 unsigned long serial; 5061 Bool send_event; 5062 Display *display; 5063 Window window; 5064 XID deviceid; 5065 Time time; 5066 int request; 5067 int first_keycode; 5068 int count; 5069} XDeviceMappingEvent; 5070</literallayout> 5071<!-- .eM --> 5072</para> 5073</sect4> 5074<sect4 id="ChangeDeviceNotify_Event"> 5075<title>ChangeDeviceNotify Event</title> 5076<!-- .XS --> 5077<!-- (SN ChangeDeviceNotify Event --> 5078<!-- .XE --> 5079<para> 5080<!-- .LP --> 5081This event has no equivalent in the core protocol. It notifies client 5082programs when one of the core devices has been changed. 5083</para> 5084<para> 5085<!-- .LP --> 5086<!-- .sM --> 5087<literallayout class="monospaced"> 5088<!-- .TA .5i 3i --> 5089<!-- .ta .5i 3i --> 5090typedef struct { 5091 int type; 5092 unsigned long serial; 5093 Bool send_event; 5094 Display *display; 5095 Window window; 5096 XID deviceid; 5097 Time time; 5098 int request; 5099} XChangeDeviceNotifyEvent; 5100</literallayout> 5101<!-- .eM --> 5102</para> 5103</sect4> 5104<sect4 id="Proximity_Events"> 5105<title>Proximity Events</title> 5106<!-- .XS --> 5107<!-- (SN Proximity Events --> 5108<!-- .XE --> 5109<para> 5110<!-- .LP --> 5111These events have no equivalent in the core protocol. Some input 5112devices such as graphics tablets or touchscreens may send these 5113events to indicate that a stylus has moved into or out of contact 5114with a positional sensing surface. 5115</para> 5116<para> 5117<!-- .LP --> 5118The event contains the current value of any valuators on the device 5119if that device is reporting absolute data. 5120If data for more than six valuators is being reported, more than one 5121proximity event may be sent. 5122The axes_count member contains the number of axes that are being 5123reported. The server sends as many of these events as are 5124needed to report the device data. Each event contains the total number 5125of axes reported in the axes_count member and the first axis reported 5126in the current event in the first_axis member. 5127If the device supports input class 5128<function>Valuators , </function> 5129but is not reporting absolute mode data, 5130the axes_count member contains zero (0). 5131</para> 5132<para> 5133<!-- .LP --> 5134<!-- .sM --> 5135<literallayout class="monospaced"> 5136<!-- .TA .5i 3i --> 5137<!-- .ta .5i 3i --> 5138typedef struct { 5139 int type; /* ProximityIn or ProximityOut */ 5140 unsigned long serial; /* # of last request processed by server */ 5141 Bool send_event; /* true if this came from a SendEvent request */ 5142 Display *display; /* Display the event was read from */ 5143 Window window; 5144 XID deviceid; 5145 Window root; 5146 Window subwindow; 5147 Time time; 5148 int x, y; 5149 int x_root, y_root; 5150 unsigned int state; 5151 Bool same_screen; 5152 unsigned int device_state; /* device key or button mask */ 5153 unsigned char axes_count; 5154 unsigned char first_axis; 5155 int axis_data[6]; 5156} XProximityNotifyEvent; 5157 5158typedef XProximityNotifyEvent XProximityInEvent; 5159typedef XProximityNotifyEvent XProximityOutEvent; 5160</literallayout> 5161<!-- .eM --> 5162</para> 5163</sect4> 5164</sect3> 5165</sect2> 5166<sect2 id="Event_Handling_Functions"> 5167<title>Event Handling Functions</title> 5168<!-- .XS --> 5169<!-- (SN Event Handling Functions --> 5170<!-- .XE --> 5171<para> 5172<!-- .LP --> 5173This section discusses the X Input Extension 5174event handling functions that allow you to: 5175</para> 5176<itemizedlist> 5177 <listitem> 5178 <para> 5179Determine the extension version 5180 </para> 5181 </listitem> 5182 <listitem> 5183 <para> 5184List the available devices 5185 </para> 5186 </listitem> 5187 <listitem> 5188 <para> 5189Enable and disable extension devices 5190 </para> 5191 </listitem> 5192 <listitem> 5193 <para> 5194Change the mode of a device 5195 </para> 5196 </listitem> 5197 <listitem> 5198 <para> 5199Initialize valuators on an input device 5200 </para> 5201 </listitem> 5202 <listitem> 5203 <para> 5204Get input device controls 5205 </para> 5206 </listitem> 5207 <listitem> 5208 <para> 5209Change input device controls 5210 </para> 5211 </listitem> 5212 <listitem> 5213 <para> 5214Select extension device events 5215 </para> 5216 </listitem> 5217 <listitem> 5218 <para> 5219Determine selected device events 5220 </para> 5221 </listitem> 5222 <listitem> 5223 <para> 5224Control event propogation 5225 </para> 5226 </listitem> 5227 <listitem> 5228 <para> 5229Send an event 5230 </para> 5231 </listitem> 5232 <listitem> 5233 <para> 5234Get motion history 5235 </para> 5236 </listitem> 5237</itemizedlist> 5238<sect3 id="Determining_the_Extension_Version"> 5239<title>Determining the Extension Version</title> 5240<!-- .XS --> 5241<!-- (SN Determining the Extension Version --> 5242<!-- .XE --> 5243<para> 5244<!-- .LP --> 5245<!-- .sM --> 5246<funcsynopsis> 5247<funcprototype> 5248 <funcdef>XExtensionVersion * <function> XGetExtensionVersion</function></funcdef> 5249 <paramdef>Display<parameter> *display</parameter></paramdef> 5250 <paramdef>char<parameter> *name</parameter></paramdef> 5251</funcprototype> 5252</funcsynopsis> 5253<!-- .FN --> 5254<variablelist> 5255 <varlistentry> 5256 <term> 5257 <emphasis remap='I'>display</emphasis> 5258 </term> 5259 <listitem> 5260 <para> 5261Specifies the connection to the X server. 5262 </para> 5263 </listitem> 5264 </varlistentry> 5265 <varlistentry> 5266 <term> 5267 <emphasis remap='I'>name</emphasis> 5268 </term> 5269 <listitem> 5270 <para> 5271Specifies the name of the desired extension. 5272 </para> 5273 </listitem> 5274 </varlistentry> 5275</variablelist> 5276</para> 5277<para> 5278<!-- .LP --> 5279<!-- .eM --> 5280<function>XGetExtensionVersion</function> 5281allows a client to determine whether a server supports 5282the desired version of the input extension. 5283</para> 5284<para> 5285<!-- .LP --> 5286The 5287<function>XExtensionVersion</function> 5288structure returns information about the version of the extension 5289supported by the server and is defined as follows: 5290</para> 5291<para> 5292<!-- .LP --> 5293<!-- .sM --> 5294<literallayout class="monospaced"> 5295<!-- .TA .5i --> 5296<!-- .ta .5i --> 5297typedef struct { 5298 Bool present; 5299 short major_version; 5300 short minor_version; 5301} XExtensionVersion; 5302</literallayout> 5303</para> 5304<para> 5305<!-- .LP --> 5306<!-- .eM --> 5307The major and minor versions can be compared with constants defined in 5308the header file 5309<function>< X11/extensions/XI.h >.</function> 5310Each version is a superset of the previous versions. 5311</para> 5312<para> 5313<!-- .LP --> 5314You should use 5315<function>XFree</function> 5316to free the data returned by this function. 5317</para> 5318</sect3> 5319<sect3 id="Listing_Available_Devices"> 5320<title>Listing Available Devices</title> 5321<!-- .XS --> 5322<!-- (SN Listing Available Devices --> 5323<!-- .XE --> 5324<para> 5325<!-- .LP --> 5326A client program that wishes to access a specific device 5327must first determine whether that device is connected to the X server. This 5328is done through the 5329<function>XListInputDevices</function> 5330function, which will return a list of all devices that can be opened 5331by the X server. The client program can use one 5332of the names defined in the 5333<function>< X11/extensions/XI.h ></function> 5334header file in an 5335<function>XInternAtom </function> 5336request to determine the device type of the desired device. This type 5337can then be compared with the device types returned by the 5338<function>XListInputDevices</function> 5339request. 5340</para> 5341<para> 5342<!-- .LP --> 5343<!-- .sM --> 5344<funcsynopsis> 5345<funcprototype> 5346 <funcdef>XDeviceInfo * <function> XListInputDevices</function></funcdef> 5347 <paramdef>Display<parameter> *display</parameter></paramdef> 5348 <paramdef>int<parameter> *ndevices</parameter></paramdef> 5349</funcprototype> 5350</funcsynopsis> 5351<!-- .FN --> 5352<variablelist> 5353 <varlistentry> 5354 <term> 5355 <emphasis remap='I'>display</emphasis> 5356 </term> 5357 <listitem> 5358 <para> 5359Specifies the connection to the X server. 5360 </para> 5361 </listitem> 5362 </varlistentry> 5363 <varlistentry> 5364 <term> 5365 <emphasis remap='I'>ndevices</emphasis> 5366 </term> 5367 <listitem> 5368 <para> 5369Specifies the address of a variable into which the server 5370can return the number of input devices available to the X server. 5371 </para> 5372 </listitem> 5373 </varlistentry> 5374</variablelist> 5375</para> 5376<para> 5377<!-- .LP --> 5378<!-- .eM --> 5379<function>XListInputDevices</function> 5380allows a client to determine which devices 5381are available for X input and information about those devices. 5382An array of 5383<function>XDeviceInfo</function> 5384structures is returned, with one element in the array for each device. 5385The number of devices is returned in the ndevices argument. 5386</para> 5387<para> 5388<!-- .LP --> 5389The X pointer device and X keyboard device are reported, as well as 5390all available extension input devices. The use member of the 5391<function>XDeviceInfo</function> 5392structure specifies the current use of the device. 5393If the value of this member is 5394<function>IsXPointer ,</function> 5395the device is the X pointer device. If the value is 5396<function>IsXKeyboard ,</function> 5397the device is the X keyboard device. If the value is 5398<function>IsXExtensionDevice ,</function> 5399the device is available for use as an extension input device. 5400</para> 5401<para> 5402<!-- .LP --> 5403Each 5404<function>XDeviceInfo</function> 5405entry contains a pointer to a list of structures 5406that describe the characteristics of each class 5407of input supported by that device. The num_classes member 5408contains the number of entries in that list. 5409</para> 5410<para> 5411<!-- .LP --> 5412If the device supports input class 5413<function>Valuators ,</function> 5414one of the structures pointed to by the 5415<function>XDeviceInfo</function> 5416structure will be an 5417<function>XValuatorInfo</function> 5418structure. The axes member of that structure 5419contains the address of an array of 5420<function>XAxisInfo</function> 5421structures. 5422There is one element in this array for each axis of motion 5423reported by the device. The number of elements in this 5424array is contained in the num_axes element of the 5425<function>XValuatorInfo</function> 5426structure. 5427The size of the motion buffer for the device is 5428reported in the motion_buffer member of the 5429<function>XValuatorInfo</function> 5430structure. 5431</para> 5432<para> 5433<!-- .LP --> 5434The 5435<function>XDeviceInfo</function> 5436structure is defined as follows: 5437</para> 5438<para> 5439<!-- .LP --> 5440<!-- .sM --> 5441<literallayout class="monospaced"> 5442<!-- .TA .5i --> 5443<!-- .ta .5i --> 5444typedef struct _XDeviceInfo { 5445 XID id; 5446 Atom type; 5447 char *name; 5448 int num_classes; 5449 int use; 5450 XAnyClassPtr inputclassinfo; 5451} XDeviceInfo; 5452</literallayout> 5453</para> 5454<para> 5455<!-- .LP --> 5456<!-- .eM --> 5457The structures pointed to by the 5458<function>XDeviceInfo</function> 5459structure are defined as follows: 5460</para> 5461<para> 5462<!-- .LP --> 5463<!-- .sM --> 5464<literallayout class="monospaced"> 5465<!-- .TA .5i --> 5466<!-- .ta .5i --> 5467typedef struct _XKeyInfo { 5468 XID class; 5469 int length; 5470 unsigned short min_keycode; 5471 unsigned short max_keycode; 5472 unsigned short num_keys; 5473} XKeyInfo; 5474 5475typedef struct _XButtonInfo { 5476 XID class; 5477 int length; 5478 short num_buttons; 5479} XButtonInfo; 5480 5481typedef struct _XValuatorInfo { 5482 XID class; 5483 int length; 5484 unsigned char num_axes; 5485 unsigned char mode; 5486 unsigned long motion_buffer; 5487 XAxisInfoPtr axes; 5488} XValuatorInfo; 5489</literallayout> 5490</para> 5491<para> 5492<!-- .LP --> 5493<!-- .eM --> 5494The 5495<function>XAxisInfo</function> 5496structure pointed to by the 5497<function>XValuatorInfo</function> 5498structure is defined as follows: 5499</para> 5500<para> 5501<!-- .LP --> 5502<!-- .sM --> 5503<literallayout class="monospaced"> 5504<!-- .TA .5i --> 5505<!-- .ta .5i --> 5506typedef struct _XAxisInfo { 5507 int resolution; 5508 int min_value; 5509 int max_value; 5510} XAxisInfo; 5511</literallayout> 5512</para> 5513<para> 5514<!-- .LP --> 5515<!-- .eM --> 5516The following atom names are defined in the 5517<function>< X11/extensions/XI.h ></function> 5518header file. 5519<literallayout class="monospaced"> 5520<!-- .TA 2i --> 5521<!-- .ta 2i --> 5522MOUSE QUADRATURE 5523TABLET SPACEBALL 5524KEYBOARD DATAGLOVE 5525TOUCHSCREEN EYETRACKER 5526TOUCHPAD CURSORKEYS 5527BUTTONBOX FOOTMOUSE 5528BARCODE ID_MODULE 5529KNOB_BOX ONE_KNOB 5530TRACKBALL NINE_KNOB\s+1 5531</literallayout> 5532</para> 5533<para> 5534<!-- .LP --> 5535These names can be used in an 5536<function>XInternAtom</function> 5537request to return an atom that can be used for comparison 5538with the type member of the 5539<function>XDeviceInfo</function> 5540structure. 5541</para> 5542<para> 5543<!-- .LP --> 5544<function>XListInputDevices</function> 5545returns NULL if there are no input devices to list. 5546<!-- .sp --> 5547</para> 5548<para> 5549<!-- .LP --> 5550To free the data returned by 5551<function>XListInputDevices ,</function> 5552use 5553<function>XFreeDeviceList .</function> 5554<!-- .sp --> 5555</para> 5556<para> 5557<!-- .LP --> 5558<!-- .sM --> 5559<funcsynopsis> 5560<funcprototype> 5561 <funcdef>void <function> XFreeDeviceList</function></funcdef> 5562 <paramdef>XDeviceInfo<parameter> *list</parameter></paramdef> 5563</funcprototype> 5564</funcsynopsis> 5565<!-- .FN --> 5566<variablelist> 5567 <varlistentry> 5568 <term> 5569 <emphasis remap='I'>list</emphasis> 5570 </term> 5571 <listitem> 5572 <para> 5573Specifies the pointer to the 5574<function>XDeviceInfo</function> 5575array returned by a previous call to 5576<function>XListInputDevices .</function> 5577 </para> 5578 </listitem> 5579 </varlistentry> 5580</variablelist> 5581</para> 5582<para> 5583<!-- .LP --> 5584<!-- .eM --> 5585<function>XFreeDeviceList</function> 5586frees the list of input device information. 5587</para> 5588</sect3> 5589<sect3 id="Enabling_and_Disabling_Extension_Devices"> 5590<title>Enabling and Disabling Extension Devices</title> 5591<!-- .XS --> 5592<!-- (SN Enabling and Disabling Extension Devices --> 5593<!-- .XE --> 5594<para> 5595<!-- .LP --> 5596Each client program that wishes to access an extension device must request 5597that the server open that device by calling the 5598<function>XOpenDevice</function> 5599function. 5600<!-- .sM --> 5601<funcsynopsis> 5602<funcprototype> 5603 <funcdef>XDevice * <function> XOpenDevice</function></funcdef> 5604 <paramdef>Display<parameter> *display</parameter></paramdef> 5605 <paramdef>XID<parameter> device_id</parameter></paramdef> 5606</funcprototype> 5607</funcsynopsis> 5608<!-- .FN --> 5609<variablelist> 5610 <varlistentry> 5611 <term> 5612 <emphasis remap='I'>display</emphasis> 5613 </term> 5614 <listitem> 5615 <para> 5616Specifies the connection to the X server. 5617 </para> 5618 </listitem> 5619 </varlistentry> 5620 <varlistentry> 5621 <term> 5622 <emphasis remap='I'>device_id</emphasis> 5623 </term> 5624 <listitem> 5625 <para> 5626Specifies the ID that uniquely identifies the device to be opened. 5627This ID is obtained from the 5628<function>XListInputDevices</function> 5629request. 5630 </para> 5631 </listitem> 5632 </varlistentry> 5633</variablelist> 5634</para> 5635<para> 5636<!-- .LP --> 5637<!-- .eM --> 5638<function>XOpenDevice</function> 5639opens the device for the requesting client and, on success, returns an 5640<function>XDevice</function> 5641structure, which is defined as follows: 5642</para> 5643<para> 5644<!-- .LP --> 5645<!-- .sM --> 5646<literallayout class="monospaced"> 5647<!-- .TA .5i --> 5648<!-- .ta .5i --> 5649typedef struct { 5650 XID device_id; 5651 int num_classes; 5652 XInputClassInfo *classes; 5653} XDevice; 5654</literallayout> 5655</para> 5656<para> 5657<!-- .LP --> 5658<!-- .eM --> 5659The 5660<function>XDevice</function> 5661structure contains a pointer to an array of 5662<function>XInputClassInfo</function> 5663structures. Each element in that array 5664contains information about events of a particular input class supported 5665by the input device. 5666</para> 5667<para> 5668<!-- .LP --> 5669The 5670<function>XInputClassInfo</function> 5671structure is defined as follows: 5672</para> 5673<para> 5674<!-- .LP --> 5675<!-- .sM --> 5676<literallayout class="monospaced"> 5677<!-- .TA .5i --> 5678<!-- .ta .5i --> 5679typedef struct { 5680 unsigned char input_class; 5681 unsigned char event_type_base; 5682} XInputClassInfo; 5683</literallayout> 5684</para> 5685<para> 5686<!-- .LP --> 5687<!-- .eM --> 5688A client program can determine the event 5689type and event class for a given event by using macros defined by the 5690input extension. The name of the macro corresponds to the desired event, 5691and the macro is passed the structure that describes the device from which 5692input is desired, for example: 5693</para> 5694<para> 5695<!-- .LP --> 5696<literallayout class="monospaced"> 5697<!-- .TA .5i --> 5698<!-- .ta .5i --> 5699 DeviceKeyPress(XDevice *device, event_type, event_class) 5700</literallayout> 5701</para> 5702<para> 5703<!-- .LP --> 5704The macro will fill in the values of the event class to be used in an 5705<function>XSelectExtensionEvent</function> 5706request to select the event and the event type to be used in comparing 5707with the event types of events received via 5708<function>XNextEvent .</function> 5709</para> 5710<para> 5711<!-- .LP --> 5712<function>XOpenDevice</function> 5713can generate 5714<function>BadDevice</function> 5715errors. 5716<!-- .sp --> 5717</para> 5718<para> 5719<!-- .LP --> 5720Before terminating, the client program should request that the server close 5721the device by calling the 5722<function>XCloseDevice</function> 5723function. 5724<!-- .sM --> 5725<funcsynopsis> 5726<funcprototype> 5727 <funcdef>int <function> XCloseDevice</function></funcdef> 5728 <paramdef>Display<parameter> *display</parameter></paramdef> 5729 <paramdef>XDevice<parameter> *device</parameter></paramdef> 5730</funcprototype> 5731</funcsynopsis> 5732<!-- .FN --> 5733<variablelist> 5734 <varlistentry> 5735 <term> 5736 <emphasis remap='I'>display</emphasis> 5737 </term> 5738 <listitem> 5739 <para> 5740Specifies the connection to the X server. 5741 </para> 5742 </listitem> 5743 </varlistentry> 5744 <varlistentry> 5745 <term> 5746 <emphasis remap='I'>device</emphasis> 5747 </term> 5748 <listitem> 5749 <para> 5750Specifies the device to be closed. 5751 </para> 5752 </listitem> 5753 </varlistentry> 5754</variablelist> 5755</para> 5756<para> 5757<!-- .LP --> 5758<!-- .eM --> 5759<function>XCloseDevice</function> 5760closes the device for the requesting client and frees the associated 5761<function>XDevice</function> 5762structure. 5763</para> 5764<para> 5765<!-- .LP --> 5766A client may open the same extension device more than once. Requests 5767after the first successful one return an additional 5768<function>XDevice</function> 5769structure 5770with the same information as the first, but otherwise have no effect. 5771A single 5772<function>XCloseDevice</function> 5773request will terminate that client's access to the device. 5774</para> 5775<para> 5776<!-- .LP --> 5777Closing a device releases any active or passive grabs the requesting client 5778has established. If the device is frozen only by an active grab of the 5779requesting client, any queued events are released. 5780</para> 5781<para> 5782<!-- .LP --> 5783If a client program terminates without closing a device, the server will 5784automatically close that device on behalf of the client. This does not 5785affect any other clients that may be accessing that device. 5786</para> 5787<para> 5788<!-- .LP --> 5789<function>XCloseDevice</function> 5790can generate 5791<function>BadDevice</function> 5792errors. 5793</para> 5794</sect3> 5795<sect3 id="Changing_the_Mode_of_a_Device"> 5796<title>Changing the Mode of a Device</title> 5797<!-- .XS --> 5798<!-- (SN Changing the Mode of a Device --> 5799<!-- .XE --> 5800<para> 5801<!-- .LP --> 5802Some devices are capable of reporting either relative or absolute motion 5803data. 5804To change the mode of a device from relative to absolute, use 5805<function>XSetDeviceMode .</function> 5806<!-- .sM --> 5807<funcsynopsis> 5808<funcprototype> 5809 <funcdef>int <function> XSetDeviceMode</function></funcdef> 5810 <paramdef>Display<parameter> *display</parameter></paramdef> 5811 <paramdef>XDevice<parameter> *device</parameter></paramdef> 5812 <paramdef>int<parameter> mode</parameter></paramdef> 5813</funcprototype> 5814</funcsynopsis> 5815<!-- .FN --> 5816<variablelist> 5817 <varlistentry> 5818 <term> 5819 <emphasis remap='I'>display</emphasis> 5820 </term> 5821 <listitem> 5822 <para> 5823Specifies the connection to the X server. 5824 </para> 5825 </listitem> 5826 </varlistentry> 5827 <varlistentry> 5828 <term> 5829 <emphasis remap='I'>device</emphasis> 5830 </term> 5831 <listitem> 5832 <para> 5833Specifies the device whose mode should be changed. 5834 </para> 5835 </listitem> 5836 </varlistentry> 5837 <varlistentry> 5838 <term> 5839 <emphasis remap='I'>mode</emphasis> 5840 </term> 5841 <listitem> 5842 <para> 5843Specifies the mode. You can pass 5844<function>Absolute</function> 5845or 5846<function>Relative .</function> 5847 </para> 5848 </listitem> 5849 </varlistentry> 5850</variablelist> 5851</para> 5852<para> 5853<!-- .LP --> 5854<!-- .eM --> 5855<function>XSetDeviceMode</function> 5856allows a client to request the server to change the mode of a 5857device that is capable of reporting either absolute positional data or relative 5858motion data. If the device is invalid or if the client has not previously 5859requested that the server open the device via an 5860<function>XOpenDevice</function> 5861request, this request will fail with a 5862<function>BadDevice</function> 5863error. 5864If the device does not support input class 5865<function>Valuators</function> 5866or if it is not capable of reporting the specified mode, 5867the request will fail with a 5868<function>BadMatch</function> 5869error. 5870</para> 5871<para> 5872<!-- .LP --> 5873This request will fail and return 5874<function>DeviceBusy</function> 5875if another client has already opened the device and requested a different mode. 5876</para> 5877<para> 5878<!-- .LP --> 5879<function>XSetDeviceMode</function> 5880can generate 5881<function>BadDevice ,</function> 5882<function>BadMatch ,</function> 5883<function>BadMode ,</function> 5884and 5885<function>DeviceBusy</function> 5886errors. 5887</para> 5888</sect3> 5889<sect3 id="Initializing_Valuators_on_an_Input_Device"> 5890<title>Initializing Valuators on an Input Device</title> 5891<!-- .XS --> 5892<!-- (SN Initializing Valuators on an Input Device --> 5893<!-- .XE --> 5894<para> 5895<!-- .LP --> 5896Some devices that report absolute positional data can be initialized to a 5897starting value. Devices that are capable of reporting relative motion or 5898absolute positional data may require that their valuators be initialized 5899to a starting value after the mode of the device is changed to 5900<function>Absolute .</function> 5901<!-- .sp --> 5902</para> 5903<para> 5904<!-- .LP --> 5905To initialize the valuators on such a device, use 5906<function>XSetDeviceValuators .</function> 5907<!-- .sM --> 5908<funcsynopsis> 5909<funcprototype> 5910 <funcdef>Status <function> XSetDeviceValuators</function></funcdef> 5911 <paramdef>Display<parameter> *display</parameter></paramdef> 5912 <paramdef>XDevice<parameter> *device</parameter></paramdef> 5913 <paramdef>int*valuators,first_valuator,<parameter> num_valuators</parameter></paramdef> 5914</funcprototype> 5915</funcsynopsis> 5916<!-- .FN --> 5917<variablelist> 5918 <varlistentry> 5919 <term> 5920 <emphasis remap='I'>display</emphasis> 5921 </term> 5922 <listitem> 5923 <para> 5924Specifies the connection to the X server. 5925 </para> 5926 </listitem> 5927 </varlistentry> 5928 <varlistentry> 5929 <term> 5930 <emphasis remap='I'>device</emphasis> 5931 </term> 5932 <listitem> 5933 <para> 5934Specifies the device whose valuators should be initialized. 5935 </para> 5936 </listitem> 5937 </varlistentry> 5938 <varlistentry> 5939 <term> 5940 <emphasis remap='I'>valuators</emphasis> 5941 </term> 5942 <listitem> 5943 <para> 5944Specifies the values to which each valuator should be set. 5945 </para> 5946 </listitem> 5947 </varlistentry> 5948 <varlistentry> 5949 <term> 5950 <emphasis remap='I'>first_valuator</emphasis> 5951 </term> 5952 <listitem> 5953 <para> 5954Specifies the first valuator to be set. 5955 </para> 5956 </listitem> 5957 </varlistentry> 5958 <varlistentry> 5959 <term> 5960 <emphasis remap='I'>num_valuators</emphasis> 5961 </term> 5962 <listitem> 5963 <para> 5964Specifies the number of valuators to be set. 5965 </para> 5966 </listitem> 5967 </varlistentry> 5968</variablelist> 5969</para> 5970<para> 5971<!-- .LP --> 5972<!-- .eM --> 5973<function>XSetDeviceValuators</function> 5974initializes the specified valuators on the specified extension 5975input device. Valuators are numbered beginning with zero. Only the valuators 5976in the range specified by first_valuator and num_valuators are set. 5977A 5978<function>BadValue</function> 5979error results if the number of valuators supported by the device 5980is less than the following expression: 5981<literallayout class="monospaced"> 5982<!-- .TA .5i --> 5983<!-- .ta .5i --> 5984 first_valuator + num_valuators 5985</literallayout> 5986</para> 5987<para> 5988<!-- .LP --> 5989If the request succeeds, 5990<function>Success</function> 5991is returned. If the specified device is grabbed by some other client, 5992the request will fail and a status of 5993<function>AlreadyGrabbed</function> 5994will be returned. 5995</para> 5996<para> 5997<!-- .LP --> 5998<function>XSetDeviceValuators</function> 5999can generate 6000<function>BadDevice ,</function> 6001<function>BadLength ,</function> 6002<function>BadMatch ,</function> 6003and 6004<function>BadValue</function> 6005errors. 6006</para> 6007</sect3> 6008<sect3 id="Getting_Input_Device_Controls"> 6009<title>Getting Input Device Controls</title> 6010<!-- .XS --> 6011<!-- (SN Getting Input Device Controls --> 6012<!-- .XE --> 6013<para> 6014<!-- .LP --> 6015Some input devices support various configuration controls 6016that can be queried or changed by clients. The set of supported 6017controls will vary from one input device to another. Requests 6018to manipulate these controls will fail if either the target 6019X server or the target input device does not support the 6020requested device control. 6021</para> 6022<para> 6023<!-- .LP --> 6024Each device control has a unique identifier. Information 6025passed with each device control varies in length and is mapped 6026by data structures unique to that device control. 6027<!-- .sp --> 6028</para> 6029<para> 6030<!-- .LP --> 6031To query a device control, use 6032<function>XGetDeviceControl .</function> 6033<!-- .sM --> 6034<funcsynopsis> 6035<funcprototype> 6036 <funcdef>XDeviceControl * <function> XGetDeviceControl</function></funcdef> 6037 <paramdef>Display<parameter> *display</parameter></paramdef> 6038 <paramdef>XDevice<parameter> *device</parameter></paramdef> 6039 <paramdef>int<parameter> control</parameter></paramdef> 6040</funcprototype> 6041</funcsynopsis> 6042<!-- .FN --> 6043<variablelist> 6044 <varlistentry> 6045 <term> 6046 <emphasis remap='I'>display</emphasis> 6047 </term> 6048 <listitem> 6049 <para> 6050Specifies the connection to the X server. 6051 </para> 6052 </listitem> 6053 </varlistentry> 6054 <varlistentry> 6055 <term> 6056 <emphasis remap='I'>device</emphasis> 6057 </term> 6058 <listitem> 6059 <para> 6060Specifies the device whose configuration control status is to be returned. 6061 </para> 6062 </listitem> 6063 </varlistentry> 6064 <varlistentry> 6065 <term> 6066 <emphasis remap='I'>control</emphasis> 6067 </term> 6068 <listitem> 6069 <para> 6070Identifies the specific device control to be queried. 6071 </para> 6072 </listitem> 6073 </varlistentry> 6074</variablelist> 6075</para> 6076<para> 6077<!-- .LP --> 6078<!-- .eM --> 6079<function>XGetDeviceControl</function> 6080returns the current state of the specified device control. 6081If the target X server does not support that device control, a 6082<function>BadValue</function> 6083error is returned. 6084If the specified device does not support that device control, a 6085<function>BadMatch</function> 6086error 6087is returned. 6088</para> 6089<para> 6090<!-- .LP --> 6091If the request is successful, a pointer to a generic 6092<function>XDeviceState</function> 6093structure is returned. The information returned varies according 6094to the specified control and is mapped by a structure appropriate 6095for that control. 6096The first two members are common to all device controls 6097and are defined as follows: 6098</para> 6099<para> 6100<!-- .LP --> 6101<!-- .sM --> 6102<literallayout class="monospaced"> 6103<!-- .TA .5i --> 6104<!-- .ta .5i --> 6105typedef struct { 6106 XID control; 6107 int length; 6108} XDeviceState; 6109\fP 6110</literallayout> 6111</para> 6112<para> 6113<!-- .LP --> 6114<!-- .eM --> 6115The control may be compared to constants defined in the file 6116<function>< X11/extensions/XI.h >.</function> 6117Currently defined device controls include DEVICE_RESOLUTION. 6118</para> 6119<para> 6120<!-- .LP --> 6121The information returned for the DEVICE_RESOLUTION control is 6122defined in the 6123<function>XDeviceResolutionState</function> 6124structure, which is defined as follows: 6125</para> 6126<para> 6127<!-- .LP --> 6128<!-- .sM --> 6129<literallayout class="monospaced"> 6130<!-- .TA .5i --> 6131<!-- .ta .5i --> 6132typedef struct { 6133 XID control; 6134 int length; 6135 int num_valuators; 6136 int *resolutions; 6137 int *min_resolutions; 6138 int *max_resolutions; 6139} XDeviceResolutionState; 6140</literallayout> 6141</para> 6142<para> 6143<!-- .LP --> 6144<!-- .eM --> 6145This device control returns a list of valuators and the range of 6146valid resolutions allowed for each. Valuators are numbered 6147beginning with zero (0). Resolutions for all valuators on the device are 6148returned. For each valuator i on the device, resolutions[i] returns 6149the current setting of the resolution, min_resolutions[i] returns 6150the minimum valid setting, and max_resolutions[i] returns the 6151maximum valid setting. 6152</para> 6153<para> 6154<!-- .LP --> 6155When this control is specified, 6156<function>XGetDeviceControl</function> 6157fails with a 6158<function>BadMatch</function> 6159error if the specified device has no valuators. 6160</para> 6161<para> 6162<!-- .LP --> 6163<function>XGetDeviceControl</function> 6164can generate 6165<function>BadMatch</function> 6166and 6167<function>BadValue</function> 6168errors. 6169</para> 6170</sect3> 6171<sect3 id="Changing_Input_Device_Controls"> 6172<title>Changing Input Device Controls</title> 6173<!-- .XS --> 6174<!-- (SN Changing Input Device Controls --> 6175<!-- .XE --> 6176<para> 6177<!-- .LP --> 6178Some input devices support various configuration controls 6179that can be changed by clients. Typically, this would be 6180done to initialize the device to a known state or configuration. 6181The set of supported controls will vary from one input device 6182to another. Requests to manipulate these controls will fail if 6183either the target X server or the target input device does not 6184support the requested device control. Setting the device control 6185will also fail if the target input device is grabbed by another 6186client or is open by another client and has been set to a conflicting 6187state. 6188</para> 6189<para> 6190<!-- .LP --> 6191Each device control has a unique identifier. Information 6192passed with each device control varies in length and is mapped 6193by data structures unique to that device control. 6194<!-- .sp --> 6195</para> 6196<para> 6197<!-- .LP --> 6198To change a device control, use 6199<function>XChangeDeviceControl .</function> 6200<!-- .sM --> 6201<funcsynopsis> 6202<funcprototype> 6203 <funcdef>Status <function> XChangeDeviceControl</function></funcdef> 6204 <paramdef>Display<parameter> *display</parameter></paramdef> 6205 <paramdef>XDevice<parameter> *device</parameter></paramdef> 6206 <paramdef>int<parameter> control</parameter></paramdef> 6207 <paramdef>XDeviceControl<parameter> *value</parameter></paramdef> 6208</funcprototype> 6209</funcsynopsis> 6210<!-- .FN --> 6211<variablelist> 6212 <varlistentry> 6213 <term> 6214 <emphasis remap='I'>display</emphasis> 6215 </term> 6216 <listitem> 6217 <para> 6218Specifies the connection to the X server. 6219 </para> 6220 </listitem> 6221 </varlistentry> 6222 <varlistentry> 6223 <term> 6224 <emphasis remap='I'>device</emphasis> 6225 </term> 6226 <listitem> 6227 <para> 6228Specifies the device whose configuration control status is to be modified. 6229 </para> 6230 </listitem> 6231 </varlistentry> 6232 <varlistentry> 6233 <term> 6234 <emphasis remap='I'>control</emphasis> 6235 </term> 6236 <listitem> 6237 <para> 6238Identifies the specific device control to be changed. 6239 </para> 6240 </listitem> 6241 </varlistentry> 6242 <varlistentry> 6243 <term> 6244 <emphasis remap='I'>value</emphasis> 6245 </term> 6246 <listitem> 6247 <para> 6248Specifies a pointer to an 6249<function>XDeviceControl</function> 6250structure that describes which control is to be changed 6251and how it is to be changed. 6252 </para> 6253 </listitem> 6254 </varlistentry> 6255</variablelist> 6256</para> 6257<para> 6258<!-- .LP --> 6259<!-- .eM --> 6260<function>XChangeDeviceControl</function> 6261changes the current state of the specified device control. 6262If the target X server does not support that device control, a 6263<function>BadValue</function> 6264error is returned. 6265If the specified device does not support that device control, a 6266<function>BadMatch</function> 6267error is returned. 6268If another client has the target device grabbed, a status of 6269<function>AlreadyGrabbed</function> 6270is returned. 6271If another client has the device open and has set it to a 6272conflicting state, a status of 6273<function>DeviceBusy</function> 6274is returned. 6275If the request fails for any reason, the device control will not 6276be changed. 6277</para> 6278<para> 6279<!-- .LP --> 6280If the request is successful, the device control will be changed 6281and a status of 6282<function>Success</function> 6283is returned. 6284The information passed varies according to the specified control 6285and is mapped by a structure appropriate for that control. 6286The first two members are common to all device controls: 6287</para> 6288<para> 6289<!-- .LP --> 6290<!-- .sM --> 6291<literallayout class="monospaced"> 6292<!-- .TA .5i --> 6293<!-- .ta .5i --> 6294typedef struct { 6295 XID control; 6296 int length; 6297} XDeviceControl; 6298</literallayout> 6299</para> 6300<para> 6301<!-- .LP --> 6302<!-- .eM --> 6303The control may be set using constants defined in the 6304<function>< X11/extensions/XI.h ></function> 6305header file. 6306Currently defined device controls include DEVICE_RESOLUTION. 6307</para> 6308<para> 6309<!-- .LP --> 6310The information that can be changed by the DEVICE_RESOLUTION 6311control is defined in the 6312<function>XDeviceResolutionControl</function> 6313structure, which is defined as follows: 6314</para> 6315<para> 6316<!-- .LP --> 6317<!-- .sM --> 6318<literallayout class="monospaced"> 6319<!-- .TA .5i --> 6320<!-- .ta .5i --> 6321typedef struct { 6322 XID control; 6323 int length; 6324 int first_valuator; 6325 int num_valuators; 6326 int *resolutions; 6327} XDeviceResolutionControl; 6328</literallayout> 6329</para> 6330<para> 6331<!-- .LP --> 6332<!-- .eM --> 6333This device control changes the resolution of the specified 6334valuators on the specified extension input device. Valuators 6335are numbered beginning with zero. Only the valuators in the range 6336specified by first_valuator and num_valuators are set. A value 6337of -1 in the resolutions list indicates that the resolution for 6338this valuator is not to be changed. The num_valuators member 6339specifies the number of valuators in the resolutions list. 6340</para> 6341<para> 6342<!-- .LP --> 6343When this control is specified, 6344<function>XChangeDeviceControl</function> 6345fails with a 6346<function>BadMatch</function> 6347error if the specified device has no valuators. 6348If a resolution is specified that is not within the range of valid values 6349(as returned by 6350<function>XGetDeviceControl ),</function> 6351<function>XChangeDeviceControl</function> 6352fails with a 6353<function>BadValue</function> 6354error. 6355A 6356<function>BadValue</function> 6357error results if the number of valuators supported by the device 6358is less than the following expression: 6359</para> 6360<para> 6361<!-- .LP --> 6362<literallayout class="monospaced"> 6363<!-- .TA .5i --> 6364<!-- .ta .5i --> 6365 first_valuator + num_valuators, 6366</literallayout> 6367</para> 6368<para> 6369<!-- .LP --> 6370<function>XChangeDeviceControl</function> 6371can generate 6372<function>BadMatch</function> 6373and 6374<function>BadValue</function> 6375errors. 6376</para> 6377</sect3> 6378<sect3 id="Selecting_Extension_Device_Events"> 6379<title>Selecting Extension Device Events</title> 6380<!-- .XS --> 6381<!-- (SN Selecting Extension Device Events --> 6382<!-- .XE --> 6383<para> 6384<!-- .LP --> 6385To select device input events, use 6386<function>XSelectExtensionEvent .</function> 6387The parameters passed are a pointer to 6388a list of classes that define the desired event types and devices, a count 6389of the number of elements in the list, and the ID of the window from which 6390events are desired. 6391<!-- .sM --> 6392<funcsynopsis> 6393<funcprototype> 6394 <funcdef>int <function> XSelectExtensionEvent</function></funcdef> 6395 <paramdef>Display<parameter> *display</parameter></paramdef> 6396 <paramdef>Window<parameter> window</parameter></paramdef> 6397 <paramdef>XEventClass<parameter> *event_list</parameter></paramdef> 6398 <paramdef>int<parameter> event_count</parameter></paramdef> 6399</funcprototype> 6400</funcsynopsis> 6401<!-- .FN --> 6402<variablelist> 6403 <varlistentry> 6404 <term> 6405 <emphasis remap='I'>display</emphasis> 6406 </term> 6407 <listitem> 6408 <para> 6409Specifies the connection to the X server. 6410 </para> 6411 </listitem> 6412 </varlistentry> 6413 <varlistentry> 6414 <term> 6415 <emphasis remap='I'>window</emphasis> 6416 </term> 6417 <listitem> 6418 <para> 6419Specifies the ID of the window from which the client wishes to receive events. 6420 </para> 6421 </listitem> 6422 </varlistentry> 6423 <varlistentry> 6424 <term> 6425 <emphasis remap='I'>event_list</emphasis> 6426 </term> 6427 <listitem> 6428 <para> 6429Specifies a pointer to an array of event classes 6430that specify which events are desired. 6431 </para> 6432 </listitem> 6433 </varlistentry> 6434 <varlistentry> 6435 <term> 6436 <emphasis remap='I'>event_count</emphasis> 6437 </term> 6438 <listitem> 6439 <para> 6440Specifies the number of elements in the event_list. 6441 </para> 6442 </listitem> 6443 </varlistentry> 6444</variablelist> 6445</para> 6446<para> 6447<!-- .LP --> 6448<!-- .eM --> 6449<function>XSelectExtensionEvent</function> 6450requests the server to send events that match the events and 6451devices described by the event list and that come from the requested 6452window. 6453The elements of the 6454<function>XEventClass</function> 6455array are the event_class values 6456obtained by invoking a macro with the pointer to an 6457<function>XDevice</function> 6458structure returned by the 6459<function>XOpenDevice</function> 6460request. 6461For example, the 6462<function>DeviceKeyPress</function> 6463macro would return the 6464<function>XEventClass</function> 6465for 6466<function>DeviceKeyPress</function> 6467events from the specified device if it were invoked in the following form: 6468<literallayout class="monospaced"> 6469<!-- .TA .5i --> 6470<!-- .ta .5i --> 6471 DeviceKeyPress (XDevice *device, event_type, event_class) 6472</literallayout> 6473</para> 6474<para> 6475<!-- .LP --> 6476Macros are defined for the following event classes: 6477<literallayout class="monospaced"> 6478<function>DeviceKeyPress</function> 6479<function>DeviceKeyRelease</function> 6480<function>DeviceButtonPress</function> 6481<function>DeviceButtonRelease</function> 6482<function>DeviceMotionNotify</function> 6483<function>DeviceFocusIn</function> 6484<function>DeviceFocusOut</function> 6485<function>ProximityIn</function> 6486<function>ProximityOut</function> 6487<function>DeviceStateNotify</function> 6488<function>DeviceMappingNotify</function> 6489<function>ChangeDeviceNotify</function> 6490<function>DevicePointerMotionHint</function> 6491<function>DeviceButton1Motion </function> 6492<function>DeviceButton2Motion</function> 6493<function>DeviceButton3Motion, </function> 6494<function>DeviceButton4Motion</function> 6495<function>DeviceButton5Motion</function> 6496<function>DeviceButtonMotion,</function> 6497<function>DeviceOwnerGrabButton</function> 6498<function>DeviceButtonPressGrab</function> 6499</literallayout> 6500</para> 6501<para> 6502<!-- .LP --> 6503To get the next available event from within a client program, use the core 6504<function>XNextEvent</function> 6505function. This returns the next event whether it 6506came from a core device or an extension device. 6507</para> 6508<para> 6509<!-- .LP --> 6510Succeeding 6511<function>XSelectExtensionEvent</function> 6512requests using event classes 6513for the same device as was specified on a previous request will replace 6514the previous set of selected events from that device with the new set. 6515</para> 6516<para> 6517<!-- .LP --> 6518<function>XSelectExtensionEvent</function> 6519can generate 6520<function>BadAccess , </function> 6521<function>BadClass ,</function> 6522<function>BadLength ,</function> 6523and 6524<function>BadWindow</function> 6525errors. 6526</para> 6527</sect3> 6528<sect3 id="Determining_Selected_Device_Events"> 6529<title>Determining Selected Device Events</title> 6530<!-- .XS --> 6531<!-- (SN Determining Selected Device Events --> 6532<!-- .XE --> 6533<para> 6534<!-- .LP --> 6535To determine which extension events are currently selected from a given 6536window, use 6537<function>XGetSelectedExtensionEvents .</function> 6538<!-- .sM --> 6539<funcsynopsis> 6540<funcprototype> 6541 <funcdef>int <function> XGetSelectedExtensionEvents</function></funcdef> 6542 <paramdef>Display<parameter> *display</parameter></paramdef> 6543 <paramdef>Window<parameter> window</parameter></paramdef> 6544 <paramdef>int<parameter> *this_client_count</parameter></paramdef> 6545 <paramdef>XEventClass<parameter> **this_client</parameter></paramdef> 6546 <paramdef>int<parameter> *all_clients_count</parameter></paramdef> 6547 <paramdef>XEventClass<parameter> **all_clients</parameter></paramdef> 6548</funcprototype> 6549</funcsynopsis> 6550<!-- .FN --> 6551<variablelist> 6552 <varlistentry> 6553 <term> 6554 <emphasis remap='I'>display</emphasis> 6555 </term> 6556 <listitem> 6557 <para> 6558Specifies the connection to the X server. 6559 </para> 6560 </listitem> 6561 </varlistentry> 6562 <varlistentry> 6563 <term> 6564 <emphasis remap='I'>window</emphasis> 6565 </term> 6566 <listitem> 6567 <para> 6568Specifies the ID of the window from which the client wishes to receive events. 6569 </para> 6570 </listitem> 6571 </varlistentry> 6572 <varlistentry> 6573 <term> 6574 <emphasis remap='I'>this_client_count</emphasis> 6575 </term> 6576 <listitem> 6577 <para> 6578Returns the number of elements in the this_client list. 6579 </para> 6580 </listitem> 6581 </varlistentry> 6582 <varlistentry> 6583 <term> 6584 <emphasis remap='I'>this_client</emphasis> 6585 </term> 6586 <listitem> 6587 <para> 6588Returns a list of 6589<function>XEventClasses</function> 6590that specify which events are 6591selected by this client. 6592 </para> 6593 </listitem> 6594 </varlistentry> 6595 <varlistentry> 6596 <term> 6597 <emphasis remap='I'>all_clients_count</emphasis> 6598 </term> 6599 <listitem> 6600 <para> 6601Returns the number of elements in the all_clients list. 6602 </para> 6603 </listitem> 6604 </varlistentry> 6605 <varlistentry> 6606 <term> 6607 <emphasis remap='I'>all_clients</emphasis> 6608 </term> 6609 <listitem> 6610 <para> 6611Returns a list of 6612<function>XEventClasses</function> 6613that specify which events are 6614selected by all clients. 6615 </para> 6616 </listitem> 6617 </varlistentry> 6618</variablelist> 6619</para> 6620<para> 6621<!-- .LP --> 6622<!-- .eM --> 6623<function>XGetSelectedExtensionEvents</function> 6624returns pointers to two event class arrays. 6625One lists the extension events selected by this client from 6626the specified window. The other lists the extension events selected by 6627all clients from the specified window. This information is analogous 6628to that returned in your_event_mask and all_event_masks of the 6629<function>XWindowAttributes</function> 6630structure when an 6631<function>XGetWindowAttributes</function> 6632request is made. 6633To free the two arrays returned by this function, use 6634<function>XFree .</function> 6635</para> 6636<para> 6637<!-- .LP --> 6638<function>XGetSelectedExtensionEvents</function> 6639can generate 6640<function>BadWindow</function> 6641errors. 6642</para> 6643</sect3> 6644<sect3 id="Controlling_Event_Propagation"> 6645<title>Controlling Event Propagation</title> 6646<!-- .XS --> 6647<!-- (SN Controlling Event Propagation --> 6648<!-- .XE --> 6649<para> 6650<!-- .LP --> 6651Extension events propagate up the window hierarchy in the same manner 6652as core events. If a window is not interested in an extension event, 6653it usually propagates to the closest ancestor that is interested, 6654unless the dont_propagate list prohibits it. 6655Grabs of extension devices may alter the set of windows that receive a 6656particular extension event. 6657</para> 6658<para> 6659<!-- .LP --> 6660Client programs may control event propagation through the use 6661of the following two functions: 6662<function>XChangeDeviceDontPropagateList</function> 6663and 6664<function>XGetDeviceDontPropagateList . </function> 6665</para> 6666<para> 6667<!-- .LP --> 6668<!-- .sM --> 6669<funcsynopsis> 6670<funcprototype> 6671 <funcdef>int <function> XChangeDeviceDontPropagateList</function></funcdef> 6672 <paramdef>Display<parameter> *display</parameter></paramdef> 6673 <paramdef>Window<parameter> window</parameter></paramdef> 6674 <paramdef>int<parameter> event_count</parameter></paramdef> 6675 <paramdef>XEventClass<parameter> *events</parameter></paramdef> 6676 <paramdef>int<parameter> mode</parameter></paramdef> 6677</funcprototype> 6678</funcsynopsis> 6679<!-- .FN --> 6680<variablelist> 6681 <varlistentry> 6682 <term> 6683 <emphasis remap='I'>display</emphasis> 6684 </term> 6685 <listitem> 6686 <para> 6687Specifies the connection to the X server. 6688 </para> 6689 </listitem> 6690 </varlistentry> 6691 <varlistentry> 6692 <term> 6693 <emphasis remap='I'>window</emphasis> 6694 </term> 6695 <listitem> 6696 <para> 6697Specifies the desired window. 6698 </para> 6699 </listitem> 6700 </varlistentry> 6701 <varlistentry> 6702 <term> 6703 <emphasis remap='I'>event_count</emphasis> 6704 </term> 6705 <listitem> 6706 <para> 6707Specifies the number of elements in the events list. 6708 </para> 6709 </listitem> 6710 </varlistentry> 6711 <varlistentry> 6712 <term> 6713 <emphasis remap='I'>events</emphasis> 6714 </term> 6715 <listitem> 6716 <para> 6717Specifies a pointer to the list of XEventClasses. 6718 </para> 6719 </listitem> 6720 </varlistentry> 6721 <varlistentry> 6722 <term> 6723 <emphasis remap='I'>mode</emphasis> 6724 </term> 6725 <listitem> 6726 <para> 6727Specifies the mode. You can pass 6728<function>AddToList</function> 6729or 6730<function>DeleteFromList .</function> 6731 </para> 6732 </listitem> 6733 </varlistentry> 6734</variablelist> 6735</para> 6736<para> 6737<!-- .LP --> 6738<!-- .eM --> 6739<function>XChangeDeviceDontPropagateList</function> 6740adds an event to or deletes an event from the do_not_propagate list 6741of extension events for the specified window. 6742There is one list per window, and the list remains for the life of the window. 6743The list is not altered if a client that changed the list terminates. 6744</para> 6745<para> 6746<!-- .LP --> 6747Suppression of event propagation is not allowed for all events. If a 6748specified 6749<function>XEventClass</function> 6750is invalid because suppression of that event is not allowed, a 6751<function>BadClass</function> 6752error results. 6753</para> 6754<para> 6755<!-- .LP --> 6756<function>XChangeDeviceDontPropagateList</function> 6757can generate 6758<function>BadClass ,</function> 6759<function>BadMode ,</function> 6760and 6761<function>BadWindow</function> 6762errors. 6763<!-- .sp --> 6764</para> 6765<para> 6766<!-- .LP --> 6767<!-- .sM --> 6768<funcsynopsis> 6769<funcprototype> 6770 <funcdef>XEventClass * <function> XGetDeviceDontPropagateList</function></funcdef> 6771 <paramdef>Display<parameter> *display</parameter></paramdef> 6772 <paramdef>Window<parameter> window</parameter></paramdef> 6773 <paramdef>int<parameter> *event_count</parameter></paramdef> 6774</funcprototype> 6775</funcsynopsis> 6776<!-- .FN --> 6777<variablelist> 6778 <varlistentry> 6779 <term> 6780 <emphasis remap='I'>display</emphasis> 6781 </term> 6782 <listitem> 6783 <para> 6784Specifies the connection to the X server. 6785 </para> 6786 </listitem> 6787 </varlistentry> 6788 <varlistentry> 6789 <term> 6790 <emphasis remap='I'>window</emphasis> 6791 </term> 6792 <listitem> 6793 <para> 6794Specifies the desired window. 6795 </para> 6796 </listitem> 6797 </varlistentry> 6798 <varlistentry> 6799 <term> 6800 <emphasis remap='I'>event_count</emphasis> 6801 </term> 6802 <listitem> 6803 <para> 6804Returns the number of elements in the array returned by this function. 6805 </para> 6806 </listitem> 6807 </varlistentry> 6808</variablelist> 6809</para> 6810<para> 6811<!-- .LP --> 6812<!-- .eM --> 6813<function>XGetDeviceDontPropagateList</function> 6814allows a client to determine the do_not_propagate list of extension events 6815for the specified window. 6816It returns an array of 6817<function>XEventClass ,</function> 6818each 6819<function>XEventClass</function> 6820representing a device/event type pair. 6821To free the data returned by this function, use 6822<function>XFree .</function> 6823</para> 6824<para> 6825<!-- .LP --> 6826<function>XGetDeviceDontPropagateList</function> 6827can generate 6828<function>BadWindow</function> 6829errors. 6830</para> 6831</sect3> 6832<sect3 id="Sending_an_Event"> 6833<title>Sending an Event</title> 6834<!-- .XS --> 6835<!-- (SN Sending an Event --> 6836<!-- .XE --> 6837<para> 6838<!-- .LP --> 6839To send an extension event to another client, use 6840<function>XSendExtensionEvent .</function> 6841<!-- .sM --> 6842<funcsynopsis> 6843<funcprototype> 6844 <funcdef>int <function> XSendExtensionEvent</function></funcdef> 6845 <paramdef>Display<parameter> *display</parameter></paramdef> 6846 <paramdef>XDevice<parameter> *device</parameter></paramdef> 6847 <paramdef>Window<parameter> window</parameter></paramdef> 6848 <paramdef>Bool<parameter> propagate</parameter></paramdef> 6849 <paramdef>int<parameter> event_count</parameter></paramdef> 6850 <paramdef>XEventClass<parameter> *event_list</parameter></paramdef> 6851 <paramdef>XEvent<parameter> *event</parameter></paramdef> 6852</funcprototype> 6853</funcsynopsis> 6854<!-- .FN --> 6855<variablelist> 6856 <varlistentry> 6857 <term> 6858 <emphasis remap='I'>display</emphasis> 6859 </term> 6860 <listitem> 6861 <para> 6862Specifies the connection to the X server. 6863 </para> 6864 </listitem> 6865 </varlistentry> 6866 <varlistentry> 6867 <term> 6868 <emphasis remap='I'>device</emphasis> 6869 </term> 6870 <listitem> 6871 <para> 6872Specifies the device whose ID is recorded in the event. 6873 </para> 6874 </listitem> 6875 </varlistentry> 6876 <varlistentry> 6877 <term> 6878 <emphasis remap='I'>window</emphasis> 6879 </term> 6880 <listitem> 6881 <para> 6882Specifies the destination window ID. You can pass a window ID, 6883<function>PointerWindow</function> 6884or 6885<function>InputFocus .</function> 6886 </para> 6887 </listitem> 6888 </varlistentry> 6889 <varlistentry> 6890 <term> 6891 <emphasis remap='I'>propagate</emphasis> 6892 </term> 6893 <listitem> 6894 <para> 6895Specifies a boolean value that is either 6896<function>True</function> 6897or 6898<function>False .</function> 6899 </para> 6900 </listitem> 6901 </varlistentry> 6902 <varlistentry> 6903 <term> 6904 <emphasis remap='I'>event_count</emphasis> 6905 </term> 6906 <listitem> 6907 <para> 6908Specifies the number of elements in the event_list array. 6909 </para> 6910 </listitem> 6911 </varlistentry> 6912 <varlistentry> 6913 <term> 6914 <emphasis remap='I'>event_list</emphasis> 6915 </term> 6916 <listitem> 6917 <para> 6918Specifies a pointer to an array of 6919<function>XEventClass .</function> 6920 </para> 6921 </listitem> 6922 </varlistentry> 6923 <varlistentry> 6924 <term> 6925 <emphasis remap='I'>event</emphasis> 6926 </term> 6927 <listitem> 6928 <para> 6929Specifies a pointer to the event that is to be sent. 6930 </para> 6931 </listitem> 6932 </varlistentry> 6933</variablelist> 6934</para> 6935<para> 6936<!-- .LP --> 6937<!-- .eM --> 6938<function>XSendExtensionEvent</function> 6939identifies the destination window, determines which clients should receive 6940the specified event, and ignores any active grabs. 6941It requires a list of 6942<function>XEventClass</function> 6943to be specified. 6944These are obtained by opening an input device with the 6945<function>XOpenDevice</function> 6946request. 6947</para> 6948<para> 6949<!-- .LP --> 6950<function>XSendExtensionEvent</function> 6951uses the window argument to identify the destination window as follows: 6952</para> 6953<itemizedlist> 6954 <listitem> 6955 <para> 6956If you pass 6957<function>PointerWindow ,</function> 6958the destination window is the window that contains the pointer. 6959 </para> 6960 </listitem> 6961 <listitem> 6962 <para> 6963If you pass 6964<function>InputFocus</function> 6965and if the focus window contains the pointer, 6966the destination window is the window that contains the pointer. 6967If the focus window does not contain the pointer, 6968the destination window is the focus window. 6969 </para> 6970 </listitem> 6971</itemizedlist> 6972<para> 6973<!-- .LP --> 6974To determine which clients should receive the specified events, 6975<function>XSendExtensionEvent</function> 6976uses the propagate argument as follows: 6977</para> 6978<itemizedlist> 6979 <listitem> 6980 <para> 6981If propagate is 6982<function>False ,</function> 6983the event is sent to every client selecting 6984from the destination window 6985any of the events specified in the event_list array. 6986 </para> 6987 </listitem> 6988 <listitem> 6989 <para> 6990If propagate is 6991<function>True </function> 6992and no clients have selected from the destination window 6993any of the events specified in the event_list array, the destination is 6994replaced with the closest ancestor of destination for which some client 6995has selected one of the specified events and for which no intervening 6996window has that event in its do_not_propagate mask. 6997If no such window exists, 6998or if the window is an ancestor of the focus window, and 6999<function>InputFocus</function> 7000was originally specified as the destination, 7001the event is not sent to any clients. Otherwise, the event is reported to every 7002client selecting on the final destination any of the events specified 7003in event_list. 7004 </para> 7005 </listitem> 7006</itemizedlist> 7007<para> 7008<!-- .LP --> 7009The event in the 7010<function>XEvent</function> 7011structure must be one of the events defined 7012by the input extension, so that the X server can correctly byte swap the 7013contents as necessary. The contents of the event are otherwise unaltered 7014and unchecked by the X server except to force send_event to 7015<function>True</function> 7016in the forwarded event and to set the sequence number in the event correctly. 7017</para> 7018<para> 7019<!-- .LP --> 7020<function>XSendExtensionEvent</function> 7021returns zero if the conversion-to-wire protocol failed; 7022otherwise, it returns nonzero. 7023</para> 7024<para> 7025<!-- .LP --> 7026<function>XSendExtensionEvent</function> 7027can generate 7028<function>BadClass ,</function> 7029<function>BadDevice ,</function> 7030<function>BadValue ,</function> 7031and 7032<function>BadWindow</function> 7033errors. 7034</para> 7035</sect3> 7036<sect3 id="Getting_Motion_History"> 7037<title>Getting Motion History</title> 7038<!-- .XS --> 7039<!-- (SN Getting Motion History --> 7040<!-- .XE --> 7041<para> 7042<!-- .LP --> 7043<!-- .sM --> 7044<funcsynopsis> 7045<funcprototype> 7046 <funcdef>XDeviceTimeCoord * <function> XGetDeviceMotionEvents</function></funcdef> 7047 <paramdef><parameter> axis_count_return)</parameter></paramdef> 7048 <paramdef>Display<parameter> *display</parameter></paramdef> 7049 <paramdef>XDevice<parameter> *device</parameter></paramdef> 7050 <paramdef>Timestart,<parameter> stop</parameter></paramdef> 7051 <paramdef>int<parameter> *nevents_return</parameter></paramdef> 7052 <paramdef>int<parameter> *mode_return</parameter></paramdef> 7053 <paramdef>int<parameter> *axis_count_return</parameter></paramdef> 7054</funcprototype> 7055</funcsynopsis> 7056<!-- .FN --> 7057<variablelist> 7058 <varlistentry> 7059 <term> 7060 <emphasis remap='I'>display</emphasis> 7061 </term> 7062 <listitem> 7063 <para> 7064Specifies the connection to the X server. 7065 </para> 7066 </listitem> 7067 </varlistentry> 7068 <varlistentry> 7069 <term> 7070 <emphasis remap='I'>device</emphasis> 7071 </term> 7072 <listitem> 7073 <para> 7074Specifies the desired device. 7075 </para> 7076 </listitem> 7077 </varlistentry> 7078 <varlistentry> 7079 <term> 7080 <emphasis remap='I'>start</emphasis> 7081 </term> 7082 <listitem> 7083 <para> 7084Specifies the start time. 7085 </para> 7086 </listitem> 7087 </varlistentry> 7088 <varlistentry> 7089 <term> 7090 <emphasis remap='I'>stop</emphasis> 7091 </term> 7092 <listitem> 7093 <para> 7094Specifies the stop time. 7095 </para> 7096 </listitem> 7097 </varlistentry> 7098 <varlistentry> 7099 <term> 7100 <emphasis remap='I'>nevents_return</emphasis> 7101 </term> 7102 <listitem> 7103 <para> 7104Returns the number of positions in the motion buffer returned 7105for this request. 7106 </para> 7107 </listitem> 7108 </varlistentry> 7109 <varlistentry> 7110 <term> 7111 <emphasis remap='I'>mode_return</emphasis> 7112 </term> 7113 <listitem> 7114 <para> 7115Returns the mode of the nevents information. 7116The mode will be one of the following: 7117<function>Absolute</function> 7118or 7119<function>Relative .</function> 7120 </para> 7121 </listitem> 7122 </varlistentry> 7123 <varlistentry> 7124 <term> 7125 <emphasis remap='I'>axis_count_return</emphasis> 7126 </term> 7127 <listitem> 7128 <para> 7129Returns the number of axes reported in each of the positions returned. 7130 </para> 7131 </listitem> 7132 </varlistentry> 7133</variablelist> 7134</para> 7135<para> 7136<!-- .LP --> 7137<!-- .eM --> 7138<function>XGetDeviceMotionEvents</function> 7139returns all positions in the device's motion history buffer 7140that fall between the specified start and stop times inclusive. 7141If the start time is in the future or is later than the stop time, 7142no positions are returned. 7143</para> 7144<para> 7145<!-- .LP --> 7146The return type for this function is an 7147<function>XDeviceTimeCoord</function> 7148structure, which is defined as follows: 7149</para> 7150<para> 7151<!-- .LP --> 7152<!-- .sM --> 7153<literallayout class="monospaced"> 7154<!-- .TA .5i --> 7155<!-- .ta .5i --> 7156typedef struct { 7157 Time time; 7158 unsigned int *data; 7159} XDeviceTimeCoord; 7160</literallayout> 7161</para> 7162<para> 7163<!-- .LP --> 7164<!-- .eM --> 7165The data member is a pointer to an array of data items. 7166Each item is of type int, and there is one data item 7167per axis of motion reported by the device. 7168The number of axes reported by the device is returned in the axis_count variable. 7169</para> 7170<para> 7171<!-- .LP --> 7172The value of the data items depends on the mode of the device. 7173The mode is returned in the mode variable. If the 7174mode is 7175<function>Absolute ,</function> 7176the data items are the raw values generated by the device. 7177These may be scaled by the client program using the 7178maximum values that the device can generate for each axis of motion 7179that it reports. The maximum value for each axis is reported in 7180the max_val member of the 7181<function>XAxisInfo</function> 7182structure, which is part of the information returned by the 7183<function>XListInputDevices</function> 7184request. 7185</para> 7186<para> 7187<!-- .LP --> 7188If the mode is 7189<function>Relative ,</function> 7190the data items are the relative values generated by the device. 7191The client program must choose an initial 7192position for the device and maintain a current position by 7193accumulating these relative values. 7194</para> 7195<para> 7196<!-- .LP --> 7197Consecutive calls to 7198<function>XGetDeviceMotionEvents</function> 7199can return data of different modes, that is, if 7200some client program has changed the mode of the device via an 7201<function>XSetDeviceMode</function> 7202request. 7203</para> 7204<para> 7205<!-- .LP --> 7206<function>XGetDeviceMotionEvents</function> 7207can generate 7208<function>BadDevice</function> 7209and 7210<function>BadMatch</function> 7211errors. 7212<!-- .sp --> 7213</para> 7214<para> 7215<!-- .LP --> 7216To free the data returned by 7217<function>XGetDeviceMotionEvents ,</function> 7218use 7219<function>XFreeDeviceMotionEvents .</function> 7220</para> 7221<para> 7222<!-- .LP --> 7223<!-- .sM --> 7224<funcsynopsis> 7225<funcprototype> 7226 <funcdef>void <function> XFreeDeviceMotionEvents</function></funcdef> 7227 <paramdef>XDeviceTimeCoord<parameter> *events</parameter></paramdef> 7228</funcprototype> 7229</funcsynopsis> 7230<!-- .FN --> 7231<variablelist> 7232 <varlistentry> 7233 <term> 7234 <emphasis remap='I'>events</emphasis> 7235 </term> 7236 <listitem> 7237 <para> 7238Specifies the pointer to the 7239<function>XDeviceTimeCoord</function> 7240array returned by a previous call to 7241<function>XGetDeviceMotionEvents .</function> 7242 </para> 7243 </listitem> 7244 </varlistentry> 7245</variablelist> 7246</para> 7247<para> 7248<!-- .LP --> 7249<!-- .eM --> 7250<function>XFreeDeviceMotionEvents</function> 7251frees the specified array of motion information. 7252<!-- .\" --> 7253<!-- .\" --> 7254<!-- .\" Appendicies --> 7255<!-- .\" --> 7256<!-- .\" --> 7257<!-- .bp --> 7258<!-- .ds Ch ~ --> 7259<!-- .sp 1 --> 7260<!-- .ce 3 --> 7261<function>Appendix A</function> 7262<!-- .XS --> 7263<!-- (SN Appendix A --> 7264<!-- .XE --> 7265</para> 7266<para> 7267<!-- .LP --> 7268The following information is contained in the <function><X11/extensions/XInput.h></function> 7269and <function><X11/extensions/XI.h></function> header files: 7270<literallayout class="monospaced"> 7271<!-- .cs CW 20 --> 7272 7273<!-- .ps 8 --> 7274/* Definitions used by the library and client */ 7275 7276#ifndef _XINPUT_H_ 7277#define _XINPUT_H_ 7278 7279#ifndef _XLIB_H_ 7280#include <X11/Xlib.h> 7281#endif 7282 7283#ifndef _XI_H_ 7284#include "XI.h" 7285#endif 7286 7287#define _deviceKeyPress 0 7288#define _deviceKeyRelease 1 7289 7290#define _deviceButtonPress 0 7291#define _deviceButtonRelease 1 7292 7293#define _deviceMotionNotify 0 7294 7295#define _deviceFocusIn 0 7296#define _deviceFocusOut 1 7297 7298#define _proximityIn 0 7299#define _proximityOut 1 7300 7301#define _deviceStateNotify 0 7302#define _deviceMappingNotify 1 7303#define _changeDeviceNotify 2 7304 7305#define FindTypeAndClass(d, type, class, classid, offset) \ 7306 { int i; XInputClassInfo *ip; \ 7307 type = 0; class = 0; \ 7308 for (i=0, ip= ((XDevice *) d)->classes; \ 7309 i< ((XDevice *) d)->num_classes; \ 7310 i++, ip++) \ 7311 if (ip->input_class == classid) \ 7312 {type = ip->event_type_base + offset; \ 7313 class = ((XDevice *) d)->device_id << 8 | type;}} 7314 7315#define DeviceKeyPress(d, type, class) \ 7316 FindTypeAndClass(d, type, class, KeyClass, _deviceKeyPress) 7317 7318#define DeviceKeyRelease(d, type, class) \ 7319 FindTypeAndClass(d, type, class, KeyClass, _deviceKeyRelease) 7320 7321#define DeviceButtonPress(d, type, class) \ 7322 FindTypeAndClass(d, type, class, ButtonClass, _deviceButtonPress) 7323 7324#define DeviceButtonRelease(d, type, class) \ 7325 FindTypeAndClass(d, type, class, ButtonClass, _deviceButtonRelease) 7326 7327#define DeviceMotionNotify(d, type, class) \ 7328 FindTypeAndClass(d, type, class, ValuatorClass, _deviceMotionNotify) 7329 7330#define DeviceFocusIn(d, type, class) \ 7331 FindTypeAndClass(d, type, class, FocusClass, _deviceFocusIn) 7332 7333#define DeviceFocusOut(d, type, class) \ 7334 FindTypeAndClass(d, type, class, FocusClass, _deviceFocusOut) 7335 7336#define ProximityIn(d, type, class) \ 7337 FindTypeAndClass(d, type, class, ProximityClass, _proximityIn) 7338 7339#define ProximityOut(d, type, class) \ 7340 FindTypeAndClass(d, type, class, ProximityClass, _proximityOut) 7341 7342#define DeviceStateNotify(d, type, class) \ 7343 FindTypeAndClass(d, type, class, OtherClass, _deviceStateNotify) 7344 7345#define DeviceMappingNotify(d, type, class) \ 7346 FindTypeAndClass(d, type, class, OtherClass, _deviceMappingNotify) 7347 7348#define ChangeDeviceNotify(d, type, class) \ 7349 FindTypeAndClass(d, type, class, OtherClass, _changeDeviceNotify) 7350 7351#define DevicePointerMotionHint(d, type, class) \ 7352 { class = ((XDevice *) d)->device_id << 8 | _devicePointerMotionHint;} 7353 7354#define DeviceButton1Motion(d, type, class) \ 7355 { class = ((XDevice *) d)->device_id << 8 | _deviceButton1Motion;} 7356 7357#define DeviceButton2Motion(d, type, class) \ 7358 { class = ((XDevice *) d)->device_id << 8 | _deviceButton2Motion;} 7359 7360#define DeviceButton3Motion(d, type, class) \ 7361 { class = ((XDevice *) d)->device_id << 8 | _deviceButton3Motion;} 7362 7363#define DeviceButton4Motion(d, type, class) \ 7364 { class = ((XDevice *) d)->device_id << 8 | _deviceButton4Motion;} 7365 7366#define DeviceButton5Motion(d, type, class) \ 7367 { class = ((XDevice *) d)->device_id << 8 | _deviceButton5Motion;} 7368 7369#define DeviceButtonMotion(d, type, class) \ 7370 { class = ((XDevice *) d)->device_id << 8 | _deviceButtonMotion;} 7371 7372#define DeviceOwnerGrabButton(d, type, class) \ 7373 { class = ((XDevice *) d)->device_id << 8 | _deviceOwnerGrabButton;} 7374 7375#define DeviceButtonPressGrab(d, type, class) \ 7376 { class = ((XDevice *) d)->device_id << 8 | _deviceButtonGrab;} 7377 7378#define NoExtensionEvent(d, type, class) \ 7379 { class = ((XDevice *) d)->device_id << 8 | _noExtensionEvent;} 7380 7381#define BadDevice(dpy, error) _xibaddevice(dpy, &error) 7382 7383#define BadClass(dpy, error) _xibadclass(dpy, &error) 7384 7385#define BadEvent(dpy, error) _xibadevent(dpy, &error) 7386 7387#define BadMode(dpy, error) _xibadmode(dpy, &error) 7388 7389#define DeviceBusy(dpy, error) _xidevicebusy(dpy, &error) 7390 7391/*************************************************************** 7392 * 7393 * DeviceKey events. These events are sent by input devices that 7394 * support input class Keys. 7395 * The location of the X pointer is reported in the coordinate 7396 * fields of the x,y and x_root,y_root fields. 7397 * 7398 */ 7399 7400typedef struct 7401 { 7402 int type; /* of event */ 7403 unsigned long serial; /* # of last request processed */ 7404 Bool send_event; /* true if from SendEvent request */ 7405 Display *display; /* Display the event was read from */ 7406 Window window; /* "event" window reported relative to */ 7407 XID deviceid; 7408 Window root; /* root window event occured on */ 7409 Window subwindow; /* child window */ 7410 Time time; /* milliseconds */ 7411 int x, y; /* x, y coordinates in event window */ 7412 int x_root; /* coordinates relative to root */ 7413 int y_root; /* coordinates relative to root */ 7414 unsigned int state; /* key or button mask */ 7415 unsigned int keycode; /* detail */ 7416 Bool same_screen; /* same screen flag */ 7417 unsigned int device_state; /* device key or button mask */ 7418 unsigned char axes_count; 7419 unsigned char first_axis; 7420 int axis_data[6]; 7421 } XDeviceKeyEvent; 7422 7423typedef XDeviceKeyEvent XDeviceKeyPressedEvent; 7424typedef XDeviceKeyEvent XDeviceKeyReleasedEvent; 7425 7426/******************************************************************* 7427 * 7428 * DeviceButton events. These events are sent by extension devices 7429 * that support input class Buttons. 7430 * 7431 */ 7432 7433typedef struct { 7434 int type; /* of event */ 7435 unsigned long serial; /* # of last request processed by server */ 7436 Bool send_event; /* true if from a SendEvent request */ 7437 Display *display; /* Display the event was read from */ 7438 Window window; /* "event" window reported relative to */ 7439 XID deviceid; 7440 Window root; /* root window that the event occured on */ 7441 Window subwindow; /* child window */ 7442 Time time; /* milliseconds */ 7443 int x, y; /* x, y coordinates in event window */ 7444 int x_root; /* coordinates relative to root */ 7445 int y_root; /* coordinates relative to root */ 7446 unsigned int state; /* key or button mask */ 7447 unsigned int button; /* detail */ 7448 Bool same_screen; /* same screen flag */ 7449 unsigned int device_state; /* device key or button mask */ 7450 unsigned char axes_count; 7451 unsigned char first_axis; 7452 int axis_data[6]; 7453 } XDeviceButtonEvent; 7454 7455typedef XDeviceButtonEvent XDeviceButtonPressedEvent; 7456typedef XDeviceButtonEvent XDeviceButtonReleasedEvent; 7457 7458/******************************************************************* 7459 * 7460 * DeviceMotionNotify event. These events are sent by extension devices 7461 * that support input class Valuators. 7462 * 7463 */ 7464 7465typedef struct 7466 { 7467 int type; /* of event */ 7468 unsigned long serial; /* # of last request processed by server */ 7469 Bool send_event; /* true if from a SendEvent request */ 7470 Display *display; /* Display the event was read from */ 7471 Window window; /* "event" window reported relative to */ 7472 XID deviceid; 7473 Window root; /* root window that the event occured on */ 7474 Window subwindow; /* child window */ 7475 Time time; /* milliseconds */ 7476 int x, y; /* x, y coordinates in event window */ 7477 int x_root; /* coordinates relative to root */ 7478 int y_root; /* coordinates relative to root */ 7479 unsigned int state; /* key or button mask */ 7480 char is_hint; /* detail */ 7481 Bool same_screen; /* same screen flag */ 7482 unsigned int device_state; /* device key or button mask */ 7483 unsigned char axes_count; 7484 unsigned char first_axis; 7485 int axis_data[6]; 7486 } XDeviceMotionEvent; 7487 7488/******************************************************************* 7489 * 7490 * DeviceFocusChange events. These events are sent when the focus 7491 * of an extension device that can be focused is changed. 7492 * 7493 */ 7494 7495typedef struct 7496 { 7497 int type; /* of event */ 7498 unsigned long serial; /* # of last request processed by server */ 7499 Bool send_event; /* true if from a SendEvent request */ 7500 Display *display; /* Display the event was read from */ 7501 Window window; /* "event" window reported relative to */ 7502 XID deviceid; 7503 int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */ 7504 int detail; 7505 /* 7506 * NotifyAncestor, NotifyVirtual, NotifyInferior, 7507 * NotifyNonLinear,NotifyNonLinearVirtual, NotifyPointer, 7508 * NotifyPointerRoot, NotifyDetailNone 7509 */ 7510 Time time; 7511 } XDeviceFocusChangeEvent; 7512 7513typedef XDeviceFocusChangeEvent XDeviceFocusInEvent; 7514typedef XDeviceFocusChangeEvent XDeviceFocusOutEvent; 7515 7516/******************************************************************* 7517 * 7518 * ProximityNotify events. These events are sent by those absolute 7519 * positioning devices that are capable of generating proximity information. 7520 * 7521 */ 7522 7523typedef struct 7524 { 7525 int type; /* ProximityIn or ProximityOut */ 7526 unsigned long serial; /* # of last request processed by server */ 7527 Bool send_event; /* true if this came from a SendEvent request */ 7528 Display *display; /* Display the event was read from */ 7529 Window window; 7530 XID deviceid; 7531 Window root; 7532 Window subwindow; 7533 Time time; 7534 int x, y; 7535 int x_root, y_root; 7536 unsigned int state; 7537 Bool same_screen; 7538 unsigned int device_state; /* device key or button mask */ 7539 unsigned char axes_count; 7540 unsigned char first_axis; 7541 int axis_data[6]; 7542 } XProximityNotifyEvent; 7543typedef XProximityNotifyEvent XProximityInEvent; 7544typedef XProximityNotifyEvent XProximityOutEvent; 7545 7546/******************************************************************* 7547 * 7548 * DeviceStateNotify events are generated on EnterWindow and FocusIn 7549 * for those clients who have selected DeviceState. 7550 * 7551 */ 7552 7553typedef struct 7554 { 7555 unsigned char class; 7556 unsigned char length; 7557 } XInputClass; 7558 7559typedef struct { 7560 int type; 7561 unsigned long serial; /* # of last request processed by server */ 7562 Bool send_event; /* true if this came from a SendEvent request */ 7563 Display *display; /* Display the event was read from */ 7564 Window window; 7565 XID deviceid; 7566 Time time; 7567 int num_classes; 7568 char data[64]; 7569} XDeviceStateNotifyEvent; 7570 7571typedef struct { 7572 unsigned char class; 7573 unsigned char length; 7574 unsigned char num_valuators; 7575 unsigned char mode; 7576 int valuators[6]; 7577} XValuatorStatus; 7578 7579typedef struct { 7580 unsigned char class; 7581 unsigned char length; 7582 short num_keys; 7583 char keys[32]; 7584} XKeyStatus; 7585 7586typedef struct { 7587 unsigned char class; 7588 unsigned char length; 7589 short num_buttons; 7590 char buttons[32]; 7591} XButtonStatus; 7592 7593/******************************************************************* 7594 * 7595 * DeviceMappingNotify event. This event is sent when the key mapping, 7596 * modifier mapping, or button mapping of an extension device is changed. 7597 * 7598 */ 7599 7600typedef struct { 7601 int type; 7602 unsigned long serial; /* # of last request processed by server */ 7603 Bool send_event; /* true if this came from a SendEvent request */ 7604 Display *display; /* Display the event was read from */ 7605 Window window; /* unused */ 7606 XID deviceid; 7607 Time time; 7608 int request; /* one of MappingModifier, MappingKeyboard, 7609 MappingPointer */ 7610 int first_keycode;/* first keycode */ 7611 int count; /* defines range of change w. first_keycode*/ 7612} XDeviceMappingEvent; 7613 7614/******************************************************************* 7615 * 7616 * ChangeDeviceNotify event. This event is sent when an 7617 * XChangeKeyboard or XChangePointer request is made. 7618 * 7619 */ 7620 7621typedef struct { 7622 int type; 7623 unsigned long serial; /* # of last request processed by server */ 7624 Bool send_event; /* true if this came from a SendEvent request */ 7625 Display *display; /* Display the event was read from */ 7626 Window window; /* unused */ 7627 XID deviceid; 7628 Time time; 7629 int request; /* NewPointer or NewKeyboard */ 7630} XChangeDeviceNotifyEvent; 7631 7632/******************************************************************* 7633 * 7634 * Control structures for input devices that support input class 7635 * Feedback. These are used by the XGetFeedbackControl and 7636 * XChangeFeedbackControl functions. 7637 * 7638 */ 7639 7640typedef struct { 7641 XID class; 7642 int length; 7643 XID id; 7644} XFeedbackState; 7645 7646typedef struct { 7647 XID class; 7648 int length; 7649 XID id; 7650 int click; 7651 int percent; 7652 int pitch; 7653 int duration; 7654 int led_mask; 7655 int global_auto_repeat; 7656 char auto_repeats[32]; 7657} XKbdFeedbackState; 7658 7659typedef struct { 7660 XID class; 7661 int length; 7662 XID id; 7663 int accelNum; 7664 int accelDenom; 7665 int threshold; 7666} XPtrFeedbackState; 7667 7668typedef struct { 7669 XID class; 7670 int length; 7671 XID id; 7672 int resolution; 7673 int minVal; 7674 int maxVal; 7675} XIntegerFeedbackState; 7676 7677typedef struct { 7678 XID class; 7679 int length; 7680 XID id; 7681 int max_symbols; 7682 int num_syms_supported; 7683 KeySym *syms_supported; 7684} XStringFeedbackState; 7685 7686typedef struct { 7687 XID class; 7688 int length; 7689 XID id; 7690 int percent; 7691 int pitch; 7692 int duration; 7693} XBellFeedbackState; 7694 7695typedef struct { 7696 XID class; 7697 int length; 7698 XID id; 7699 int led_values; 7700 int led_mask; 7701} XLedFeedbackState; 7702 7703typedef struct { 7704 XID class; 7705 int length; 7706 XID id; 7707} XFeedbackControl; 7708 7709typedef struct { 7710 XID class; 7711 int length; 7712 XID id; 7713 int accelNum; 7714 int accelDenom; 7715 int threshold; 7716} XPtrFeedbackControl; 7717 7718typedef struct { 7719 XID class; 7720 int length; 7721 XID id; 7722 int click; 7723 int percent; 7724 int pitch; 7725 int duration; 7726 int led_mask; 7727 int led_value; 7728 int key; 7729 int auto_repeat_mode; 7730} XKbdFeedbackControl; 7731 7732typedef struct { 7733 XID class; 7734 int length; 7735 XID id; 7736 int num_keysyms; 7737 KeySym *syms_to_display; 7738} XStringFeedbackControl; 7739 7740typedef struct { 7741 XID class; 7742 int length; 7743 XID id; 7744 int int_to_display; 7745} XIntegerFeedbackControl; 7746 7747typedef struct { 7748 XID class; 7749 int length; 7750 XID id; 7751 int percent; 7752 int pitch; 7753 int duration; 7754} XBellFeedbackControl; 7755 7756typedef struct { 7757 XID class; 7758 int length; 7759 XID id; 7760 int led_mask; 7761 int led_values; 7762} XLedFeedbackControl; 7763 7764/******************************************************************* 7765 * 7766 * Device control structures. 7767 * 7768 */ 7769 7770typedef struct { 7771 XID control; 7772 int length; 7773} XDeviceControl; 7774 7775typedef struct { 7776 XID control; 7777 int length; 7778 int first_valuator; 7779 int num_valuators; 7780 int *resolutions; 7781} XDeviceResolutionControl; 7782 7783typedef struct { 7784 XID control; 7785 int length; 7786 int num_valuators; 7787 int *resolutions; 7788 int *min_resolutions; 7789 int *max_resolutions; 7790} XDeviceResolutionState; 7791 7792/******************************************************************* 7793 * 7794 * An array of XDeviceList structures is returned by the 7795 * XListInputDevices function. Each entry contains information 7796 * about one input device. Among that information is an array of 7797 * pointers to structures that describe the characteristics of 7798 * the input device. 7799 * 7800 */ 7801 7802typedef struct _XAnyClassinfo *XAnyClassPtr; 7803 7804typedef struct _XAnyClassinfo { 7805 XID class; 7806 int length; 7807 } XAnyClassInfo; 7808 7809typedef struct _XDeviceInfo *XDeviceInfoPtr; 7810 7811typedef struct _XDeviceInfo 7812 { 7813 XID id; 7814 Atom type; 7815 char *name; 7816 int num_classes; 7817 int use; 7818 XAnyClassPtr inputclassinfo; 7819 } XDeviceInfo; 7820 7821typedef struct _XKeyInfo *XKeyInfoPtr; 7822 7823typedef struct _XKeyInfo 7824 { 7825 XID class; 7826 int length; 7827 unsigned short min_keycode; 7828 unsigned short max_keycode; 7829 unsigned short num_keys; 7830 } XKeyInfo; 7831 7832typedef struct _XButtonInfo *XButtonInfoPtr; 7833 7834typedef struct _XButtonInfo { 7835 XID class; 7836 int length; 7837 short num_buttons; 7838 } XButtonInfo; 7839 7840typedef struct _XAxisInfo *XAxisInfoPtr; 7841 7842typedef struct _XAxisInfo { 7843 int resolution; 7844 int min_value; 7845 int max_value; 7846 } XAxisInfo; 7847 7848typedef struct _XValuatorInfo *XValuatorInfoPtr; 7849 7850typedef struct _XValuatorInfo 7851 { 7852 XID class; 7853 int length; 7854 unsigned char num_axes; 7855 unsigned char mode; 7856 unsigned long motion_buffer; 7857 XAxisInfoPtr axes; 7858 } XValuatorInfo; 7859 7860 7861/******************************************************************* 7862 * 7863 * An XDevice structure is returned by the XOpenDevice function. 7864 * It contains an array of pointers to XInputClassInfo structures. 7865 * Each contains information about a class of input supported by the 7866 * device, including a pointer to an array of data for each type of event 7867 * the device reports. 7868 * 7869 */ 7870 7871 7872typedef struct { 7873 unsigned char input_class; 7874 unsigned char event_type_base; 7875} XInputClassInfo; 7876 7877typedef struct { 7878 XID device_id; 7879 int num_classes; 7880 XInputClassInfo *classes; 7881} XDevice; 7882 7883 7884/******************************************************************* 7885 * 7886 * The following structure is used to return information for the 7887 * XGetSelectedExtensionEvents function. 7888 * 7889 */ 7890 7891typedef struct { 7892 XEventClass event_type; 7893 XID device; 7894} XEventList; 7895 7896/******************************************************************* 7897 * 7898 * The following structure is used to return motion history data from 7899 * an input device that supports the input class Valuators. 7900 * This information is returned by the XGetDeviceMotionEvents function. 7901 * 7902 */ 7903 7904typedef struct { 7905 Time time; 7906 int *data; 7907} XDeviceTimeCoord; 7908 7909 7910/******************************************************************* 7911 * 7912 * Device state structure. 7913 * This is returned by the XQueryDeviceState request. 7914 * 7915 */ 7916 7917typedef struct { 7918 XID device_id; 7919 int num_classes; 7920 XInputClass *data; 7921} XDeviceState; 7922 7923/******************************************************************* 7924 * 7925 * Note that the mode field is a bitfield that reports the Proximity 7926 * status of the device as well as the mode. The mode field should 7927 * be OR'd with the mask DeviceMode and compared with the values 7928 * Absolute and Relative to determine the mode, and should be OR'd 7929 * with the mask ProximityState and compared with the values InProximity 7930 * and OutOfProximity to determine the proximity state. 7931 * 7932 */ 7933 7934typedef struct { 7935 unsigned char class; 7936 unsigned char length; 7937 unsigned char num_valuators; 7938 unsigned char mode; 7939 int *valuators; 7940} XValuatorState; 7941 7942typedef struct { 7943 unsigned char class; 7944 unsigned char length; 7945 short num_keys; 7946 char keys[32]; 7947} XKeyState; 7948 7949typedef struct { 7950 unsigned char class; 7951 unsigned char length; 7952 short num_buttons; 7953 char buttons[32]; 7954} XButtonState; 7955 7956/******************************************************************* 7957 * 7958 * Function definitions. 7959 * 7960 */ 7961 7962_XFUNCPROTOBEGIN 7963 7964extern int XChangeKeyboardDevice( 7965#if NeedFunctionPrototypes 7966 Display* /* display */, 7967 XDevice* /* device */ 7968#endif 7969); 7970 7971extern int XChangePointerDevice( 7972#if NeedFunctionPrototypes 7973 Display* /* display */, 7974 XDevice* /* device */, 7975 int /* xaxis */, 7976 int /* yaxis */ 7977#endif 7978); 7979 7980extern int XGrabDevice( 7981#if NeedFunctionPrototypes 7982 Display* /* display */, 7983 XDevice* /* device */, 7984 Window /* grab_window */, 7985 Bool /* ownerEvents */, 7986 int /* event count */, 7987 XEventClass* /* event_list */, 7988 int /* this_device_mode */, 7989 int /* other_devices_mode */, 7990 Time /* time */ 7991#endif 7992); 7993 7994extern int XUngrabDevice( 7995#if NeedFunctionPrototypes 7996 Display* /* display */, 7997 XDevice* /* device */, 7998 Time /* time */ 7999#endif 8000); 8001 8002extern int XGrabDeviceKey( 8003#if NeedFunctionPrototypes 8004 Display* /* display */, 8005 XDevice* /* device */, 8006 unsigned int /* key */, 8007 unsigned int /* modifiers */, 8008 XDevice* /* modifier_device */, 8009 Window /* grab_window */, 8010 Bool /* owner_events */, 8011 unsigned int /* event_count */, 8012 XEventClass* /* event_list */, 8013 int /* this_device_mode */, 8014 int /* other_devices_mode */ 8015#endif 8016); 8017 8018extern int XUngrabDeviceKey( 8019#if NeedFunctionPrototypes 8020 Display* /* display */, 8021 XDevice* /* device */, 8022 unsigned int /* key */, 8023 unsigned int /* modifiers */, 8024 XDevice* /* modifier_dev */, 8025 Window /* grab_window */ 8026#endif 8027); 8028 8029extern int XGrabDeviceButton( 8030#if NeedFunctionPrototypes 8031 Display* /* display */, 8032 XDevice* /* device */, 8033 unsigned int /* button */, 8034 unsigned int /* modifiers */, 8035 XDevice* /* modifier_device */, 8036 Window /* grab_window */, 8037 Bool /* owner_events */, 8038 unsigned int /* event_count */, 8039 XEventClass* /* event_list */, 8040 int /* this_device_mode */, 8041 int /* other_devices_mode */ 8042#endif 8043); 8044 8045extern int XUngrabDeviceButton( 8046#if NeedFunctionPrototypes 8047 Display* /* display */, 8048 XDevice* /* device */, 8049 unsigned int /* button */, 8050 unsigned int /* modifiers */, 8051 XDevice* /* modifier_dev */, 8052 Window /* grab_window */ 8053#endif 8054); 8055 8056extern int XAllowDeviceEvents( 8057#if NeedFunctionPrototypes 8058 Display* /* display */, 8059 XDevice* /* device */, 8060 int /* event_mode */, 8061 Time /* time */ 8062#endif 8063); 8064 8065extern int XGetDeviceFocus( 8066#if NeedFunctionPrototypes 8067 Display* /* display */, 8068 XDevice* /* device */, 8069 Window* /* focus */, 8070 int* /* revert_to */, 8071 Time* /* time */ 8072#endif 8073); 8074 8075extern int XSetDeviceFocus( 8076#if NeedFunctionPrototypes 8077 Display* /* display */, 8078 XDevice* /* device */, 8079 Window /* focus */, 8080 int /* revert_to */, 8081 Time /* time */ 8082#endif 8083); 8084 8085extern XFeedbackState *XGetFeedbackControl( 8086#if NeedFunctionPrototypes 8087 Display* /* display */, 8088 XDevice* /* device */, 8089 int* /* num_feedbacks */ 8090#endif 8091); 8092 8093extern int XFreeFeedbackList( 8094#if NeedFunctionPrototypes 8095 XFeedbackState* /* list */ 8096#endif 8097); 8098 8099extern int XChangeFeedbackControl( 8100#if NeedFunctionPrototypes 8101 Display* /* display */, 8102 XDevice* /* device */, 8103 unsigned long /* mask */, 8104 XFeedbackControl* /* f */ 8105#endif 8106); 8107 8108extern int XDeviceBell( 8109#if NeedFunctionPrototypes 8110 Display* /* display */, 8111 XDevice* /* device */, 8112 XID /* feedbackclass */, 8113 XID /* feedbackid */, 8114 int /* percent */ 8115#endif 8116); 8117 8118extern KeySym *XGetDeviceKeyMapping( 8119#if NeedFunctionPrototypes 8120 Display* /* display */, 8121 XDevice* /* device */, 8122#if NeedWidePrototypes 8123 unsigned int /* first */, 8124#else 8125 KeyCode /* first */, 8126#endif 8127 int /* keycount */, 8128 int* /* syms_per_code */ 8129#endif 8130); 8131 8132extern int XChangeDeviceKeyMapping( 8133#if NeedFunctionPrototypes 8134 Display* /* display */, 8135 XDevice* /* device */, 8136 int /* first */, 8137 int /* syms_per_code */, 8138 KeySym* /* keysyms */, 8139 int /* count */ 8140#endif 8141); 8142 8143extern XModifierKeymap *XGetDeviceModifierMapping( 8144#if NeedFunctionPrototypes 8145 Display* /* display */, 8146 XDevice* /* device */ 8147#endif 8148); 8149 8150extern int XSetDeviceModifierMapping( 8151#if NeedFunctionPrototypes 8152 Display* /* display */, 8153 XDevice* /* device */, 8154 XModifierKeymap* /* modmap */ 8155#endif 8156); 8157 8158extern int XSetDeviceButtonMapping( 8159#if NeedFunctionPrototypes 8160 Display* /* display */, 8161 XDevice* /* device */, 8162 unsigned char* /* map[] */, 8163 int /* nmap */ 8164#endif 8165); 8166 8167extern int XGetDeviceButtonMapping( 8168#if NeedFunctionPrototypes 8169 Display* /* display */, 8170 XDevice* /* device */, 8171 unsigned char* /* map[] */, 8172 unsigned int /* nmap */ 8173#endif 8174); 8175 8176extern XDeviceState *XQueryDeviceState( 8177#if NeedFunctionPrototypes 8178 Display* /* display */, 8179 XDevice* /* device */ 8180#endif 8181); 8182 8183extern int XFreeDeviceState( 8184#if NeedFunctionPrototypes 8185 XDeviceState* /* list */ 8186#endif 8187); 8188 8189extern XExtensionVersion *XGetExtensionVersion( 8190#if NeedFunctionPrototypes 8191 Display* /* display */, 8192 _Xconst char* /* name */ 8193#endif 8194); 8195 8196extern XDeviceInfo *XListInputDevices( 8197#if NeedFunctionPrototypes 8198 Display* /* display */, 8199 int* /* ndevices */ 8200#endif 8201); 8202 8203extern int XFreeDeviceList( 8204#if NeedFunctionPrototypes 8205 XDeviceInfo* /* list */ 8206#endif 8207); 8208 8209extern XDevice *XOpenDevice( 8210#if NeedFunctionPrototypes 8211 Display* /* display */, 8212 XID /* id */ 8213#endif 8214); 8215 8216extern int XCloseDevice( 8217#if NeedFunctionPrototypes 8218 Display* /* display */, 8219 XDevice* /* device */ 8220#endif 8221); 8222 8223extern int XSetDeviceMode( 8224#if NeedFunctionPrototypes 8225 Display* /* display */, 8226 XDevice* /* device */, 8227 int /* mode */ 8228#endif 8229); 8230 8231extern int XSetDeviceValuators( 8232#if NeedFunctionPrototypes 8233 Display* /* display */, 8234 XDevice* /* device */, 8235 int* /* valuators */, 8236 int /* first_valuator */, 8237 int /* num_valuators */ 8238#endif 8239); 8240 8241extern XDeviceControl *XGetDeviceControl( 8242#if NeedFunctionPrototypes 8243 Display* /* display */, 8244 XDevice* /* device */, 8245 int /* control */ 8246#endif 8247); 8248 8249extern int XChangeDeviceControl( 8250#if NeedFunctionPrototypes 8251 Display* /* display */, 8252 XDevice* /* device */, 8253 int /* control */, 8254 XDeviceControl* /* d */ 8255#endif 8256); 8257 8258extern int XSelectExtensionEvent( 8259#if NeedFunctionPrototypes 8260 Display* /* display */, 8261 Window /* w */, 8262 XEventClass* /* event_list */, 8263 int /* count */ 8264#endif 8265); 8266 8267extern int XGetSelectedExtensionEvents( 8268#if NeedFunctionPrototypes 8269 Display* /* display */, 8270 Window /* w */, 8271 int* /* this_client_count */, 8272 XEventClass** /* this_client_list */, 8273 int* /* all_clients_count */, 8274 XEventClass** /* all_clients_list */ 8275#endif 8276); 8277 8278extern int XChangeDeviceDontPropagateList( 8279#if NeedFunctionPrototypes 8280 Display* /* display */, 8281 Window /* window */, 8282 int /* count */, 8283 XEventClass* /* events */, 8284 int /* mode */ 8285#endif 8286); 8287 8288extern XEventClass *XGetDeviceDontPropagateList( 8289#if NeedFunctionPrototypes 8290 Display* /* display */, 8291 Window /* window */, 8292 int* /* count */ 8293#endif 8294); 8295 8296extern Status XSendExtensionEvent( 8297#if NeedFunctionPrototypes 8298 Display* /* display */, 8299 XDevice* /* device */, 8300 Window /* dest */, 8301 Bool /* prop */, 8302 int /* count */, 8303 XEventClass* /* list */, 8304 XEvent* /* event */ 8305#endif 8306); 8307 8308extern XDeviceTimeCoord *XGetDeviceMotionEvents( 8309#if NeedFunctionPrototypes 8310 Display* /* display */, 8311 XDevice* /* device */, 8312 Time /* start */, 8313 Time /* stop */, 8314 int* /* nEvents */, 8315 int* /* mode */, 8316 int* /* axis_count */ 8317#endif 8318); 8319 8320extern int XFreeDeviceMotionEvents( 8321#if NeedFunctionPrototypes 8322 XDeviceTimeCoord* /* events */ 8323#endif 8324); 8325 8326extern int XFreeDeviceControl( 8327#if NeedFunctionPrototypes 8328 XDeviceControl* /* control */ 8329#endif 8330); 8331 8332_XFUNCPROTOEND 8333 8334#endif /* _XINPUT_H_ */ 8335 8336/* Definitions used by the server, library and client */ 8337 8338#ifndef _XI_H_ 8339 8340#define _XI_H_ 8341 8342#define sz_xGetExtensionVersionReq 8 8343#define sz_xGetExtensionVersionReply 32 8344#define sz_xListInputDevicesReq 4 8345#define sz_xListInputDevicesReply 32 8346#define sz_xOpenDeviceReq 8 8347#define sz_xOpenDeviceReply 32 8348#define sz_xCloseDeviceReq 8 8349#define sz_xSetDeviceModeReq 8 8350#define sz_xSetDeviceModeReply 32 8351#define sz_xSelectExtensionEventReq 12 8352#define sz_xGetSelectedExtensionEventsReq 8 8353#define sz_xGetSelectedExtensionEventsReply 32 8354#define sz_xChangeDeviceDontPropagateListReq 12 8355#define sz_xGetDeviceDontPropagateListReq 8 8356#define sz_xGetDeviceDontPropagateListReply 32 8357#define sz_xGetDeviceMotionEventsReq 16 8358#define sz_xGetDeviceMotionEventsReply 32 8359#define sz_xChangeKeyboardDeviceReq 8 8360#define sz_xChangeKeyboardDeviceReply 32 8361#define sz_xChangePointerDeviceReq 8 8362#define sz_xChangePointerDeviceReply 32 8363#define sz_xGrabDeviceReq 20 8364#define sz_xGrabDeviceReply 32 8365#define sz_xUngrabDeviceReq 12 8366#define sz_xGrabDeviceKeyReq 20 8367#define sz_xGrabDeviceKeyReply 32 8368#define sz_xUngrabDeviceKeyReq 16 8369#define sz_xGrabDeviceButtonReq 20 8370#define sz_xGrabDeviceButtonReply 32 8371#define sz_xUngrabDeviceButtonReq 16 8372#define sz_xAllowDeviceEventsReq 12 8373#define sz_xGetDeviceFocusReq 8 8374#define sz_xGetDeviceFocusReply 32 8375#define sz_xSetDeviceFocusReq 16 8376#define sz_xGetFeedbackControlReq 8 8377#define sz_xGetFeedbackControlReply 32 8378#define sz_xChangeFeedbackControlReq 12 8379#define sz_xGetDeviceKeyMappingReq 8 8380#define sz_xGetDeviceKeyMappingReply 32 8381#define sz_xChangeDeviceKeyMappingReq 8 8382#define sz_xGetDeviceModifierMappingReq 8 8383#define sz_xSetDeviceModifierMappingReq 8 8384#define sz_xSetDeviceModifierMappingReply 32 8385#define sz_xGetDeviceButtonMappingReq 8 8386#define sz_xGetDeviceButtonMappingReply 32 8387#define sz_xSetDeviceButtonMappingReq 8 8388#define sz_xSetDeviceButtonMappingReply 32 8389#define sz_xQueryDeviceStateReq 8 8390#define sz_xQueryDeviceStateReply 32 8391#define sz_xSendExtensionEventReq 16 8392#define sz_xDeviceBellReq 8 8393#define sz_xSetDeviceValuatorsReq 8 8394#define sz_xSetDeviceValuatorsReply 32 8395#define sz_xGetDeviceControlReq 8 8396#define sz_xGetDeviceControlReply 32 8397#define sz_xChangeDeviceControlReq 8 8398#define sz_xChangeDeviceControlReply 32 8399 8400#define INAME "XInputExtension" 8401 8402#define XI_KEYBOARD "KEYBOARD" 8403#define XI_MOUSE "MOUSE" 8404#define XI_TABLET "TABLET" 8405#define XI_TOUCHSCREEN "TOUCHSCREEN" 8406#define XI_TOUCHPAD "TOUCHPAD" 8407#define XI_BARCODE "BARCODE" 8408#define XI_BUTTONBOX "BUTTONBOX" 8409#define XI_KNOB_BOX "KNOB_BOX" 8410#define XI_ONE_KNOB "ONE_KNOB" 8411#define XI_NINE_KNOB "NINE_KNOB" 8412#define XI_TRACKBALL "TRACKBALL" 8413#define XI_QUADRATURE "QUADRATURE" 8414#define XI_ID_MODULE "ID_MODULE" 8415#define XI_SPACEBALL "SPACEBALL" 8416#define XI_DATAGLOVE "DATAGLOVE" 8417#define XI_EYETRACKER "EYETRACKER" 8418#define XI_CURSORKEYS "CURSORKEYS" 8419#define XI_FOOTMOUSE "FOOTMOUSE" 8420 8421#define Dont_Check 0 8422#define XInput_Initial_Release 1 8423#define XInput_Add_XDeviceBell 2 8424#define XInput_Add_XSetDeviceValuators 3 8425#define XInput_Add_XChangeDeviceControl 4 8426 8427#define XI_Absent 0 8428#define XI_Present 1 8429 8430#define XI_Initial_Release_Major 1 8431#define XI_Initial_Release_Minor 0 8432 8433#define XI_Add_XDeviceBell_Major 1 8434#define XI_Add_XDeviceBell_Minor 1 8435 8436#define XI_Add_XSetDeviceValuators_Major 1 8437#define XI_Add_XSetDeviceValuators_Minor 2 8438 8439#define XI_Add_XChangeDeviceControl_Major 1 8440#define XI_Add_XChangeDeviceControl_Minor 3 8441 8442#define DEVICE_RESOLUTION 1 8443 8444#define NoSuchExtension 1 8445 8446#define COUNT 0 8447#define CREATE 1 8448 8449#define NewPointer 0 8450#define NewKeyboard 1 8451 8452#define XPOINTER 0 8453#define XKEYBOARD 1 8454 8455#define UseXKeyboard 0xFF 8456 8457#define IsXPointer 0 8458#define IsXKeyboard 1 8459#define IsXExtensionDevice 2 8460 8461#define AsyncThisDevice 0 8462#define SyncThisDevice 1 8463#define ReplayThisDevice 2 8464#define AsyncOtherDevices 3 8465#define AsyncAll 4 8466#define SyncAll 5 8467 8468#define FollowKeyboard 3 8469#define RevertToFollowKeyboard 3 8470 8471#define DvAccelNum (1L << 0) 8472#define DvAccelDenom (1L << 1) 8473#define DvThreshold (1L << 2) 8474 8475#define DvKeyClickPercent (1L<<0) 8476#define DvPercent (1L<<1) 8477#define DvPitch (1L<<2) 8478#define DvDuration (1L<<3) 8479#define DvLed (1L<<4) 8480#define DvLedMode (1L<<5) 8481#define DvKey (1L<<6) 8482#define DvAutoRepeatMode (1L<<7) 8483 8484#define DvString (1L << 0) 8485 8486#define DvInteger (1L << 0) 8487 8488#define DeviceMode (1L << 0) 8489#define Relative 0 8490#define Absolute 1 8491 8492#define ProximityState (1L << 1) 8493#define InProximity (0L << 1) 8494#define OutOfProximity (1L << 1) 8495 8496#define AddToList 0 8497#define DeleteFromList 1 8498 8499#define KeyClass 0 8500#define ButtonClass 1 8501#define ValuatorClass 2 8502#define FeedbackClass 3 8503#define ProximityClass 4 8504#define FocusClass 5 8505#define OtherClass 6 8506 8507#define KbdFeedbackClass 0 8508#define PtrFeedbackClass 1 8509#define StringFeedbackClass 2 8510#define IntegerFeedbackClass 3 8511#define LedFeedbackClass 4 8512#define BellFeedbackClass 5 8513 8514#define _devicePointerMotionHint 0 8515#define _deviceButton1Motion 1 8516#define _deviceButton2Motion 2 8517#define _deviceButton3Motion 3 8518#define _deviceButton4Motion 4 8519#define _deviceButton5Motion 5 8520#define _deviceButtonMotion 6 8521#define _deviceButtonGrab 7 8522#define _deviceOwnerGrabButton 8 8523#define _noExtensionEvent 9 8524 8525#define XI_BadDevice 0 8526#define XI_BadEvent 1 8527#define XI_BadMode 2 8528#define XI_DeviceBusy 3 8529#define XI_BadClass 4 8530 8531typedef unsigned long XEventClass; 8532 8533/******************************************************************* 8534 * 8535 * Extension version structure. 8536 * 8537 */ 8538 8539typedef struct { 8540 int present; 8541 short major_version; 8542 short minor_version; 8543} XExtensionVersion; 8544 8545#endif /* _XI_H_ */ 8546 8547</literallayout> 8548<!-- .\" print Table of Contents --> 8549<!-- .if o .bp \" blank page to make count even --> 8550<!-- .bp 1 --> 8551<!-- .af PN i --> 8552<!-- .PX --> 8553 8554 8555</para> 8556</sect3> 8557</sect2> 8558</sect1> 8559</chapter> 8560