1 | /*
|
---|
2 | * Copyright © 2009 Red Hat, Inc.
|
---|
3 | *
|
---|
4 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
5 | * copy of this software and associated documentation files (the "Software"),
|
---|
6 | * to deal in the Software without restriction, including without limitation
|
---|
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
8 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
9 | * Software is furnished to do so, subject to the following conditions:
|
---|
10 | *
|
---|
11 | * The above copyright notice and this permission notice (including the next
|
---|
12 | * paragraph) shall be included in all copies or substantial portions of the
|
---|
13 | * Software.
|
---|
14 | *
|
---|
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
---|
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
---|
21 | * DEALINGS IN THE SOFTWARE.
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef EVENTSTR_H
|
---|
26 | #define EVENTSTR_H
|
---|
27 |
|
---|
28 | #include <events.h>
|
---|
29 | /**
|
---|
30 | * @file events.h
|
---|
31 | * This file describes the event structures used internally by the X
|
---|
32 | * server during event generation and event processing.
|
---|
33 | *
|
---|
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.
|
---|
38 | */
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * Event types. Used exclusively internal to the server, not visible on the
|
---|
42 | * protocol.
|
---|
43 | *
|
---|
44 | * Note: Keep KeyPress to Motion aligned with the core events.
|
---|
45 | * Keep ET_Raw* in the same order as KeyPress - Motion
|
---|
46 | */
|
---|
47 | enum EventType {
|
---|
48 | ET_KeyPress = 2,
|
---|
49 | ET_KeyRelease,
|
---|
50 | ET_ButtonPress,
|
---|
51 | ET_ButtonRelease,
|
---|
52 | ET_Motion,
|
---|
53 | ET_TouchBegin,
|
---|
54 | ET_TouchUpdate,
|
---|
55 | ET_TouchEnd,
|
---|
56 | ET_TouchOwnership,
|
---|
57 | ET_Enter,
|
---|
58 | ET_Leave,
|
---|
59 | ET_FocusIn,
|
---|
60 | ET_FocusOut,
|
---|
61 | ET_ProximityIn,
|
---|
62 | ET_ProximityOut,
|
---|
63 | ET_DeviceChanged,
|
---|
64 | ET_Hierarchy,
|
---|
65 | ET_DGAEvent,
|
---|
66 | ET_RawKeyPress,
|
---|
67 | ET_RawKeyRelease,
|
---|
68 | ET_RawButtonPress,
|
---|
69 | ET_RawButtonRelease,
|
---|
70 | ET_RawMotion,
|
---|
71 | ET_RawTouchBegin,
|
---|
72 | ET_RawTouchUpdate,
|
---|
73 | ET_RawTouchEnd,
|
---|
74 | ET_XQuartz,
|
---|
75 | ET_BarrierHit,
|
---|
76 | ET_BarrierLeave,
|
---|
77 | ET_Internal = 0xFF /* First byte */
|
---|
78 | };
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Used for ALL input device events internal in the server until
|
---|
82 | * copied into the matching protocol event.
|
---|
83 | *
|
---|
84 | * Note: We only use the device id because the DeviceIntPtr may become invalid while
|
---|
85 | * the event is in the EQ.
|
---|
86 | */
|
---|
87 | struct _DeviceEvent {
|
---|
88 | unsigned char header; /**< Always ET_Internal */
|
---|
89 | enum EventType type; /**< One of EventType */
|
---|
90 | int length; /**< Length in bytes */
|
---|
91 | Time time; /**< Time in ms */
|
---|
92 | int deviceid; /**< Device to post this event for */
|
---|
93 | int sourceid; /**< The physical source device */
|
---|
94 | union {
|
---|
95 | uint32_t button; /**< Button number (also used in pointer emulating
|
---|
96 | touch events) */
|
---|
97 | uint32_t key; /**< Key code */
|
---|
98 | } detail;
|
---|
99 | uint32_t touchid; /**< Touch ID (client_id) */
|
---|
100 | int16_t root_x; /**< Pos relative to root window in integral data */
|
---|
101 | float root_x_frac; /**< Pos relative to root window in frac part */
|
---|
102 | int16_t root_y; /**< Pos relative to root window in integral part */
|
---|
103 | float root_y_frac; /**< Pos relative to root window in frac part */
|
---|
104 | uint8_t buttons[(MAX_BUTTONS + 7) / 8]; /**< Button mask */
|
---|
105 | struct {
|
---|
106 | uint8_t mask[(MAX_VALUATORS + 7) / 8];/**< Valuator mask */
|
---|
107 | uint8_t mode[(MAX_VALUATORS + 7) / 8];/**< Valuator mode (Abs or Rel)*/
|
---|
108 | double data[MAX_VALUATORS]; /**< Valuator data */
|
---|
109 | } valuators;
|
---|
110 | struct {
|
---|
111 | uint32_t base; /**< XKB base modifiers */
|
---|
112 | uint32_t latched; /**< XKB latched modifiers */
|
---|
113 | uint32_t locked; /**< XKB locked modifiers */
|
---|
114 | uint32_t effective;/**< XKB effective modifiers */
|
---|
115 | } mods;
|
---|
116 | struct {
|
---|
117 | uint8_t base; /**< XKB base group */
|
---|
118 | uint8_t latched; /**< XKB latched group */
|
---|
119 | uint8_t locked; /**< XKB locked group */
|
---|
120 | uint8_t effective;/**< XKB effective group */
|
---|
121 | } group;
|
---|
122 | Window root; /**< Root window of the event */
|
---|
123 | int corestate; /**< Core key/button state BEFORE the event */
|
---|
124 | int key_repeat; /**< Internally-generated key repeat event */
|
---|
125 | uint32_t flags; /**< Flags to be copied into the generated event */
|
---|
126 | };
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Generated internally whenever a touch ownership chain changes - an owner
|
---|
130 | * has accepted or rejected a touch, or a grab/event selection in the delivery
|
---|
131 | * chain has been removed.
|
---|
132 | */
|
---|
133 | struct _TouchOwnershipEvent {
|
---|
134 | unsigned char header; /**< Always ET_Internal */
|
---|
135 | enum EventType type; /**< ET_TouchOwnership */
|
---|
136 | int length; /**< Length in bytes */
|
---|
137 | Time time; /**< Time in ms */
|
---|
138 | int deviceid; /**< Device to post this event for */
|
---|
139 | int sourceid; /**< The physical source device */
|
---|
140 | uint32_t touchid; /**< Touch ID (client_id) */
|
---|
141 | uint8_t reason; /**< ::XIAcceptTouch, ::XIRejectTouch */
|
---|
142 | uint32_t resource; /**< Provoking grab or event selection */
|
---|
143 | uint32_t flags; /**< Flags to be copied into the generated event */
|
---|
144 | };
|
---|
145 |
|
---|
146 | /* Flags used in DeviceChangedEvent to signal if the slave has changed */
|
---|
147 | #define DEVCHANGE_SLAVE_SWITCH 0x2
|
---|
148 | /* Flags used in DeviceChangedEvent to signal whether the event was a
|
---|
149 | * pointer event or a keyboard event */
|
---|
150 | #define DEVCHANGE_POINTER_EVENT 0x4
|
---|
151 | #define DEVCHANGE_KEYBOARD_EVENT 0x8
|
---|
152 | /* device capabilities changed */
|
---|
153 | #define DEVCHANGE_DEVICE_CHANGE 0x10
|
---|
154 |
|
---|
155 | /**
|
---|
156 | * Sent whenever a device's capabilities have changed.
|
---|
157 | */
|
---|
158 | struct _DeviceChangedEvent {
|
---|
159 | unsigned char header; /**< Always ET_Internal */
|
---|
160 | enum EventType type; /**< ET_DeviceChanged */
|
---|
161 | int length; /**< Length in bytes */
|
---|
162 | Time time; /**< Time in ms */
|
---|
163 | int deviceid; /**< Device whose capabilities have changed */
|
---|
164 | int flags; /**< Mask of ::HAS_NEW_SLAVE,
|
---|
165 | ::POINTER_EVENT, ::KEYBOARD_EVENT */
|
---|
166 | int masterid; /**< MD when event was generated */
|
---|
167 | int sourceid; /**< The device that caused the change */
|
---|
168 |
|
---|
169 | struct {
|
---|
170 | int num_buttons; /**< Number of buttons */
|
---|
171 | Atom names[MAX_BUTTONS];/**< Button names */
|
---|
172 | } buttons;
|
---|
173 |
|
---|
174 | int num_valuators; /**< Number of axes */
|
---|
175 | struct {
|
---|
176 | uint32_t min; /**< Minimum value */
|
---|
177 | uint32_t max; /**< Maximum value */
|
---|
178 | /* FIXME: frac parts of min/max */
|
---|
179 | uint32_t resolution; /**< Resolution counts/m */
|
---|
180 | uint8_t mode; /**< Relative or Absolute */
|
---|
181 | Atom name; /**< Axis name */
|
---|
182 | ScrollInfo scroll; /**< Smooth scrolling info */
|
---|
183 | } valuators[MAX_VALUATORS];
|
---|
184 |
|
---|
185 | struct {
|
---|
186 | int min_keycode;
|
---|
187 | int max_keycode;
|
---|
188 | } keys;
|
---|
189 | };
|
---|
190 |
|
---|
191 | #if XFreeXDGA
|
---|
192 | /**
|
---|
193 | * DGAEvent, used by DGA to intercept and emulate input events.
|
---|
194 | */
|
---|
195 | struct _DGAEvent {
|
---|
196 | unsigned char header; /**< Always ET_Internal */
|
---|
197 | enum EventType type; /**< ET_DGAEvent */
|
---|
198 | int length; /**< Length in bytes */
|
---|
199 | Time time; /**< Time in ms */
|
---|
200 | int subtype; /**< KeyPress, KeyRelease, ButtonPress,
|
---|
201 | ButtonRelease, MotionNotify */
|
---|
202 | int detail; /**< Button number or key code */
|
---|
203 | int dx; /**< Relative x coordinate */
|
---|
204 | int dy; /**< Relative y coordinate */
|
---|
205 | int screen; /**< Screen number this event applies to */
|
---|
206 | uint16_t state; /**< Core modifier/button state */
|
---|
207 | };
|
---|
208 | #endif
|
---|
209 |
|
---|
210 | /**
|
---|
211 | * Raw event, contains the data as posted by the device.
|
---|
212 | */
|
---|
213 | struct _RawDeviceEvent {
|
---|
214 | unsigned char header; /**< Always ET_Internal */
|
---|
215 | enum EventType type; /**< ET_Raw */
|
---|
216 | int length; /**< Length in bytes */
|
---|
217 | Time time; /**< Time in ms */
|
---|
218 | int deviceid; /**< Device to post this event for */
|
---|
219 | int sourceid; /**< The physical source device */
|
---|
220 | union {
|
---|
221 | uint32_t button; /**< Button number */
|
---|
222 | uint32_t key; /**< Key code */
|
---|
223 | } detail;
|
---|
224 | struct {
|
---|
225 | uint8_t mask[(MAX_VALUATORS + 7) / 8];/**< Valuator mask */
|
---|
226 | double data[MAX_VALUATORS]; /**< Valuator data */
|
---|
227 | double data_raw[MAX_VALUATORS]; /**< Valuator data as posted */
|
---|
228 | } valuators;
|
---|
229 | uint32_t flags; /**< Flags to be copied into the generated event */
|
---|
230 | };
|
---|
231 |
|
---|
232 | struct _BarrierEvent {
|
---|
233 | unsigned char header; /**< Always ET_Internal */
|
---|
234 | enum EventType type; /**< ET_BarrierHit, ET_BarrierLeave */
|
---|
235 | int length; /**< Length in bytes */
|
---|
236 | Time time; /**< Time in ms */
|
---|
237 | int deviceid; /**< Device to post this event for */
|
---|
238 | int sourceid; /**< The physical source device */
|
---|
239 | int barrierid;
|
---|
240 | Window window;
|
---|
241 | Window root;
|
---|
242 | double dx;
|
---|
243 | double dy;
|
---|
244 | double root_x;
|
---|
245 | double root_y;
|
---|
246 | int16_t dt;
|
---|
247 | int32_t event_id;
|
---|
248 | uint32_t flags;
|
---|
249 | };
|
---|
250 |
|
---|
251 | #ifdef XQUARTZ
|
---|
252 | #define XQUARTZ_EVENT_MAXARGS 5
|
---|
253 | struct _XQuartzEvent {
|
---|
254 | unsigned char header; /**< Always ET_Internal */
|
---|
255 | enum EventType type; /**< Always ET_XQuartz */
|
---|
256 | int length; /**< Length in bytes */
|
---|
257 | Time time; /**< Time in ms. */
|
---|
258 | int subtype; /**< Subtype defined by XQuartz DDX */
|
---|
259 | uint32_t data[XQUARTZ_EVENT_MAXARGS]; /**< Up to 5 32bit values passed to handler */
|
---|
260 | };
|
---|
261 | #endif
|
---|
262 |
|
---|
263 | /**
|
---|
264 | * Event type used inside the X server for input event
|
---|
265 | * processing.
|
---|
266 | */
|
---|
267 | union _InternalEvent {
|
---|
268 | struct {
|
---|
269 | unsigned char header; /**< Always ET_Internal */
|
---|
270 | enum EventType type; /**< One of ET_* */
|
---|
271 | int length; /**< Length in bytes */
|
---|
272 | Time time; /**< Time in ms. */
|
---|
273 | } any;
|
---|
274 | DeviceEvent device_event;
|
---|
275 | DeviceChangedEvent changed_event;
|
---|
276 | TouchOwnershipEvent touch_ownership_event;
|
---|
277 | BarrierEvent barrier_event;
|
---|
278 | #if XFreeXDGA
|
---|
279 | DGAEvent dga_event;
|
---|
280 | #endif
|
---|
281 | RawDeviceEvent raw_event;
|
---|
282 | #ifdef XQUARTZ
|
---|
283 | XQuartzEvent xquartz_event;
|
---|
284 | #endif
|
---|
285 | };
|
---|
286 |
|
---|
287 | #endif
|
---|