2 * Copyright © 2009 Red Hat, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
31 * This file describes the event structures used internally by the X
32 * server during event generation and event processing.
34 * When are internal events used?
35 * Events from input devices are stored as internal events in the EQ and
36 * processed as internal events until late in the processing cycle. Only then
37 * do they switch to their respective wire events.
41 * Event types. Used exclusively internal to the server, not visible on the
44 * Note: Keep KeyPress to Motion aligned with the core events.
45 * Keep ET_Raw* in the same order as KeyPress - Motion
75 #ifdef _F_GESTURE_EXTENSION_
77 #endif//_F_GESTURE_EXTENSION_
78 ET_Internal = 0xFF /* First byte */
82 * Used for ALL input device events internal in the server until
83 * copied into the matching protocol event.
85 * Note: We only use the device id because the DeviceIntPtr may become invalid while
86 * the event is in the EQ.
89 unsigned char header; /**< Always ET_Internal */
90 enum EventType type; /**< One of EventType */
91 int length; /**< Length in bytes */
92 Time time; /**< Time in ms */
93 int deviceid; /**< Device to post this event for */
94 int sourceid; /**< The physical source device */
96 uint32_t button; /**< Button number (also used in pointer emulating
98 uint32_t key; /**< Key code */
100 uint32_t touchid; /**< Touch ID (client_id) */
101 int16_t root_x; /**< Pos relative to root window in integral data */
102 float root_x_frac; /**< Pos relative to root window in frac part */
103 int16_t root_y; /**< Pos relative to root window in integral part */
104 float root_y_frac; /**< Pos relative to root window in frac part */
105 uint8_t buttons[(MAX_BUTTONS + 7) / 8]; /**< Button mask */
107 uint8_t mask[(MAX_VALUATORS + 7) / 8];/**< Valuator mask */
108 uint8_t mode[(MAX_VALUATORS + 7) / 8];/**< Valuator mode (Abs or Rel)*/
109 double data[MAX_VALUATORS]; /**< Valuator data */
112 uint32_t base; /**< XKB base modifiers */
113 uint32_t latched; /**< XKB latched modifiers */
114 uint32_t locked; /**< XKB locked modifiers */
115 uint32_t effective;/**< XKB effective modifiers */
118 uint8_t base; /**< XKB base group */
119 uint8_t latched; /**< XKB latched group */
120 uint8_t locked; /**< XKB locked group */
121 uint8_t effective;/**< XKB effective group */
123 Window root; /**< Root window of the event */
124 int corestate; /**< Core key/button state BEFORE the event */
125 int key_repeat; /**< Internally-generated key repeat event */
126 uint32_t flags; /**< Flags to be copied into the generated event */
130 * Generated internally whenever a touch ownership chain changes - an owner
131 * has accepted or rejected a touch, or a grab/event selection in the delivery
132 * chain has been removed.
134 struct _TouchOwnershipEvent {
135 unsigned char header; /**< Always ET_Internal */
136 enum EventType type; /**< One of EventType */
137 int length; /**< Length in bytes */
138 Time time; /**< Time in ms */
139 int deviceid; /**< Device to post this event for */
140 int sourceid; /**< The physical source device */
141 uint32_t touchid; /**< Touch ID (client_id) */
142 uint8_t reason; /**< ::XIAcceptTouch, ::XIRejectTouch */
143 uint32_t resource; /**< Provoking grab or event selection */
144 uint32_t flags; /**< Flags to be copied into the generated event */
147 /* Flags used in DeviceChangedEvent to signal if the slave has changed */
148 #define DEVCHANGE_SLAVE_SWITCH 0x2
149 /* Flags used in DeviceChangedEvent to signal whether the event was a
150 * pointer event or a keyboard event */
151 #define DEVCHANGE_POINTER_EVENT 0x4
152 #define DEVCHANGE_KEYBOARD_EVENT 0x8
153 /* device capabilities changed */
154 #define DEVCHANGE_DEVICE_CHANGE 0x10
157 * Sent whenever a device's capabilities have changed.
159 struct _DeviceChangedEvent {
160 unsigned char header; /**< Always ET_Internal */
161 enum EventType type; /**< ET_DeviceChanged */
162 int length; /**< Length in bytes */
163 Time time; /**< Time in ms */
164 int deviceid; /**< Device whose capabilities have changed */
165 int flags; /**< Mask of ::HAS_NEW_SLAVE,
166 ::POINTER_EVENT, ::KEYBOARD_EVENT */
167 int masterid; /**< MD when event was generated */
168 int sourceid; /**< The device that caused the change */
171 int num_buttons; /**< Number of buttons */
172 Atom names[MAX_BUTTONS];/**< Button names */
175 int num_valuators; /**< Number of axes */
177 uint32_t min; /**< Minimum value */
178 uint32_t max; /**< Maximum value */
179 /* FIXME: frac parts of min/max */
180 uint32_t resolution; /**< Resolution counts/m */
181 uint8_t mode; /**< Relative or Absolute */
182 Atom name; /**< Axis name */
183 ScrollInfo scroll; /**< Smooth scrolling info */
184 } valuators[MAX_VALUATORS];
194 * DGAEvent, used by DGA to intercept and emulate input events.
197 unsigned char header; /**< Always ET_Internal */
198 enum EventType type; /**< ET_DGAEvent */
199 int length; /**< Length in bytes */
200 Time time; /**< Time in ms */
201 int subtype; /**< KeyPress, KeyRelease, ButtonPress,
202 ButtonRelease, MotionNotify */
203 int detail; /**< Button number or key code */
204 int dx; /**< Relative x coordinate */
205 int dy; /**< Relative y coordinate */
206 int screen; /**< Screen number this event applies to */
207 uint16_t state; /**< Core modifier/button state */
212 * Raw event, contains the data as posted by the device.
214 struct _RawDeviceEvent {
215 unsigned char header; /**< Always ET_Internal */
216 enum EventType type; /**< ET_Raw */
217 int length; /**< Length in bytes */
218 Time time; /**< Time in ms */
219 int deviceid; /**< Device to post this event for */
220 int sourceid; /**< The physical source device */
222 uint32_t button; /**< Button number */
223 uint32_t key; /**< Key code */
226 uint8_t mask[(MAX_VALUATORS + 7) / 8];/**< Valuator mask */
227 double data[MAX_VALUATORS]; /**< Valuator data */
228 double data_raw[MAX_VALUATORS]; /**< Valuator data as posted */
230 uint32_t flags; /**< Flags to be copied into the generated event */
234 #define XQUARTZ_EVENT_MAXARGS 5
235 struct _XQuartzEvent {
236 unsigned char header; /**< Always ET_Internal */
237 enum EventType type; /**< Always ET_XQuartz */
238 int length; /**< Length in bytes */
239 Time time; /**< Time in ms. */
240 int subtype; /**< Subtype defined by XQuartz DDX */
241 uint32_t data[XQUARTZ_EVENT_MAXARGS]; /**< Up to 5 32bit values passed to handler */
246 * Event type used inside the X server for input event
249 union _InternalEvent {
251 unsigned char header; /**< Always ET_Internal */
252 enum EventType type; /**< One of ET_* */
253 int length; /**< Length in bytes */
254 Time time; /**< Time in ms. */
256 DeviceEvent device_event;
257 DeviceChangedEvent changed_event;
258 TouchOwnershipEvent touch_ownership_event;
262 RawDeviceEvent raw_event;
264 XQuartzEvent xquartz_event;