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_Internal = 0xFF /* First byte */
|
---|
76 | };
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Used for ALL input device events internal in the server until
|
---|
80 | * copied into the matching protocol event.
|
---|
81 | *
|
---|
82 | * Note: We only use the device id because the DeviceIntPtr may become invalid while
|
---|
83 | * the event is in the EQ.
|
---|
84 | */
|
---|
85 | struct _DeviceEvent
|
---|
86 | {
|
---|
87 | unsigned char header; /**< Always ET_Internal */
|
---|
88 | enum EventType type; /**< One of EventType */
|
---|
89 | int length; /**< Length in bytes */
|
---|
90 | Time time; /**< Time in ms */
|
---|
91 | int deviceid; /**< Device to post this event for */
|
---|
92 | int sourceid; /**< The physical source device */
|
---|
93 | union {
|
---|
94 | uint32_t button; /**< Button number (also used in pointer emulating
|
---|
95 | touch events) */
|
---|
96 | uint32_t key; /**< Key code */
|
---|
97 | } detail;
|
---|
98 | uint32_t touchid; /**< Touch ID (client_id) */
|
---|
99 | int16_t root_x; /**< Pos relative to root window in integral data */
|
---|
100 | float root_x_frac; /**< Pos relative to root window in frac part */
|
---|
101 | int16_t root_y; /**< Pos relative to root window in integral part */
|
---|
102 | float root_y_frac; /**< Pos relative to root window in frac part */
|
---|
103 | uint8_t buttons[(MAX_BUTTONS + 7)/8]; /**< Button mask */
|
---|
104 | struct {
|
---|
105 | uint8_t mask[(MAX_VALUATORS + 7)/8]; /**< Valuator mask */
|
---|
106 | uint8_t mode[(MAX_VALUATORS + 7)/8]; /**< Valuator mode (Abs or Rel)*/
|
---|
107 | double data[MAX_VALUATORS]; /**< Valuator data */
|
---|
108 | } valuators;
|
---|
109 | struct {
|
---|
110 | uint32_t base; /**< XKB base modifiers */
|
---|
111 | uint32_t latched; /**< XKB latched modifiers */
|
---|
112 | uint32_t locked; /**< XKB locked modifiers */
|
---|
113 | uint32_t effective;/**< XKB effective modifiers */
|
---|
114 | } mods;
|
---|
115 | struct {
|
---|
116 | uint8_t base; /**< XKB base group */
|
---|
117 | uint8_t latched; /**< XKB latched group */
|
---|
118 | uint8_t locked; /**< XKB locked group */
|
---|
119 | uint8_t effective;/**< XKB effective group */
|
---|
120 | } group;
|
---|
121 | Window root; /**< Root window of the event */
|
---|
122 | int corestate; /**< Core key/button state BEFORE the event */
|
---|
123 | int key_repeat; /**< Internally-generated key repeat event */
|
---|
124 | uint32_t flags; /**< Flags to be copied into the generated event */
|
---|
125 | };
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * Generated internally whenever a touch ownership chain changes - an owner
|
---|
129 | * has accepted or rejected a touch, or a grab/event selection in the delivery
|
---|
130 | * chain has been removed.
|
---|
131 | */
|
---|
132 | struct _TouchOwnershipEvent
|
---|
133 | {
|
---|
134 | unsigned char header; /**< Always ET_Internal */
|
---|
135 | enum EventType type; /**< One of EventType */
|
---|
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 | {
|
---|
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 */
|
---|
169 |
|
---|
170 | struct {
|
---|
171 | int num_buttons; /**< Number of buttons */
|
---|
172 | Atom names[MAX_BUTTONS];/**< Button names */
|
---|
173 | } buttons;
|
---|
174 |
|
---|
175 | int num_valuators; /**< Number of axes */
|
---|
176 | struct {
|
---|
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];
|
---|
185 |
|
---|
186 | struct {
|
---|
187 | int min_keycode;
|
---|
188 | int max_keycode;
|
---|
189 | } keys;
|
---|
190 | };
|
---|
191 |
|
---|
192 | #if XFreeXDGA
|
---|
193 | /**
|
---|
194 | * DGAEvent, used by DGA to intercept and emulate input events.
|
---|
195 | */
|
---|
196 | struct _DGAEvent
|
---|
197 | {
|
---|
198 | unsigned char header; /**< Always ET_Internal */
|
---|
199 | enum EventType type; /**< ET_DGAEvent */
|
---|
200 | int length; /**< Length in bytes */
|
---|
201 | Time time; /**< Time in ms */
|
---|
202 | int subtype; /**< KeyPress, KeyRelease, ButtonPress,
|
---|
203 | ButtonRelease, MotionNotify */
|
---|
204 | int detail; /**< Button number or key code */
|
---|
205 | int dx; /**< Relative x coordinate */
|
---|
206 | int dy; /**< Relative y coordinate */
|
---|
207 | int screen; /**< Screen number this event applies to */
|
---|
208 | uint16_t state; /**< Core modifier/button state */
|
---|
209 | };
|
---|
210 | #endif
|
---|
211 |
|
---|
212 | /**
|
---|
213 | * Raw event, contains the data as posted by the device.
|
---|
214 | */
|
---|
215 | struct _RawDeviceEvent
|
---|
216 | {
|
---|
217 | unsigned char header; /**< Always ET_Internal */
|
---|
218 | enum EventType type; /**< ET_Raw */
|
---|
219 | int length; /**< Length in bytes */
|
---|
220 | Time time; /**< Time in ms */
|
---|
221 | int deviceid; /**< Device to post this event for */
|
---|
222 | int sourceid; /**< The physical source device */
|
---|
223 | union {
|
---|
224 | uint32_t button; /**< Button number */
|
---|
225 | uint32_t key; /**< Key code */
|
---|
226 | } detail;
|
---|
227 | struct {
|
---|
228 | uint8_t mask[(MAX_VALUATORS + 7)/8]; /**< Valuator mask */
|
---|
229 | double data[MAX_VALUATORS]; /**< Valuator data */
|
---|
230 | double data_raw[MAX_VALUATORS]; /**< Valuator data as posted */
|
---|
231 | } valuators;
|
---|
232 | uint32_t flags; /**< Flags to be copied into the generated event */
|
---|
233 | };
|
---|
234 |
|
---|
235 | #ifdef XQUARTZ
|
---|
236 | #define XQUARTZ_EVENT_MAXARGS 5
|
---|
237 | struct _XQuartzEvent {
|
---|
238 | unsigned char header; /**< Always ET_Internal */
|
---|
239 | enum EventType type; /**< Always ET_XQuartz */
|
---|
240 | int length; /**< Length in bytes */
|
---|
241 | Time time; /**< Time in ms. */
|
---|
242 | int subtype; /**< Subtype defined by XQuartz DDX */
|
---|
243 | uint32_t data[XQUARTZ_EVENT_MAXARGS]; /**< Up to 5 32bit values passed to handler */
|
---|
244 | };
|
---|
245 | #endif
|
---|
246 |
|
---|
247 | /**
|
---|
248 | * Event type used inside the X server for input event
|
---|
249 | * processing.
|
---|
250 | */
|
---|
251 | union _InternalEvent {
|
---|
252 | struct {
|
---|
253 | unsigned char header; /**< Always ET_Internal */
|
---|
254 | enum EventType type; /**< One of ET_* */
|
---|
255 | int length; /**< Length in bytes */
|
---|
256 | Time time; /**< Time in ms. */
|
---|
257 | } any;
|
---|
258 | DeviceEvent device_event;
|
---|
259 | DeviceChangedEvent changed_event;
|
---|
260 | TouchOwnershipEvent touch_ownership_event;
|
---|
261 | #if XFreeXDGA
|
---|
262 | DGAEvent dga_event;
|
---|
263 | #endif
|
---|
264 | RawDeviceEvent raw_event;
|
---|
265 | #ifdef XQUARTZ
|
---|
266 | XQuartzEvent xquartz_event;
|
---|
267 | #endif
|
---|
268 | };
|
---|
269 |
|
---|
270 | #endif
|
---|