|
|
HP Xlib Extensions: > Chapter 5 X Input Device Extension FunctionsSelecting Input from Extension Input Devices |
|
To select input from an extended input device, use XSelectExtensionEvent
Title not available (Selecting Extension Events )
The XSelectExtensionEvent function requests that the X server report the events associated with the specified list of event classes. Initially, X will not report any of these events. Events are reported relative to a window. If a window is not interested in a device event, it usually propagates to the closest ancestor that is interested, unless the do_not_propagate mask prohibits it. Multiple clients can select for the same events on the same window with the following restrictions:
The server reports the event to all interested clients. Information contained in the XDevice structure returned by XOpenDevice is used by macros to obtain the event classes that clients use in making XSelectExtensionEvent requests. Currently defined macros include DeviceKeyPress, DeviceKeyRelease, DeviceButtonPress, DeviceButtonRelese, DeviceMotionNotify, DeviceFocusIn, DeviceFocusOut, ProximityIn, ProximityOut, DeviceStateNotify, DeviceMappingNotify, ChangeDeviceNotify, DevicePointerMotionHint, DeviceButton1Motion, DeviceButton2Motion, DeviceButton3Motion, DeviceButton4Motion, DeviceButton5Motion, DeviceButtonMotion, DeviceOwnerGrabButton, DeviceButtonPressGrab, and NoExtensionEvent. To obtain the proper event class for a particular device, one of the above macros is invoked using the XDevice structure for that device. For example,
returns the DeviceKeyPress event type and the eventclass for DeviceKeyPress events from the specified device. DeviceKeyPress from other devices will have a different event class since the event class identifies both the event and the device. XSelectExtensionEvent can generate a BadWindow or BadClass error. To get the list of currently selected extension events, use XGetSelectedExtensionEvents.
Title not available (Getting the List of Currently Selected Extension Events)
The XGetSelectedExtensionEvents function reports the extension events selected by this client and all clients for the specified window. This function returns pointers to two event class arrays. One lists the input extension events selected by this client from the specified window. The other lists the event classes selected by all clients from the specified window. You should use XFree to free these two arrays. XGetSelectedExtensionEvents can generate a BadWindow error. To send input extension events to a client, use XSendExtensionEvent.
Title not available (Sending Extension Events )
The XSendExtensionEvent function identifies the destination window, determines which clients should receive the specified events, and ignores any active grabs. This function requires you to pass an event class list. For a discussion of the valid event class names, see XOpenDevice(3X11). This function uses the destination argument to identify the destination window as follows:
To determine which clients should receive the specified events, XSendExtensionEvent uses the propagate argument as follows:
The event in the XEvent structure must be one of the events defined by the input extension (or a BadValue error results) so that the X server can correctly byte-swap the contents as necessary. The contents of the event are otherwise unaltered and unchecked by the X server except to force send_event to True in the forwarded event and to set the serial number in the event correctly. XSendExtensionEvent returns zero if the conversion to wire protocol format failed and returns nonzero otherwise. XSendExtensionEvent can generate BadDevice, BadValue, BadClass, and BadWindow errors. Input extension events are propagated to ancestor windows unless some client specifies otherwise. Grabs of extension input devices may alter the set of windows that receive a particular input extension event. To determine which events will not be propagated from a given window, use XGetDeviceDontPropagateList.
Title not available (Getting the dont-propagate-list )
The XGetDeviceDontPropagateList function returns a list of input extension events that will not be propagated to ancestors of the event window. An array of event classes is returned that identifies which events will not be propagated. XGetDeviceDontPropagateList can generate a BadClass or BadWindow error. You should use XFree to free the data returned by this function. Suppression of event propagation is not allowed for all input extension events. If a specified event class is one that cannot be suppressed, a BadClass error will result. Events whose propagation can be suppressed include: DeviceKeyPress, DeviceKeyRelease, DeviceButtonPress, DeviceButtonRelease, DeviceMotionNotify, ProximityIn, and ProximityOut. To change which events will not be propagated from a given window, use XChangeDeviceDontPropagateList.
Title not available (Changing the dont-propagate-list )
The XChangeDeviceDontPropagateList function modifies the list of input extension events that should not be propagated to ancestors of the event window. This function allows extension events to be added to or deleted from that list. By default, all events are propagated to ancestor windows. Once modified, the list remains modified for the life of the window. Events are not removed from the list because the client that added them has terminated. XChangeDeviceDontPropagateList can generate a BadDevice, BadClass, or BadValue error. To get the device motion history, use XGetDeviceMotionEvents.
Title not available (Getting Extended Device Motion History )
The server may retain the recent history of the device motion and do so to a finer granularity than is reported by DeviceMotionNotify events. The XGetDeviceMotionEvents function makes this history available. The XGetDeviceMotionEvents function returns all events in the motion history buffer that fall between the specified start and stop times, inclusive. If the start time is later than the stop time or if the start time is in the future, no events are returned. If the stop time is in the future, it is equivalent to specifying CurrentTime. The mode indicates whether the device is reporting absolute positional data (mode=Absolute) or relative motion data (mode=Relative). These constants are defined in the file XI.h. The axis_count returns the number of axes or valuators being reported by the device. XGetDeviceMotionEvents can generate a BadDevice, BadMatch or BadWindow error. The XDeviceTimeCoord structure contains:
The time member is set to the time, in milliseconds. The data member is a pointer to an array of integers. These integers are set to the values of each valuator or axis reported by the device. There is one element in the array per axis of motion reported by the device. The value of the array elements depends on the mode of the device. If the mode is Absolute, the values are the raw values generated by the device. These may be scaled by client programs using the maximum values that the device can generate. The maximum value for each axis of the device is reported in the max_val field of the XAxisInfo structure returned by the XListInputDevices function. If the mode is Relative, the data values are the relative values generated by the device. You should use XFreeDeviceMotionEvents to free the data returned by this function. XGetDeviceMotionEvents can generate a BadDevice or BadMatch error. To free the device motion array, use XFreeDeviceMotionEvents.
Title not available (Freeing the Device Motion Array )
This function frees the array of motion information. |
|