home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 August - Disc 2 / chip_20018102_hu.iso / linux / X-4.1.0 / doc / xilib.txt < prev    next >
Text File  |  2001-06-27  |  162KB  |  6,931 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.           X Input Device Extension Library
  19.  
  20.  
  21.            X Consortium Standard
  22.  
  23.          X Version 11, Release 6.4
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.           Mark Patrick    Ardent Computer
  41.  
  42.           George Sachs    Hewlett-Packard
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. Copyright (C) 1989, 1990, 1991 by Hewlett-Packard Company,
  86. Ardent Computer.
  87.  
  88. Permission to use, copy, modify, and distribute this docu-
  89. mentation for any purpose and without fee is hereby granted,
  90. provided that the above copyright notice and this permission
  91. notice appear in all copies.  Ardent, and Hewlett-Packard
  92. make no representations about the suitability for any pur-
  93. pose of the information in this document.  It is provided
  94. ``as is'' without express or implied warranty.
  95.  
  96.  
  97.  
  98.  
  99.  
  100. Copyright (c) 1989, 1990, 1991, 1992  X Consortium
  101.  
  102. Permission is hereby granted, free of charge, to any person
  103. obtaining a copy of this software and associated documenta-
  104. tion files (the ``Software''), to deal in the Software with-
  105. out restriction, including without limitation the rights to
  106. use, copy, modify, merge, publish, distribute, sublicense,
  107. and/or sell copies of the Software, and to permit persons to
  108. whom the Software is furnished to do so, subject to the fol-
  109. lowing conditions:
  110.  
  111. The above copyright notice and this permission notice shall
  112. be included in all copies or substantial portions of the
  113. Software.
  114.  
  115. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY
  116. KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  117. WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PUR-
  118. POSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE X CONSOR-
  119. TIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  120. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  121. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  122. OR OTHER DEALINGS IN THE SOFTWARE.
  123.  
  124. Except as contained in this notice, the name of the X Con-
  125. sortium shall not be used in advertising or otherwise to
  126. promote the sale, use or other dealings in this Software
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. without prior written authorization from the X Consortium.
  140.  
  141.  
  142.  
  143. X Window System is a trademark of X Consortium, Inc.
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. 1.  Input Extension Overview
  206.  
  207. This document describes an extension to the X11 server.  The
  208. purpose of this extension is to support the use of addi-
  209. tional input devices beyond the pointer and keyboard devices
  210. defined by the core X protocol.  This first section gives an
  211. overview of the input extension.  The following sections
  212. correspond to chapters 9, 10, and 11, ``Window and Session
  213. Manager Functions'', ``Events'', and ``Event Handling Func-
  214. tions'' of the ``Xlib - C Language Interface'' manual and
  215. describe how to use the input device extension.
  216.  
  217. 1.1.  Design Approach
  218.  
  219. The design approach of the extension is to define functions
  220. and events analogous to the core functions and events.    This
  221. allows extension input devices and events to be individually
  222. distinguishable from each other and from the core input
  223. devices and events.  These functions and events make use of
  224. a device identifier and support the reporting of n-dimen-
  225. sional motion data as well as other data that is not cur-
  226. rently reportable via the core input events.
  227.  
  228. 1.2.  Core Input Devices
  229.  
  230. The X server core protocol supports two input devices:    a
  231. pointer and a keyboard.  The pointer device has two major
  232. functions.  First, it may be used to generate motion infor-
  233. mation that client programs can detect. Second, it may also
  234. be used to indicate the current location and focus of the X
  235. keyboard.  To accomplish this, the server echoes a cursor at
  236. the current position of the X pointer.    Unless the X key-
  237. board has been explicitly focused, this cursor also shows
  238. the current location and focus of the X keyboard.
  239.  
  240. The X keyboard is used to generate input that client pro-
  241. grams can detect.
  242.  
  243. The X keyboard and X pointer are referred to in this docu-
  244. ment as the core devices, and the input events they generate
  245. (KeyPress, KeyRelease, ButtonPress, ButtonRelease, and
  246. MotionNotify) are known as the core input events.  All other
  247. input devices are referred to as extension input devices,
  248. and the input events they generate are referred to as exten-
  249. sion input events.
  250.  
  251.                 Note
  252.  
  253.      This input extension does not change the behavior
  254.      or functionality of the core input devices, core
  255.      events, or core protocol requests, with the excep-
  256.      tion of the core grab requests.  These requests
  257.      may affect the synchronization of events from
  258.      extension devices.  See the explanation in the
  259.  
  260.  
  261.  
  262.                   1
  263.  
  264.  
  265.  
  266.  
  267.  
  268. X Input Extension Library            X11, Release 6.4
  269.  
  270.  
  271.      section titled ``Event Synchronization and Core
  272.      Grabs.''
  273.  
  274.  
  275. Selection of the physical devices to be initially used by
  276. the server as the core devices is left implementation depen-
  277. dent.  Functions are defined that allow client programs to
  278. change which physical devices are used as the core devices.
  279.  
  280. 1.3.  Extension Input Devices
  281.  
  282. The input extension controls access to input devices other
  283. than the X keyboard and X pointer.  It allows client pro-
  284. grams to select input from these devices independently from
  285. each other and independently from the core devices.  Input
  286. events from these devices are of extension types
  287. (DeviceKeyPress, DeviceKeyRelease, DeviceButtonPress,
  288. DeviceButtonRelease, DeviceMotionNotify, and so on) and con-
  289. tain a device identifier so that events of the same type
  290. coming from different input devices can be distinguished.
  291.  
  292. Extension input events are not limited in size by the size
  293. of the server 32-byte wire events.  Extension input events
  294. may be constructed by the server sending as many wire-sized
  295. events as necessary to return the information required for
  296. that event.  The library event reformatting routines are
  297. responsible for combining these into one or more client
  298. XEvents.
  299.  
  300. Any input device that generates key, button, or motion data
  301. may be used as an extension input device.  Extension input
  302. devices may have zero or more keys, zero or more buttons,
  303. and may report zero or more axes of motion.  Motion may be
  304. reported as relative movements from a previous position or
  305. as an absolute position.  All valuators reporting motion
  306. information for a given extension input device must report
  307. the same kind of motion information (absolute or relative).
  308.  
  309. This extension is designed to accommodate new types of input
  310. devices that may be added in the future.  The protocol
  311. requests that refer to specific characteristics of input
  312. devices organize that information by input device classes.
  313. Server implementors may add new classes of input devices
  314. without changing the protocol requests.
  315.  
  316. All extension input devices are treated like the core X key-
  317. board in determining their location and focus.    The server
  318. does not track the location of these devices on an individ-
  319. ual basis and, therefore, does not echo a cursor to indicate
  320. their current location.  Instead, their location is deter-
  321. mined by the location of the core X pointer.  Like the core
  322. X keyboard, some may be explicitly focused. If they are not
  323. explicitly focused,  their focus is determined by the loca-
  324. tion of the core X pointer.
  325.  
  326.  
  327.  
  328.                   2
  329.  
  330.  
  331.  
  332.  
  333.  
  334. X Input Extension Library            X11, Release 6.4
  335.  
  336.  
  337. 1.3.1.    Input Device Classes
  338.  
  339. Some of the input extension requests divide input devices
  340. into classes based on their functionality.  This is intended
  341. to allow new classes of input devices to be defined at a
  342. later time without changing the semantics of these func-
  343. tions.    The following input device classes are currently
  344. defined:
  345.  
  346. KEY      The device reports key events.
  347.  
  348. BUTTON      The device reports button events.
  349.  
  350. VALUATOR  The device reports valuator data in motion events.
  351.  
  352. PROXIMITY The device reports proximity events.
  353.  
  354. FOCUS      The device can be focused.
  355.  
  356. FEEDBACK  The device supports feedbacks.
  357.  
  358. Additional classes may be added in the future.    Functions
  359. that support multiple input classes, such as the XListInput-
  360. Devices function that lists all available input devices,
  361. organize the data they return by input class.  Client pro-
  362. grams that use these functions should not access data unless
  363. it matches a class defined at the time those clients were
  364. compiled.  In this way, new classes can be added without
  365. forcing existing clients that use these functions to be
  366. recompiled.
  367.  
  368. 1.4.  Using Extension Input Devices
  369.  
  370. A client that wishes to access an input device does so
  371. through the library functions defined in the following sec-
  372. tions.    A typical sequence of requests that a client would
  373. make is as follows:
  374.  
  375. o    XListInputDevices - lists all of the available input
  376.      devices.  From the information returned by this
  377.      request, determine whether the desired input device is
  378.      attached to the server.  For a description of the
  379.      XListInputDevices request, see the section entitled
  380.      ``Listing Available Devices.''
  381.  
  382. o    XOpenDevice - requests that the server open the device
  383.      for access by this client.  This request returns an
  384.      XDevice structure that is used by most other input
  385.      extension requests to identify the specified device.
  386.      For a description of the XOpenDevice request, see the
  387.      section entitled ``Enabling and Disabling Extension
  388.      Devices.''
  389.  
  390.  
  391.  
  392.  
  393.  
  394.                   3
  395.  
  396.  
  397.  
  398.  
  399.  
  400. X Input Extension Library            X11, Release 6.4
  401.  
  402.  
  403. o    Determine the event types and event classes needed to
  404.      select the desired input extension events, and identify
  405.      them when they are received.  This is done via macros
  406.      whose name corresponds to the desired event, for exam-
  407.      ple, DeviceKeyPress.  For a description of these
  408.      macros, see the section entitled ``Selecting Extension
  409.      Device Events.''
  410.  
  411. o    XSelectExtensionEvent - selects the desired events from
  412.      the server.  For a description of the XSelextExtension-
  413.      Event request, see the section entitled ``Selecting
  414.      Extension Device Events.''
  415.  
  416. o    XNextEvent - receives the next available event.  This
  417.      is the core XNextEvent function provided by the stan-
  418.      dard X libarary.
  419.  
  420. Other requests are defined to grab and focus extension
  421. devices, to change their key, button, or modifier mappings,
  422. to control the propagation of input extension events, to get
  423. motion history from an extension device, and to send input
  424. extension events to another client.  These functions are
  425. described in the following sections.
  426.  
  427. 2.  Library Extension Requests
  428.  
  429. Extension input devices are accessed by client programs
  430. through the use of new protocol requests.  The following
  431. requests are provided as extensions to Xlib.  Constants and
  432. structures referenced by these functions may be found in the
  433. files <X11/extensions/XI.h> and <X11/extensions/XInput.h>,
  434. which are attached to this document as Appendix A.
  435.  
  436. The library will return NoSuchExtension if an extension
  437. request is made to a server that does not support the input
  438. extension.
  439.  
  440. Input extension requests cannot be used to access the X key-
  441. board and X pointer devices.
  442.  
  443. 2.1.  Window Manager Functions
  444.  
  445. This section discusses the following X Input Extension Win-
  446. dow Manager topics:
  447.  
  448. o    Changing the core devices
  449.  
  450. o    Event synchronization and core grabs
  451.  
  452. o    Extension active grabs
  453.  
  454. o    Passively grabbing a key
  455.  
  456.  
  457.  
  458.  
  459.  
  460.                   4
  461.  
  462.  
  463.  
  464.  
  465.  
  466. X Input Extension Library            X11, Release 6.4
  467.  
  468.  
  469. o    Passively grabbing a button
  470.  
  471. o    Thawing a device
  472.  
  473. o    Controlling device focus
  474.  
  475. o    Controlling device feedback
  476.  
  477. o    Ringing a bell on an input device
  478.  
  479. o    Controlling device encoding
  480.  
  481. o    Controlling button mapping
  482.  
  483. o    Obtaining the state of a device
  484.  
  485. 2.1.1.    Changing the Core Devices
  486.  
  487. These functions are provided to change which physical device
  488. is used as the X pointer or X keyboard.
  489.  
  490.                 Note
  491.  
  492.      Using these functions may change the characteris-
  493.      tics of the core devices.    The new pointer device
  494.      may have a different number of buttons from the
  495.      old one, or the new keyboard device may have a
  496.      different number of keys or report a different
  497.      range of keycodes.  Client programs may be running
  498.      that depend on those characteristics.  For exam-
  499.      ple, a client program could allocate an array
  500.      based on the number of buttons on the pointer
  501.      device and then use the button numbers received in
  502.      button events as indices into that array.    Chang-
  503.      ing the core devices could cause such client pro-
  504.      grams to behave improperly or to terminate abnor-
  505.      mally if they ignore the ChangeDeviceNotify event
  506.      generated by these requests.
  507.  
  508.  
  509. These functions change the X keyboard or X pointer device
  510. and generate an XChangeDeviceNotify event and a MappingNo-
  511. tify event.  The specified device becomes the new X keyboard
  512. or X pointer device.  The location of the core device does
  513. not change as a result of this request.
  514.  
  515. These requests fail and return AlreadyGrabbed if either the
  516. specified device or the core device it would replace are
  517. grabbed by some other client.  They fail and return
  518. GrabFrozen if either device is frozen by the active grab of
  519. another client.
  520.  
  521. These requests fail with a BadDevice error if the specified
  522. device is invalid, has not previously been opened via
  523.  
  524.  
  525.  
  526.                   5
  527.  
  528.  
  529.  
  530.  
  531.  
  532. X Input Extension Library            X11, Release 6.4
  533.  
  534.  
  535. XOpenDevice, or is not supported as a core device by the
  536. server implementation.
  537.  
  538. Once the device has successfully replaced one of the core
  539. devices, it is treated as a core device until it is in turn
  540. replaced by another ChangeDevice request or until the server
  541. terminates.  The termination of the client that changed the
  542. device will not cause it to change back.  Attempts to use
  543. the XCloseDevice request to close the new core device will
  544. fail with a BadDevice error.
  545.  
  546.  
  547. To change which physical device is used as the X keyboard,
  548. use the XChangeKeyboardDevice function.  The specified
  549. device must support input class Keys (as reported in the
  550. ListInputDevices request) or the request will fail with a
  551. BadMatch error.
  552.  
  553. __
  554. |
  555. int XChangeKeyboardDevice(display, device)
  556.      Display *display;
  557.      XDevice *device;
  558.  
  559.  
  560. display   Specifies the connection to the X server.
  561.  
  562. device      Specifies the desired device.
  563. |__
  564.  
  565. If no error occurs, XChangeKeyboardDevice returns Success.
  566. A ChangeDeviceNotify event with the request field set to
  567. NewKeyboard is sent to all clients selecting that event.  A
  568. MappingNotify event with the request field set to Map-
  569. pingKeyboard is sent to all clients.  The requested device
  570. becomes the X keyboard, and the old keyboard becomes avail-
  571. able as an extension input device.  The focus state of the
  572. new keyboard is the same as the focus state of the old X
  573. keyboard.
  574.  
  575. XChangeKeyboardDevice can generate AlreadyGrabbed,
  576. BadDevice, BadMatch, and GrabFrozen errors.
  577.  
  578.  
  579. To change which physical device is used as the X pointer,
  580. use the XChangePointerDevice function.    The specified device
  581. must support input class Valuators (as reported in the
  582. XListInputDevices request) and report at least two axes of
  583. motion, or the request will fail with a BadMatch error.  If
  584. the specified device reports more than two axes, the two
  585. specified in the xaxis and yaxis arguments will be used.
  586. Data from other valuators on the device will be ignored.
  587.  
  588.  
  589.  
  590.  
  591.  
  592.                   6
  593.  
  594.  
  595.  
  596.  
  597.  
  598. X Input Extension Library            X11, Release 6.4
  599.  
  600.  
  601. If the specified device reports absolute positional informa-
  602. tion, and the server implementation does not allow such a
  603. device to be used as the X pointer, the request will fail
  604. with a BadDevice error.
  605. __
  606. |
  607. int XChangePointerDevice(display, device, xaxis, yaxis)
  608.      Display *display;
  609.      XDevice *device;
  610.      int xaxis;
  611.      int yaxis;
  612.  
  613.  
  614. display   Specifies the connection to the X server.
  615.  
  616. device      Specifies the desired device.
  617.  
  618. xaxis      Specifies the zero-based index of the axis to be
  619.       used as the x-axis of the pointer device.
  620.  
  621. yaxis      Specifies the zero-based index of the axis to be
  622.       used as the y-axis of the pointer device.
  623. |__
  624.  
  625. If no error occurs, XChangePointerDevice returns Success.  A
  626. ChangeDeviceNotify event with the request field set to New-
  627. Pointer is sent to all clients selecting that event.  A Map-
  628. pingNotify event with the request field set to Mapping-
  629. Pointer is sent to all clients.  The requested device
  630. becomes the X pointer, and the old pointer becomes available
  631. as an extension input device.
  632.  
  633. XChangePointerDevice can generate AlreadyGrabbed, BadDevice,
  634. BadMatch, and GrabFrozen errors.
  635.  
  636. 2.1.2.    Event Synchronization and Core Grabs
  637.  
  638. Implementation of the input extension requires an extension
  639. of the meaning of event synchronization for the core grab
  640. requests.  This is necessary in order to allow window man-
  641. agers to freeze all input devices with a single request.
  642.  
  643. The core grab requests require a pointer_mode and key-
  644. board_mode argument.  The meaning of these modes is changed
  645. by the input extension.  For the XGrabPointer and XGrabBut-
  646. ton requests, pointer_mode controls synchronization of the
  647. pointer device, and keyboard_mode controls the synchroniza-
  648. tion of all other input devices.  For the XGrabKeyboard and
  649. XGrabKey requests, pointer_mode controls the synchronization
  650. of all input devices, except the X keyboard, while key-
  651. board_mode controls the synchronization of the keyboard.
  652. When using one of the core grab requests, the synchroniza-
  653. tion of extension devices is controlled by the mode speci-
  654. fied for the device not being grabbed.
  655.  
  656.  
  657.  
  658.                   7
  659.  
  660.  
  661.  
  662.  
  663.  
  664. X Input Extension Library            X11, Release 6.4
  665.  
  666.  
  667. 2.1.3.    Extension Active Grabs
  668.  
  669. Active grabs of extension devices are supported via the
  670. XGrabDevice function in the same way that core devices are
  671. grabbed using the core XGrabKeyboard function, except that
  672. an extension input device is passed as a function parameter.
  673. The XUngrabDevice function allows a previous active grab for
  674. an extension device to be released.
  675.  
  676. Passive grabs of buttons and keys on extension devices are
  677. supported via the XGrabDeviceButton and XGrabDeviceKey func-
  678. tions.    These passive grabs are released via the XUngrabDe-
  679. viceKey and XUngrabDeviceButton functions.
  680.  
  681.  
  682. To grab an extension device, use the XGrabDevice function.
  683. The device must have previously been opened using the XOpen-
  684. Device function.
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.                   8
  725.  
  726.  
  727.  
  728.  
  729.  
  730. X Input Extension Library            X11, Release 6.4
  731.  
  732. __
  733. |
  734. int XGrabDevice(display, device, grab_window, owner_events, event_count, event_list,
  735.            this_device_mode, other_device_mode, time)
  736.      Display *display;
  737.      XDevice *device;
  738.      Window grab_window;
  739.      Bool owner_events;
  740.      int event_count;
  741.      XEventClass *event_list;
  742.      int this_device_mode;
  743.      int other_device_mode;
  744.      Time time;
  745.  
  746.  
  747. display   Specifies the connection to the X server.
  748.  
  749. device      Specifies the desired device.
  750.  
  751. grab_window
  752.       Specifies the ID of a window associated with the
  753.       device specified above.
  754.  
  755. owner_events
  756.       Specifies a boolean value of either True or False.
  757.  
  758. event_count
  759.       Specifies the number of elements in the event_list
  760.       array.
  761.  
  762. event_list
  763.       Specifies a pointer to a list of event classes
  764.       that indicate which events the client wishes to
  765.       receive.  These event classes must have been
  766.       obtained using the device being grabbed.
  767.  
  768. this_device_mode
  769.       Controls further processing of events from this
  770.       device.  You can pass one of these constants:
  771.       GrabModeSync or GrabModeAsync.
  772.  
  773. other_device_mode
  774.       Controls further processing of events from all
  775.       other devices.  You can pass one of these con-
  776.       stants: GrabModeSync or GrabModeAsync.
  777.  
  778. time      Specifies the time.  This may be either a times-
  779.       tamp expressed in milliseconds or CurrentTime.
  780. |__
  781.  
  782. XGrabDevice actively grabs an extension input device and
  783. generates DeviceFocusIn and DeviceFocusOut events.  Further
  784. input events from this device are reported only to the grab-
  785. bing client.  This function overrides any previous active
  786. grab by this client for this device.
  787.  
  788.  
  789.  
  790.                   9
  791.  
  792.  
  793.  
  794.  
  795.  
  796. X Input Extension Library            X11, Release 6.4
  797.  
  798.  
  799. The event_list parameter is a pointer to a list of event
  800. classes.  This list indicates which events the client wishes
  801. to receive while the grab is active.  If owner_events is
  802. False, input events from this device are reported with
  803. respect to grab_window and are reported only if specified in
  804. event_list.  If owner_events is True, then if a generated
  805. event would normally be reported to this client, it is
  806. reported normally.  Otherwise, the event is reported with
  807. respect to the grab_window and is only reported if specified
  808. in event_list.
  809.  
  810. The this_device_mode argument controls the further process-
  811. ing of events from this device, and the other_device_mode
  812. argument controls the further processing of input events
  813. from all other devices.
  814.  
  815. o    If the this_device_mode argument is GrabModeAsync,
  816.      device event processing continues normally; if the
  817.      device is currently frozen by this client, then pro-
  818.      cessing of device events is resumed.  If the
  819.      this_device_mode  argument is GrabModeSync, the state
  820.      of the grabbed device (as seen by client applications)
  821.      appears to freeze, and no further device events are
  822.      generated by the server until the grabbing client
  823.      issues a releasing XAllowDeviceEvents call or until the
  824.      device grab is released.  Actual device input events
  825.      are not lost while the device is frozen; they are sim-
  826.      ply queued for later processing.
  827.  
  828. o    If the other_device_mode is GrabModeAsync, event pro-
  829.      cessing from other input devices is unaffected by acti-
  830.      vation of the grab.  If other_device_mode is
  831.      GrabModeSync, the state of all devices except the
  832.      grabbed device (as seen by client applications) appears
  833.      to freeze, and no further events are generated by the
  834.      server until the grabbing client issues a releasing
  835.      XAllowEvents or XAllowDeviceEvents call or until the
  836.      device grab is released.  Actual events are not lost
  837.      while the other devices are frozen; they are simply
  838.      queued for later processing.
  839.  
  840. XGrabDevice fails on the following conditions:
  841.  
  842. o    If the device is actively grabbed by some other client,
  843.      it returns AlreadyGrabbed.
  844.  
  845. o    If grab_window is not viewable, it returns
  846.      GrabNotViewable.
  847.  
  848. o    If the specified time is earlier than the last-grab-
  849.      time for the specified device or later than the current
  850.      X server time, it returns GrabInvalidTime.  Otherwise,
  851.      the last-grab-time for the specified device is set to
  852.      the specified time and CurrentTime is replaced by the
  853.  
  854.  
  855.  
  856.                  10
  857.  
  858.  
  859.  
  860.  
  861.  
  862. X Input Extension Library            X11, Release 6.4
  863.  
  864.  
  865.      current X server time.
  866.  
  867. o    If the device is frozen by an active grab of another
  868.      client, it returns GrabFrozen.
  869.  
  870. If a grabbed device is closed by a client while an active
  871. grab by that client is in effect, that active grab will be
  872. released.  Any passive grabs established by that client will
  873. be released.  If the device is frozen only by an active grab
  874. of the requesting client, it is thawed.
  875.  
  876. XGrabDevice can generate BadClass, BadDevice, BadValue, and
  877. BadWindow errors.
  878.  
  879.  
  880. To release a grab of an extension device, use the XUngrabDe-
  881. vice function.
  882.  
  883. __
  884. |
  885. int XUngrabDevice(display, device, time)
  886.      Display *display;
  887.      XDevice *device;
  888.      Time time;
  889.  
  890.  
  891. display   Specifies the connection to the X server.
  892.  
  893. device      Specifies the desired device.
  894.  
  895. time      Specifies the time.  This may be either a times-
  896.       tamp expressed in milliseconds, or CurrentTime.
  897. |__
  898.  
  899. XUngrabDevice allows a client to release an extension input
  900. device and any queued events if this client has it grabbed
  901. from either XGrabDevice or XGrabDeviceKey.  If any other
  902. devices are frozen by the grab, XUngrabDevice thaws them.
  903. This function does not release the device and any queued
  904. events if the specified time is earlier than the last-
  905. device-grab time or is later than the current X server time.
  906. It also generates DeviceFocusIn and DeviceFocusOut events.
  907. The X server automatically performs an XUngrabDevice if the
  908. event window for an active device grab becomes not viewable
  909. or if the client terminates without releasing the grab.
  910.  
  911. XUngrabDevice can generate BadDevice errors.
  912.  
  913. 2.1.4.    Passively Grabbing a Key
  914.  
  915. To passively grab a single key on an extension device, use
  916. XGrabDeviceKey.  That device must have previously been
  917. opened using the XOpenDevice function, or the request will
  918. fail with a BadDevice error.  If the specified device does
  919.  
  920.  
  921.  
  922.                  11
  923.  
  924.  
  925.  
  926.  
  927.  
  928. X Input Extension Library            X11, Release 6.4
  929.  
  930.  
  931. not support input class Keys, the request will fail with a
  932. BadMatch error.
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.                  12
  989.  
  990.  
  991.  
  992.  
  993.  
  994. X Input Extension Library            X11, Release 6.4
  995.  
  996. __
  997. |
  998. int XGrabDeviceKey(display, device, keycode, modifiers, modifier_device, grab_window,
  999.        owner_events, event_count, event_list, this_device_mode, other_device_mode)
  1000.      Display *display;
  1001.      XDevice *device;
  1002.      int keycode;
  1003.      unsigned int modifiers;
  1004.      XDevice *modifier_device;
  1005.      Window grab_window;
  1006.      Bool owner_events;
  1007.      int event_count;
  1008.      XEventClass *event_list;
  1009.      int this_device_mode;
  1010.      int other_device_mode;
  1011.  
  1012.  
  1013. display   Specifies the connection to the X server.
  1014.  
  1015. device      Specifies the desired device.
  1016.  
  1017. keycode   Specifies the keycode of the key that is to be
  1018.       grabbed.  You can pass either the keycode or
  1019.       AnyKey.
  1020.  
  1021. modifiers Specifies the set of keymasks.  This mask is the
  1022.       bitwise inclusive OR of these keymask bits:
  1023.       ShiftMask, LockMask, ControlMask, Mod1Mask,
  1024.       Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask.
  1025.  
  1026.       You can also pass AnyModifier, which is equivalent
  1027.       to issuing the grab key request for all possible
  1028.       modifier combinations (including the combination
  1029.       of no modifiers).
  1030.  
  1031. modifier_device
  1032.       Specifies the device whose modifiers are to be
  1033.       used.  If NULL is specified, the core X keyboard
  1034.       is used as the modifier_device.
  1035.  
  1036. grab_window
  1037.       Specifies the ID of a window associated with the
  1038.       device specified above.
  1039.  
  1040. owner_events
  1041.       Specifies a boolean value of either True or False.
  1042.  
  1043. event_count
  1044.       Specifies the number of elements in the event_list
  1045.       array.
  1046.  
  1047. event_list
  1048.       Specifies a pointer to a list of event classes
  1049.       that indicate which events the client wishes to
  1050.       receive.
  1051.  
  1052.  
  1053.  
  1054.                  13
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. X Input Extension Library            X11, Release 6.4
  1061.  
  1062.  
  1063. this_device_mode
  1064.       Controls further processing of events from this
  1065.       device.  You can pass one of these constants:
  1066.       GrabModeSync or GrabModeAsync.
  1067.  
  1068. other_device_mode
  1069.       Controls further processing of events from all
  1070.       other devices.  You can pass one of these con-
  1071.       stants: GrabModeSync or GrabModeAsync.
  1072. |__
  1073.  
  1074. XGrabDeviceKey is analogous to the core XGrabKey function.
  1075. It creates an explicit passive grab for a key on an exten-
  1076. sion device.  The XGrabDeviceKey function establishes a pas-
  1077. sive grab on a device.    Consequently, in the future,
  1078.  
  1079. o    IF the device is not grabbed and the specified key,
  1080.      which itself can be a modifier key, is logically
  1081.      pressed when the specified modifier keys logically are
  1082.      down on the specified modifier device (and no other
  1083.      keys are down),
  1084.  
  1085. o    AND no other modifier keys logically are down,
  1086.  
  1087. o    AND EITHER the grab window is an ancestor of (or is)
  1088.      the focus window or the grab window is a descendent of
  1089.      the focus window and contains the pointer,
  1090.  
  1091. o    AND a passive grab on the same device and key combina-
  1092.      tion does not exist on any ancestor of the grab window,
  1093.  
  1094. o    THEN the device is actively grabbed, as for
  1095.      XGrabDevice, the last-device-grab time is set to the
  1096.      time at which the key was pressed (as transmitted in
  1097.      the DeviceKeyPress event), and the DeviceKeyPress event
  1098.      is reported.
  1099.  
  1100. The interpretation of the remaining arguments is as for
  1101. XGrabDevice.  The active grab is terminated automatically
  1102. when the logical state of the device has the specified key
  1103. released (independent of the logical state of the modifier
  1104. keys).
  1105.  
  1106. Note that the logical state of a device (as seen by means of
  1107. the X protocol) may lag the physical state if device event
  1108. processing is frozen.
  1109.  
  1110. A modifier of AnyModifier is equivalent to issuing the
  1111. request for all possible modifier combinations (including
  1112. the combination of no modifiers).  It is not required that
  1113. all modifiers specified have currently assigned keycodes.  A
  1114. key of AnyKey is equivalent to issuing the request for all
  1115. possible keycodes.  Otherwise, the key must be in the range
  1116. specified by min_keycode and max_keycode in the information
  1117.  
  1118.  
  1119.  
  1120.                  14
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. X Input Extension Library            X11, Release 6.4
  1127.  
  1128.  
  1129. returned by the XListInputDevices function.  If it is not
  1130. within that range, XGrabDeviceKey generates a BadValue
  1131. error.
  1132.  
  1133. XGrabDeviceKey generates a BadAccess error if some other
  1134. client has issued a XGrabDeviceKey with the same device and
  1135. key combination on the same window.  When using AnyModifier
  1136. or AnyKey, the request fails completely and the X server
  1137. generates a BadAccess error, and no grabs are established if
  1138. there is a conflicting grab for any combination.
  1139.  
  1140. XGrabDeviceKey returns Success upon successful completion of
  1141. the request.
  1142.  
  1143. XGrabDeviceKey can generate BadAccess, BadClass, BadDevice,
  1144. BadMatch, BadValue, and BadWindow errors.
  1145.  
  1146.  
  1147. To release a passive grab of a single key on an extension
  1148. device, use XUngrabDeviceKey.
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.                  15
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. X Input Extension Library            X11, Release 6.4
  1193.  
  1194. __
  1195. |
  1196. int XUngrabDeviceKey(display, device, keycode, modifiers, modifier_device, ungrab_window)
  1197.      Display *display;
  1198.      XDevice *device;
  1199.      int keycode;
  1200.      unsigned int modifiers;
  1201.      XDevice *modifier_device;
  1202.      Window ungrab_window;
  1203.  
  1204.  
  1205. display   Specifies the connection to the X server.
  1206.  
  1207. device      Specifies the desired device.
  1208.  
  1209. keycode   Specifies the keycode of the key that is to be
  1210.       ungrabbed.  You can pass either the keycode or
  1211.       AnyKey.
  1212.  
  1213. modifiers Specifies the set of keymasks.  This mask is the
  1214.       bitwise inclusive OR of these keymask bits:
  1215.       ShiftMask, LockMask, ControlMask, Mod1Mask,
  1216.       Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask.
  1217.  
  1218.       You can also pass AnyModifier, which is equivalent
  1219.       to issuing the ungrab key request for all possible
  1220.       modifier combinations (including the combination
  1221.       of no modifiers).
  1222.  
  1223. modifier_device
  1224.            Specifies the device whose modifiers are to
  1225.            be used.  If NULL is specified, the core X
  1226.            keyboard is used as the modifier_device.
  1227.  
  1228. ungrab_window  Specifies the ID of a window associated with
  1229.            the device specified above.
  1230. |__
  1231.  
  1232. XUngrabDeviceKey is analogous to the core XUngrabKey func-
  1233. tion.  It releases an explicit passive grab for a key on an
  1234. extension input device.
  1235.  
  1236. XUngrabDeviceKey can generate BadAlloc, BadDevice, BadMatch,
  1237. BadValue, and BadWindow errors.
  1238.  
  1239. 2.1.5.    Passively Grabbing a Button
  1240.  
  1241. To establish a passive grab for a single button on an exten-
  1242. sion device, use XGrabDeviceButton.  The specified device
  1243. must have previously been opened using the XOpenDevice func-
  1244. tion, or the request will fail with a BadDevice error.    If
  1245. the specified device does not support input class Buttons,
  1246. the request will fail with a BadMatch error.
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.                  16
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. X Input Extension Library            X11, Release 6.4
  1259.  
  1260. __
  1261. |
  1262. int XGrabDeviceButton(display, device, button, modifiers, modifier_device , grab_window,
  1263.          owner_events, event_count, event_list, this_device_mode, other_device_mode)
  1264.      Display *display;
  1265.      XDevice *device;
  1266.      unsigned int button;
  1267.      unsigned int modifiers;
  1268.      XDevice *modifier_device ;
  1269.      Window grab_window;
  1270.      Bool owner_events;
  1271.      int event_count;
  1272.      XEventClass *event_list;
  1273.      int this_device_mode;
  1274.      int other_device_mode;
  1275.  
  1276.  
  1277. display   Specifies the connection to the X server.
  1278.  
  1279. device      Specifies the desired device.
  1280.  
  1281. button      Specifies the code of the button that is to be
  1282.       grabbed.  You can pass either the button or
  1283.       AnyButton.
  1284.  
  1285. modifiers Specifies the set of keymasks.  This mask is the
  1286.       bitwise inclusive OR of these keymask bits:
  1287.       ShiftMask, LockMask, ControlMask, Mod1Mask,
  1288.       Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask.
  1289.  
  1290.       You can also pass AnyModifier, which is equivalent
  1291.       to issuing the grab request for all possible modi-
  1292.       fier combinations (including the combination of no
  1293.       modifiers).
  1294.  
  1295. modifier_device
  1296.       Specifies the device whose modifiers are to be
  1297.       used.  If NULL is specified, the core X keyboard
  1298.       is used as the modifier_device.
  1299.  
  1300. grab_window
  1301.       Specifies the ID of a window associated with the
  1302.       device specified above.
  1303.  
  1304. owner_events
  1305.       Specifies a boolean value of either True or False.
  1306.  
  1307. event_count
  1308.       Specifies the number of elements in the event_list
  1309.       array.
  1310.  
  1311. event_list
  1312.       Specifies a list of event classes that indicates
  1313.       which device events are to be reported to the
  1314.       client.
  1315.  
  1316.  
  1317.  
  1318.                  17
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. X Input Extension Library            X11, Release 6.4
  1325.  
  1326.  
  1327. this_device_mode
  1328.       Controls further processing of events from this
  1329.       device.  You can pass one of these constants:
  1330.       GrabModeSync or GrabModeAsync.
  1331.  
  1332. other_device_mode
  1333.       Controls further processing of events from all
  1334.       other devices.  You can pass one of these con-
  1335.       stants: GrabModeSync or GrabModeAsync.
  1336. |__
  1337.  
  1338. XGrabDeviceButton is analogous to the core XGrabButton func-
  1339. tion.  It creates an explicit passive grab for a button on
  1340. an extension input device.  Because the server does not
  1341. track extension devices, no cursor is specified with this
  1342. request.  For the same reason, there is no confine_to param-
  1343. eter.  The device must have previously been opened using the
  1344. XOpenDevice function.
  1345.  
  1346. The XGrabDeviceButton function establishes a passive grab on
  1347. a device.  Consequently, in the future,
  1348.  
  1349. o    IF the device is not grabbed and the specified button
  1350.      is logically pressed when the specified modifier keys
  1351.      logically are down (and no other buttons or modifier
  1352.      keys are down),
  1353.  
  1354. o    AND EITHER the grab window is an ancestor of (or is)
  1355.      the focus window OR the grab window is a descendent of
  1356.      the focus window and contains the pointer,
  1357.  
  1358. o    AND a passive grab on the same device and button/key
  1359.      combination does not exist on any ancestor of the grab
  1360.      window,
  1361.  
  1362. o    THEN the device is actively grabbed, as for
  1363.      XGrabDevice, the last-grab time is set to the time at
  1364.      which the button was pressed (as transmitted in the
  1365.      DeviceButtonPress event), and the DeviceButtonPress
  1366.      event is reported.
  1367.  
  1368. The interpretation of the remaining arguments is as for
  1369. XGrabDevice.  The active grab is terminated automatically
  1370. when logical state of the device has all buttons released
  1371. (independent of the logical state of the modifier keys).
  1372.  
  1373. Note that the logical state of a device (as seen by means of
  1374. the X protocol) may lag the physical state if device event
  1375. processing is frozen.
  1376.  
  1377. A modifier of AnyModifier is equivalent to issuing the
  1378. request for all possible modifier combinations (including
  1379. the combination of no modifiers).  It is not required that
  1380. all modifiers specified have currently assigned keycodes.  A
  1381.  
  1382.  
  1383.  
  1384.                  18
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. X Input Extension Library            X11, Release 6.4
  1391.  
  1392.  
  1393. button of AnyButton is equivalent to issuing the request for
  1394. all possible buttons.  Otherwise, it is not required that
  1395. the specified button be assigned to a physical button.
  1396.  
  1397. XGrabDeviceButton generates a BadAccess error if some other
  1398. client has issued a XGrabDeviceButton with the same device
  1399. and button combination on the same window.  When using Any-
  1400. Modifier or AnyButton, the request fails completely and the
  1401. X server generates a BadAccess error and no grabs are estab-
  1402. lished if there is a conflicting grab for any combination.
  1403.  
  1404. XGrabDeviceButton can generate BadAccess, BadClass,
  1405. BadDevice, BadMatch, BadValue, and BadWindow errors.
  1406.  
  1407.  
  1408. To release a passive grab of a button on an extension
  1409. device, use XUngrabDeviceButton.
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.                  19
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. X Input Extension Library            X11, Release 6.4
  1457.  
  1458. __
  1459. |
  1460. int XUngrabDeviceButton(display, device, button, modifiers, modifier_device, ungrab_window)
  1461.      Display *display;
  1462.      XDevice *device;
  1463.      unsigned int button;
  1464.      unsigned int modifiers;
  1465.      XDevice *modifier_device;
  1466.      Window ungrab_window;
  1467.  
  1468.  
  1469. display   Specifies the connection to the X server.
  1470.  
  1471. device      Specifies the desired device.
  1472.  
  1473. button      Specifies the code of the button that is to be
  1474.       ungrabbed.  You can pass either a button or
  1475.       AnyButton.
  1476.  
  1477. modifiers Specifies the set of keymasks.  This mask is the
  1478.       bitwise inclusive OR of these keymask bits:
  1479.       ShiftMask, LockMask, ControlMask, Mod1Mask,
  1480.       Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask.
  1481.  
  1482.       You can also pass AnyModifier, which is equivalent
  1483.       to issuing the ungrab key request for all possible
  1484.       modifier combinations (including the combination
  1485.       of no modifiers).
  1486.  
  1487. modifier_device
  1488.       Specifies the device whose modifiers are to be
  1489.       used.  If NULL is specified, the core X keyboard
  1490.       is used as the modifier_device.
  1491.  
  1492. ungrab_window
  1493.       Specifies the ID of a window associated with the
  1494.       device specified above.
  1495. |__
  1496.  
  1497. XUngrabDeviceButton is analogous to the core XUngrabButton
  1498. function.  It releases an explicit passive grab for a button
  1499. on an extension device.  That device must have previously
  1500. been opened using the XOpenDevice function, or a BadDevice
  1501. error will result.
  1502.  
  1503. A modifier of AnyModifier is equivalent to issuing the
  1504. request for all possible modifier combinations (including
  1505. the combination of no modifiers).
  1506.  
  1507. XUngrabDeviceButton can generate BadAlloc, BadDevice,
  1508. BadMatch, BadValue, and BadWindow errors.
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.                  20
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. X Input Extension Library            X11, Release 6.4
  1523.  
  1524.  
  1525. 2.1.6.    Thawing a Device
  1526.  
  1527. To allow further events to be processed when a device has
  1528. been frozen, use XAllowDeviceEvents.
  1529. __
  1530. |
  1531. int XAllowDeviceEvents(display, device, event_mode, time)
  1532.      Display *display;
  1533.      XDevice *device;
  1534.      int event_mode;
  1535.      Time time;
  1536.  
  1537.  
  1538. display   Specifies the connection to the X server.
  1539.  
  1540. device      Specifies the desired device.
  1541.  
  1542. event_mode
  1543.       Specifies the event mode.  You can pass one of
  1544.       these constants: AsyncThisDevice, SyncThisDevice,
  1545.       AsyncOtherDevices, ReplayThisDevice, AsyncAll, or
  1546.       SyncAll.
  1547.  
  1548. time      Specifies the time.  This may be either a times-
  1549.       tamp expressed in milliseconds, or CurrentTime.
  1550. |__
  1551.  
  1552. XAllowDeviceEvents releases some queued events if the client
  1553. has caused a device to freeze.    It has no effect if the
  1554. specified time is earlier than the last-grab time of the
  1555. most recent active grab for the client and device, or if the
  1556. specified time is later than the current X server time.  The
  1557. following describes the processing that occurs depending on
  1558. what constant you pass to the event_mode argument:
  1559.  
  1560. o    AsyncThisDevice
  1561.  
  1562.      If the specified device is frozen by the client, event
  1563.      processing for that continues as usual.  If the device
  1564.      is frozen multiple times by the client on behalf of
  1565.      multiple separate grabs, AsyncThisDevice thaws for all.
  1566.      AsyncThisDevice has no effect if the specified device
  1567.      is not frozen by the client, but the device need not be
  1568.      grabbed by the client.
  1569.  
  1570. o    SyncThisDevice
  1571.  
  1572.      If the specified device is frozen and actively grabbed
  1573.      by the client, event processing for that device contin-
  1574.      ues normally until the next key or button event is
  1575.      reported to the client.  At this time, the specified
  1576.      device again appears to freeze.  However, if the
  1577.      reported event causes the grab to be released, the
  1578.      specified device does not freeze.    SyncThisDevice has
  1579.  
  1580.  
  1581.  
  1582.                  21
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. X Input Extension Library            X11, Release 6.4
  1589.  
  1590.  
  1591.      no effect if the specified device is not frozen by the
  1592.      client or is not grabbed by the client.
  1593.  
  1594. o    ReplayThisDevice
  1595.  
  1596.      If the specified device is actively grabbed by the
  1597.      client and is frozen as the result of an event having
  1598.      been sent to the client (either from the activation of
  1599.      a GrabDeviceButton or from a previous AllowDeviceEvents
  1600.      with mode SyncThisDevice, but not from a Grab), the
  1601.      grab is released and that event is completely repro-
  1602.      cessed.  This time, however, the request ignores any
  1603.      passive grabs at or above (toward the root) the grab-
  1604.      window of the grab just released.    The request has no
  1605.      effect if the specified device is not grabbed by the
  1606.      client or if it is not frozen as the result of an
  1607.      event.
  1608.  
  1609. o    AsyncOtherDevices
  1610.  
  1611.      If the remaining devices are frozen by the client,
  1612.      event processing for them continues as usual.  If the
  1613.      other devices are frozen multiple times  by the client
  1614.      on behalf of multiple separate grabs, AsyncOtherDevices
  1615.      ``thaws'' for all.  AsyncOtherDevices has no effect if
  1616.      the devices are not frozen by the client, but those
  1617.      devices need not be grabbed by the client.
  1618.  
  1619. o    SyncAll
  1620.  
  1621.      If all devices are frozen by the client, event process-
  1622.      ing (for all devices) continues normally until the next
  1623.      button or key event is reported to the client for a
  1624.      grabbed device, at which time the devices again appear
  1625.      to freeze.  However, if the reported event causes the
  1626.      grab to be released, then the devices do not freeze
  1627.      (but if any device is still grabbed, then a subsequent
  1628.      event for it will still cause all devices to freeze).
  1629.      SyncAll has no effect unless all devices are frozen by
  1630.      the client.  If any device is frozen twice by the
  1631.      client on behalf of two separate grabs, SyncAll "thaws"
  1632.      for both (but a subsequent freeze for SyncAll will
  1633.      freeze each device only once).
  1634.  
  1635. o    AsyncAll
  1636.  
  1637.      If all devices are frozen by the client, event process-
  1638.      ing (for all devices) continues normally.    If any
  1639.      device is frozen multiple times by the client on behalf
  1640.      of multiple separate grabs, AsyncAll ``thaws ''for all.
  1641.      If any device is frozen twice by the client on behalf
  1642.      of two separate grabs, AsyncAll ``thaws'' for both.
  1643.      AsyncAll has no effect unless all devices are frozen by
  1644.      the client.
  1645.  
  1646.  
  1647.  
  1648.                  22
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. X Input Extension Library            X11, Release 6.4
  1655.  
  1656.  
  1657. AsyncThisDevice, SyncThisDevice, and ReplayThisDevice have
  1658. no effect on the processing of events from the remaining
  1659. devices.  AsyncOtherDevices has no effect on the processing
  1660. of events from the specified device.  When the event_mode is
  1661. SyncAll or AsyncAll, the device parameter is ignored.
  1662.  
  1663. It is possible for several grabs of different devices (by
  1664. the same or different clients) to be active simultaneously.
  1665. If a device is frozen on behalf of any grab, no event pro-
  1666. cessing is performed for the device.  It is possible for a
  1667. single device to be frozen because of several grabs.  In
  1668. this case, the freeze must be released on behalf of each
  1669. grab before events can again be processed.
  1670.  
  1671. XAllowDeviceEvents can generate BadDevice and BadValue
  1672. errors.
  1673.  
  1674. 2.1.7.    Controlling Device Focus
  1675.  
  1676. The current focus window for an extension input device can
  1677. be determined using the XGetDeviceFocus function.  Extension
  1678. devices are focused using the XSetDeviceFocus function in
  1679. the same way that the keyboard is focused using the core
  1680. XSetInputFocus function, except that a device ID is passed
  1681. as a function parameter.  One additional focus state,
  1682. FollowKeyboard, is provided for extension devices.
  1683.  
  1684. To get the current focus state, revert state, and focus time
  1685. of an extension device, use XGetDeviceFocus.
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.                  23
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. X Input Extension Library            X11, Release 6.4
  1721.  
  1722. __
  1723. |
  1724. int XGetDeviceFocus(display, device, focus_return, revert_to_return, focus_time_return)
  1725.      Display *display;
  1726.      XDevice *device;
  1727.      Window *focus_return;
  1728.      int *revert_to_return;
  1729.      Time *focus_time_return;
  1730.  
  1731.  
  1732. display   Specifies the connection to the X server.
  1733.  
  1734. device      Specifies the desired device.
  1735.  
  1736. focus_return
  1737.       Specifies the address of a variable into which the
  1738.       server can return the ID of the window that con-
  1739.       tains the device focus or one of the constants
  1740.       None, PointerRoot, or FollowKeyboard.
  1741.  
  1742. revert_to_return
  1743.       Specifies the address of a variable into which the
  1744.       server can return the current revert_to status for
  1745.       the device.
  1746.  
  1747. focus_time_return
  1748.       Specifies the address of a variable into which the
  1749.       server can return the focus time last set for the
  1750.       device.
  1751. |__
  1752.  
  1753. XGetDeviceFocus returns the focus state, the revert-to
  1754. state, and the last-focus-time for an extension input
  1755. device.
  1756.  
  1757. XGetDeviceFocus can generate BadDevice and BadMatch errors.
  1758.  
  1759.  
  1760. To set the focus of an extension device, use
  1761. XSetDeviceFocus.
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.                  24
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. X Input Extension Library            X11, Release 6.4
  1787.  
  1788. __
  1789. |
  1790. int XSetDeviceFocus(display, device, focus, revert_to, time)
  1791.     Display *display;
  1792.     XDevice *device;
  1793.     Window focus;
  1794.     int revert_to;
  1795.     Time time;
  1796.  
  1797.  
  1798. display   Specifies the connection to the X server.
  1799.  
  1800. device      Specifies the desired device.
  1801.  
  1802. focus      Specifies the ID of the window to which the
  1803.       device's focus should be set.  This may be a win-
  1804.       dow ID, or PointerRoot, FollowKeyboard, or None.
  1805.  
  1806. revert_to Specifies to which window the focus of the device
  1807.       should revert if the focus window becomes not
  1808.       viewable.  One of the following constants may be
  1809.       passed: RevertToParent, RevertToPointerRoot,
  1810.       RevertToNone, or RevertToFollowKeyboard.
  1811.  
  1812. time      Specifies the time.  You can pass either a times-
  1813.       tamp, expressed in milliseconds, or CurrentTime.
  1814. |__
  1815.  
  1816. XSetDeviceFocus changes the focus for an extension input
  1817. device and the last-focus-change-time.    It has no effect if
  1818. the specified time is earlier than the last-focus-change-
  1819. time or is later than the current X server time.  Otherwise,
  1820. the last-focus-change-time is set to the specified time.
  1821. This function causes the X server to generate DeviceFocusIn
  1822. and DeviceFocusOut events.
  1823.  
  1824. The action taken by the server when this function is
  1825. requested depends on the value of the focus argument:
  1826.  
  1827. o    If the focus argument is None, all input events from
  1828.      this device will be discarded until a new focus window
  1829.      is set.  In this case, the revert_to argument is
  1830.      ignored.
  1831.  
  1832. o    If the focus argument is a window ID, it becomes the
  1833.      focus window of the device.  If an input event from the
  1834.      device would normally be reported to this window or to
  1835.      one of its inferiors, the event is reported normally.
  1836.      Otherwise, the event is reported relative to the focus
  1837.      window.
  1838.  
  1839. o    If the focus argument is PointerRoot, the focus window
  1840.      is dynamically taken to be the root window of whatever
  1841.      screen the pointer is on at each input event.  In this
  1842.      case, the revert_to argument is ignored.
  1843.  
  1844.  
  1845.  
  1846.                  25
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. X Input Extension Library            X11, Release 6.4
  1853.  
  1854.  
  1855. o    If the focus argument is FollowKeyboard, the focus win-
  1856.      dow is dynamically taken to be the same as the focus of
  1857.      the X keyboard at each input event.
  1858.  
  1859. The specified focus window must be viewable at the time
  1860. XSetDeviceFocus is called.  Otherwise, it generates a Bad-
  1861. Match error.  If the focus window later becomes not view-
  1862. able, the X server evaluates the revert_to argument to
  1863. determine the new focus window.
  1864.  
  1865. o    If the revert_to argument is RevertToParent, the focus
  1866.      reverts to the parent (or the closest viewable ances-
  1867.      tor), and the new revert_to value is taken to be
  1868.      RevertToNone.
  1869.  
  1870. o    If the revert_to argument is RevertToPointerRoot,
  1871.      RevertToFollowKeyboard, or RevertToNone, the focus
  1872.      reverts to that value.
  1873.  
  1874. When the focus reverts, the X server generates DeviceFocusIn
  1875. and DeviceFocusOut events, but the last-focus-change time is
  1876. not affected.
  1877.  
  1878. XSetDeviceFocus can generate BadDevice, BadMatch, BadValue,
  1879. and BadWindow errors.
  1880.  
  1881. 2.1.8.    Controlling Device Feedback
  1882.  
  1883. To determine the current feedback settings of an extension
  1884. input device, use XGetFeedbackControl.
  1885. __
  1886. |
  1887. XFeedbackState * XGetFeedbackControl(display, device, num_feedbacks_return)
  1888.      Display *display;
  1889.      XDevice *device;
  1890.      int *num_feedbacks_return;
  1891.  
  1892.  
  1893. display   Specifies the connection to the X server.
  1894.  
  1895. device      Specifies the desired device.
  1896.  
  1897. num_feedbacks_return
  1898.       Returns the number of feedbacks supported by the
  1899.       device.
  1900. |__
  1901.  
  1902. XGetFeedbackControl returns a list of FeedbackState struc-
  1903. tures that describe the feedbacks supported by the specified
  1904. device.  There is an XFeedbackState structure for each class
  1905. of feedback.  These are of variable length, but the first
  1906. three members are common to all.
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.                  26
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918. X Input Extension Library            X11, Release 6.4
  1919.  
  1920. __
  1921. |
  1922. typedef struct {
  1923.      XID class;
  1924.      int length;
  1925.      XID id;
  1926. } XFeedbackState;
  1927.  
  1928. |__
  1929.  
  1930. The common members are as follows:
  1931.  
  1932. o    The class member identifies the class of feedback.  It
  1933.      may be compared to constants defined in the file
  1934.      <X11/extensions/XI.h>.  Currently defined feedback con-
  1935.      stants include: KbdFeedbackClass, PtrFeedbackClass,
  1936.      StringFeedbackClass, IntegerFeedbackClass,
  1937.      LedFeedbackClass, and BellFeedbackClass.
  1938.  
  1939. o    The length member specifies the length of the Feedback-
  1940.      State structure and can be used by clients to traverse
  1941.      the list.
  1942.  
  1943. o    The id member uniquely identifies a feedback for a
  1944.      given device and class.  This allows a device to sup-
  1945.      port more than one feedback of the same class.  Other
  1946.      feedbacks of other classes or devices may have the same
  1947.      ID.
  1948.  
  1949.  
  1950. Those feedbacks equivalent to those supported by the core
  1951. keyboard are reported in class KbdFeedback using the XKbd-
  1952. FeedbackState structure, which is defined as follows:
  1953.  
  1954. __
  1955. |
  1956. typedef struct {
  1957.      XID class;
  1958.      int length;
  1959.      XID id;
  1960.      int click;
  1961.      int percent;
  1962.      int pitch;
  1963.      int duration;
  1964.      int led_mask;
  1965.      int global_auto_repeat;
  1966.      char auto_repeats[32];
  1967. } XKbdFeedbackState;
  1968.  
  1969. |__
  1970.  
  1971. The additional members of the XKbdFeedbackState structure
  1972. report the current state of the feedback:
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.                  27
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. X Input Extension Library            X11, Release 6.4
  1985.  
  1986.  
  1987. o    The click member specifies the key-click volume and has
  1988.      a value in the range 0 (off) to 100 (loud).
  1989.  
  1990. o    The percent member specifies the bell volume and has a
  1991.      value in the range 0 (off) to 100 (loud).
  1992.  
  1993. o    The pitch member specifies the bell pitch in Hz. The
  1994.      range of the value is implementation-dependent.
  1995.  
  1996. o    The duration member specifies the duration in millisec-
  1997.      onds of the bell.
  1998.  
  1999. o    The led_mask member is a bit mask that describes the
  2000.      current state of up to 32 LEDs.  A value of 1 in a bit
  2001.      indicates that the corresponding LED is on.
  2002.  
  2003. o    The global_auto_repeat member has a value of AutoRe-
  2004.      peatModeOn or AutoRepeatModeOff.
  2005.  
  2006. o    The auto_repeats member is a bit vector.  Each bit set
  2007.      to 1 indicates that auto-repeat is enabled for the cor-
  2008.      responding key.  The vector is represented as 32 bytes.
  2009.      Byte N (from 0) contains the bits for keys 8N to 8N +
  2010.      7, with the least significant bit in the byte repre-
  2011.      senting key 8N.
  2012.  
  2013.  
  2014. Those feedbacks equivalent to those supported by the core
  2015. pointer are reported in class PtrFeedback using the XPtr-
  2016. FeedbackState structure, which is defined as follows:
  2017.  
  2018. __
  2019. |
  2020. typedef struct {
  2021.      XID class;
  2022.      int length;
  2023.      XID id;
  2024.      int accelNum;
  2025.      int accelDenom;
  2026.      int threshold;
  2027. } XPtrFeedbackState;
  2028.  
  2029. |__
  2030.  
  2031. The additional members of the XPtrFeedbackState structure
  2032. report the current state of the feedback:
  2033.  
  2034. o    The accelNum member returns the numerator for the
  2035.      acceleration multiplier.
  2036.  
  2037. o    The accelDenom member returns the denominator for the
  2038.      acceleration multiplier.
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.                  28
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050. X Input Extension Library            X11, Release 6.4
  2051.  
  2052.  
  2053. o    The accelDenom member returns the threshold for the
  2054.      acceleration.
  2055.  
  2056.  
  2057. Integer feedbacks are those capable of displaying integer
  2058. numbers and reported via the XIntegerFeedbackState struc-
  2059. ture.  The minimum and maximum values that they can display
  2060. are reported.
  2061.  
  2062. __
  2063. |
  2064. typedef struct {
  2065.      XID class;
  2066.      int length;
  2067.      XID id;
  2068.      int resolution;
  2069.      int minVal;
  2070.      int maxVal;
  2071. } XIntegerFeedbackState;
  2072.  
  2073. |__
  2074.  
  2075. The additional members of the XIntegerFeedbackState struc-
  2076. ture report the capabilities of the feedback:
  2077.  
  2078. o    The resolution member specifies the number of digits
  2079.      that the feedback can display.
  2080.  
  2081. o    The minVal member specifies the minimum value that the
  2082.      feedback can display.
  2083.  
  2084. o    The maxVal specifies the maximum value that the feed-
  2085.      back can display.
  2086.  
  2087.  
  2088. String feedbacks are those that can display character infor-
  2089. mation and are reported via the XStringFeedbackState struc-
  2090. ture.  Clients set these feedbacks by passing a list of
  2091. KeySyms to be displayed.  The XGetFeedbackControl function
  2092. returns the set of key symbols that the feedback can dis-
  2093. play, as well as the maximum number of symbols that can be
  2094. displayed.  The XStringFeedbackState structure is defined as
  2095. follows:
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.                  29
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. X Input Extension Library            X11, Release 6.4
  2117.  
  2118. __
  2119. |
  2120. typedef struct {
  2121.      XID class;
  2122.      int length;
  2123.      XID id;
  2124.      int max_symbols;
  2125.      int  num_syms_supported;
  2126.      KeySym *syms_supported;
  2127. } XStringFeedbackState;
  2128.  
  2129. |__
  2130.  
  2131. The additional members of the XStringFeedbackState structure
  2132. report the capabilities of the feedback:
  2133.  
  2134. o    The max_symbols member specifies the maximum number of
  2135.      symbols that can be displayed.
  2136.  
  2137. o    The syms_supported member is a pointer to the list of
  2138.      supported symbols.
  2139.  
  2140. o    The num_syms_supported member specifies the length of
  2141.      the list of supported symbols.
  2142.  
  2143.  
  2144. Bell feedbacks are those that can generate a sound and are
  2145. reported via the XBellFeedbackState structure.    Some imple-
  2146. mentations may support a bell as part of a KbdFeedback feed-
  2147. back.  Class BellFeedback is provided for implementations
  2148. that do not choose to do so and for devices that support
  2149. multiple feedbacks that can produce sound.  The meaning of
  2150. the members is the same as that of the corresponding fields
  2151. in the XKbdFeedbackState structure.
  2152.  
  2153. __
  2154. |
  2155. typedef struct {
  2156.      XID class;
  2157.      int length;
  2158.      XID id;
  2159.      int percent;
  2160.      int pitch;
  2161.      int duration;
  2162. } XBellFeedbackState;
  2163.  
  2164. |__
  2165.  
  2166. Led feedbacks are those that can generate a light and are
  2167. reported via the XLedFeedbackState structure.  Up to 32
  2168. lights per feedback are supported.  Each bit in led_mask
  2169. corresponds to one supported light, and the corresponding
  2170. bit in led_values indicates whether that light is currently
  2171. on (1) or off (0).  Some implementations may support leds as
  2172. part of a KbdFeedback feedback.  Class LedFeedback is
  2173.  
  2174.  
  2175.  
  2176.                  30
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182. X Input Extension Library            X11, Release 6.4
  2183.  
  2184.  
  2185. provided for implementations that do not choose to do so and
  2186. for devices that support multiple led feedbacks.
  2187.  
  2188. __
  2189. |
  2190. typedef struct {
  2191.      XID class;
  2192.      int length;
  2193.      XID id;
  2194.      Mask led_values;
  2195.      Mask led_mask;
  2196. } XLedFeedbackState;
  2197.  
  2198. |__
  2199.  
  2200. XGetFeedbackControl can generate BadDevice and BadMatch
  2201. errors.
  2202.  
  2203.  
  2204. To free the information returned by the XGetFeedbackControl
  2205. function, use XFreeFeedbackList.
  2206. __
  2207. |
  2208. void XFreeFeedbackList(list)
  2209.      XFeedbackState *list;
  2210.  
  2211.  
  2212. list      Specifies the pointer to the XFeedbackState struc-
  2213.       ture returned by a previous call to
  2214.       XGetFeedbackControl.
  2215. |__
  2216.  
  2217. XFreeFeedbackList frees the list of feedback control infor-
  2218. mation.
  2219.  
  2220.  
  2221. To change the settings of a feedback on an extension device,
  2222. use XChangeFeedbackControl.  This function modifies the cur-
  2223. rent control values of the specified feedback using informa-
  2224. tion passed in the appropriate XFeedbackControl structure
  2225. for the feedback.  Which values are modified depends on the
  2226. valuemask passed.
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.                  31
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248. X Input Extension Library            X11, Release 6.4
  2249.  
  2250. __
  2251. |
  2252. int XChangeFeedbackControl(display, device, valuemask, value)
  2253.      Display *display;
  2254.      XDevice *device;
  2255.      unsigned long valuemask;
  2256.      XFeedbackControl *value;
  2257.  
  2258.  
  2259. display   Specifies the connection to the X server.
  2260.  
  2261. device      Specifies the desired device.
  2262.  
  2263. valuemask Specifies one value for each bit in the mask
  2264.       (least to most significant bit).  The values are
  2265.       associated with the feedbacks for the specified
  2266.       device.
  2267.  
  2268. value      Specifies a pointer to the XFeedbackControl struc-
  2269.       ture.
  2270. |__
  2271.  
  2272. XChangeFeedbackControl controls the device characteristics
  2273. described by the XFeedbackControl structure.  There is an
  2274. XFeedbackControl structure for each class of feedback.
  2275. These are of variable length, but the first three members
  2276. are common to all and are as follows:
  2277.  
  2278. __
  2279. |
  2280. typedef struct {
  2281.      XID class;
  2282.      int length;
  2283.      XID id;
  2284. } XFeedbackControl;
  2285.  
  2286. |__
  2287.  
  2288. Feedback class KbdFeedback controls feedbacks equivalent to
  2289. those provided by the core keyboard using the KbdFeedback-
  2290. Control structure, which is defined as follows:.
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.                  32
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314. X Input Extension Library            X11, Release 6.4
  2315.  
  2316. __
  2317. |
  2318. typedef struct {
  2319.      XID class;
  2320.      int length;
  2321.      XID id;
  2322.      int click;
  2323.      int percent;
  2324.      int pitch;
  2325.      int duration;
  2326.      int led_mask;
  2327.      int led_value;
  2328.      int key;
  2329.      int auto_repeat_mode;
  2330. } XKbdFeedbackControl;
  2331.  
  2332. |__
  2333.  
  2334. This class controls the device characteristics described by
  2335. the XKbdFeedbackControl structure.  These include the
  2336. key_click_percent, global_auto_repeat, and individual key
  2337. auto-repeat.  Valid modes are AutoRepeatModeOn,
  2338. AutoRepeatModeOff, and AutoRepeatModeDefault.
  2339.  
  2340. Valid masks are as follows:
  2341. __
  2342. |
  2343.  
  2344. #define   DvKeyClickPercent          (1L <<
  2345.                       0)
  2346. #define   DvPercent              (1L <<
  2347.                       1)
  2348. #define   DvPitch              (1L <<
  2349.                       2)
  2350. #define   DvDuration              (1L <<
  2351.                       3)
  2352. #define   DvLed               (1L <<
  2353.                       4)
  2354. #define   DvLedMode              (1L <<
  2355.                       5)
  2356. #define   DvKey               (1L <<
  2357.                       6)
  2358. #define   DvAutoRepeatMode          (1L <<
  2359.                       7)
  2360. |__
  2361.  
  2362.  
  2363. Feedback class PtrFeedback controls feedbacks equivalent to
  2364. those provided by the core pointer using the PtrFeedbackCon-
  2365. trol structure, which is defined as follows:
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.                  33
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380. X Input Extension Library            X11, Release 6.4
  2381.  
  2382. __
  2383. |
  2384. typedef struct {
  2385.      XID class;
  2386.      int length;
  2387.      XID id;
  2388.      int accelNum;
  2389.      int accelDenom;
  2390.      int threshold;
  2391. } XPtrFeedbackControl;
  2392.  
  2393. |__
  2394.  
  2395. Which values are modified depends on the valuemask passed.
  2396.  
  2397. Valid masks are as follows:
  2398. __
  2399. |
  2400.  
  2401. #define   DvAccelnum              (1L <<
  2402.                       0)
  2403. #define   DvAccelDenom              (1L <<
  2404.                       1)
  2405. #define   DvThreshold              (1L <<
  2406.                       2)
  2407.  
  2408. |__
  2409.  
  2410. The acceleration, expressed as a fraction, is a multiplier
  2411. for movement.  For example, specifying 3/1 means that the
  2412. device moves three times as fast as normal.  The fraction
  2413. may be rounded arbitrarily by the X server.  Acceleration
  2414. takes effect only if the device moves more than threshold
  2415. pixels at once and applies only to the amount beyond the
  2416. value in the threshold argument.  Setting a value to -1
  2417. restores the default.  The values of the accelNumerator and
  2418. threshold fields must be nonzero for the pointer values to
  2419. be set.  Otherwise, the parameters will be unchanged.  Nega-
  2420. tive values generate a BadValue error, as does a zero value
  2421. for the accelDenominator field.
  2422.  
  2423. This request fails with a BadMatch error if the specified
  2424. device is not currently reporting relative motion.  If a
  2425. device that is capable of reporting both relative and abso-
  2426. lute motion has its mode changed from Relative to Absolute
  2427. by an XSetDeviceMode request, valuator control values will
  2428. be ignored by the server while the device is in that mode.
  2429.  
  2430. Feedback class IntegerFeedback controls integer feedbacks
  2431. displayed on input devices and are reported via the Inte-
  2432. gerFeedbackControl structure, which is defined as follows:
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.                  34
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446. X Input Extension Library            X11, Release 6.4
  2447.  
  2448. __
  2449. |
  2450. typedef struct {
  2451.      XID class;
  2452.      int length;
  2453.      XID id;
  2454.      int int_to_display;
  2455. } XIntegerFeedbackControl;
  2456.  
  2457. |__
  2458.  
  2459. Valid masks are as follows:
  2460. __
  2461. |
  2462.  
  2463. #define   DvInteger              (1L <<
  2464.                       0)
  2465.  
  2466. |__
  2467.  
  2468. Feedback class StringFeedback controls string feedbacks dis-
  2469. played on input devices and reported via the StringFeedback-
  2470. Control structure, which is defined as follows:
  2471.  
  2472. __
  2473. |
  2474. typedef struct {
  2475.      XID class;
  2476.      int length;
  2477.      XID id;
  2478.      int num_keysyms;
  2479.      KeySym *syms_to_display;
  2480. } XStringFeedbackControl;
  2481.  
  2482. |__
  2483.  
  2484. Valid masks are as follows:
  2485. __
  2486. |
  2487.  
  2488. #define   DvString              (1L <<
  2489.                       0)
  2490.  
  2491. |__
  2492.  
  2493. Feedback class BellFeedback controls a bell on an input
  2494. device and is reported via the BellFeedbackControl struc-
  2495. ture, which is defined as follows:
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.                  35
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512. X Input Extension Library            X11, Release 6.4
  2513.  
  2514. __
  2515. |
  2516. typedef struct {
  2517.      XID class;
  2518.      int length;
  2519.      XID id;
  2520.      int percent;
  2521.      int pitch;
  2522.      int duration;
  2523. } XBellFeedbackControl;
  2524.  
  2525. |__
  2526.  
  2527. Valid masks are as follows:
  2528. __
  2529. |
  2530.  
  2531. #define   DvPercent              (1L <<
  2532.                       1)
  2533. #define   DvPitch              (1L <<
  2534.                       2)
  2535. #define   DvDuration              (1L <<
  2536.                       3)
  2537.  
  2538. |__
  2539.  
  2540. Feedback class LedFeedback controls lights on an input
  2541. device and are reported via the LedFeedbackControl struc-
  2542. ture, which is defined as follows:
  2543.  
  2544. __
  2545. |
  2546. typedef struct {
  2547.      XID class;
  2548.      int length;
  2549.      XID id;
  2550.      int led_mask;
  2551.      int led_values;
  2552. } XLedFeedbackControl;
  2553.  
  2554. |__
  2555.  
  2556. Valid masks are as follows:
  2557. __
  2558. |
  2559.  
  2560. #define   DvLed               (1L <<
  2561.                       4)
  2562. #define   DvLedMode              (1L <<
  2563.                       5)
  2564.  
  2565. |__
  2566.  
  2567. XChangeFeedbackControl can generate BadDevice, BadFeedBack,
  2568. BadMatch, and BadValue errors.
  2569.  
  2570.  
  2571.  
  2572.                  36
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578. X Input Extension Library            X11, Release 6.4
  2579.  
  2580.  
  2581. 2.1.9.    Ringing a Bell on an Input Device
  2582.  
  2583. To ring a bell on an extension input device, use
  2584. XDeviceBell.
  2585. __
  2586. |
  2587. int XDeviceBell(display, device, feedbackclass, feedbackid, percent)
  2588.      Display *display;
  2589.      XDevice *device;
  2590.      XID feedbackclass, feedbackid;
  2591.      int percent;
  2592.  
  2593.  
  2594. display   Specifies the connection to the X server.
  2595.  
  2596. device      Specifies the desired device.
  2597.  
  2598. feedbackclass
  2599.       Specifies the feedbackclass.    Valid values are
  2600.       KbdFeedbackClass and BellFeedbackClass.
  2601.  
  2602. feedbackid
  2603.       Specifies the ID of the feedback that has the
  2604.       bell.
  2605.  
  2606. percent   Specifies the volume in the range -100 (quiet) to
  2607.       100 percent (loud).
  2608. |__
  2609.  
  2610. XDeviceBell is analogous to the core XBell function.  It
  2611. rings the specified bell on the specified input device feed-
  2612. back, using the specified volume.  The specified volume is
  2613. relative to the base volume for the feedback.  If the value
  2614. for the percent argument is not in the range -100 to 100
  2615. inclusive, a BadValue error results.  The volume at which
  2616. the bell rings when the percent argument is nonnegative is:
  2617.  
  2618.  
  2619.         base - [(base * percent) / 100] + percent
  2620.  
  2621.  
  2622. The volume at which the bell rings when the percent argument
  2623. is negative is:
  2624.  
  2625.  
  2626.         base + [(base * percent) / 100]
  2627.  
  2628.  
  2629. To change the base volume of the bell, use
  2630. XChangeFeedbackControl.
  2631.  
  2632. XDeviceBell can generate BadDevice and BadValue errors.
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.                  37
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. X Input Extension Library            X11, Release 6.4
  2645.  
  2646.  
  2647. 2.1.10.  Controlling Device Encoding
  2648.  
  2649. To get the key mapping of an extension device that supports
  2650. input class Keys, use XGetDeviceKeyMapping.
  2651. __
  2652. |
  2653. KeySym * XGetDeviceKeyMapping(display, device, first_keycode_wanted, keycode_count,
  2654.              keysyms_per_keycode_return)
  2655.       Display *display;
  2656.       XDevice *device;
  2657.       KeyCode first_keycode_wanted;
  2658.       int keycode_count;
  2659.       int *keysyms_per_keycode_return;
  2660.  
  2661.  
  2662. display   Specifies the connection to the X server.
  2663.  
  2664. device      Specifies the desired device.
  2665.  
  2666. first_keycode_wanted
  2667.       Specifies the first keycode that is to be
  2668.       returned.
  2669.  
  2670. keycode_count
  2671.       Specifies the number of keycodes that are to be
  2672.       returned.
  2673.  
  2674. keysyms_per_keycode_return
  2675.       Returns the number of keysyms per keycode.
  2676. |__
  2677.  
  2678. XGetDeviceKeyMapping is analogous to the core XGetKey-
  2679. boardMapping function.    It returns the symbols for the spec-
  2680. ified number of keycodes for the specified extension device.
  2681.  
  2682. XGetDeviceKeyMapping returns the symbols for the specified
  2683. number of keycodes for the specified extension device,
  2684. starting with the specified keycode.  The first_key-
  2685. code_wanted must be greater than or equal to min-keycode as
  2686. returned by the XListInputDevices request (else a BadValue
  2687. error results). The following value:
  2688.  
  2689.      first_keycode_wanted + keycode_count - 1
  2690.  
  2691.  
  2692. must be less than or equal to max-keycode as returned by the
  2693. XListInputDevices request (else a BadValue error results).
  2694.  
  2695. The number of elements in the keysyms list is as follows:
  2696.  
  2697.      keycode_count * keysyms_per_keycode_return
  2698.  
  2699. And KEYSYM number N (counting from zero) for keycode K has
  2700. an index (counting from zero), in keysyms, of the following:
  2701.  
  2702.  
  2703.  
  2704.                  38
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710. X Input Extension Library            X11, Release 6.4
  2711.  
  2712.  
  2713.      (K - first_keycode_wanted) * keysyms_per_keycode_return + N
  2714.  
  2715.  
  2716. The keysyms_per_keycode_return value is chosen arbitrarily
  2717. by the server to be large enough to report all requested
  2718. symbols.  A special KEYSYM value of NoSymbol is used to fill
  2719. in unused elements for individual keycodes.
  2720.  
  2721. To free the data returned by this function, use XFree.
  2722.  
  2723. If the specified device has not first been opened by this
  2724. client via XOpenDevice, this request will fail with a BadDe-
  2725. vice error.  If that device does not support input class
  2726. Keys, this request will fail with a BadMatch error.
  2727.  
  2728. XGetDeviceKeyMapping can generate BadDevice, BadMatch, and
  2729. BadValue errors.
  2730.  
  2731.  
  2732. To change the keyboard mapping of an extension device that
  2733. supports input class Keys, use XChangeDeviceKeyMapping.
  2734. __
  2735. |
  2736. int
  2737. XChangeDeviceKeyMapping(display, device, first_keycode, keysyms_per_keycode, keysyms,
  2738.              num_codes)
  2739.      Display *display;
  2740.      XDevice *device;
  2741.      int first_keycode;
  2742.      int keysyms_per_keycode;
  2743.      KeySym *keysyms;
  2744.      int num_codes;
  2745.  
  2746.  
  2747. display   Specifies the connection to the X server.
  2748.  
  2749. device      Specifies the desired device.
  2750.  
  2751. first_keycode
  2752.       Specifies the first keycode that is to be changed.
  2753.  
  2754. keysyms_per_keycode
  2755.       Specifies the keysyms that are to be used.
  2756.  
  2757. keysyms   Specifies a pointer to an array of keysyms.
  2758.  
  2759. num_codes Specifies the number of keycodes that are to be
  2760.       changed.
  2761. |__
  2762.  
  2763. XChangeDeviceKeyMapping is analogous to the core XChangeKey-
  2764. boardMapping function.    It defines the symbols for the spec-
  2765. ified number of keycodes for the specified extension key-
  2766. board device.
  2767.  
  2768.  
  2769.  
  2770.                  39
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776. X Input Extension Library            X11, Release 6.4
  2777.  
  2778.  
  2779. If the specified device has not first been opened by this
  2780. client via XOpenDevice, this request will fail with a BadDe-
  2781. vice error.  If the specified device does not support input
  2782. class Keys, this request will fail with a BadMatch error.
  2783.  
  2784. The number of elements in the keysyms list must be a multi-
  2785. ple of keysyms_per_keycode.  Otherwise, XChangeDeviceKeyMap-
  2786. ping generates a BadLength error.  The specified first_key-
  2787. code must be greater than or equal to the min_keycode value
  2788. returned by the ListInputDevices request, or this request
  2789. will fail with a BadValue error.  In addition, if the fol-
  2790. lowing expression is not less than the max_keycode value
  2791. returned by the ListInputDevices request, the request will
  2792. fail with a BadValue error:
  2793.  
  2794.         first_keycode + (num_codes / keysyms_per_keycode) - 1
  2795.  
  2796.  
  2797. XChangeDeviceKeyMapping can generate BadAlloc, BadDevice,
  2798. BadMatch, and BadValue errors.
  2799.  
  2800.  
  2801. To obtain the keycodes that are used as modifiers on an
  2802. extension device that supports input class Keys, use
  2803. XGetDeviceModifierMapping.
  2804. __
  2805. |
  2806. XModifierKeymap * XGetDeviceModifierMapping(display, device)
  2807.      Display *display;
  2808.      XDevice *device;
  2809.  
  2810.  
  2811. display   Specifies the connection to the X server.
  2812.  
  2813. device      Specifies the desired device.
  2814. |__
  2815.  
  2816. XGetDeviceModifierMapping is analogous to the core XGetModi-
  2817. fierMapping function.  The XGetDeviceModifierMapping func-
  2818. tion returns a newly created XModifierKeymap structure that
  2819. contains the keys being used as modifiers for the specified
  2820. device.  The structure should be freed after use with
  2821. XFreeModifierMapping.  If only zero values appear in the set
  2822. for any modifier, that modifier is disabled.
  2823.  
  2824. XGetDeviceModifierMapping can generate BadDevice and Bad-
  2825. Match errors.
  2826.  
  2827.  
  2828. To set which keycodes are to be used as modifiers for an
  2829. extension device, use XSetDeviceModifierMapping.
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836.                  40
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842. X Input Extension Library            X11, Release 6.4
  2843.  
  2844. __
  2845. |
  2846. int XSetDeviceModifierMapping(display, device, modmap)
  2847.      Display *display;
  2848.      XDevice *device;
  2849.      XModifierKeymap *modmap;
  2850.  
  2851.  
  2852. display   Specifies the connection to the X server.
  2853.  
  2854. device      Specifies the desired device.
  2855.  
  2856. modmap      Specifies a pointer to the XModifierKeymap struc-
  2857.       ture.
  2858. |__
  2859.  
  2860. XSetDeviceModifierMapping is analogous to the core XSetModi-
  2861. fierMapping function.  The XSetDeviceModifierMapping func-
  2862. tion specifies the keycodes of the keys, if any, that are to
  2863. be used as modifiers.  A zero value means that no key should
  2864. be used.  No two arguments can have the same nonzero keycode
  2865. value.    Otherwise, XSetDeviceModifierMapping generates a
  2866. BadValue error.  There are eight modifiers, and the modi-
  2867. fiermap member of the XModifierKeymap structure contains
  2868. eight sets of max_keypermod keycodes, one for each modifier
  2869. in the order Shift, Lock, Control, Mod1, Mod2, Mod3, Mod4,
  2870. and Mod5.  Only nonzero keycodes have meaning in each set,
  2871. and zero keycodes are ignored.    In addition, all of the
  2872. nonzero keycodes must be in the range specified by min_key-
  2873. code and max_keycode reported by the XListInputDevices func-
  2874. tion.  Otherwise, XSetModifierMapping generates a BadValue
  2875. error.    No keycode may appear twice in the entire map.    Oth-
  2876. erwise, it generates a BadValue error.
  2877.  
  2878. A X server can impose restrictions on how modifiers can be
  2879. changed, for example, if certain keys do not generate up
  2880. transitions in hardware or if multiple modifier keys are not
  2881. supported.  If some such restriction is violated, the status
  2882. reply is MappingFailed, and none of the modifiers are
  2883. changed.  If the new keycodes specified for a modifier dif-
  2884. fer from those currently defined and any (current or new)
  2885. keys for that modifier are in the logically down state, the
  2886. status reply is MappingBusy, and none of the modifiers are
  2887. changed.  XSetModifierMapping generates a DeviceMappingNo-
  2888. tify event on a MappingSuccess status.
  2889.  
  2890. XSetDeviceModifierMapping can generate BadAlloc, BadDevice,
  2891. BadMatch, and BadValue errors.
  2892.  
  2893. 2.1.11.  Controlling Button Mapping
  2894.  
  2895. To set the mapping of the buttons on an extension device,
  2896. use XSetDeviceButtonMapping.
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.                  41
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908. X Input Extension Library            X11, Release 6.4
  2909.  
  2910. __
  2911. |
  2912. int XSetDeviceButtonMapping(display, device, map, nmap)
  2913.      Display *display;
  2914.      XDevice *device;
  2915.      unsigned char map[];
  2916.      int nmap;
  2917.  
  2918.  
  2919. display   Specifies the connection to the X server.
  2920.  
  2921. device      Specifies the desired device.
  2922.  
  2923. map      Specifies the mapping list.
  2924.  
  2925. nmap      Specifies the number of items in the mapping list.
  2926. |__
  2927.  
  2928. XSetDeviceButtonMapping sets the mapping of the buttons on
  2929. an extension device.  If it succeeds, the X server generates
  2930. a DeviceMappingNotify event, and XSetDeviceButtonMapping
  2931. returns MappingSuccess.  Elements of the list are indexed
  2932. starting from one.  The length of the list must be the same
  2933. as XGetDeviceButtonMapping would return, or a BadValue error
  2934. results.  The index is a button number, and the element of
  2935. the list defines the effective number.    A zero element dis-
  2936. ables a button, and elements are not restricted in value by
  2937. the number of physical buttons.  However, no two elements
  2938. can have the same nonzero value, or a BadValue error
  2939. results.  If any of the buttons to be altered are logically
  2940. in the down state, XSetDeviceButtonMapping returns
  2941. MappingBusy, and the mapping is not changed.
  2942.  
  2943. XSetDeviceButtonMapping can generate BadDevice, BadMatch,
  2944. and BadValue errors.
  2945.  
  2946.  
  2947. To get the button mapping, use XGetDeviceButtonMapping.
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.                  42
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974. X Input Extension Library            X11, Release 6.4
  2975.  
  2976. __
  2977. |
  2978. int XGetDeviceButtonMapping(display, device, map_return, nmap)
  2979.      Display *display;
  2980.      XDevice *device;
  2981.      unsigned char map_return[];
  2982.      int nmap;
  2983.  
  2984.  
  2985. display   Specifies the connection to the X server.
  2986.  
  2987. device      Specifies the desired device.
  2988.  
  2989. map_return
  2990.       Specifies the mapping list.
  2991.  
  2992. nmap      Specifies the number of items in the mapping list.
  2993. |__
  2994.  
  2995. XGetDeviceButtonMapping returns the current mapping of the
  2996. specified extension device.  Elements of the list are
  2997. indexed starting from one.  XGetDeviceButtonMapping returns
  2998. the number of physical buttons actually on the pointer.  The
  2999. nominal mapping for the buttons is the identity mapping:
  3000. map[i]=i.  The nmap argument specifies the length of the
  3001. array where the button mapping is returned, and only the
  3002. first nmap elements are returned in map_return.
  3003.  
  3004. XGetDeviceButtonMapping can generate BadDevice and BadMatch
  3005. errors.
  3006.  
  3007. 2.1.12.  Obtaining the State of a Device
  3008.  
  3009. To obtain information that describes the state of the keys,
  3010. buttons, and valuators of an extension device, use
  3011. XQueryDeviceState.
  3012. __
  3013. |
  3014. XDeviceState * XQueryDeviceState(display, device)
  3015.      Display *display;
  3016.      XDevice *device;
  3017.  
  3018.  
  3019. display   Specifies the connection to the X server.
  3020.  
  3021. device      Specifies the desired device.
  3022. |__
  3023.  
  3024. XQueryDeviceState returns a pointer to an XDeviceState
  3025. structure, which points to a list of structures that
  3026. describe the state of the keys, buttons, and valuators on
  3027. the device:
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034.                  43
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040. X Input Extension Library            X11, Release 6.4
  3041.  
  3042. __
  3043. |
  3044. typedef struct {
  3045.      XID device_id;
  3046.      int num_classes;
  3047.      XInputClass *data;
  3048. } XDeviceState;
  3049.  
  3050. |__
  3051.  
  3052. The structures are of variable length, but the first two
  3053. members are common to all and are as follows:
  3054.  
  3055. __
  3056. |
  3057. typedef struct {
  3058.      unsigned char class;
  3059.      unsigned char length;
  3060. } XInputClass;
  3061.  
  3062. |__
  3063.  
  3064. The class member contains a class identifier.  This identi-
  3065. fier can be compared with constants defined in the file
  3066. <X11/extensions/XI.h>.    Currently defined constants are:
  3067. KeyClass, ButtonClass, and ValuatorClass.
  3068.  
  3069. The length member contains the length of the structure and
  3070. can be used by clients to traverse the list.
  3071.  
  3072. The XValuatorState structure describes the current state of
  3073. the valuators on the device.  The num_valuators member con-
  3074. tains the number of valuators on the device.  The mode mem-
  3075. ber is a mask whose bits report the data mode and other
  3076. state information for the device.  The following bits are
  3077. currently defined:
  3078.  
  3079.      DeviceMode      1 << 0Relative = 0, Absolute = 1
  3080.      ProximityState     1 << 1InProximity = 0, OutOfProximity = 1
  3081.  
  3082. The valuators member contains a pointer to an array of inte-
  3083. gers that describe the current value of the valuators.    If
  3084. the mode is Relative, these values are undefined.
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.                  44
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106. X Input Extension Library            X11, Release 6.4
  3107.  
  3108. __
  3109. |
  3110. typedef struct {
  3111.      unsigned char class;
  3112.      unsigned char length;
  3113.      unsigned char num_valuators;
  3114.      unsigned char mode;
  3115.      int *valuators;
  3116. } XValuatorState;
  3117.  
  3118. |__
  3119.  
  3120. The XKeyState structure describes the current state of the
  3121. keys on the device.  Byte N (from 0) contains the bits for
  3122. key 8N to 8N + 7 with the least significant bit in the byte
  3123. representing key 8N.
  3124.  
  3125. __
  3126. |
  3127. typedef struct {
  3128.      unsigned char class;
  3129.      unsigned char length;
  3130.      short num_keys;
  3131.      char keys[32];
  3132. } XKeyState;
  3133.  
  3134. |__
  3135.  
  3136. The XButtonState structure describes the current state of
  3137. the buttons on the device.  Byte N (from 0) contains the
  3138. bits for button 8N to 8N + 7 with the least significant bit
  3139. in the byte representing button 8N.
  3140.  
  3141. __
  3142. |
  3143. typedef struct {
  3144.      unsigned char class;
  3145.      unsigned char length;
  3146.      short num_buttons;
  3147.      char buttons[32];
  3148. } XButtonState;
  3149.  
  3150. |__
  3151.  
  3152. XQueryDeviceState can generate BadDevice errors.
  3153.  
  3154.  
  3155. To free the data returned by this function, use
  3156. XFreeDeviceState.
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.                  45
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172. X Input Extension Library            X11, Release 6.4
  3173.  
  3174. __
  3175. |
  3176. void XFreeDeviceState(state)
  3177.      XDeviceState *state;
  3178.  
  3179.  
  3180. state      Specifies the pointer to the XDeviceState data
  3181.       returned by a previous call to XQueryDeviceState.
  3182. |__
  3183.  
  3184. XFreeDeviceState frees the device state data.
  3185.  
  3186. 2.2.  Events
  3187.  
  3188. The input extension creates input events analogous to the
  3189. core input events.  These extension input events are gener-
  3190. ated by manipulating one of the extension input devices.
  3191. The remainder of this section discusses the following X
  3192. Input Extension event topics:
  3193.  
  3194. o    Event types
  3195.  
  3196. o    Event classes
  3197.  
  3198. o    Event structures
  3199.  
  3200. 2.2.1.    Event Types
  3201.  
  3202. Event types are integer numbers that a client can use to
  3203. determine what kind of event it has received.  The client
  3204. compares the type field of the event structure with known
  3205. event types to make this determination.
  3206.  
  3207. The core input event types are constants and are defined in
  3208. the header file <X11/X.h>.  Extension event types are not
  3209. constants.  Instead, they are dynamically allocated by the
  3210. extension's request to the X server when the extension is
  3211. initialized.  Because of this, extension event types must be
  3212. obtained by the client from the server.
  3213.  
  3214. The client program determines the event type for an exten-
  3215. sion event by using the information returned by the XOpenDe-
  3216. vice request.  This type can then be used for comparison
  3217. with the type field of events received by the client.
  3218.  
  3219. Extension events propagate up the window hierarchy in the
  3220. same manner as core events.  If a window is not interested
  3221. in an extension event, it usually propagates to the closest
  3222. ancestor that is interested, unless the dont_propagate list
  3223. prohibits it.  Grabs of extension devices may alter the set
  3224. of windows that receive a particular extension event.
  3225.  
  3226. The following table lists the event category and its associ-
  3227. ated event type or types.
  3228.  
  3229.  
  3230.  
  3231.  
  3232.                  46
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238. X Input Extension Library            X11, Release 6.4
  3239.  
  3240.  
  3241. ------------------------------------------------------
  3242. Event Category            Event Type
  3243. ------------------------------------------------------
  3244. Device key            DeviceKeyPress
  3245.                 DeviceKeyRelease
  3246. Device motion            DeviceButtonPress
  3247.                 DeviceButtonRelease
  3248.                 DeviceMotionNotify
  3249. Device input focus        DeviceFocusIn
  3250.                 DeviceFocusOut
  3251. Device state notification   DeviceStateNotify
  3252. Device proximity        ProximityIn
  3253.                 ProximityOut
  3254. Device mapping            DeviceMappingNotify
  3255. Device change            ChangeDeviceNotify
  3256. ------------------------------------------------------
  3257.  
  3258.  
  3259. 2.2.2.    Event Classes
  3260.  
  3261. Event classes are integer numbers that are used in the same
  3262. way as the core event masks.  They are used by a client pro-
  3263. gram to indicate to the server which events that client pro-
  3264. gram wishes to receive.
  3265.  
  3266. The core input event masks are constants and are defined in
  3267. the header file <X11/X.h>.  Extension event classes are not
  3268. constants.  Instead, they are dynamically allocated by the
  3269. extension's request to the X server when the extension is
  3270. initialized.  Because of this, extension event classes must
  3271. be obtained by the client from the server.
  3272.  
  3273. The event class for an extension event and device is
  3274. obtained from information returned by the XOpenDevice func-
  3275. tion.  This class can then be used in an XSelectExtension-
  3276. Event request to ask that events of that type from that
  3277. device be sent to the client program.
  3278.  
  3279. For DeviceButtonPress events, the client may specify whether
  3280. or not an implicit passive grab should be done when the but-
  3281. ton is pressed.  If the client wants to guarantee that it
  3282. will receive a DeviceButtonRelease event for each DeviceBut-
  3283. tonPress event it receives, it should specify the DeviceBut-
  3284. tonPressGrab class in addition to the DeviceButtonPress
  3285. class.    This restricts the client in that only one client at
  3286. a time may request DeviceButtonPress events from the same
  3287. device and window if any client specifies this class.
  3288.  
  3289. If any client has specified the DeviceButtonPressGrab class,
  3290. any requests by any other client that specify the same
  3291. device and window and specify either DeviceButtonPress or
  3292. DeviceButtonPressGrab will cause an Access error to be gen-
  3293. erated.
  3294.  
  3295.  
  3296.  
  3297.  
  3298.                  47
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304. X Input Extension Library            X11, Release 6.4
  3305.  
  3306.  
  3307. If only the DeviceButtonPress class is specified, no
  3308. implicit passive grab will be done when a button is pressed
  3309. on the device.    Multiple clients may use this class to spec-
  3310. ify the same device and window combination.
  3311.  
  3312. The client may also select DeviceMotion events only when a
  3313. button is down.  It does this by specifying the event
  3314. classes DeviceButton1Motion through DeviceButton5Motion.  An
  3315. input device will support only as many button motion classes
  3316. as it has buttons.
  3317.  
  3318. 2.2.3.    Event Structures
  3319.  
  3320. Each extension event type has a corresponding structure
  3321. declared in <X11/extensions/XInput.h>.    All event structures
  3322. have the following common members:
  3323.  
  3324. type      Set to the event type number that uniquely identi-
  3325.       fies it.  For example, when the X server reports a
  3326.       DeviceKeyPress event to a client application, it
  3327.       sends an XDeviceKeyPressEvent structure.
  3328.  
  3329. serial      Set from the serial number reported in the proto-
  3330.       col but expanded from the 16-bit least significant
  3331.       bits to a full 32-bit value.
  3332.  
  3333. send_event
  3334.       Set to True if the event came from an XSendEvent
  3335.       request.
  3336.  
  3337. display   Set to a pointer to a structure that defines the
  3338.       display on which the event was read.
  3339.  
  3340. Extension event structures report the current position of
  3341. the X pointer.    In addition, if the device reports motion
  3342. data and is reporting absolute data, the current value of
  3343. any valuators the device contains is also reported.
  3344.  
  3345. 2.2.3.1.  Device Key Events
  3346.  
  3347. Key events from extension devices contain all the informa-
  3348. tion that is contained in a key event from the X keyboard.
  3349. In addition, they contain a device ID and report the current
  3350. value of any valuators on the device, if that device is
  3351. reporting absolute data.  If data for more than six valua-
  3352. tors is being reported, more than one key event will be
  3353. sent.  The axes_count member contains the number of axes
  3354. that are being reported.  The server sends as many of these
  3355. events as are needed to report the device data.  Each event
  3356. contains the total number of axes reported in the axes_count
  3357. member and the first axis reported in the current event in
  3358. the first_axis member.    If the device supports input class
  3359. Valuators, but is not reporting absolute mode data, the
  3360. axes_count member  contains zero (0).
  3361.  
  3362.  
  3363.  
  3364.                  48
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370. X Input Extension Library            X11, Release 6.4
  3371.  
  3372.  
  3373. The location reported in the x, y and x_root, y_root members
  3374. is the location of the core X pointer.
  3375.  
  3376. The XDeviceKeyEvent structure is defined as follows:
  3377.  
  3378. __
  3379. |
  3380. typedef struct {
  3381.      int type;              /* of event */
  3382.      unsigned long serial;    /* # of last request processed */
  3383.      Bool send_event;          /* true if from SendEvent request */
  3384.      Display *display;          /* Display the event was read from */
  3385.      Window window;          /* "event" window reported relative to */
  3386.      XID deviceid;
  3387.      Window root;          /* root window event occurred on */
  3388.      Window subwindow;          /* child window */
  3389.      Time time;           /* milliseconds */
  3390.      int x, y;              /* x, y coordinates in event window */
  3391.      int x_root;          /* coordinates relative to root */
  3392.      int y_root;          /* coordinates relative to root */
  3393.      unsigned int state;      /* key or button mask */
  3394.      unsigned int keycode;    /* detail */
  3395.      Bool same_screen;          /* same screen flag */
  3396.      unsigned int device_state;/* device key or button mask */
  3397.      unsigned char axes_count;
  3398.      unsigned char first_axis;
  3399.      int axis_data[6];
  3400. } XDeviceKeyEvent;
  3401.  
  3402. typedef XDeviceKeyEvent XDeviceKeyPressedEvent;
  3403. typedef XDeviceKeyEvent XDeviceKeyReleasedEvent;
  3404. |__
  3405.  
  3406.  
  3407. 2.2.3.2.  Device Button Events
  3408.  
  3409. Button events from extension devices contain all the infor-
  3410. mation that is contained in a button event from the X
  3411. pointer.  In addition, they contain a device ID and report
  3412. the current value of any valuators on the device if that
  3413. device is reporting absolute data.  If data for more than
  3414. six valuators is being reported, more than one button event
  3415. may be sent.  The axes_count member contains the number of
  3416. axes that are being reported.  The server sends as many of
  3417. these events as are needed to report the device data.  Each
  3418. event contains the total number of axes reported in the
  3419. axes_count member and the first axis reported in the current
  3420. event in the first_axis member.  If the device supports
  3421. input class Valuators, but is not reporting absolute mode
  3422. data, the axes_count member contains zero (0).
  3423.  
  3424. The location reported in the x, y and x_root, y_root members
  3425. is the location of the core X pointer.
  3426.  
  3427.  
  3428.  
  3429.  
  3430.                  49
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436. X Input Extension Library            X11, Release 6.4
  3437.  
  3438. __
  3439. |
  3440. typedef struct {
  3441.      int type;              /* of event */
  3442.      unsigned long serial;    /* # of last request processed by server */
  3443.      Bool send_event;          /* true if from a SendEvent request */
  3444.      Display *display;          /* Display the event was read from */
  3445.      Window window;          /* "event" window reported relative to */
  3446.      XID deviceid;
  3447.      Window root;          /* root window that the event occurred on */
  3448.      Window subwindow;          /* child window */
  3449.      Time time;           /* milliseconds */
  3450.      int x, y;              /* x, y coordinates in event window */
  3451.      int x_root;          /* coordinates relative to root */
  3452.      int y_root;          /* coordinates relative to root */
  3453.      unsigned int state;      /* key or button mask */
  3454.      unsigned int button;     /* detail */
  3455.      Bool same_screen;          /* same screen flag */
  3456.      unsigned int device_state;/* device key or button mask */
  3457.      unsigned char axes_count;
  3458.      unsigned char first_axis;
  3459.      int axis_data[6];
  3460. } XDeviceButtonEvent;
  3461.  
  3462. typedef XDeviceButtonEvent XDeviceButtonPressedEvent;
  3463. typedef XDeviceButtonEvent XDeviceButtonReleasedEvent;
  3464. |__
  3465.  
  3466.  
  3467. 2.2.3.3.  Device Motion Events
  3468.  
  3469. Motion events from extension devices contain all the infor-
  3470. mation that is contained in a motion event from the X
  3471. pointer.  In addition, they contain a device ID and report
  3472. the current value of any valuators on the device.
  3473.  
  3474. The location reported in the x, y and x_root, y_root members
  3475. is the location of the core X pointer, and so is 2-dimen-
  3476. sional.
  3477.  
  3478. Extension motion devices may report motion data for a vari-
  3479. able number of axes.  The axes_count member contains the
  3480. number of axes that are being reported.  The server sends as
  3481. many of these events as are needed to report the device
  3482. data.  Each event contains the total number of axes reported
  3483. in the axes_count member and the first axis reported in the
  3484. current event in the first_axis member.
  3485.  
  3486.  
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.  
  3494.  
  3495.  
  3496.                  50
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502. X Input Extension Library            X11, Release 6.4
  3503.  
  3504. __
  3505. |
  3506. typedef struct {
  3507.      int type;              /* of event */
  3508.      unsigned long serial;    /* # of last request processed by server */
  3509.      Bool send_event;          /* true if from a SendEvent request */
  3510.      Display *display;          /* Display the event was read from */
  3511.      Window window;          /* "event" window reported relative to */
  3512.      XID deviceid;
  3513.      Window root;          /* root window that the event occurred on */
  3514.      Window subwindow;          /* child window */
  3515.      Time time;           /* milliseconds */
  3516.      int x, y;              /* x, y coordinates in event window */
  3517.      int x_root;          /* coordinates relative to root */
  3518.      int y_root;          /* coordinates relative to root */
  3519.      unsigned int state;      /* key or button mask */
  3520.      char is_hint;          /* detail */
  3521.      Bool same_screen;          /* same screen flag */
  3522.      unsigned int device_state;/* device key or button mask */
  3523.      unsigned char axes_count;
  3524.      unsigned char first_axis;
  3525.      int axis_data[6];
  3526. } XDeviceMotionEvent;
  3527. |__
  3528.  
  3529.  
  3530. 2.2.3.4.  Device Focus Events
  3531.  
  3532. These events are equivalent to the core focus events.  They
  3533. contain the same information, with the addition of a device
  3534. ID to identify which device has had a focus change, and a
  3535. timestamp.
  3536.  
  3537. DeviceFocusIn and DeviceFocusOut events are generated for
  3538. focus changes of extension devices in the same manner as
  3539. core focus events are generated.
  3540.  
  3541.  
  3542.  
  3543.  
  3544.  
  3545.  
  3546.  
  3547.  
  3548.  
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.                  51
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568. X Input Extension Library            X11, Release 6.4
  3569.  
  3570. __
  3571. |
  3572. typedef struct {
  3573.      int type;         /* of event */
  3574.      unsigned long serial;/* # of last request processed by server */
  3575.      Bool send_event;     /* true if this came from a SendEvent request */
  3576.      Display *display;     /* Display the event was read from */
  3577.      Window window;     /* "event" window it is reported relative to */
  3578.      XID deviceid;
  3579.      int mode;         /* NotifyNormal, NotifyGrab, NotifyUngrab */
  3580.      int detail;
  3581.              /*
  3582.              * NotifyAncestor, NotifyVirtual, NotifyInferior,
  3583.              * NotifyNonLinear,NotifyNonLinearVirtual, NotifyPointer,
  3584.              * NotifyPointerRoot, NotifyDetailNone
  3585.              */
  3586.      Time time;
  3587. } XDeviceFocusChangeEvent;
  3588.  
  3589. typedef XDeviceFocusChangeEvent XDeviceFocusInEvent;
  3590. typedef XDeviceFocusChangeEvent XDeviceFocusOutEvent;
  3591. |__
  3592.  
  3593.  
  3594. 2.2.3.5.  Device StateNotify Event
  3595.  
  3596. This event is analogous to the core keymap event but reports
  3597. the current state of the device for each input class that it
  3598. supports.  It is generated after every DeviceFocusIn event
  3599. and EnterNotify event and is delivered to clients who have
  3600. selected XDeviceStateNotify events.
  3601.  
  3602. If the device supports input class Valuators, the mode mem-
  3603. ber in the XValuatorStatus structure is a bitmask that
  3604. reports the device mode, proximity state, and other state
  3605. information.  The following bits are currently defined:
  3606.  
  3607.      0x01      Relative = 0, Absolute = 1
  3608.      0x02      InProximity = 0, OutOfProximity = 1
  3609.  
  3610.  
  3611. If the device supports more valuators than can be reported
  3612. in a single XEvent, multiple XDeviceStateNotify events will
  3613. be generated.
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.                  52
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634. X Input Extension Library            X11, Release 6.4
  3635.  
  3636. __
  3637. |
  3638. typedef struct {
  3639.      unsigned char class;
  3640.      unsigned char length;
  3641. } XInputClass;
  3642.  
  3643. typedef struct {
  3644.      int type;
  3645.      unsigned long serial;    /* # of last request processed by server */
  3646.      Bool send_event;          /* true if this came from a SendEvent request */
  3647.      Display *display;          /* Display the event was read from */
  3648.      Window window;
  3649.      XID deviceid;
  3650.      Time time;
  3651.      int num_classes;
  3652.      char data[64];
  3653. } XDeviceStateNotifyEvent;
  3654.  
  3655. typedef struct {
  3656.      unsigned char class;
  3657.      unsigned char length;
  3658.      unsigned char num_valuators;
  3659.      unsigned char mode;
  3660.      int valuators[6];
  3661. } XValuatorStatus;
  3662.  
  3663. typedef struct {
  3664.      unsigned char class;
  3665.      unsigned char length;
  3666.      short num_keys;
  3667.      char keys[32];
  3668. } XKeyStatus;
  3669.  
  3670. typedef struct {
  3671.      unsigned char class;
  3672.      unsigned char length;
  3673.      short num_buttons;
  3674.      char buttons[32];
  3675. } XButtonStatus;
  3676. |__
  3677.  
  3678.  
  3679. 2.2.3.6.  Device Mapping Event
  3680.  
  3681. This event is equivalent to the core MappingNotify event.
  3682. It notifies client programs when the mapping of keys, modi-
  3683. fiers, or buttons on an extension device has changed.
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.                  53
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700. X Input Extension Library            X11, Release 6.4
  3701.  
  3702. __
  3703. |
  3704. typedef struct {
  3705.      int type;
  3706.      unsigned long serial;
  3707.      Bool send_event;
  3708.      Display *display;
  3709.      Window window;
  3710.      XID deviceid;
  3711.      Time time;
  3712.      int request;
  3713.      int first_keycode;
  3714.      int count;
  3715. } XDeviceMappingEvent;
  3716. |__
  3717.  
  3718.  
  3719. 2.2.3.7.  ChangeDeviceNotify Event
  3720.  
  3721. This event has no equivalent in the core protocol.  It noti-
  3722. fies client programs when one of the core devices has been
  3723. changed.
  3724.  
  3725. __
  3726. |
  3727. typedef struct {
  3728.      int type;
  3729.      unsigned long serial;
  3730.      Bool send_event;
  3731.      Display *display;
  3732.      Window window;
  3733.      XID deviceid;
  3734.      Time time;
  3735.      int request;
  3736. } XChangeDeviceNotifyEvent;
  3737. |__
  3738.  
  3739.  
  3740. 2.2.3.8.  Proximity Events
  3741.  
  3742. These events have no equivalent in the core protocol.  Some
  3743. input devices such as graphics tablets or touchscreens may
  3744. send these events to indicate that a stylus has moved into
  3745. or out of contact with a positional sensing surface.
  3746.  
  3747. The event contains the current value of any valuators on the
  3748. device if that device is reporting absolute data.  If data
  3749. for more than six valuators is being reported, more than one
  3750. proximity event may be sent.  The axes_count member contains
  3751. the number of axes that are being reported.  The server
  3752. sends as many of these events as are needed to report the
  3753. device data.  Each event contains the total number of axes
  3754. reported in the axes_count member and the first axis
  3755. reported in the current event in the first_axis member.  If
  3756. the device supports input class Valuators, but is not
  3757.  
  3758.  
  3759.  
  3760.                  54
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766. X Input Extension Library            X11, Release 6.4
  3767.  
  3768.  
  3769. reporting absolute mode data, the axes_count member contains
  3770. zero (0).
  3771.  
  3772. __
  3773. |
  3774. typedef struct {
  3775.      int type;              /* ProximityIn or ProximityOut */
  3776.      unsigned long serial;    /* # of last request processed by server */
  3777.      Bool send_event;          /* true if this came from a SendEvent request */
  3778.      Display *display;          /* Display the event was read from */
  3779.      Window window;
  3780.      XID deviceid;
  3781.      Window root;
  3782.      Window subwindow;
  3783.      Time time;
  3784.      int x, y;
  3785.      int x_root, y_root;
  3786.      unsigned int state;
  3787.      Bool same_screen;
  3788.      unsigned int device_state;/* device key or button mask */
  3789.      unsigned char axes_count;
  3790.      unsigned char first_axis;
  3791.      int axis_data[6];
  3792. } XProximityNotifyEvent;
  3793.  
  3794. typedef XProximityNotifyEvent XProximityInEvent;
  3795. typedef XProximityNotifyEvent XProximityOutEvent;
  3796. |__
  3797.  
  3798.  
  3799. 2.3.  Event Handling Functions
  3800.  
  3801. This section discusses the X Input Extension event handling
  3802. functions that allow you to:
  3803.  
  3804. o    Determine the extension version
  3805.  
  3806. o    List the available devices
  3807.  
  3808. o    Enable and disable extension devices
  3809.  
  3810. o    Change the mode of a device
  3811.  
  3812. o    Initialize valuators on an input device
  3813.  
  3814. o    Get input device controls
  3815.  
  3816. o    Change input device controls
  3817.  
  3818. o    Select extension device events
  3819.  
  3820. o    Determine selected device events
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.                  55
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832. X Input Extension Library            X11, Release 6.4
  3833.  
  3834.  
  3835. o    Control event propogation
  3836.  
  3837. o    Send an event
  3838.  
  3839. o    Get motion history
  3840.  
  3841. 2.3.1.    Determining the Extension Version
  3842.  
  3843. __
  3844. |
  3845. XExtensionVersion * XGetExtensionVersion(display, name)
  3846.      Display *display;
  3847.      char *name;
  3848.  
  3849.  
  3850. display   Specifies the connection to the X server.
  3851.  
  3852. name      Specifies the name of the desired extension.
  3853. |__
  3854.  
  3855. XGetExtensionVersion allows a client to determine whether a
  3856. server supports the desired version of the input extension.
  3857.  
  3858. The XExtensionVersion structure returns information about
  3859. the version of the extension supported by the server and is
  3860. defined as follows:
  3861.  
  3862. __
  3863. |
  3864. typedef struct {
  3865.      Bool present;
  3866.      short major_version;
  3867.      short minor_version;
  3868. } XExtensionVersion;
  3869.  
  3870. |__
  3871.  
  3872. The major and minor versions can be compared with constants
  3873. defined in the header file <X11/extensions/XI.h>.  Each ver-
  3874. sion is a superset of the previous versions.
  3875.  
  3876. You should use XFree to free the data returned by this func-
  3877. tion.
  3878.  
  3879. 2.3.2.    Listing Available Devices
  3880.  
  3881. A client program that wishes to access a specific device
  3882. must first determine whether that device is connected to the
  3883. X server.  This is done through the XListInputDevices func-
  3884. tion, which will return a list of all devices that can be
  3885. opened by the X server.  The client program can use one of
  3886. the names defined in the <X11/extensions/XI.h> header file
  3887. in an XInternAtom request to determine the device type of
  3888. the desired device.  This type can then be compared with the
  3889.  
  3890.  
  3891.  
  3892.                  56
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898. X Input Extension Library            X11, Release 6.4
  3899.  
  3900.  
  3901. device types returned by the XListInputDevices request.
  3902.  
  3903. __
  3904. |
  3905. XDeviceInfo * XListInputDevices(display, ndevices)
  3906.      Display *display;
  3907.      int *ndevices;           /* RETURN */
  3908.  
  3909.  
  3910. display   Specifies the connection to the X server.
  3911.  
  3912. ndevices  Specifies the address of a variable into which the
  3913.       server can return the number of input devices
  3914.       available to the X server.
  3915. |__
  3916.  
  3917. XListInputDevices allows a client to determine which devices
  3918. are available for X input and information about those
  3919. devices.  An array of XDeviceInfo structures is returned,
  3920. with one element in the array for each device.    The number
  3921. of devices is returned in the ndevices argument.
  3922.  
  3923. The X pointer device and X keyboard device are reported, as
  3924. well as all available extension input devices.    The use mem-
  3925. ber of the XDeviceInfo structure specifies the current use
  3926. of the device.    If the value of this member is IsXPointer,
  3927. the device is the X pointer device.  If the value is
  3928. IsXKeyboard, the device is the X keyboard device.  If the
  3929. value is IsXExtensionDevice, the device is available for use
  3930. as an extension input device.
  3931.  
  3932. Each XDeviceInfo entry contains a pointer to a list of
  3933. structures that describe the characteristics of each class
  3934. of input supported by that device.  The num_classes member
  3935. contains the number of entries in that list.
  3936.  
  3937. If the device supports input class Valuators, one of the
  3938. structures pointed to by the XDeviceInfo structure will be
  3939. an XValuatorInfo structure.  The axes member of that struc-
  3940. ture contains the address of an array of XAxisInfo struc-
  3941. tures.    There is one element in this array for each axis of
  3942. motion reported by the device.    The number of elements in
  3943. this array is contained in the num_axes element of the XVal-
  3944. uatorInfo structure.  The size of the motion buffer for the
  3945. device is reported in the motion_buffer member of the XValu-
  3946. atorInfo structure.
  3947.  
  3948. The XDeviceInfo structure is defined as follows:
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.                  57
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964. X Input Extension Library            X11, Release 6.4
  3965.  
  3966. __
  3967. |
  3968. typedef struct _XDeviceInfo {
  3969.      XID id;
  3970.      Atom type;
  3971.      char *name;
  3972.      int num_classes;
  3973.      int use;
  3974.      XAnyClassPtr inputclassinfo;
  3975. } XDeviceInfo;
  3976.  
  3977. |__
  3978.  
  3979. The structures pointed to by the XDeviceInfo structure are
  3980. defined as follows:
  3981.  
  3982. __
  3983. |
  3984. typedef struct _XKeyInfo {
  3985.      XID class;
  3986.      int length;
  3987.      unsigned short min_keycode;
  3988.      unsigned short max_keycode;
  3989.      unsigned short num_keys;
  3990. } XKeyInfo;
  3991.  
  3992. typedef struct _XButtonInfo {
  3993.      XID class;
  3994.      int length;
  3995.      short num_buttons;
  3996. } XButtonInfo;
  3997.  
  3998. typedef struct _XValuatorInfo {
  3999.      XID class;
  4000.      int length;
  4001.      unsigned char num_axes;
  4002.      unsigned char mode;
  4003.      unsigned long motion_buffer;
  4004.      XAxisInfoPtr axes;
  4005. } XValuatorInfo;
  4006.  
  4007. |__
  4008.  
  4009. The XAxisInfo structure pointed to by the XValuatorInfo
  4010. structure is defined as follows:
  4011.  
  4012.  
  4013.  
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.  
  4022.  
  4023.  
  4024.                  58
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030. X Input Extension Library            X11, Release 6.4
  4031.  
  4032. __
  4033. |
  4034. typedef struct _XAxisInfo {
  4035.      int resolution;
  4036.      int min_value;
  4037.      int max_value;
  4038. } XAxisInfo;
  4039.  
  4040. |__
  4041.  
  4042. The following atom names are defined in the
  4043. <X11/extensions/XI.h> header file.
  4044.  
  4045. MOUSE            QUADRATURE
  4046. TABLET            SPACEBALL
  4047. KEYBOARD        DATAGLOVE
  4048. TOUCHSCREEN        EYETRACKER
  4049. TOUCHPAD        CURSORKEYS
  4050. BUTTONBOX        FOOTMOUSE
  4051. BARCODE         ID_MODULE
  4052. KNOB_BOX        ONE_KNOB
  4053. TRACKBALL        NINE_KNOB
  4054.  
  4055.  
  4056. These names can be used in an XInternAtom request to return
  4057. an atom that can be used for comparison with the type member
  4058. of the XDeviceInfo structure.
  4059.  
  4060. XListInputDevices returns NULL if there are no input devices
  4061. to list.
  4062.  
  4063.  
  4064. To free the data returned by XListInputDevices, use
  4065. XFreeDeviceList.
  4066.  
  4067.  
  4068. __
  4069. |
  4070. void XFreeDeviceList(list)
  4071.     XDeviceInfo *list;
  4072.  
  4073.  
  4074. list      Specifies the pointer to the XDeviceInfo array
  4075.       returned by a previous call to XListInputDevices.
  4076. |__
  4077.  
  4078. XFreeDeviceList frees the list of input device information.
  4079.  
  4080. 2.3.3.    Enabling and Disabling Extension Devices
  4081.  
  4082. Each client program that wishes to access an extension
  4083. device must request that the server open that device by
  4084. calling the XOpenDevice function.
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.                  59
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096. X Input Extension Library            X11, Release 6.4
  4097.  
  4098. __
  4099. |
  4100. XDevice * XOpenDevice(display, device_id)
  4101.      Display *display;
  4102.      XID device_id;
  4103.  
  4104.  
  4105. display   Specifies the connection to the X server.
  4106.  
  4107. device_id Specifies the ID that uniquely identifies the
  4108.       device to be opened.    This ID is obtained from the
  4109.       XListInputDevices request.
  4110. |__
  4111.  
  4112. XOpenDevice opens the device for the requesting client and,
  4113. on success, returns an XDevice structure, which is defined
  4114. as follows:
  4115.  
  4116. __
  4117. |
  4118. typedef struct {
  4119.      XID device_id;
  4120.      int num_classes;
  4121.      XInputClassInfo *classes;
  4122. } XDevice;
  4123.  
  4124. |__
  4125.  
  4126. The XDevice structure contains a pointer to an array of XIn-
  4127. putClassInfo structures.  Each element in that array con-
  4128. tains information about events of a particular input class
  4129. supported by the input device.
  4130.  
  4131. The XInputClassInfo structure is defined as follows:
  4132.  
  4133. __
  4134. |
  4135. typedef struct {
  4136.      unsigned char input_class;
  4137.      unsigned char event_type_base;
  4138. } XInputClassInfo;
  4139.  
  4140. |__
  4141.  
  4142. A client program can determine the event type and event
  4143. class for a given event by using macros defined by the input
  4144. extension.  The name of the macro corresponds to the desired
  4145. event, and the macro is passed the structure that describes
  4146. the device from which input is desired, for example:
  4147.  
  4148.  
  4149.      DeviceKeyPress(XDevice *device, event_type, event_class)
  4150.  
  4151.  
  4152.  
  4153.  
  4154.  
  4155.  
  4156.                  60
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162. X Input Extension Library            X11, Release 6.4
  4163.  
  4164.  
  4165. The macro will fill in the values of the event class to be
  4166. used in an XSelectExtensionEvent request to select the event
  4167. and the event type to be used in comparing with the event
  4168. types of events received via XNextEvent.
  4169.  
  4170. XOpenDevice can generate BadDevice errors.
  4171.  
  4172.  
  4173. Before terminating, the client program should request that
  4174. the server close the device by calling the XCloseDevice
  4175. function.
  4176. __
  4177. |
  4178. int XCloseDevice(display, device)
  4179.      Display *display;
  4180.      XDevice *device;
  4181.  
  4182.  
  4183. display   Specifies the connection to the X server.
  4184.  
  4185. device      Specifies the device to be closed.
  4186. |__
  4187.  
  4188. XCloseDevice closes the device for the requesting client and
  4189. frees the associated XDevice structure.
  4190.  
  4191. A client may open the same extension device more than once.
  4192. Requests after the first successful one return an additional
  4193. XDevice structure with the same information as the first,
  4194. but otherwise have no effect.  A single XCloseDevice request
  4195. will terminate that client's access to the device.
  4196.  
  4197. Closing a device releases any active or passive grabs the
  4198. requesting client has established.  If the device is frozen
  4199. only by an active grab of the requesting client, any queued
  4200. events are released.
  4201.  
  4202. If a client program terminates without closing a device, the
  4203. server will automatically close that device on behalf of the
  4204. client.  This does not affect any other clients that may be
  4205. accessing that device.
  4206.  
  4207. XCloseDevice can generate BadDevice errors.
  4208.  
  4209. 2.3.4.    Changing the Mode of a Device
  4210.  
  4211. Some devices are capable of reporting either relative or
  4212. absolute motion data.  To change the mode of a device from
  4213. relative to absolute, use XSetDeviceMode.
  4214.  
  4215.  
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.  
  4222.                  61
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228. X Input Extension Library            X11, Release 6.4
  4229.  
  4230. __
  4231. |
  4232. int XSetDeviceMode(display, device, mode)
  4233.      Display *display;
  4234.      XDevice *device;
  4235.      int mode;
  4236.  
  4237.  
  4238. display   Specifies the connection to the X server.
  4239.  
  4240. device      Specifies the device whose mode should be changed.
  4241.  
  4242. mode      Specifies the mode.  You can pass Absolute or
  4243.       Relative.
  4244. |__
  4245.  
  4246. XSetDeviceMode allows a client to request the server to
  4247. change the mode of a device that is capable of reporting
  4248. either absolute positional data or relative motion data.  If
  4249. the device is invalid or if the client has not previously
  4250. requested that the server open the device via an XOpenDevice
  4251. request, this request will fail with a BadDevice error.  If
  4252. the device does not support input class Valuators or if it
  4253. is not capable of reporting the specified mode, the request
  4254. will fail with a BadMatch error.
  4255.  
  4256. This request will fail and return DeviceBusy if another
  4257. client has already opened the device and requested a differ-
  4258. ent mode.
  4259.  
  4260. XSetDeviceMode can generate BadDevice, BadMatch, BadMode,
  4261. and DeviceBusy errors.
  4262.  
  4263. 2.3.5.    Initializing Valuators on an Input Device
  4264.  
  4265. Some devices that report absolute positional data can be
  4266. initialized to a starting value.  Devices that are capable
  4267. of reporting relative motion or absolute positional data may
  4268. require that their valuators be initialized to a starting
  4269. value after the mode of the device is changed to Absolute.
  4270.  
  4271.  
  4272. To initialize the valuators on such a device, use
  4273. XSetDeviceValuators.
  4274.  
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288.                  62
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294. X Input Extension Library            X11, Release 6.4
  4295.  
  4296. __
  4297. |
  4298. Status XSetDeviceValuators(display, device, valuators, first_valuator, num_valuators)
  4299.      Display *display;
  4300.      XDevice *device;
  4301.      int *valuators, first_valuator, num_valuators;
  4302.  
  4303.  
  4304. display   Specifies the connection to the X server.
  4305.  
  4306. device      Specifies the device whose valuators should be
  4307.       initialized.
  4308.  
  4309. valuators Specifies the values to which each valuator should
  4310.       be set.
  4311.  
  4312. first_valuator
  4313.       Specifies the first valuator to be set.
  4314.  
  4315. num_valuators
  4316.       Specifies the number of valuators to be set.
  4317. |__
  4318.  
  4319. XSetDeviceValuators initializes the specified valuators on
  4320. the specified extension input device.  Valuators are num-
  4321. bered beginning with zero.  Only the valuators in the range
  4322. specified by first_valuator and num_valuators are set.    A
  4323. BadValue error results if the number of valuators supported
  4324. by the device is less than the following expression:
  4325.  
  4326.      first_valuator + num_valuators
  4327.  
  4328.  
  4329. If the request succeeds, Success is returned.  If the speci-
  4330. fied device is grabbed by some other client, the request
  4331. will fail and a status of AlreadyGrabbed will be returned.
  4332.  
  4333. XSetDeviceValuators can generate BadDevice, BadLength,
  4334. BadMatch, and BadValue errors.
  4335.  
  4336. 2.3.6.    Getting Input Device Controls
  4337.  
  4338. Some input devices support various configuration controls
  4339. that can be queried or changed by clients.  The set of sup-
  4340. ported controls will vary from one input device to another.
  4341. Requests to manipulate these controls will fail if either
  4342. the target X server or the target input device does not sup-
  4343. port the requested device control.
  4344.  
  4345. Each device control has a unique identifier.  Information
  4346. passed with each device control varies in length and is
  4347. mapped by data structures unique to that device control.
  4348.  
  4349.  
  4350.  
  4351.  
  4352.  
  4353.  
  4354.                  63
  4355.  
  4356.  
  4357.  
  4358.  
  4359.  
  4360. X Input Extension Library            X11, Release 6.4
  4361.  
  4362.  
  4363. To query a device control, use XGetDeviceControl.
  4364. __
  4365. |
  4366. XDeviceControl * XGetDeviceControl(display, device, control)
  4367.      Display *display;
  4368.      XDevice *device;
  4369.      int control;
  4370.  
  4371.  
  4372. display   Specifies the connection to the X server.
  4373.  
  4374. device      Specifies the device whose configuration control
  4375.       status is to be returned.
  4376.  
  4377. control   Identifies the specific device control to be
  4378.       queried.
  4379. |__
  4380.  
  4381. XGetDeviceControl returns the current state of the specified
  4382. device control.  If the target X server does not support
  4383. that device control, a BadValue error is returned.  If the
  4384. specified device does not support that device control, a
  4385. BadMatch error is returned.
  4386.  
  4387. If the request is successful, a pointer to a generic XDe-
  4388. viceState structure is returned.  The information returned
  4389. varies according to the specified control and is mapped by a
  4390. structure appropriate for that control.  The first two mem-
  4391. bers are common to all device controls and are defined as
  4392. follows:
  4393.  
  4394. __
  4395. |
  4396. typedef struct {
  4397.      XID control;
  4398.      int length;
  4399. } XDeviceState;
  4400.  
  4401.  
  4402. |__
  4403.  
  4404. The control may be compared to constants defined in the file
  4405. <X11/extensions/XI.h>.    Currently defined device controls
  4406. include DEVICE_RESOLUTION.
  4407.  
  4408. The information returned for the DEVICE_RESOLUTION control
  4409. is defined in the XDeviceResolutionState structure, which is
  4410. defined as follows:
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.                  64
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426. X Input Extension Library            X11, Release 6.4
  4427.  
  4428. __
  4429. |
  4430. typedef struct {
  4431.      XID control;
  4432.      int length;
  4433.      int num_valuators;
  4434.      int *resolutions;
  4435.      int *min_resolutions;
  4436.      int *max_resolutions;
  4437. } XDeviceResolutionState;
  4438.  
  4439. |__
  4440.  
  4441. This device control returns a list of valuators and the
  4442. range of valid resolutions allowed for each.  Valuators are
  4443. numbered beginning with zero (0).  Resolutions for all valu-
  4444. ators on the device are returned.  For each valuator i on
  4445. the device, resolutions[i] returns the current setting of
  4446. the resolution, min_resolutions[i] returns the minimum valid
  4447. setting, and max_resolutions[i] returns the maximum valid
  4448. setting.
  4449.  
  4450. When this control is specified, XGetDeviceControl fails with
  4451. a BadMatch error if the specified device has no valuators.
  4452.  
  4453. XGetDeviceControl can generate BadMatch and BadValue errors.
  4454.  
  4455. 2.3.7.    Changing Input Device Controls
  4456.  
  4457. Some input devices support various configuration controls
  4458. that can be changed by clients.  Typically, this would be
  4459. done to initialize the device to a known state or configura-
  4460. tion.  The set of supported controls will vary from one
  4461. input device to another.  Requests to manipulate these con-
  4462. trols will fail if either the target X server or the target
  4463. input device does not support the requested device control.
  4464. Setting the device control will also fail if the target
  4465. input device is grabbed by another client or is open by
  4466. another client and has been set to a conflicting state.
  4467.  
  4468. Each device control has a unique identifier.  Information
  4469. passed with each device control varies in length and is
  4470. mapped by data structures unique to that device control.
  4471.  
  4472.  
  4473. To change a device control, use XChangeDeviceControl.
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  
  4479.  
  4480.  
  4481.  
  4482.  
  4483.  
  4484.  
  4485.  
  4486.                  65
  4487.  
  4488.  
  4489.  
  4490.  
  4491.  
  4492. X Input Extension Library            X11, Release 6.4
  4493.  
  4494. __
  4495. |
  4496. Status XChangeDeviceControl(display, device, control, value)
  4497.      Display *display;
  4498.      XDevice *device;
  4499.      int control;
  4500.      XDeviceControl *value;
  4501.  
  4502.  
  4503. display   Specifies the connection to the X server.
  4504.  
  4505. device      Specifies the device whose configuration control
  4506.       status is to be modified.
  4507.  
  4508. control   Identifies the specific device control to be
  4509.       changed.
  4510.  
  4511. value      Specifies a pointer to an XDeviceControl structure
  4512.       that describes which control is to be changed and
  4513.       how it is to be changed.
  4514. |__
  4515.  
  4516. XChangeDeviceControl changes the current state of the speci-
  4517. fied device control.  If the target X server does not sup-
  4518. port that device control, a BadValue error is returned.  If
  4519. the specified device does not support that device control, a
  4520. BadMatch error is returned.  If another client has the tar-
  4521. get device grabbed, a status of AlreadyGrabbed is returned.
  4522. If another client has the device open and has set it to a
  4523. conflicting state, a status of DeviceBusy is returned.    If
  4524. the request fails for any reason, the device control will
  4525. not be changed.
  4526.  
  4527. If the request is successful, the device control will be
  4528. changed and a status of Success is returned.  The informa-
  4529. tion passed varies according to the specified control and is
  4530. mapped by a structure appropriate for that control.  The
  4531. first two members are common to all device controls:
  4532.  
  4533. __
  4534. |
  4535. typedef struct {
  4536.      XID control;
  4537.      int length;
  4538. } XDeviceControl;
  4539.  
  4540. |__
  4541.  
  4542. The control may be set using constants defined in the
  4543. <X11/extensions/XI.h> header file.  Currently defined device
  4544. controls include DEVICE_RESOLUTION.
  4545.  
  4546. The information that can be changed by the DEVICE_RESOLUTION
  4547. control is defined in the XDeviceResolutionControl struc-
  4548. ture, which is defined as follows:
  4549.  
  4550.  
  4551.  
  4552.                  66
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558. X Input Extension Library            X11, Release 6.4
  4559.  
  4560. __
  4561. |
  4562. typedef struct {
  4563.      XID control;
  4564.      int length;
  4565.      int first_valuator;
  4566.      int num_valuators;
  4567.      int *resolutions;
  4568. } XDeviceResolutionControl;
  4569.  
  4570. |__
  4571.  
  4572. This device control changes the resolution of the specified
  4573. valuators on the specified extension input device.  Valua-
  4574. tors are numbered beginning with zero.    Only the valuators
  4575. in the range specified by first_valuator and num_valuators
  4576. are set.  A value of -1 in the resolutions list indicates
  4577. that the resolution for this valuator is not to be changed.
  4578. The num_valuators member specifies the number of valuators
  4579. in the resolutions list.
  4580.  
  4581. When this control is specified, XChangeDeviceControl fails
  4582. with a BadMatch error if the specified device has no valua-
  4583. tors.  If a resolution is specified that is not within the
  4584. range of valid values (as returned by XGetDeviceControl),
  4585. XChangeDeviceControl fails with a BadValue error.  A Bad-
  4586. Value error results if the number of valuators supported by
  4587. the device is less than the following expression:
  4588.  
  4589.  
  4590.      first_valuator + num_valuators,
  4591.  
  4592.  
  4593. XChangeDeviceControl can generate BadMatch and BadValue
  4594. errors.
  4595.  
  4596. 2.3.8.    Selecting Extension Device Events
  4597.  
  4598. To select device input events, use XSelectExtensionEvent.
  4599. The parameters passed are a pointer to a list of classes
  4600. that define the desired event types and devices, a count of
  4601. the number of elements in the list, and the ID of the window
  4602. from which events are desired.
  4603.  
  4604.  
  4605.  
  4606.  
  4607.  
  4608.  
  4609.  
  4610.  
  4611.  
  4612.  
  4613.  
  4614.  
  4615.  
  4616.  
  4617.  
  4618.                  67
  4619.  
  4620.  
  4621.  
  4622.  
  4623.  
  4624. X Input Extension Library            X11, Release 6.4
  4625.  
  4626. __
  4627. |
  4628. int XSelectExtensionEvent(display, window, event_list, event_count)
  4629.      Display *display;
  4630.      Window window;
  4631.      XEventClass *event_list;
  4632.      int event_count;
  4633.  
  4634.  
  4635. display   Specifies the connection to the X server.
  4636.  
  4637. window      Specifies the ID of the window from which the
  4638.       client wishes to receive events.
  4639.  
  4640. event_list
  4641.       Specifies a pointer to an array of event classes
  4642.       that specify which events are desired.
  4643.  
  4644. event_count
  4645.       Specifies the number of elements in the
  4646.       event_list.
  4647. |__
  4648.  
  4649. XSelectExtensionEvent requests the server to send events
  4650. that match the events and devices described by the event
  4651. list and that come from the requested window.  The elements
  4652. of the XEventClass array are the event_class values obtained
  4653. by invoking a macro with the pointer to an XDevice structure
  4654. returned by the XOpenDevice request.  For example, the
  4655. DeviceKeyPress macro would return the XEventClass for
  4656. DeviceKeyPress events from the specified device if it were
  4657. invoked in the following form:
  4658.  
  4659.      DeviceKeyPress (XDevice *device, event_type, event_class)
  4660.  
  4661.  
  4662. Macros are defined for the following event classes:
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.  
  4680.  
  4681.  
  4682.  
  4683.  
  4684.                  68
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690. X Input Extension Library            X11, Release 6.4
  4691.  
  4692.  
  4693. DeviceKeyPress
  4694. DeviceKeyRelease
  4695. DeviceButtonPress
  4696. DeviceButtonRelease
  4697. DeviceMotionNotify
  4698. DeviceFocusIn
  4699. DeviceFocusOut
  4700. ProximityIn
  4701. ProximityOut
  4702. DeviceStateNotify
  4703. DeviceMappingNotify
  4704. ChangeDeviceNotify
  4705. DevicePointerMotionHint
  4706. DeviceButton1Motion
  4707. DeviceButton2Motion
  4708. DeviceButton3Motion,
  4709. DeviceButton4Motion
  4710. DeviceButton5Motion
  4711. DeviceButtonMotion,
  4712. DeviceOwnerGrabButton
  4713. DeviceButtonPressGrab
  4714.  
  4715.  
  4716. To get the next available event from within a client pro-
  4717. gram, use the core XNextEvent function.  This returns the
  4718. next event whether it came from a core device or an exten-
  4719. sion device.
  4720.  
  4721. Succeeding XSelectExtensionEvent requests using event
  4722. classes for the same device as was specified on a previous
  4723. request will replace the previous set of selected events
  4724. from that device with the new set.
  4725.  
  4726. XSelectExtensionEvent can generate BadAccess, BadClass,
  4727. BadLength, and BadWindow errors.
  4728.  
  4729. 2.3.9.    Determining Selected Device Events
  4730.  
  4731. To determine which extension events are currently selected
  4732. from a given window, use XGetSelectedExtensionEvents.
  4733.  
  4734.  
  4735.  
  4736.  
  4737.  
  4738.  
  4739.  
  4740.  
  4741.  
  4742.  
  4743.  
  4744.  
  4745.  
  4746.  
  4747.  
  4748.  
  4749.  
  4750.                  69
  4751.  
  4752.  
  4753.  
  4754.  
  4755.  
  4756. X Input Extension Library            X11, Release 6.4
  4757.  
  4758. __
  4759. |
  4760. int XGetSelectedExtensionEvents(display, window, this_client_count, this_client,
  4761.             all_clients_count, all_clients)
  4762.      Display *display;
  4763.      Window window;
  4764.      int *this_client_count;  /* RETURN */
  4765.      XEventClass **this_client;       /* RETURN */
  4766.      int *all_clients_count;  /* RETURN */
  4767.      XEventClass **all_clients;       /* RETURN */
  4768.  
  4769.  
  4770. display   Specifies the connection to the X server.
  4771.  
  4772. window      Specifies the ID of the window from which the
  4773.       client wishes to receive events.
  4774.  
  4775. this_client_count
  4776.       Returns the number of elements in the this_client
  4777.       list.
  4778.  
  4779. this_client
  4780.       Returns a list of XEventClasses that specify which
  4781.       events are selected by this client.
  4782.  
  4783. all_clients_count
  4784.       Returns the number of elements in the all_clients
  4785.       list.
  4786.  
  4787. all_clients
  4788.       Returns a list of XEventClasses that specify which
  4789.       events are selected by all clients.
  4790. |__
  4791.  
  4792. XGetSelectedExtensionEvents returns pointers to two event
  4793. class arrays.  One lists the extension events selected by
  4794. this client from the specified window.    The other lists the
  4795. extension events selected by all clients from the specified
  4796. window.  This information is analogous to that returned in
  4797. your_event_mask and all_event_masks of the XWindowAttributes
  4798. structure when an XGetWindowAttributes request is made.  To
  4799. free the two arrays returned by this function, use XFree.
  4800.  
  4801. XGetSelectedExtensionEvents can generate BadWindow errors.
  4802.  
  4803. 2.3.10.  Controlling Event Propagation
  4804.  
  4805. Extension events propagate up the window hierarchy in the
  4806. same manner as core events.  If a window is not interested
  4807. in an extension event, it usually propagates to the closest
  4808. ancestor that is interested, unless the dont_propagate list
  4809. prohibits it.  Grabs of extension devices may alter the set
  4810. of windows that receive a particular extension event.
  4811.  
  4812.  
  4813.  
  4814.  
  4815.  
  4816.                  70
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822. X Input Extension Library            X11, Release 6.4
  4823.  
  4824.  
  4825. Client programs may control event propagation through the
  4826. use of the following two functions: XChangeDeviceDontPropa-
  4827. gateList and XGetDeviceDontPropagateList.
  4828.  
  4829. __
  4830. |
  4831. int XChangeDeviceDontPropagateList(display, window, event_count, events, mode)
  4832.      Display *display;
  4833.      Window window;
  4834.      int event_count;
  4835.      XEventClass *events;
  4836.      int mode;
  4837.  
  4838.  
  4839. display   Specifies the connection to the X server.
  4840.  
  4841. window      Specifies the desired window.
  4842.  
  4843. event_count
  4844.       Specifies the number of elements in the events
  4845.       list.
  4846.  
  4847. events      Specifies a pointer to the list of XEventClasses.
  4848.  
  4849. mode      Specifies the mode.  You can pass AddToList or
  4850.       DeleteFromList.
  4851. |__
  4852.  
  4853. XChangeDeviceDontPropagateList adds an event to or deletes
  4854. an event from the do_not_propagate list of extension events
  4855. for the specified window.  There is one list per window, and
  4856. the list remains for the life of the window.  The list is
  4857. not altered if a client that changed the list terminates.
  4858.  
  4859. Suppression of event propagation is not allowed for all
  4860. events.  If a specified XEventClass is invalid because sup-
  4861. pression of that event is not allowed, a BadClass error
  4862. results.
  4863.  
  4864. XChangeDeviceDontPropagateList can generate BadClass,
  4865. BadMode, and BadWindow errors.
  4866.  
  4867.  
  4868.  
  4869.  
  4870.  
  4871.  
  4872.  
  4873.  
  4874.  
  4875.  
  4876.  
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882.                  71
  4883.  
  4884.  
  4885.  
  4886.  
  4887.  
  4888. X Input Extension Library            X11, Release 6.4
  4889.  
  4890. __
  4891. |
  4892. XEventClass * XGetDeviceDontPropagateList(display, window, event_count)
  4893.       Display *display;
  4894.       Window window;
  4895.       int *event_count;       /*RETURN */
  4896.  
  4897.  
  4898. display   Specifies the connection to the X server.
  4899.  
  4900. window      Specifies the desired window.
  4901.  
  4902. event_count
  4903.       Returns the number of elements in the array
  4904.       returned by this function.
  4905. |__
  4906.  
  4907. XGetDeviceDontPropagateList allows a client to determine the
  4908. do_not_propagate list of extension events for the specified
  4909. window.  It returns an array of XEventClass, each XEvent-
  4910. Class representing a device/event type pair.  To free the
  4911. data returned by this function, use XFree.
  4912.  
  4913. XGetDeviceDontPropagateList can generate BadWindow errors.
  4914.  
  4915. 2.3.11.  Sending an Event
  4916.  
  4917. To send an extension event to another client, use
  4918. XSendExtensionEvent.
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.  
  4925.  
  4926.  
  4927.  
  4928.  
  4929.  
  4930.  
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.  
  4946.  
  4947.  
  4948.                  72
  4949.  
  4950.  
  4951.  
  4952.  
  4953.  
  4954. X Input Extension Library            X11, Release 6.4
  4955.  
  4956. __
  4957. |
  4958. int XSendExtensionEvent(display, device, window, propagate, event_count, event_list, event)
  4959.      Display *display;
  4960.      XDevice *device;
  4961.      Window window;
  4962.      Bool propagate;
  4963.      int event_count;
  4964.      XEventClass *event_list;
  4965.      XEvent *event;
  4966.  
  4967.  
  4968. display   Specifies the connection to the X server.
  4969.  
  4970. device      Specifies the device whose ID is recorded in the
  4971.       event.
  4972.  
  4973. window      Specifies the destination window ID.    You can pass
  4974.       a window ID, PointerWindow or InputFocus.
  4975.  
  4976. propagate Specifies a boolean value that is either True or
  4977.       False.
  4978.  
  4979. event_count
  4980.       Specifies the number of elements in the event_list
  4981.       array.
  4982.  
  4983. event_list
  4984.       Specifies a pointer to an array of XEventClass.
  4985.  
  4986. event      Specifies a pointer to the event that is to be
  4987.       sent.
  4988. |__
  4989.  
  4990. XSendExtensionEvent identifies the destination window,
  4991. determines which clients should receive the specified event,
  4992. and ignores any active grabs.  It requires a list of XEvent-
  4993. Class to be specified.    These are obtained by opening an
  4994. input device with the XOpenDevice request.
  4995.  
  4996. XSendExtensionEvent uses the window argument to identify the
  4997. destination window as follows:
  4998.  
  4999. o    If you pass PointerWindow, the destination window is
  5000.      the window that contains the pointer.
  5001.  
  5002. o    If you pass InputFocus and if the focus window contains
  5003.      the pointer, the destination window is the window that
  5004.      contains the pointer.  If the focus window does not
  5005.      contain the pointer, the destination window is the
  5006.      focus window.
  5007.  
  5008. To determine which clients should receive the specified
  5009. events, XSendExtensionEvent uses the propagate argument as
  5010. follows:
  5011.  
  5012.  
  5013.  
  5014.                  73
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020. X Input Extension Library            X11, Release 6.4
  5021.  
  5022.  
  5023. o    If propagate is False, the event is sent to every
  5024.      client selecting from the destination window any of the
  5025.      events specified in the event_list array.
  5026.  
  5027. o    If propagate is True and no clients have selected from
  5028.      the destination window any of the events specified in
  5029.      the event_list array, the destination is replaced with
  5030.      the closest ancestor of destination for which some
  5031.      client has selected one of the specified events and for
  5032.      which no intervening window has that event in its
  5033.      do_not_propagate mask.  If no such window exists, or if
  5034.      the window is an ancestor of the focus window, and
  5035.      InputFocus was originally specified as the destination,
  5036.      the event is not sent to any clients.  Otherwise, the
  5037.      event is reported to every client selecting on the
  5038.      final destination any of the events specified in
  5039.      event_list.
  5040.  
  5041. The event in the XEvent structure must be one of the events
  5042. defined by the input extension, so that the X server can
  5043. correctly byte swap the contents as necessary.    The contents
  5044. of the event are otherwise unaltered and unchecked by the X
  5045. server except to force send_event to True in the forwarded
  5046. event and to set the sequence number in the event correctly.
  5047.  
  5048. XSendExtensionEvent returns zero if the conversion-to-wire
  5049. protocol failed; otherwise, it returns nonzero.
  5050.  
  5051. XSendExtensionEvent can generate BadClass, BadDevice,
  5052. BadValue, and BadWindow errors.
  5053.  
  5054. 2.3.12.  Getting Motion History
  5055.  
  5056.  
  5057.  
  5058.  
  5059.  
  5060.  
  5061.  
  5062.  
  5063.  
  5064.  
  5065.  
  5066.  
  5067.  
  5068.  
  5069.  
  5070.  
  5071.  
  5072.  
  5073.  
  5074.  
  5075.  
  5076.  
  5077.  
  5078.  
  5079.  
  5080.                  74
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086. X Input Extension Library            X11, Release 6.4
  5087.  
  5088. __
  5089. |
  5090. XDeviceTimeCoord * XGetDeviceMotionEvents(display, device, start, stop, nevents_return, mode_return,
  5091.              axis_count_return);
  5092.      Display *display;
  5093.      XDevice *device;
  5094.      Time start, stop;
  5095.      int *nevents_return;
  5096.      int *mode_return;
  5097.      int *axis_count_return;
  5098.  
  5099.  
  5100. display   Specifies the connection to the X server.
  5101.  
  5102. device      Specifies the desired device.
  5103.  
  5104. start      Specifies the start time.
  5105.  
  5106. stop      Specifies the stop time.
  5107.  
  5108. nevents_return
  5109.       Returns the number of positions in the motion
  5110.       buffer returned for this request.
  5111.  
  5112. mode_return
  5113.       Returns the mode of the nevents information.    The
  5114.       mode will be one of the following: Absolute or
  5115.       Relative.
  5116.  
  5117. axis_count_return
  5118.       Returns the number of axes reported in each of the
  5119.       positions returned.
  5120. |__
  5121.  
  5122. XGetDeviceMotionEvents returns all positions in the device's
  5123. motion history buffer that fall between the specified start
  5124. and stop times inclusive.  If the start time is in the
  5125. future or is later than the stop time, no positions are
  5126. returned.
  5127.  
  5128. The return type for this function is an XDeviceTimeCoord
  5129. structure, which is defined as follows:
  5130.  
  5131. __
  5132. |
  5133. typedef struct {
  5134.      Time time;
  5135.      unsigned int *data;
  5136. } XDeviceTimeCoord;
  5137.  
  5138. |__
  5139.  
  5140. The data member is a pointer to an array of data items.
  5141. Each item is of type int, and there is one data item per
  5142. axis of motion reported by the device.    The number of axes
  5143.  
  5144.  
  5145.  
  5146.                  75
  5147.  
  5148.  
  5149.  
  5150.  
  5151.  
  5152. X Input Extension Library            X11, Release 6.4
  5153.  
  5154.  
  5155. reported by the device is returned in the axis_count vari-
  5156. able.
  5157.  
  5158. The value of the data items depends on the mode of the
  5159. device.  The mode is returned in the mode variable.  If the
  5160. mode is Absolute, the data items are the raw values gener-
  5161. ated by the device.  These may be scaled by the client pro-
  5162. gram using the maximum values that the device can generate
  5163. for each axis of motion that it reports.  The maximum value
  5164. for each axis is reported in the max_val member of the XAx-
  5165. isInfo structure, which is part of the information returned
  5166. by the XListInputDevices request.
  5167.  
  5168. If the mode is Relative, the data items are the relative
  5169. values generated by the device.  The client program must
  5170. choose an initial position for the device and maintain a
  5171. current position by accumulating these relative values.
  5172.  
  5173. Consecutive calls to XGetDeviceMotionEvents can return data
  5174. of different modes, that is, if some client program has
  5175. changed the mode of the device via an XSetDeviceMode
  5176. request.
  5177.  
  5178. XGetDeviceMotionEvents can generate BadDevice and BadMatch
  5179. errors.
  5180.  
  5181.  
  5182. To free the data returned by XGetDeviceMotionEvents, use
  5183. XFreeDeviceMotionEvents.
  5184.  
  5185. __
  5186. |
  5187. void XFreeDeviceMotionEvents(events)
  5188.       XDeviceTimeCoord *events;
  5189.  
  5190.  
  5191. events      Specifies the pointer to the XDeviceTimeCoord
  5192.       array returned by a previous call to
  5193.       XGetDeviceMotionEvents.
  5194. |__
  5195.  
  5196. XFreeDeviceMotionEvents frees the specified array of motion
  5197. information.
  5198.  
  5199.  
  5200.  
  5201.  
  5202.  
  5203.  
  5204.  
  5205.  
  5206.  
  5207.  
  5208.  
  5209.  
  5210.  
  5211.  
  5212.                  76
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218. X Input Extension Library            X11, Release 6.4
  5219.  
  5220.  
  5221.              Appendix A
  5222.  
  5223. The following information is contained in the <X11/exten-
  5224. sions/XInput.h> and <X11/extensions/XI.h> header files:
  5225.  
  5226.  
  5227.  
  5228.  
  5229.  
  5230.  
  5231.  
  5232.  
  5233.  
  5234.  
  5235.  
  5236.  
  5237.  
  5238.  
  5239.  
  5240.  
  5241.  
  5242.  
  5243.  
  5244.  
  5245.  
  5246.  
  5247.  
  5248.  
  5249.  
  5250.  
  5251.  
  5252.  
  5253.  
  5254.  
  5255.  
  5256.  
  5257.  
  5258.  
  5259.  
  5260.  
  5261.  
  5262.  
  5263.  
  5264.  
  5265.  
  5266.  
  5267.  
  5268.  
  5269.  
  5270.  
  5271.  
  5272.  
  5273.  
  5274.  
  5275.  
  5276.  
  5277.  
  5278.                  77
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284. X Input Extension Library            X11, Release 6.4
  5285.  
  5286.  
  5287. /* Definitions used by the library and client */
  5288.  
  5289. #ifndef _XINPUT_H_
  5290. #define _XINPUT_H_
  5291.  
  5292. #ifndef _XLIB_H_
  5293. #include <X11/Xlib.h>
  5294. #endif
  5295.  
  5296. #ifndef _XI_H_
  5297. #include "XI.h"
  5298. #endif
  5299.  
  5300. #define _deviceKeyPress       0
  5301. #define _deviceKeyRelease     1
  5302.  
  5303. #define _deviceButtonPress    0
  5304. #define _deviceButtonRelease  1
  5305.  
  5306. #define _deviceMotionNotify   0
  5307.  
  5308. #define _deviceFocusIn          0
  5309. #define _deviceFocusOut       1
  5310.  
  5311. #define _proximityIn          0
  5312. #define _proximityOut          1
  5313.  
  5314. #define _deviceStateNotify    0
  5315. #define _deviceMappingNotify  1
  5316. #define _changeDeviceNotify   2
  5317.  
  5318. #define FindTypeAndClass(d, type, class, classid, offset)     { int i; XInputClassInfo *ip;    type = 0; class = 0;     for (i=0, ip= ((XDevice *) d)->classes;      i< ((XDevice *) d)->num_classes;     i++, ip++)    if (ip->input_class == classid)          {type =  ip->event_type_base + offset;        class =  ((XDevice *) d)->device_id << 8 | type;}}
  5319.  
  5320. #define DeviceKeyPress(d, type, class)       FindTypeAndClass(d, type, class, KeyClass, _deviceKeyPress)
  5321.  
  5322. #define DeviceKeyRelease(d, type, class)     FindTypeAndClass(d, type, class, KeyClass, _deviceKeyRelease)
  5323.  
  5324. #define DeviceButtonPress(d, type, class)     FindTypeAndClass(d, type, class, ButtonClass, _deviceButtonPress)
  5325.  
  5326. #define DeviceButtonRelease(d, type, class)    FindTypeAndClass(d, type, class, ButtonClass, _deviceButtonRelease)
  5327.  
  5328. #define DeviceMotionNotify(d, type, class)     FindTypeAndClass(d, type, class, ValuatorClass, _deviceMotionNotify)
  5329.  
  5330. #define DeviceFocusIn(d, type, class)      FindTypeAndClass(d, type, class, FocusClass, _deviceFocusIn)
  5331.  
  5332. #define DeviceFocusOut(d, type, class)       FindTypeAndClass(d, type, class, FocusClass, _deviceFocusOut)
  5333.  
  5334. #define ProximityIn(d, type, class)    FindTypeAndClass(d, type, class, ProximityClass, _proximityIn)
  5335.  
  5336. #define ProximityOut(d, type, class)     FindTypeAndClass(d, type, class, ProximityClass, _proximityOut)
  5337.  
  5338. #define DeviceStateNotify(d, type, class)     FindTypeAndClass(d, type, class, OtherClass, _deviceStateNotify)
  5339.  
  5340. #define DeviceMappingNotify(d, type, class)    FindTypeAndClass(d, type, class, OtherClass, _deviceMappingNotify)
  5341.  
  5342.  
  5343.  
  5344.                  78
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350. X Input Extension Library            X11, Release 6.4
  5351.  
  5352.  
  5353. #define ChangeDeviceNotify(d, type, class)     FindTypeAndClass(d, type, class, OtherClass, _changeDeviceNotify)
  5354.  
  5355. #define DevicePointerMotionHint(d, type, class)     { class =  ((XDevice *) d)->device_id << 8 | _devicePointerMotionHint;}
  5356.  
  5357. #define DeviceButton1Motion(d, type, class)    { class =  ((XDevice *) d)->device_id << 8 | _deviceButton1Motion;}
  5358.  
  5359. #define DeviceButton2Motion(d, type, class)    { class =  ((XDevice *) d)->device_id << 8 | _deviceButton2Motion;}
  5360.  
  5361. #define DeviceButton3Motion(d, type, class)    { class =  ((XDevice *) d)->device_id << 8 | _deviceButton3Motion;}
  5362.  
  5363. #define DeviceButton4Motion(d, type, class)    { class =  ((XDevice *) d)->device_id << 8 | _deviceButton4Motion;}
  5364.  
  5365. #define DeviceButton5Motion(d, type, class)    { class =  ((XDevice *) d)->device_id << 8 | _deviceButton5Motion;}
  5366.  
  5367. #define DeviceButtonMotion(d, type, class)     { class =  ((XDevice *) d)->device_id << 8 | _deviceButtonMotion;}
  5368.  
  5369. #define DeviceOwnerGrabButton(d, type, class)      { class =  ((XDevice *) d)->device_id << 8 | _deviceOwnerGrabButton;}
  5370.  
  5371. #define DeviceButtonPressGrab(d, type, class)      { class =  ((XDevice *) d)->device_id << 8 | _deviceButtonGrab;}
  5372.  
  5373. #define NoExtensionEvent(d, type, class)     { class =    ((XDevice *) d)->device_id << 8 | _noExtensionEvent;}
  5374.  
  5375. #define BadDevice(dpy, error) _xibaddevice(dpy, &error)
  5376.  
  5377. #define BadClass(dpy, error) _xibadclass(dpy, &error)
  5378.  
  5379. #define BadEvent(dpy, error) _xibadevent(dpy, &error)
  5380.  
  5381. #define BadMode(dpy, error) _xibadmode(dpy, &error)
  5382.  
  5383. #define DeviceBusy(dpy, error) _xidevicebusy(dpy, &error)
  5384.  
  5385. /***************************************************************
  5386.  *
  5387.  * DeviceKey events.  These events are sent by input devices that
  5388.  * support input class Keys.
  5389.  * The location of the X pointer is reported in the coordinate
  5390.  * fields of the x,y and x_root,y_root fields.
  5391.  *
  5392.  */
  5393.  
  5394. typedef struct
  5395.     {
  5396.     int        type;     /* of event */
  5397.     unsigned long  serial;     /* # of last request processed */
  5398.     Bool       send_event;     /* true if from SendEvent request */
  5399.     Display       *display;     /* Display the event was read from */
  5400.     Window       window;     /* "event" window reported relative to */
  5401.     XID        deviceid;
  5402.     Window       root;     /* root window event occured on */
  5403.     Window       subwindow;     /* child window */
  5404.     Time       time;     /* milliseconds */
  5405.     int        x, y;     /* x, y coordinates in event window */
  5406.     int        x_root;     /* coordinates relative to root */
  5407.  
  5408.  
  5409.  
  5410.                  79
  5411.  
  5412.  
  5413.  
  5414.  
  5415.  
  5416. X Input Extension Library            X11, Release 6.4
  5417.  
  5418.  
  5419.     int        y_root;     /* coordinates relative to root */
  5420.     unsigned int   state;     /* key or button mask */
  5421.     unsigned int   keycode;     /* detail */
  5422.     Bool       same_screen;  /* same screen flag */
  5423.     unsigned int   device_state; /* device key or button mask */
  5424.     unsigned char  axes_count;
  5425.     unsigned char  first_axis;
  5426.     int        axis_data[6];
  5427.     } XDeviceKeyEvent;
  5428.  
  5429. typedef XDeviceKeyEvent XDeviceKeyPressedEvent;
  5430. typedef XDeviceKeyEvent XDeviceKeyReleasedEvent;
  5431.  
  5432. /*******************************************************************
  5433.  *
  5434.  * DeviceButton events.  These events are sent by extension devices
  5435.  * that support input class Buttons.
  5436.  *
  5437.  */
  5438.  
  5439. typedef struct {
  5440.     int       type;     /* of event */
  5441.     unsigned long serial;    /* # of last request processed by server */
  5442.     Bool      send_event;    /* true if from a SendEvent request */
  5443.     Display      *display;    /* Display the event was read from */
  5444.     Window      window;    /* "event" window reported relative to */
  5445.     XID       deviceid;
  5446.     Window      root;     /* root window that the event occured on */
  5447.     Window      subwindow;    /* child window */
  5448.     Time      time;     /* milliseconds */
  5449.     int       x, y;     /* x, y coordinates in event window */
  5450.     int       x_root;    /* coordinates relative to root */
  5451.     int       y_root;    /* coordinates relative to root */
  5452.     unsigned int  state;    /* key or button mask */
  5453.     unsigned int  button;    /* detail */
  5454.     Bool      same_screen;    /* same screen flag */
  5455.     unsigned int  device_state; /* device key or button mask */
  5456.     unsigned char axes_count;
  5457.     unsigned char first_axis;
  5458.     int       axis_data[6];
  5459.     } XDeviceButtonEvent;
  5460.  
  5461. typedef XDeviceButtonEvent XDeviceButtonPressedEvent;
  5462. typedef XDeviceButtonEvent XDeviceButtonReleasedEvent;
  5463.  
  5464. /*******************************************************************
  5465.  *
  5466.  * DeviceMotionNotify event.  These events are sent by extension devices
  5467.  * that support input class Valuators.
  5468.  *
  5469.  */
  5470.  
  5471. typedef struct
  5472.     {
  5473.  
  5474.  
  5475.  
  5476.                  80
  5477.  
  5478.  
  5479.  
  5480.  
  5481.  
  5482. X Input Extension Library            X11, Release 6.4
  5483.  
  5484.  
  5485.     int       type;        /* of event */
  5486.     unsigned long serial;      /* # of last request processed by server */
  5487.     Bool      send_event;  /* true if from a SendEvent request */
  5488.     Display      *display;    /* Display the event was read from */
  5489.     Window      window;      /* "event" window reported relative to */
  5490.     XID       deviceid;
  5491.     Window      root;        /* root window that the event occured on */
  5492.     Window      subwindow;   /* child window */
  5493.     Time      time;        /* milliseconds */
  5494.     int       x, y;        /* x, y coordinates in event window */
  5495.     int       x_root;      /* coordinates relative to root */
  5496.     int       y_root;      /* coordinates relative to root */
  5497.     unsigned int  state;       /* key or button mask */
  5498.     char      is_hint;     /* detail */
  5499.     Bool      same_screen; /* same screen flag */
  5500.     unsigned int  device_state; /* device key or button mask */
  5501.     unsigned char axes_count;
  5502.     unsigned char first_axis;
  5503.     int       axis_data[6];
  5504.     } XDeviceMotionEvent;
  5505.  
  5506. /*******************************************************************
  5507.  *
  5508.  * DeviceFocusChange events.  These events are sent when the focus
  5509.  * of an extension device that can be focused is changed.
  5510.  *
  5511.  */
  5512.  
  5513. typedef struct
  5514.     {
  5515.     int       type;       /* of event */
  5516.     unsigned long serial;     /* # of last request processed by server */
  5517.     Bool      send_event; /* true if from a SendEvent request */
  5518.     Display      *display;   /* Display the event was read from */
  5519.     Window      window;     /* "event" window reported relative to */
  5520.     XID       deviceid;
  5521.     int       mode;       /* NotifyNormal, NotifyGrab, NotifyUngrab */
  5522.     int       detail;
  5523.      /*
  5524.       * NotifyAncestor, NotifyVirtual, NotifyInferior,
  5525.       * NotifyNonLinear,NotifyNonLinearVirtual, NotifyPointer,
  5526.       * NotifyPointerRoot, NotifyDetailNone
  5527.       */
  5528.     Time        time;
  5529.     } XDeviceFocusChangeEvent;
  5530.  
  5531. typedef XDeviceFocusChangeEvent XDeviceFocusInEvent;
  5532. typedef XDeviceFocusChangeEvent XDeviceFocusOutEvent;
  5533.  
  5534. /*******************************************************************
  5535.  *
  5536.  * ProximityNotify events.  These events are sent by those absolute
  5537.  * positioning devices that are capable of generating proximity information.
  5538.  *
  5539.  
  5540.  
  5541.  
  5542.                  81
  5543.  
  5544.  
  5545.  
  5546.  
  5547.  
  5548. X Input Extension Library            X11, Release 6.4
  5549.  
  5550.  
  5551.  */
  5552.  
  5553. typedef struct
  5554.     {
  5555.     int         type;      /* ProximityIn or ProximityOut */
  5556.     unsigned long   serial;    /* # of last request processed by server */
  5557.     Bool        send_event; /* true if this came from a SendEvent request */
  5558.     Display        *display;  /* Display the event was read from */
  5559.     Window        window;
  5560.     XID           deviceid;
  5561.     Window        root;
  5562.     Window        subwindow;
  5563.     Time        time;
  5564.     int         x, y;
  5565.     int         x_root, y_root;
  5566.     unsigned int    state;
  5567.     Bool        same_screen;
  5568.     unsigned int    device_state; /* device key or button mask */
  5569.     unsigned char   axes_count;
  5570.     unsigned char   first_axis;
  5571.     int         axis_data[6];
  5572.     } XProximityNotifyEvent;
  5573. typedef XProximityNotifyEvent XProximityInEvent;
  5574. typedef XProximityNotifyEvent XProximityOutEvent;
  5575.  
  5576. /*******************************************************************
  5577.  *
  5578.  * DeviceStateNotify events are generated on EnterWindow and FocusIn
  5579.  * for those clients who have selected DeviceState.
  5580.  *
  5581.  */
  5582.  
  5583. typedef struct
  5584.     {
  5585.     unsigned char   class;
  5586.     unsigned char   length;
  5587.     } XInputClass;
  5588.  
  5589. typedef struct {
  5590.     int       type;
  5591.     unsigned long serial;    /* # of last request processed by server */
  5592.     Bool      send_event;    /* true if this came from a SendEvent request */
  5593.     Display      *display;    /* Display the event was read from */
  5594.     Window      window;
  5595.     XID       deviceid;
  5596.     Time      time;
  5597.     int       num_classes;
  5598.     char    data[64];
  5599. } XDeviceStateNotifyEvent;
  5600.  
  5601. typedef struct {
  5602.     unsigned char   class;
  5603.     unsigned char   length;
  5604.     unsigned char   num_valuators;
  5605.  
  5606.  
  5607.  
  5608.                  82
  5609.  
  5610.  
  5611.  
  5612.  
  5613.  
  5614. X Input Extension Library            X11, Release 6.4
  5615.  
  5616.  
  5617.     unsigned char   mode;
  5618.     int          valuators[6];
  5619. } XValuatorStatus;
  5620.  
  5621. typedef struct {
  5622.     unsigned char   class;
  5623.     unsigned char   length;
  5624.     short      num_keys;
  5625.     char        keys[32];
  5626. } XKeyStatus;
  5627.  
  5628. typedef struct {
  5629.     unsigned char   class;
  5630.     unsigned char   length;
  5631.     short      num_buttons;
  5632.     char        buttons[32];
  5633. } XButtonStatus;
  5634.  
  5635. /*******************************************************************
  5636.  *
  5637.  * DeviceMappingNotify event.  This event is sent when the key mapping,
  5638.  * modifier mapping, or button mapping of an extension device is changed.
  5639.  *
  5640.  */
  5641.  
  5642. typedef struct {
  5643.     int       type;
  5644.     unsigned long serial;    /* # of last request processed by server */
  5645.     Bool      send_event;    /* true if this came from a SendEvent request */
  5646.     Display      *display;    /* Display the event was read from */
  5647.     Window      window;    /* unused */
  5648.     XID       deviceid;
  5649.     Time      time;
  5650.     int       request;    /* one of MappingModifier, MappingKeyboard,
  5651.                     MappingPointer */
  5652.     int       first_keycode;/* first keycode */
  5653.     int       count;    /* defines range of change w. first_keycode*/
  5654. } XDeviceMappingEvent;
  5655.  
  5656. /*******************************************************************
  5657.  *
  5658.  * ChangeDeviceNotify event.  This event is sent when an
  5659.  * XChangeKeyboard or XChangePointer request is made.
  5660.  *
  5661.  */
  5662.  
  5663. typedef struct {
  5664.     int       type;
  5665.     unsigned long serial;    /* # of last request processed by server */
  5666.     Bool      send_event;    /* true if this came from a SendEvent request */
  5667.     Display      *display;    /* Display the event was read from */
  5668.     Window      window;    /* unused */
  5669.     XID       deviceid;
  5670.     Time      time;
  5671.  
  5672.  
  5673.  
  5674.                  83
  5675.  
  5676.  
  5677.  
  5678.  
  5679.  
  5680. X Input Extension Library            X11, Release 6.4
  5681.  
  5682.  
  5683.     int       request;    /* NewPointer or NewKeyboard */
  5684. } XChangeDeviceNotifyEvent;
  5685.  
  5686. /*******************************************************************
  5687.  *
  5688.  * Control structures for input devices that support input class
  5689.  * Feedback.  These are used by the XGetFeedbackControl and
  5690.  * XChangeFeedbackControl functions.
  5691.  *
  5692.  */
  5693.  
  5694. typedef struct {
  5695.      XID        class;
  5696.      int        length;
  5697.      XID        id;
  5698. } XFeedbackState;
  5699.  
  5700. typedef struct {
  5701.     XID     class;
  5702.     int     length;
  5703.     XID     id;
  5704.     int     click;
  5705.     int     percent;
  5706.     int     pitch;
  5707.     int     duration;
  5708.     int     led_mask;
  5709.     int     global_auto_repeat;
  5710.     char    auto_repeats[32];
  5711. } XKbdFeedbackState;
  5712.  
  5713. typedef struct {
  5714.     XID     class;
  5715.     int     length;
  5716.     XID     id;
  5717.     int     accelNum;
  5718.     int     accelDenom;
  5719.     int     threshold;
  5720. } XPtrFeedbackState;
  5721.  
  5722. typedef struct {
  5723.     XID     class;
  5724.     int     length;
  5725.     XID     id;
  5726.     int     resolution;
  5727.     int     minVal;
  5728.     int     maxVal;
  5729. } XIntegerFeedbackState;
  5730.  
  5731. typedef struct {
  5732.     XID     class;
  5733.     int     length;
  5734.     XID     id;
  5735.     int     max_symbols;
  5736.     int     num_syms_supported;
  5737.  
  5738.  
  5739.  
  5740.                  84
  5741.  
  5742.  
  5743.  
  5744.  
  5745.  
  5746. X Input Extension Library            X11, Release 6.4
  5747.  
  5748.  
  5749.     KeySym  *syms_supported;
  5750. } XStringFeedbackState;
  5751.  
  5752. typedef struct {
  5753.     XID     class;
  5754.     int     length;
  5755.     XID     id;
  5756.     int     percent;
  5757.     int     pitch;
  5758.     int     duration;
  5759. } XBellFeedbackState;
  5760.  
  5761. typedef struct {
  5762.     XID     class;
  5763.     int     length;
  5764.     XID     id;
  5765.     int     led_values;
  5766.     int     led_mask;
  5767. } XLedFeedbackState;
  5768.  
  5769. typedef struct {
  5770.      XID        class;
  5771.      int        length;
  5772.      XID      id;
  5773. } XFeedbackControl;
  5774.  
  5775. typedef struct {
  5776.     XID     class;
  5777.     int     length;
  5778.     XID     id;
  5779.     int     accelNum;
  5780.     int     accelDenom;
  5781.     int     threshold;
  5782. } XPtrFeedbackControl;
  5783.  
  5784. typedef struct {
  5785.     XID     class;
  5786.     int     length;
  5787.     XID     id;
  5788.     int     click;
  5789.     int     percent;
  5790.     int     pitch;
  5791.     int     duration;
  5792.     int     led_mask;
  5793.     int     led_value;
  5794.     int     key;
  5795.     int     auto_repeat_mode;
  5796. } XKbdFeedbackControl;
  5797.  
  5798. typedef struct {
  5799.     XID     class;
  5800.     int     length;
  5801.     XID     id;
  5802.     int     num_keysyms;
  5803.  
  5804.  
  5805.  
  5806.                  85
  5807.  
  5808.  
  5809.  
  5810.  
  5811.  
  5812. X Input Extension Library            X11, Release 6.4
  5813.  
  5814.  
  5815.     KeySym  *syms_to_display;
  5816. } XStringFeedbackControl;
  5817.  
  5818. typedef struct {
  5819.     XID     class;
  5820.     int     length;
  5821.     XID     id;
  5822.     int     int_to_display;
  5823. } XIntegerFeedbackControl;
  5824.  
  5825. typedef struct {
  5826.     XID     class;
  5827.     int     length;
  5828.     XID     id;
  5829.     int     percent;
  5830.     int     pitch;
  5831.     int     duration;
  5832. } XBellFeedbackControl;
  5833.  
  5834. typedef struct {
  5835.     XID     class;
  5836.     int     length;
  5837.     XID     id;
  5838.     int     led_mask;
  5839.     int     led_values;
  5840. } XLedFeedbackControl;
  5841.  
  5842. /*******************************************************************
  5843.  *
  5844.  * Device control structures.
  5845.  *
  5846.  */
  5847.  
  5848. typedef struct {
  5849.      XID        control;
  5850.      int        length;
  5851. } XDeviceControl;
  5852.  
  5853. typedef struct {
  5854.      XID        control;
  5855.      int        length;
  5856.      int        first_valuator;
  5857.      int        num_valuators;
  5858.      int        *resolutions;
  5859. } XDeviceResolutionControl;
  5860.  
  5861. typedef struct {
  5862.      XID        control;
  5863.      int        length;
  5864.      int        num_valuators;
  5865.      int        *resolutions;
  5866.      int        *min_resolutions;
  5867.      int        *max_resolutions;
  5868. } XDeviceResolutionState;
  5869.  
  5870.  
  5871.  
  5872.                  86
  5873.  
  5874.  
  5875.  
  5876.  
  5877.  
  5878. X Input Extension Library            X11, Release 6.4
  5879.  
  5880.  
  5881. /*******************************************************************
  5882.  *
  5883.  * An array of XDeviceList structures is returned by the
  5884.  * XListInputDevices function.    Each entry contains information
  5885.  * about one input device.  Among that information is an array of
  5886.  * pointers to structures that describe the characteristics of
  5887.  * the input device.
  5888.  *
  5889.  */
  5890.  
  5891. typedef struct _XAnyClassinfo *XAnyClassPtr;
  5892.  
  5893. typedef struct _XAnyClassinfo {
  5894.     XID   class;
  5895.     int   length;
  5896.     } XAnyClassInfo;
  5897.  
  5898. typedef struct _XDeviceInfo *XDeviceInfoPtr;
  5899.  
  5900. typedef struct _XDeviceInfo
  5901.     {
  5902.     XID         id;
  5903.     Atom        type;
  5904.     char        *name;
  5905.     int         num_classes;
  5906.     int         use;
  5907.     XAnyClassPtr    inputclassinfo;
  5908.     } XDeviceInfo;
  5909.  
  5910. typedef struct _XKeyInfo *XKeyInfoPtr;
  5911.  
  5912. typedef struct _XKeyInfo
  5913.     {
  5914.     XID         class;
  5915.     int         length;
  5916.     unsigned short    min_keycode;
  5917.     unsigned short    max_keycode;
  5918.     unsigned short    num_keys;
  5919.     } XKeyInfo;
  5920.  
  5921. typedef struct _XButtonInfo *XButtonInfoPtr;
  5922.  
  5923. typedef struct _XButtonInfo {
  5924.     XID        class;
  5925.     int        length;
  5926.     short      num_buttons;
  5927.     } XButtonInfo;
  5928.  
  5929. typedef struct _XAxisInfo *XAxisInfoPtr;
  5930.  
  5931. typedef struct _XAxisInfo {
  5932.     int   resolution;
  5933.     int   min_value;
  5934.     int   max_value;
  5935.  
  5936.  
  5937.  
  5938.                  87
  5939.  
  5940.  
  5941.  
  5942.  
  5943.  
  5944. X Input Extension Library            X11, Release 6.4
  5945.  
  5946.  
  5947.     } XAxisInfo;
  5948.  
  5949. typedef struct _XValuatorInfo *XValuatorInfoPtr;
  5950.  
  5951. typedef struct _XValuatorInfo
  5952.     {
  5953.     XID         class;
  5954.     int         length;
  5955.     unsigned char    num_axes;
  5956.     unsigned char    mode;
  5957.     unsigned long    motion_buffer;
  5958.     XAxisInfoPtr    axes;
  5959.     } XValuatorInfo;
  5960.  
  5961.  
  5962. /*******************************************************************
  5963.  *
  5964.  * An XDevice structure is returned by the XOpenDevice function.
  5965.  * It contains an array of pointers to XInputClassInfo structures.
  5966.  * Each contains information about a class of input supported by the
  5967.  * device, including a pointer to an array of data for each type of event
  5968.  * the device reports.
  5969.  *
  5970.  */
  5971.  
  5972.  
  5973. typedef struct {
  5974.     unsigned char    input_class;
  5975.     unsigned char    event_type_base;
  5976. } XInputClassInfo;
  5977.  
  5978. typedef struct {
  5979.     XID               device_id;
  5980.     int               num_classes;
  5981.     XInputClassInfo        *classes;
  5982. } XDevice;
  5983.  
  5984.  
  5985. /*******************************************************************
  5986.  *
  5987.  * The following structure is used to return information for the
  5988.  * XGetSelectedExtensionEvents function.
  5989.  *
  5990.  */
  5991.  
  5992. typedef struct {
  5993.     XEventClass    event_type;
  5994.     XID        device;
  5995. } XEventList;
  5996.  
  5997. /*******************************************************************
  5998.  *
  5999.  * The following structure is used to return motion history data from
  6000.  * an input device that supports the input class Valuators.
  6001.  
  6002.  
  6003.  
  6004.                  88
  6005.  
  6006.  
  6007.  
  6008.  
  6009.  
  6010. X Input Extension Library            X11, Release 6.4
  6011.  
  6012.  
  6013.  * This information is returned by the XGetDeviceMotionEvents function.
  6014.  *
  6015.  */
  6016.  
  6017. typedef struct {
  6018.     Time   time;
  6019.     int    *data;
  6020. } XDeviceTimeCoord;
  6021.  
  6022.  
  6023. /*******************************************************************
  6024.  *
  6025.  * Device state structure.
  6026.  * This is returned by the XQueryDeviceState request.
  6027.  *
  6028.  */
  6029.  
  6030. typedef struct {
  6031.     XID        device_id;
  6032.     int        num_classes;
  6033.     XInputClass *data;
  6034. } XDeviceState;
  6035.  
  6036. /*******************************************************************
  6037.  *
  6038.  * Note that the mode field is a bitfield that reports the Proximity
  6039.  * status of the device as well as the mode.  The mode field should
  6040.  * be OR'd with the mask DeviceMode and compared with the values
  6041.  * Absolute and Relative to determine the mode, and should be OR'd
  6042.  * with the mask ProximityState and compared with the values InProximity
  6043.  * and OutOfProximity to determine the proximity state.
  6044.  *
  6045.  */
  6046.  
  6047. typedef struct {
  6048.     unsigned char   class;
  6049.     unsigned char   length;
  6050.     unsigned char   num_valuators;
  6051.     unsigned char   mode;
  6052.     int          *valuators;
  6053. } XValuatorState;
  6054.  
  6055. typedef struct {
  6056.     unsigned char   class;
  6057.     unsigned char   length;
  6058.     short      num_keys;
  6059.     char        keys[32];
  6060. } XKeyState;
  6061.  
  6062. typedef struct {
  6063.     unsigned char   class;
  6064.     unsigned char   length;
  6065.     short      num_buttons;
  6066.     char        buttons[32];
  6067.  
  6068.  
  6069.  
  6070.                  89
  6071.  
  6072.  
  6073.  
  6074.  
  6075.  
  6076. X Input Extension Library            X11, Release 6.4
  6077.  
  6078.  
  6079. } XButtonState;
  6080.  
  6081. /*******************************************************************
  6082.  *
  6083.  * Function definitions.
  6084.  *
  6085.  */
  6086.  
  6087. _XFUNCPROTOBEGIN
  6088.  
  6089. extern int     XChangeKeyboardDevice(
  6090. #if NeedFunctionPrototypes
  6091.     Display*        /* display */,
  6092.     XDevice*        /* device */
  6093. #endif
  6094. );
  6095.  
  6096. extern int     XChangePointerDevice(
  6097. #if NeedFunctionPrototypes
  6098.     Display*        /* display */,
  6099.     XDevice*        /* device */,
  6100.     int         /* xaxis */,
  6101.     int         /* yaxis */
  6102. #endif
  6103. );
  6104.  
  6105. extern int     XGrabDevice(
  6106. #if NeedFunctionPrototypes
  6107.     Display*        /* display */,
  6108.     XDevice*        /* device */,
  6109.     Window        /* grab_window */,
  6110.     Bool       /* ownerEvents */,
  6111.     int         /* event count */,
  6112.     XEventClass*    /* event_list */,
  6113.     int         /* this_device_mode */,
  6114.     int         /* other_devices_mode */,
  6115.     Time       /* time */
  6116. #endif
  6117. );
  6118.  
  6119. extern int     XUngrabDevice(
  6120. #if NeedFunctionPrototypes
  6121.     Display*        /* display */,
  6122.     XDevice*        /* device */,
  6123.     Time       /* time */
  6124. #endif
  6125. );
  6126.  
  6127. extern int     XGrabDeviceKey(
  6128. #if NeedFunctionPrototypes
  6129.     Display*        /* display */,
  6130.     XDevice*        /* device */,
  6131.     unsigned int    /* key */,
  6132.     unsigned int    /* modifiers */,
  6133.  
  6134.  
  6135.  
  6136.                  90
  6137.  
  6138.  
  6139.  
  6140.  
  6141.  
  6142. X Input Extension Library            X11, Release 6.4
  6143.  
  6144.  
  6145.     XDevice*        /* modifier_device */,
  6146.     Window        /* grab_window */,
  6147.     Bool       /* owner_events */,
  6148.     unsigned int    /* event_count */,
  6149.     XEventClass*    /* event_list */,
  6150.     int         /* this_device_mode */,
  6151.     int         /* other_devices_mode */
  6152. #endif
  6153. );
  6154.  
  6155. extern int     XUngrabDeviceKey(
  6156. #if NeedFunctionPrototypes
  6157.     Display*        /* display */,
  6158.     XDevice*        /* device */,
  6159.     unsigned int    /* key */,
  6160.     unsigned int    /* modifiers */,
  6161.     XDevice*        /* modifier_dev */,
  6162.     Window        /* grab_window */
  6163. #endif
  6164. );
  6165.  
  6166. extern int     XGrabDeviceButton(
  6167. #if NeedFunctionPrototypes
  6168.     Display*        /* display */,
  6169.     XDevice*        /* device */,
  6170.     unsigned int    /* button */,
  6171.     unsigned int    /* modifiers */,
  6172.     XDevice*        /* modifier_device */,
  6173.     Window        /* grab_window */,
  6174.     Bool       /* owner_events */,
  6175.     unsigned int    /* event_count */,
  6176.     XEventClass*    /* event_list */,
  6177.     int         /* this_device_mode */,
  6178.     int         /* other_devices_mode */
  6179. #endif
  6180. );
  6181.  
  6182. extern int     XUngrabDeviceButton(
  6183. #if NeedFunctionPrototypes
  6184.     Display*        /* display */,
  6185.     XDevice*        /* device */,
  6186.     unsigned int    /* button */,
  6187.     unsigned int    /* modifiers */,
  6188.     XDevice*        /* modifier_dev */,
  6189.     Window        /* grab_window */
  6190. #endif
  6191. );
  6192.  
  6193. extern int     XAllowDeviceEvents(
  6194. #if NeedFunctionPrototypes
  6195.     Display*        /* display */,
  6196.     XDevice*        /* device */,
  6197.     int         /* event_mode */,
  6198.     Time       /* time */
  6199.  
  6200.  
  6201.  
  6202.                  91
  6203.  
  6204.  
  6205.  
  6206.  
  6207.  
  6208. X Input Extension Library            X11, Release 6.4
  6209.  
  6210.  
  6211. #endif
  6212. );
  6213.  
  6214. extern int     XGetDeviceFocus(
  6215. #if NeedFunctionPrototypes
  6216.     Display*        /* display */,
  6217.     XDevice*        /* device */,
  6218.     Window*        /* focus */,
  6219.     int*       /* revert_to */,
  6220.     Time*      /* time */
  6221. #endif
  6222. );
  6223.  
  6224. extern int     XSetDeviceFocus(
  6225. #if NeedFunctionPrototypes
  6226.     Display*        /* display */,
  6227.     XDevice*        /* device */,
  6228.     Window        /* focus */,
  6229.     int         /* revert_to */,
  6230.     Time       /* time */
  6231. #endif
  6232. );
  6233.  
  6234. extern XFeedbackState     *XGetFeedbackControl(
  6235. #if NeedFunctionPrototypes
  6236.     Display*        /* display */,
  6237.     XDevice*        /* device */,
  6238.     int*       /* num_feedbacks */
  6239. #endif
  6240. );
  6241.  
  6242. extern int     XFreeFeedbackList(
  6243. #if NeedFunctionPrototypes
  6244.     XFeedbackState* /* list */
  6245. #endif
  6246. );
  6247.  
  6248. extern int     XChangeFeedbackControl(
  6249. #if NeedFunctionPrototypes
  6250.     Display*        /* display */,
  6251.     XDevice*        /* device */,
  6252.     unsigned long   /* mask */,
  6253.     XFeedbackControl*     /* f */
  6254. #endif
  6255. );
  6256.  
  6257. extern int     XDeviceBell(
  6258. #if NeedFunctionPrototypes
  6259.     Display*        /* display */,
  6260.     XDevice*        /* device */,
  6261.     XID         /* feedbackclass */,
  6262.     XID         /* feedbackid */,
  6263.     int         /* percent */
  6264. #endif
  6265.  
  6266.  
  6267.  
  6268.                  92
  6269.  
  6270.  
  6271.  
  6272.  
  6273.  
  6274. X Input Extension Library            X11, Release 6.4
  6275.  
  6276.  
  6277. );
  6278.  
  6279. extern KeySym  *XGetDeviceKeyMapping(
  6280. #if NeedFunctionPrototypes
  6281.     Display*        /* display */,
  6282.     XDevice*        /* device */,
  6283. #if NeedWidePrototypes
  6284.     unsigned int    /* first */,
  6285. #else
  6286.     KeyCode        /* first */,
  6287. #endif
  6288.     int         /* keycount */,
  6289.     int*       /* syms_per_code */
  6290. #endif
  6291. );
  6292.  
  6293. extern int     XChangeDeviceKeyMapping(
  6294. #if NeedFunctionPrototypes
  6295.     Display*        /* display */,
  6296.     XDevice*        /* device */,
  6297.     int         /* first */,
  6298.     int         /* syms_per_code */,
  6299.     KeySym*        /* keysyms */,
  6300.     int         /* count */
  6301. #endif
  6302. );
  6303.  
  6304. extern XModifierKeymap     *XGetDeviceModifierMapping(
  6305. #if NeedFunctionPrototypes
  6306.     Display*        /* display */,
  6307.     XDevice*        /* device */
  6308. #endif
  6309. );
  6310.  
  6311. extern int     XSetDeviceModifierMapping(
  6312. #if NeedFunctionPrototypes
  6313.     Display*        /* display */,
  6314.     XDevice*        /* device */,
  6315.     XModifierKeymap*     /* modmap */
  6316. #endif
  6317. );
  6318.  
  6319. extern int     XSetDeviceButtonMapping(
  6320. #if NeedFunctionPrototypes
  6321.     Display*        /* display */,
  6322.     XDevice*        /* device */,
  6323.     unsigned char*  /* map[] */,
  6324.     int         /* nmap */
  6325. #endif
  6326. );
  6327.  
  6328. extern int     XGetDeviceButtonMapping(
  6329. #if NeedFunctionPrototypes
  6330.     Display*        /* display */,
  6331.  
  6332.  
  6333.  
  6334.                  93
  6335.  
  6336.  
  6337.  
  6338.  
  6339.  
  6340. X Input Extension Library            X11, Release 6.4
  6341.  
  6342.  
  6343.     XDevice*        /* device */,
  6344.     unsigned char*  /* map[] */,
  6345.     unsigned int    /* nmap */
  6346. #endif
  6347. );
  6348.  
  6349. extern XDeviceState *XQueryDeviceState(
  6350. #if NeedFunctionPrototypes
  6351.     Display*        /* display */,
  6352.     XDevice*        /* device */
  6353. #endif
  6354. );
  6355.  
  6356. extern int     XFreeDeviceState(
  6357. #if NeedFunctionPrototypes
  6358.     XDeviceState*   /* list */
  6359. #endif
  6360. );
  6361.  
  6362. extern XExtensionVersion *XGetExtensionVersion(
  6363. #if NeedFunctionPrototypes
  6364.     Display*        /* display */,
  6365.     _Xconst char*   /* name */
  6366. #endif
  6367. );
  6368.  
  6369. extern XDeviceInfo  *XListInputDevices(
  6370. #if NeedFunctionPrototypes
  6371.     Display*        /* display */,
  6372.     int*       /* ndevices */
  6373. #endif
  6374. );
  6375.  
  6376. extern int     XFreeDeviceList(
  6377. #if NeedFunctionPrototypes
  6378.     XDeviceInfo*    /* list */
  6379. #endif
  6380. );
  6381.  
  6382. extern XDevice *XOpenDevice(
  6383. #if NeedFunctionPrototypes
  6384.     Display*        /* display */,
  6385.     XID         /* id */
  6386. #endif
  6387. );
  6388.  
  6389. extern int     XCloseDevice(
  6390. #if NeedFunctionPrototypes
  6391.     Display*        /* display */,
  6392.     XDevice*        /* device */
  6393. #endif
  6394. );
  6395.  
  6396. extern int     XSetDeviceMode(
  6397.  
  6398.  
  6399.  
  6400.                  94
  6401.  
  6402.  
  6403.  
  6404.  
  6405.  
  6406. X Input Extension Library            X11, Release 6.4
  6407.  
  6408.  
  6409. #if NeedFunctionPrototypes
  6410.     Display*        /* display */,
  6411.     XDevice*        /* device */,
  6412.     int         /* mode */
  6413. #endif
  6414. );
  6415.  
  6416. extern int     XSetDeviceValuators(
  6417. #if NeedFunctionPrototypes
  6418.     Display*        /* display */,
  6419.     XDevice*        /* device */,
  6420.     int*       /* valuators */,
  6421.     int         /* first_valuator */,
  6422.     int         /* num_valuators */
  6423. #endif
  6424. );
  6425.  
  6426. extern XDeviceControl     *XGetDeviceControl(
  6427. #if NeedFunctionPrototypes
  6428.     Display*        /* display */,
  6429.     XDevice*        /* device */,
  6430.     int         /* control */
  6431. #endif
  6432. );
  6433.  
  6434. extern int     XChangeDeviceControl(
  6435. #if NeedFunctionPrototypes
  6436.     Display*        /* display */,
  6437.     XDevice*        /* device */,
  6438.     int         /* control */,
  6439.     XDeviceControl* /* d */
  6440. #endif
  6441. );
  6442.  
  6443. extern int     XSelectExtensionEvent(
  6444. #if NeedFunctionPrototypes
  6445.     Display*        /* display */,
  6446.     Window        /* w */,
  6447.     XEventClass*    /* event_list */,
  6448.     int         /* count */
  6449. #endif
  6450. );
  6451.  
  6452. extern int     XGetSelectedExtensionEvents(
  6453. #if NeedFunctionPrototypes
  6454.     Display*        /* display */,
  6455.     Window        /* w */,
  6456.     int*       /* this_client_count */,
  6457.     XEventClass**   /* this_client_list */,
  6458.     int*       /* all_clients_count */,
  6459.     XEventClass**   /* all_clients_list */
  6460. #endif
  6461. );
  6462.  
  6463.  
  6464.  
  6465.  
  6466.                  95
  6467.  
  6468.  
  6469.  
  6470.  
  6471.  
  6472. X Input Extension Library            X11, Release 6.4
  6473.  
  6474.  
  6475. extern int     XChangeDeviceDontPropagateList(
  6476. #if NeedFunctionPrototypes
  6477.     Display*        /* display */,
  6478.     Window        /* window */,
  6479.     int         /* count */,
  6480.     XEventClass*    /* events */,
  6481.     int         /* mode */
  6482. #endif
  6483. );
  6484.  
  6485. extern XEventClass  *XGetDeviceDontPropagateList(
  6486. #if NeedFunctionPrototypes
  6487.     Display*        /* display */,
  6488.     Window        /* window */,
  6489.     int*       /* count */
  6490. #endif
  6491. );
  6492.  
  6493. extern Status  XSendExtensionEvent(
  6494. #if NeedFunctionPrototypes
  6495.     Display*        /* display */,
  6496.     XDevice*        /* device */,
  6497.     Window        /* dest */,
  6498.     Bool       /* prop */,
  6499.     int         /* count */,
  6500.     XEventClass*    /* list */,
  6501.     XEvent*        /* event */
  6502. #endif
  6503. );
  6504.  
  6505. extern XDeviceTimeCoord  *XGetDeviceMotionEvents(
  6506. #if NeedFunctionPrototypes
  6507.     Display*        /* display */,
  6508.     XDevice*        /* device */,
  6509.     Time       /* start */,
  6510.     Time       /* stop */,
  6511.     int*       /* nEvents */,
  6512.     int*       /* mode */,
  6513.     int*       /* axis_count */
  6514. #endif
  6515. );
  6516.  
  6517. extern int     XFreeDeviceMotionEvents(
  6518. #if NeedFunctionPrototypes
  6519.     XDeviceTimeCoord*     /* events */
  6520. #endif
  6521. );
  6522.  
  6523. extern int     XFreeDeviceControl(
  6524. #if NeedFunctionPrototypes
  6525.     XDeviceControl* /* control */
  6526. #endif
  6527. );
  6528.  
  6529.  
  6530.  
  6531.  
  6532.                  96
  6533.  
  6534.  
  6535.  
  6536.  
  6537.  
  6538. X Input Extension Library            X11, Release 6.4
  6539.  
  6540.  
  6541. _XFUNCPROTOEND
  6542.  
  6543. #endif /* _XINPUT_H_ */
  6544.  
  6545. /* Definitions used by the server, library and client */
  6546.  
  6547. #ifndef _XI_H_
  6548.  
  6549. #define _XI_H_
  6550.  
  6551. #define sz_xGetExtensionVersionReq    8
  6552. #define sz_xGetExtensionVersionReply         32
  6553. #define sz_xListInputDevicesReq          4
  6554. #define sz_xListInputDevicesReply    32
  6555. #define sz_xOpenDeviceReq        8
  6556. #define sz_xOpenDeviceReply        32
  6557. #define sz_xCloseDeviceReq        8
  6558. #define sz_xSetDeviceModeReq        8
  6559. #define sz_xSetDeviceModeReply             32
  6560. #define sz_xSelectExtensionEventReq         12
  6561. #define sz_xGetSelectedExtensionEventsReq    8
  6562. #define sz_xGetSelectedExtensionEventsReply  32
  6563. #define sz_xChangeDeviceDontPropagateListReq 12
  6564. #define sz_xGetDeviceDontPropagateListReq    8
  6565. #define sz_xGetDeviceDontPropagateListReply  32
  6566. #define sz_xGetDeviceMotionEventsReq         16
  6567. #define sz_xGetDeviceMotionEventsReply         32
  6568. #define sz_xChangeKeyboardDeviceReq         8
  6569. #define sz_xChangeKeyboardDeviceReply         32
  6570. #define sz_xChangePointerDeviceReq    8
  6571. #define sz_xChangePointerDeviceReply         32
  6572. #define sz_xGrabDeviceReq        20
  6573. #define sz_xGrabDeviceReply        32
  6574. #define sz_xUngrabDeviceReq        12
  6575. #define sz_xGrabDeviceKeyReq        20
  6576. #define sz_xGrabDeviceKeyReply             32
  6577. #define sz_xUngrabDeviceKeyReq             16
  6578. #define sz_xGrabDeviceButtonReq          20
  6579. #define sz_xGrabDeviceButtonReply    32
  6580. #define sz_xUngrabDeviceButtonReq    16
  6581. #define sz_xAllowDeviceEventsReq    12
  6582. #define sz_xGetDeviceFocusReq        8
  6583. #define sz_xGetDeviceFocusReply          32
  6584. #define sz_xSetDeviceFocusReq        16
  6585. #define sz_xGetFeedbackControlReq    8
  6586. #define sz_xGetFeedbackControlReply         32
  6587. #define sz_xChangeFeedbackControlReq         12
  6588. #define sz_xGetDeviceKeyMappingReq    8
  6589. #define sz_xGetDeviceKeyMappingReply         32
  6590. #define sz_xChangeDeviceKeyMappingReq         8
  6591. #define sz_xGetDeviceModifierMappingReq      8
  6592. #define sz_xSetDeviceModifierMappingReq      8
  6593. #define sz_xSetDeviceModifierMappingReply    32
  6594. #define sz_xGetDeviceButtonMappingReq         8
  6595.  
  6596.  
  6597.  
  6598.                  97
  6599.  
  6600.  
  6601.  
  6602.  
  6603.  
  6604. X Input Extension Library            X11, Release 6.4
  6605.  
  6606.  
  6607. #define sz_xGetDeviceButtonMappingReply      32
  6608. #define sz_xSetDeviceButtonMappingReq         8
  6609. #define sz_xSetDeviceButtonMappingReply      32
  6610. #define sz_xQueryDeviceStateReq          8
  6611. #define sz_xQueryDeviceStateReply    32
  6612. #define sz_xSendExtensionEventReq    16
  6613. #define sz_xDeviceBellReq        8
  6614. #define sz_xSetDeviceValuatorsReq    8
  6615. #define sz_xSetDeviceValuatorsReply         32
  6616. #define sz_xGetDeviceControlReq          8
  6617. #define sz_xGetDeviceControlReply    32
  6618. #define sz_xChangeDeviceControlReq    8
  6619. #define sz_xChangeDeviceControlReply         32
  6620.  
  6621. #define INAME         "XInputExtension"
  6622.  
  6623. #define XI_KEYBOARD "KEYBOARD"
  6624. #define XI_MOUSE    "MOUSE"
  6625. #define XI_TABLET   "TABLET"
  6626. #define XI_TOUCHSCREEN     "TOUCHSCREEN"
  6627. #define XI_TOUCHPAD "TOUCHPAD"
  6628. #define XI_BARCODE  "BARCODE"
  6629. #define XI_BUTTONBOX     "BUTTONBOX"
  6630. #define XI_KNOB_BOX "KNOB_BOX"
  6631. #define XI_ONE_KNOB "ONE_KNOB"
  6632. #define XI_NINE_KNOB     "NINE_KNOB"
  6633. #define XI_TRACKBALL     "TRACKBALL"
  6634. #define XI_QUADRATURE     "QUADRATURE"
  6635. #define XI_ID_MODULE     "ID_MODULE"
  6636. #define XI_SPACEBALL     "SPACEBALL"
  6637. #define XI_DATAGLOVE     "DATAGLOVE"
  6638. #define XI_EYETRACKER     "EYETRACKER"
  6639. #define XI_CURSORKEYS     "CURSORKEYS"
  6640. #define XI_FOOTMOUSE     "FOOTMOUSE"
  6641.  
  6642. #define Dont_Check          0
  6643. #define XInput_Initial_Release        1
  6644. #define XInput_Add_XDeviceBell        2
  6645. #define XInput_Add_XSetDeviceValuators    3
  6646. #define XInput_Add_XChangeDeviceControl 4
  6647.  
  6648. #define XI_Absent     0
  6649. #define XI_Present     1
  6650.  
  6651. #define XI_Initial_Release_Major    1
  6652. #define XI_Initial_Release_Minor    0
  6653.  
  6654. #define XI_Add_XDeviceBell_Major    1
  6655. #define XI_Add_XDeviceBell_Minor    1
  6656.  
  6657. #define XI_Add_XSetDeviceValuators_Major     1
  6658. #define XI_Add_XSetDeviceValuators_Minor     2
  6659.  
  6660. #define XI_Add_XChangeDeviceControl_Major    1
  6661.  
  6662.  
  6663.  
  6664.                  98
  6665.  
  6666.  
  6667.  
  6668.  
  6669.  
  6670. X Input Extension Library            X11, Release 6.4
  6671.  
  6672.  
  6673. #define XI_Add_XChangeDeviceControl_Minor    3
  6674.  
  6675. #define DEVICE_RESOLUTION     1
  6676.  
  6677. #define NoSuchExtension       1
  6678.  
  6679. #define COUNT         0
  6680. #define CREATE         1
  6681.  
  6682. #define NewPointer     0
  6683. #define NewKeyboard     1
  6684.  
  6685. #define XPOINTER     0
  6686. #define XKEYBOARD     1
  6687.  
  6688. #define UseXKeyboard          0xFF
  6689.  
  6690. #define IsXPointer     0
  6691. #define IsXKeyboard     1
  6692. #define IsXExtensionDevice    2
  6693.  
  6694. #define AsyncThisDevice       0
  6695. #define SyncThisDevice          1
  6696. #define ReplayThisDevice 2
  6697. #define AsyncOtherDevices     3
  6698. #define AsyncAll     4
  6699. #define SyncAll           5
  6700.  
  6701. #define FollowKeyboard          3
  6702. #define RevertToFollowKeyboard       3
  6703.  
  6704. #define DvAccelNum        (1L << 0)
  6705. #define DvAccelDenom        (1L << 1)
  6706. #define DvThreshold        (1L << 2)
  6707.  
  6708. #define DvKeyClickPercent     (1L<<0)
  6709. #define DvPercent     (1L<<1)
  6710. #define DvPitch           (1L<<2)
  6711. #define DvDuration     (1L<<3)
  6712. #define DvLed         (1L<<4)
  6713. #define DvLedMode     (1L<<5)
  6714. #define DvKey         (1L<<6)
  6715. #define DvAutoRepeatMode (1L<<7)
  6716.  
  6717. #define DvString        (1L << 0)
  6718.  
  6719. #define DvInteger        (1L << 0)
  6720.  
  6721. #define DeviceMode        (1L << 0)
  6722. #define Relative        0
  6723. #define Absolute        1
  6724.  
  6725. #define ProximityState        (1L << 1)
  6726. #define InProximity        (0L << 1)
  6727.  
  6728.  
  6729.  
  6730.                  99
  6731.  
  6732.  
  6733.  
  6734.  
  6735.  
  6736. X Input Extension Library            X11, Release 6.4
  6737.  
  6738.  
  6739. #define OutOfProximity        (1L << 1)
  6740.  
  6741. #define AddToList        0
  6742. #define DeleteFromList        1
  6743.  
  6744. #define KeyClass     0
  6745. #define ButtonClass          1
  6746. #define ValuatorClass          2
  6747. #define FeedbackClass          3
  6748. #define ProximityClass     4
  6749. #define FocusClass          5
  6750. #define OtherClass          6
  6751.  
  6752. #define KbdFeedbackClass      0
  6753. #define PtrFeedbackClass      1
  6754. #define StringFeedbackClass   2
  6755. #define IntegerFeedbackClass       3
  6756. #define LedFeedbackClass      4
  6757. #define BellFeedbackClass     5
  6758.  
  6759. #define _devicePointerMotionHint 0
  6760. #define _deviceButton1Motion   1
  6761. #define _deviceButton2Motion   2
  6762. #define _deviceButton3Motion   3
  6763. #define _deviceButton4Motion   4
  6764. #define _deviceButton5Motion   5
  6765. #define _deviceButtonMotion    6
  6766. #define _deviceButtonGrab      7
  6767. #define _deviceOwnerGrabButton        8
  6768. #define _noExtensionEvent      9
  6769.  
  6770. #define XI_BadDevice     0
  6771. #define XI_BadEvent 1
  6772. #define XI_BadMode  2
  6773. #define XI_DeviceBusy     3
  6774. #define XI_BadClass 4
  6775.  
  6776. typedef   unsigned long  XEventClass;
  6777.  
  6778. /*******************************************************************
  6779.  *
  6780.  * Extension version structure.
  6781.  *
  6782.  */
  6783.  
  6784. typedef struct {
  6785.     int    present;
  6786.     short  major_version;
  6787.     short  minor_version;
  6788. } XExtensionVersion;
  6789.  
  6790. #endif /* _XI_H_ */
  6791.  
  6792.  
  6793.  
  6794.  
  6795.  
  6796.                  100
  6797.  
  6798.  
  6799.  
  6800.  
  6801.  
  6802. X Input Extension Library            X11, Release 6.4
  6803.  
  6804.  
  6805.  
  6806.  
  6807.  
  6808.  
  6809.  
  6810.  
  6811.  
  6812.  
  6813.  
  6814.  
  6815.  
  6816.  
  6817.  
  6818.  
  6819.  
  6820.  
  6821.  
  6822.  
  6823.  
  6824.  
  6825.  
  6826.  
  6827.  
  6828.  
  6829.  
  6830.  
  6831.  
  6832.  
  6833.  
  6834.  
  6835.  
  6836.  
  6837.  
  6838.  
  6839.  
  6840.  
  6841.  
  6842.  
  6843.  
  6844.  
  6845.  
  6846.  
  6847.  
  6848.  
  6849.  
  6850.  
  6851.  
  6852.  
  6853.  
  6854.  
  6855.  
  6856.  
  6857.  
  6858.  
  6859.  
  6860.  
  6861.  
  6862.                  101
  6863.  
  6864.  
  6865.  
  6866.  
  6867.  
  6868.  
  6869.  
  6870.  
  6871.              Table of Contents
  6872.  
  6873.  
  6874. 1. Input Extension Overview  . . . . . . . . . . . . . .   1
  6875. 1.1. Design Approach . . . . . . . . . . . . . . . . . .   1
  6876. 1.2. Core Input Devices  . . . . . . . . . . . . . . . .   1
  6877. 1.3. Extension Input Devices . . . . . . . . . . . . . .   2
  6878. 1.3.1. Input Device Classes  . . . . . . . . . . . . . .   3
  6879. 1.4. Using Extension Input Devices . . . . . . . . . . .   3
  6880. 2. Library Extension Requests  . . . . . . . . . . . . .   4
  6881. 2.1. Window Manager Functions  . . . . . . . . . . . . .   4
  6882. 2.1.1. Changing the Core Devices . . . . . . . . . . . .   5
  6883. 2.1.2. Event Synchronization and Core Grabs  . . . . . .   7
  6884. 2.1.3. Extension Active Grabs  . . . . . . . . . . . . .   8
  6885. 2.1.4. Passively Grabbing a Key  . . . . . . . . . . . .  11
  6886. 2.1.5. Passively Grabbing a Button . . . . . . . . . . .  16
  6887. 2.1.6. Thawing a Device  . . . . . . . . . . . . . . . .  21
  6888. 2.1.7. Controlling Device Focus  . . . . . . . . . . . .  23
  6889. 2.1.8. Controlling Device Feedback . . . . . . . . . . .  26
  6890. 2.1.9. Ringing a Bell on an Input Device . . . . . . . .  37
  6891. 2.1.10. Controlling Device Encoding  . . . . . . . . . .  38
  6892. 2.1.11. Controlling Button Mapping . . . . . . . . . . .  41
  6893. 2.1.12. Obtaining the State of a Device  . . . . . . . .  43
  6894. 2.2. Events  . . . . . . . . . . . . . . . . . . . . . .  46
  6895. 2.2.1. Event Types . . . . . . . . . . . . . . . . . . .  46
  6896. 2.2.2. Event Classes . . . . . . . . . . . . . . . . . .  47
  6897. 2.2.3. Event Structures  . . . . . . . . . . . . . . . .  48
  6898. 2.2.3.1. Device Key Events . . . . . . . . . . . . . . .  48
  6899. 2.2.3.2. Device Button Events  . . . . . . . . . . . . .  49
  6900. 2.2.3.3. Device Motion Events  . . . . . . . . . . . . .  50
  6901. 2.2.3.4. Device Focus Events . . . . . . . . . . . . . .  51
  6902. 2.2.3.5. Device StateNotify Event  . . . . . . . . . . .  52
  6903. 2.2.3.6. Device Mapping Event  . . . . . . . . . . . . .  53
  6904. 2.2.3.7. ChangeDeviceNotify Event  . . . . . . . . . . .  54
  6905. 2.2.3.8. Proximity Events  . . . . . . . . . . . . . . .  54
  6906. 2.3. Event Handling Functions  . . . . . . . . . . . . .  55
  6907. 2.3.1. Determining the Extension Version . . . . . . . .  56
  6908. 2.3.2. Listing Available Devices . . . . . . . . . . . .  56
  6909. 2.3.3. Enabling and Disabling Extension Devices  . . . .  59
  6910. 2.3.4. Changing the Mode of a Device . . . . . . . . . .  61
  6911. 2.3.5. Initializing Valuators on an Input Device . . . .  62
  6912. 2.3.6. Getting Input Device Controls . . . . . . . . . .  63
  6913. 2.3.7. Changing Input Device Controls  . . . . . . . . .  65
  6914. 2.3.8. Selecting Extension Device Events . . . . . . . .  67
  6915. 2.3.9. Determining Selected Device Events  . . . . . . .  69
  6916. 2.3.10. Controlling Event Propagation  . . . . . . . . .  70
  6917. 2.3.11. Sending an Event . . . . . . . . . . . . . . . .  72
  6918. 2.3.12. Getting Motion History . . . . . . . . . . . . .  74
  6919. 2.3.12. Appendix A . . . . . . . . . . . . . . . . . . .  77
  6920.  
  6921.  
  6922.  
  6923.  
  6924.  
  6925.  
  6926.  
  6927.  
  6928.                   i
  6929.  
  6930.  
  6931.