1*4882a593Smuzhiyun /************************************************************
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun Copyright 1987, 1998 The Open Group
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun Permission to use, copy, modify, distribute, and sell this software and its
6*4882a593Smuzhiyun documentation for any purpose is hereby granted without fee, provided that
7*4882a593Smuzhiyun the above copyright notice appear in all copies and that both that
8*4882a593Smuzhiyun copyright notice and this permission notice appear in supporting
9*4882a593Smuzhiyun documentation.
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun The above copyright notice and this permission notice shall be included in
12*4882a593Smuzhiyun all copies or substantial portions of the Software.
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*4882a593Smuzhiyun IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*4882a593Smuzhiyun FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17*4882a593Smuzhiyun OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18*4882a593Smuzhiyun AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19*4882a593Smuzhiyun CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun Except as contained in this notice, the name of The Open Group shall not be
22*4882a593Smuzhiyun used in advertising or otherwise to promote the sale, use or other dealings
23*4882a593Smuzhiyun in this Software without prior written authorization from The Open Group.
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun All Rights Reserved
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun Permission to use, copy, modify, and distribute this software and its
30*4882a593Smuzhiyun documentation for any purpose and without fee is hereby granted,
31*4882a593Smuzhiyun provided that the above copyright notice appear in all copies and that
32*4882a593Smuzhiyun both that copyright notice and this permission notice appear in
33*4882a593Smuzhiyun supporting documentation, and that the name of Digital not be
34*4882a593Smuzhiyun used in advertising or publicity pertaining to distribution of the
35*4882a593Smuzhiyun software without specific, written prior permission.
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38*4882a593Smuzhiyun ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39*4882a593Smuzhiyun DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40*4882a593Smuzhiyun ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41*4882a593Smuzhiyun WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42*4882a593Smuzhiyun ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
43*4882a593Smuzhiyun SOFTWARE.
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun ********************************************************/
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun #ifndef INPUTSTRUCT_H
48*4882a593Smuzhiyun #define INPUTSTRUCT_H
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun #include <X11/extensions/XI2proto.h>
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun #include <pixman.h>
53*4882a593Smuzhiyun #include "input.h"
54*4882a593Smuzhiyun #include "window.h"
55*4882a593Smuzhiyun #include "dixstruct.h"
56*4882a593Smuzhiyun #include "cursorstr.h"
57*4882a593Smuzhiyun #include "geext.h"
58*4882a593Smuzhiyun #include "privates.h"
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun extern _X_EXPORT void AssignTypeAndName(DeviceIntPtr dev,
61*4882a593Smuzhiyun Atom type,
62*4882a593Smuzhiyun const char *name);
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun #define BitIsOn(ptr, bit) (!!(((const BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7))))
65*4882a593Smuzhiyun #define SetBit(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] |= (1 << ((bit) & 7)))
66*4882a593Smuzhiyun #define ClearBit(ptr, bit) (((BYTE *)(ptr))[(bit)>>3] &= ~(1 << ((bit) & 7)))
67*4882a593Smuzhiyun extern _X_EXPORT int CountBits(const uint8_t * mask, int len);
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun #define SameClient(obj,client) \
70*4882a593Smuzhiyun (CLIENT_BITS((obj)->resource) == (client)->clientAsMask)
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun #define EMASKSIZE (MAXDEVICES + 2)
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun /* This is the last XI2 event supported by the server. If you add
75*4882a593Smuzhiyun * events to the protocol, the server will not support these events until
76*4882a593Smuzhiyun * this number here is bumped.
77*4882a593Smuzhiyun */
78*4882a593Smuzhiyun #define XI2LASTEVENT XI_BarrierLeave
79*4882a593Smuzhiyun #define XI2MASKSIZE ((XI2LASTEVENT >> 3) + 1) /* no of bytes for masks */
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun /**
82*4882a593Smuzhiyun * Scroll types for ::SetScrollValuator and the scroll type in the
83*4882a593Smuzhiyun * ::ScrollInfoPtr.
84*4882a593Smuzhiyun */
85*4882a593Smuzhiyun enum ScrollType {
86*4882a593Smuzhiyun SCROLL_TYPE_NONE = 0, /**< Not a scrolling valuator */
87*4882a593Smuzhiyun SCROLL_TYPE_VERTICAL = 8,
88*4882a593Smuzhiyun SCROLL_TYPE_HORIZONTAL = 9,
89*4882a593Smuzhiyun };
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun /**
92*4882a593Smuzhiyun * This struct stores the core event mask for each client except the client
93*4882a593Smuzhiyun * that created the window.
94*4882a593Smuzhiyun *
95*4882a593Smuzhiyun * Each window that has events selected from other clients has at least one of
96*4882a593Smuzhiyun * these masks. If multiple clients selected for events on the same window,
97*4882a593Smuzhiyun * these masks are in a linked list.
98*4882a593Smuzhiyun *
99*4882a593Smuzhiyun * The event mask for the client that created the window is stored in
100*4882a593Smuzhiyun * win->eventMask instead.
101*4882a593Smuzhiyun *
102*4882a593Smuzhiyun * The resource id is simply a fake client ID to associate this mask with a
103*4882a593Smuzhiyun * client.
104*4882a593Smuzhiyun *
105*4882a593Smuzhiyun * Kludge: OtherClients and InputClients must be compatible, see code.
106*4882a593Smuzhiyun */
107*4882a593Smuzhiyun typedef struct _OtherClients {
108*4882a593Smuzhiyun OtherClientsPtr next; /**< Pointer to the next mask */
109*4882a593Smuzhiyun XID resource; /**< id for putting into resource manager */
110*4882a593Smuzhiyun Mask mask; /**< Core event mask */
111*4882a593Smuzhiyun } OtherClients;
112*4882a593Smuzhiyun
113*4882a593Smuzhiyun /**
114*4882a593Smuzhiyun * This struct stores the XI event mask for each client.
115*4882a593Smuzhiyun *
116*4882a593Smuzhiyun * Each window that has events selected has at least one of these masks. If
117*4882a593Smuzhiyun * multiple client selected for events on the same window, these masks are in
118*4882a593Smuzhiyun * a linked list.
119*4882a593Smuzhiyun */
120*4882a593Smuzhiyun typedef struct _InputClients {
121*4882a593Smuzhiyun InputClientsPtr next; /**< Pointer to the next mask */
122*4882a593Smuzhiyun XID resource; /**< id for putting into resource manager */
123*4882a593Smuzhiyun Mask mask[EMASKSIZE]; /**< Actual XI event mask, deviceid is index */
124*4882a593Smuzhiyun /** XI2 event masks. One per device, each bit is a mask of (1 << type) */
125*4882a593Smuzhiyun struct _XI2Mask *xi2mask;
126*4882a593Smuzhiyun } InputClients;
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun /**
129*4882a593Smuzhiyun * Combined XI event masks from all devices.
130*4882a593Smuzhiyun *
131*4882a593Smuzhiyun * This is the XI equivalent of the deliverableEvents, eventMask and
132*4882a593Smuzhiyun * dontPropagate mask of the WindowRec (or WindowOptRec).
133*4882a593Smuzhiyun *
134*4882a593Smuzhiyun * A window that has an XI client selecting for events has exactly one
135*4882a593Smuzhiyun * OtherInputMasks struct and exactly one InputClients struct hanging off
136*4882a593Smuzhiyun * inputClients. Each further client appends to the inputClients list.
137*4882a593Smuzhiyun * Each Mask field is per-device, with the device id as the index.
138*4882a593Smuzhiyun * Exception: for non-device events (Presence events), the MAXDEVICES
139*4882a593Smuzhiyun * deviceid is used.
140*4882a593Smuzhiyun */
141*4882a593Smuzhiyun typedef struct _OtherInputMasks {
142*4882a593Smuzhiyun /**
143*4882a593Smuzhiyun * Bitwise OR of all masks by all clients and the window's parent's masks.
144*4882a593Smuzhiyun */
145*4882a593Smuzhiyun Mask deliverableEvents[EMASKSIZE];
146*4882a593Smuzhiyun /**
147*4882a593Smuzhiyun * Bitwise OR of all masks by all clients on this window.
148*4882a593Smuzhiyun */
149*4882a593Smuzhiyun Mask inputEvents[EMASKSIZE];
150*4882a593Smuzhiyun /** The do-not-propagate masks for each device. */
151*4882a593Smuzhiyun Mask dontPropagateMask[EMASKSIZE];
152*4882a593Smuzhiyun /** The clients that selected for events */
153*4882a593Smuzhiyun InputClientsPtr inputClients;
154*4882a593Smuzhiyun /* XI2 event masks. One per device, each bit is a mask of (1 << type) */
155*4882a593Smuzhiyun struct _XI2Mask *xi2mask;
156*4882a593Smuzhiyun } OtherInputMasks;
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun /*
159*4882a593Smuzhiyun * The following structure gets used for both active and passive grabs. For
160*4882a593Smuzhiyun * active grabs some of the fields (e.g. modifiers) are not used. However,
161*4882a593Smuzhiyun * that is not much waste since there aren't many active grabs (one per
162*4882a593Smuzhiyun * keyboard/pointer device) going at once in the server.
163*4882a593Smuzhiyun */
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun #define MasksPerDetailMask 8 /* 256 keycodes and 256 possible
166*4882a593Smuzhiyun modifier combinations, but only
167*4882a593Smuzhiyun 3 buttons. */
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun typedef struct _DetailRec { /* Grab details may be bit masks */
170*4882a593Smuzhiyun unsigned int exact;
171*4882a593Smuzhiyun Mask *pMask;
172*4882a593Smuzhiyun } DetailRec;
173*4882a593Smuzhiyun
174*4882a593Smuzhiyun union _GrabMask {
175*4882a593Smuzhiyun Mask core;
176*4882a593Smuzhiyun Mask xi;
177*4882a593Smuzhiyun struct _XI2Mask *xi2mask;
178*4882a593Smuzhiyun };
179*4882a593Smuzhiyun
180*4882a593Smuzhiyun /**
181*4882a593Smuzhiyun * Central struct for device grabs.
182*4882a593Smuzhiyun * The same struct is used for both core grabs and device grabs, with
183*4882a593Smuzhiyun * different fields being set.
184*4882a593Smuzhiyun * If the grab is a core grab (GrabPointer/GrabKeyboard), then the eventMask
185*4882a593Smuzhiyun * is a combination of standard event masks (i.e. PointerMotionMask |
186*4882a593Smuzhiyun * ButtonPressMask).
187*4882a593Smuzhiyun * If the grab is a device grab (GrabDevice), then the eventMask is a
188*4882a593Smuzhiyun * combination of event masks for a given XI event type (see SetEventInfo).
189*4882a593Smuzhiyun *
190*4882a593Smuzhiyun * If the grab is a result of a ButtonPress, then eventMask is the core mask
191*4882a593Smuzhiyun * and deviceMask is set to the XI event mask for the grab.
192*4882a593Smuzhiyun */
193*4882a593Smuzhiyun typedef struct _GrabRec {
194*4882a593Smuzhiyun GrabPtr next; /* for chain of passive grabs */
195*4882a593Smuzhiyun XID resource;
196*4882a593Smuzhiyun DeviceIntPtr device;
197*4882a593Smuzhiyun WindowPtr window;
198*4882a593Smuzhiyun unsigned ownerEvents:1;
199*4882a593Smuzhiyun unsigned keyboardMode:1;
200*4882a593Smuzhiyun unsigned pointerMode:1;
201*4882a593Smuzhiyun enum InputLevel grabtype;
202*4882a593Smuzhiyun CARD8 type; /* event type for passive grabs, 0 for active grabs */
203*4882a593Smuzhiyun DetailRec modifiersDetail;
204*4882a593Smuzhiyun DeviceIntPtr modifierDevice;
205*4882a593Smuzhiyun DetailRec detail; /* key or button */
206*4882a593Smuzhiyun WindowPtr confineTo; /* always NULL for keyboards */
207*4882a593Smuzhiyun CursorPtr cursor; /* always NULL for keyboards */
208*4882a593Smuzhiyun Mask eventMask;
209*4882a593Smuzhiyun Mask deviceMask;
210*4882a593Smuzhiyun /* XI2 event masks. One per device, each bit is a mask of (1 << type) */
211*4882a593Smuzhiyun struct _XI2Mask *xi2mask;
212*4882a593Smuzhiyun } GrabRec;
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun /**
215*4882a593Smuzhiyun * Sprite information for a device.
216*4882a593Smuzhiyun */
217*4882a593Smuzhiyun typedef struct _SpriteRec {
218*4882a593Smuzhiyun CursorPtr current;
219*4882a593Smuzhiyun BoxRec hotLimits; /* logical constraints of hot spot */
220*4882a593Smuzhiyun Bool confined; /* confined to screen */
221*4882a593Smuzhiyun RegionPtr hotShape; /* additional logical shape constraint */
222*4882a593Smuzhiyun BoxRec physLimits; /* physical constraints of hot spot */
223*4882a593Smuzhiyun WindowPtr win; /* window of logical position */
224*4882a593Smuzhiyun HotSpot hot; /* logical pointer position */
225*4882a593Smuzhiyun HotSpot hotPhys; /* physical pointer position */
226*4882a593Smuzhiyun #ifdef PANORAMIX
227*4882a593Smuzhiyun ScreenPtr screen; /* all others are in Screen 0 coordinates */
228*4882a593Smuzhiyun RegionRec Reg1; /* Region 1 for confining motion */
229*4882a593Smuzhiyun RegionRec Reg2; /* Region 2 for confining virtual motion */
230*4882a593Smuzhiyun WindowPtr windows[MAXSCREENS];
231*4882a593Smuzhiyun WindowPtr confineWin; /* confine window */
232*4882a593Smuzhiyun #endif
233*4882a593Smuzhiyun /* The window trace information is used at dix/events.c to avoid having
234*4882a593Smuzhiyun * to compute all the windows between the root and the current pointer
235*4882a593Smuzhiyun * window each time a button or key goes down. The grabs on each of those
236*4882a593Smuzhiyun * windows must be checked.
237*4882a593Smuzhiyun * spriteTraces should only be used at dix/events.c! */
238*4882a593Smuzhiyun WindowPtr *spriteTrace;
239*4882a593Smuzhiyun int spriteTraceSize;
240*4882a593Smuzhiyun int spriteTraceGood;
241*4882a593Smuzhiyun
242*4882a593Smuzhiyun /* Due to delays between event generation and event processing, it is
243*4882a593Smuzhiyun * possible that the pointer has crossed screen boundaries between the
244*4882a593Smuzhiyun * time in which it begins generating events and the time when
245*4882a593Smuzhiyun * those events are processed.
246*4882a593Smuzhiyun *
247*4882a593Smuzhiyun * pEnqueueScreen: screen the pointer was on when the event was generated
248*4882a593Smuzhiyun * pDequeueScreen: screen the pointer was on when the event is processed
249*4882a593Smuzhiyun */
250*4882a593Smuzhiyun ScreenPtr pEnqueueScreen;
251*4882a593Smuzhiyun ScreenPtr pDequeueScreen;
252*4882a593Smuzhiyun
253*4882a593Smuzhiyun } SpriteRec;
254*4882a593Smuzhiyun
255*4882a593Smuzhiyun typedef struct _KeyClassRec {
256*4882a593Smuzhiyun int sourceid;
257*4882a593Smuzhiyun CARD8 down[DOWN_LENGTH];
258*4882a593Smuzhiyun CARD8 postdown[DOWN_LENGTH];
259*4882a593Smuzhiyun int modifierKeyCount[8];
260*4882a593Smuzhiyun struct _XkbSrvInfo *xkbInfo;
261*4882a593Smuzhiyun } KeyClassRec, *KeyClassPtr;
262*4882a593Smuzhiyun
263*4882a593Smuzhiyun typedef struct _ScrollInfo {
264*4882a593Smuzhiyun enum ScrollType type;
265*4882a593Smuzhiyun double increment;
266*4882a593Smuzhiyun int flags;
267*4882a593Smuzhiyun } ScrollInfo, *ScrollInfoPtr;
268*4882a593Smuzhiyun
269*4882a593Smuzhiyun typedef struct _AxisInfo {
270*4882a593Smuzhiyun int resolution;
271*4882a593Smuzhiyun int min_resolution;
272*4882a593Smuzhiyun int max_resolution;
273*4882a593Smuzhiyun int min_value;
274*4882a593Smuzhiyun int max_value;
275*4882a593Smuzhiyun Atom label;
276*4882a593Smuzhiyun CARD8 mode;
277*4882a593Smuzhiyun ScrollInfo scroll;
278*4882a593Smuzhiyun } AxisInfo, *AxisInfoPtr;
279*4882a593Smuzhiyun
280*4882a593Smuzhiyun typedef struct _ValuatorAccelerationRec {
281*4882a593Smuzhiyun int number;
282*4882a593Smuzhiyun PointerAccelSchemeProc AccelSchemeProc;
283*4882a593Smuzhiyun void *accelData; /* at disposal of AccelScheme */
284*4882a593Smuzhiyun PointerAccelSchemeInitProc AccelInitProc;
285*4882a593Smuzhiyun DeviceCallbackProc AccelCleanupProc;
286*4882a593Smuzhiyun } ValuatorAccelerationRec, *ValuatorAccelerationPtr;
287*4882a593Smuzhiyun
288*4882a593Smuzhiyun typedef struct _ValuatorClassRec {
289*4882a593Smuzhiyun int sourceid;
290*4882a593Smuzhiyun int numMotionEvents;
291*4882a593Smuzhiyun int first_motion;
292*4882a593Smuzhiyun int last_motion;
293*4882a593Smuzhiyun void *motion; /* motion history buffer. Different layout
294*4882a593Smuzhiyun for MDs and SDs! */
295*4882a593Smuzhiyun WindowPtr motionHintWindow;
296*4882a593Smuzhiyun
297*4882a593Smuzhiyun AxisInfoPtr axes;
298*4882a593Smuzhiyun unsigned short numAxes;
299*4882a593Smuzhiyun double *axisVal; /* always absolute, but device-coord system */
300*4882a593Smuzhiyun ValuatorAccelerationRec accelScheme;
301*4882a593Smuzhiyun int h_scroll_axis; /* horiz smooth-scrolling axis */
302*4882a593Smuzhiyun int v_scroll_axis; /* vert smooth-scrolling axis */
303*4882a593Smuzhiyun } ValuatorClassRec;
304*4882a593Smuzhiyun
305*4882a593Smuzhiyun typedef struct _TouchListener {
306*4882a593Smuzhiyun XID listener; /* grabs/event selection IDs receiving
307*4882a593Smuzhiyun * events for this touch */
308*4882a593Smuzhiyun int resource_type; /* listener's resource type */
309*4882a593Smuzhiyun enum TouchListenerType type;
310*4882a593Smuzhiyun enum TouchListenerState state;
311*4882a593Smuzhiyun enum InputLevel level; /* matters only for emulating touches */
312*4882a593Smuzhiyun WindowPtr window;
313*4882a593Smuzhiyun GrabPtr grab;
314*4882a593Smuzhiyun } TouchListener;
315*4882a593Smuzhiyun
316*4882a593Smuzhiyun typedef struct _TouchPointInfo {
317*4882a593Smuzhiyun uint32_t client_id; /* touch ID as seen in client events */
318*4882a593Smuzhiyun int sourceid; /* Source device's ID for this touchpoint */
319*4882a593Smuzhiyun Bool active; /* whether or not the touch is active */
320*4882a593Smuzhiyun Bool pending_finish; /* true if the touch is physically inactive
321*4882a593Smuzhiyun * but still owned by a grab */
322*4882a593Smuzhiyun SpriteRec sprite; /* window trace for delivery */
323*4882a593Smuzhiyun ValuatorMask *valuators; /* last recorded axis values */
324*4882a593Smuzhiyun TouchListener *listeners; /* set of listeners */
325*4882a593Smuzhiyun int num_listeners;
326*4882a593Smuzhiyun int num_grabs; /* number of open grabs on this touch
327*4882a593Smuzhiyun * which have not accepted or rejected */
328*4882a593Smuzhiyun Bool emulate_pointer;
329*4882a593Smuzhiyun DeviceEvent *history; /* History of events on this touchpoint */
330*4882a593Smuzhiyun size_t history_elements; /* Number of current elements in history */
331*4882a593Smuzhiyun size_t history_size; /* Size of history in elements */
332*4882a593Smuzhiyun } TouchPointInfoRec;
333*4882a593Smuzhiyun
334*4882a593Smuzhiyun typedef struct _DDXTouchPointInfo {
335*4882a593Smuzhiyun uint32_t client_id; /* touch ID as seen in client events */
336*4882a593Smuzhiyun Bool active; /* whether or not the touch is active */
337*4882a593Smuzhiyun uint32_t ddx_id; /* touch ID given by the DDX */
338*4882a593Smuzhiyun Bool emulate_pointer;
339*4882a593Smuzhiyun
340*4882a593Smuzhiyun ValuatorMask *valuators; /* last axis values as posted, pre-transform */
341*4882a593Smuzhiyun } DDXTouchPointInfoRec;
342*4882a593Smuzhiyun
343*4882a593Smuzhiyun typedef struct _TouchClassRec {
344*4882a593Smuzhiyun int sourceid;
345*4882a593Smuzhiyun TouchPointInfoPtr touches;
346*4882a593Smuzhiyun unsigned short num_touches; /* number of allocated touches */
347*4882a593Smuzhiyun unsigned short max_touches; /* maximum number of touches, may be 0 */
348*4882a593Smuzhiyun CARD8 mode; /* ::XIDirectTouch, XIDependentTouch */
349*4882a593Smuzhiyun /* for pointer-emulation */
350*4882a593Smuzhiyun CARD8 buttonsDown; /* number of buttons down */
351*4882a593Smuzhiyun unsigned short state; /* logical button state */
352*4882a593Smuzhiyun Mask motionMask;
353*4882a593Smuzhiyun } TouchClassRec;
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun typedef struct _ButtonClassRec {
356*4882a593Smuzhiyun int sourceid;
357*4882a593Smuzhiyun CARD8 numButtons;
358*4882a593Smuzhiyun CARD8 buttonsDown; /* number of buttons currently down
359*4882a593Smuzhiyun This counts logical buttons, not
360*4882a593Smuzhiyun physical ones, i.e if some buttons
361*4882a593Smuzhiyun are mapped to 0, they're not counted
362*4882a593Smuzhiyun here */
363*4882a593Smuzhiyun unsigned short state;
364*4882a593Smuzhiyun Mask motionMask;
365*4882a593Smuzhiyun CARD8 down[DOWN_LENGTH];
366*4882a593Smuzhiyun CARD8 postdown[DOWN_LENGTH];
367*4882a593Smuzhiyun CARD8 map[MAP_LENGTH];
368*4882a593Smuzhiyun union _XkbAction *xkb_acts;
369*4882a593Smuzhiyun Atom labels[MAX_BUTTONS];
370*4882a593Smuzhiyun } ButtonClassRec, *ButtonClassPtr;
371*4882a593Smuzhiyun
372*4882a593Smuzhiyun typedef struct _FocusClassRec {
373*4882a593Smuzhiyun int sourceid;
374*4882a593Smuzhiyun WindowPtr win; /* May be set to a int constant (e.g. PointerRootWin)! */
375*4882a593Smuzhiyun int revert;
376*4882a593Smuzhiyun TimeStamp time;
377*4882a593Smuzhiyun WindowPtr *trace;
378*4882a593Smuzhiyun int traceSize;
379*4882a593Smuzhiyun int traceGood;
380*4882a593Smuzhiyun } FocusClassRec, *FocusClassPtr;
381*4882a593Smuzhiyun
382*4882a593Smuzhiyun typedef struct _ProximityClassRec {
383*4882a593Smuzhiyun int sourceid;
384*4882a593Smuzhiyun char in_proximity;
385*4882a593Smuzhiyun } ProximityClassRec, *ProximityClassPtr;
386*4882a593Smuzhiyun
387*4882a593Smuzhiyun typedef struct _KbdFeedbackClassRec *KbdFeedbackPtr;
388*4882a593Smuzhiyun typedef struct _PtrFeedbackClassRec *PtrFeedbackPtr;
389*4882a593Smuzhiyun typedef struct _IntegerFeedbackClassRec *IntegerFeedbackPtr;
390*4882a593Smuzhiyun typedef struct _StringFeedbackClassRec *StringFeedbackPtr;
391*4882a593Smuzhiyun typedef struct _BellFeedbackClassRec *BellFeedbackPtr;
392*4882a593Smuzhiyun typedef struct _LedFeedbackClassRec *LedFeedbackPtr;
393*4882a593Smuzhiyun
394*4882a593Smuzhiyun typedef struct _KbdFeedbackClassRec {
395*4882a593Smuzhiyun BellProcPtr BellProc;
396*4882a593Smuzhiyun KbdCtrlProcPtr CtrlProc;
397*4882a593Smuzhiyun KeybdCtrl ctrl;
398*4882a593Smuzhiyun KbdFeedbackPtr next;
399*4882a593Smuzhiyun struct _XkbSrvLedInfo *xkb_sli;
400*4882a593Smuzhiyun } KbdFeedbackClassRec;
401*4882a593Smuzhiyun
402*4882a593Smuzhiyun typedef struct _PtrFeedbackClassRec {
403*4882a593Smuzhiyun PtrCtrlProcPtr CtrlProc;
404*4882a593Smuzhiyun PtrCtrl ctrl;
405*4882a593Smuzhiyun PtrFeedbackPtr next;
406*4882a593Smuzhiyun } PtrFeedbackClassRec;
407*4882a593Smuzhiyun
408*4882a593Smuzhiyun typedef struct _IntegerFeedbackClassRec {
409*4882a593Smuzhiyun IntegerCtrlProcPtr CtrlProc;
410*4882a593Smuzhiyun IntegerCtrl ctrl;
411*4882a593Smuzhiyun IntegerFeedbackPtr next;
412*4882a593Smuzhiyun } IntegerFeedbackClassRec;
413*4882a593Smuzhiyun
414*4882a593Smuzhiyun typedef struct _StringFeedbackClassRec {
415*4882a593Smuzhiyun StringCtrlProcPtr CtrlProc;
416*4882a593Smuzhiyun StringCtrl ctrl;
417*4882a593Smuzhiyun StringFeedbackPtr next;
418*4882a593Smuzhiyun } StringFeedbackClassRec;
419*4882a593Smuzhiyun
420*4882a593Smuzhiyun typedef struct _BellFeedbackClassRec {
421*4882a593Smuzhiyun BellProcPtr BellProc;
422*4882a593Smuzhiyun BellCtrlProcPtr CtrlProc;
423*4882a593Smuzhiyun BellCtrl ctrl;
424*4882a593Smuzhiyun BellFeedbackPtr next;
425*4882a593Smuzhiyun } BellFeedbackClassRec;
426*4882a593Smuzhiyun
427*4882a593Smuzhiyun typedef struct _LedFeedbackClassRec {
428*4882a593Smuzhiyun LedCtrlProcPtr CtrlProc;
429*4882a593Smuzhiyun LedCtrl ctrl;
430*4882a593Smuzhiyun LedFeedbackPtr next;
431*4882a593Smuzhiyun struct _XkbSrvLedInfo *xkb_sli;
432*4882a593Smuzhiyun } LedFeedbackClassRec;
433*4882a593Smuzhiyun
434*4882a593Smuzhiyun typedef struct _ClassesRec {
435*4882a593Smuzhiyun KeyClassPtr key;
436*4882a593Smuzhiyun ValuatorClassPtr valuator;
437*4882a593Smuzhiyun TouchClassPtr touch;
438*4882a593Smuzhiyun ButtonClassPtr button;
439*4882a593Smuzhiyun FocusClassPtr focus;
440*4882a593Smuzhiyun ProximityClassPtr proximity;
441*4882a593Smuzhiyun KbdFeedbackPtr kbdfeed;
442*4882a593Smuzhiyun PtrFeedbackPtr ptrfeed;
443*4882a593Smuzhiyun IntegerFeedbackPtr intfeed;
444*4882a593Smuzhiyun StringFeedbackPtr stringfeed;
445*4882a593Smuzhiyun BellFeedbackPtr bell;
446*4882a593Smuzhiyun LedFeedbackPtr leds;
447*4882a593Smuzhiyun } ClassesRec;
448*4882a593Smuzhiyun
449*4882a593Smuzhiyun /* Device properties */
450*4882a593Smuzhiyun typedef struct _XIPropertyValue {
451*4882a593Smuzhiyun Atom type; /* ignored by server */
452*4882a593Smuzhiyun short format; /* format of data for swapping - 8,16,32 */
453*4882a593Smuzhiyun long size; /* size of data in (format/8) bytes */
454*4882a593Smuzhiyun void *data; /* private to client */
455*4882a593Smuzhiyun } XIPropertyValueRec;
456*4882a593Smuzhiyun
457*4882a593Smuzhiyun typedef struct _XIProperty {
458*4882a593Smuzhiyun struct _XIProperty *next;
459*4882a593Smuzhiyun Atom propertyName;
460*4882a593Smuzhiyun BOOL deletable; /* clients can delete this prop? */
461*4882a593Smuzhiyun XIPropertyValueRec value;
462*4882a593Smuzhiyun } XIPropertyRec;
463*4882a593Smuzhiyun
464*4882a593Smuzhiyun typedef XIPropertyRec *XIPropertyPtr;
465*4882a593Smuzhiyun typedef XIPropertyValueRec *XIPropertyValuePtr;
466*4882a593Smuzhiyun
467*4882a593Smuzhiyun typedef struct _XIPropertyHandler {
468*4882a593Smuzhiyun struct _XIPropertyHandler *next;
469*4882a593Smuzhiyun long id;
470*4882a593Smuzhiyun int (*SetProperty) (DeviceIntPtr dev,
471*4882a593Smuzhiyun Atom property, XIPropertyValuePtr prop, BOOL checkonly);
472*4882a593Smuzhiyun int (*GetProperty) (DeviceIntPtr dev, Atom property);
473*4882a593Smuzhiyun int (*DeleteProperty) (DeviceIntPtr dev, Atom property);
474*4882a593Smuzhiyun } XIPropertyHandler, *XIPropertyHandlerPtr;
475*4882a593Smuzhiyun
476*4882a593Smuzhiyun /* states for devices */
477*4882a593Smuzhiyun
478*4882a593Smuzhiyun #define NOT_GRABBED 0
479*4882a593Smuzhiyun #define THAWED 1
480*4882a593Smuzhiyun #define THAWED_BOTH 2 /* not a real state */
481*4882a593Smuzhiyun #define FREEZE_NEXT_EVENT 3
482*4882a593Smuzhiyun #define FREEZE_BOTH_NEXT_EVENT 4
483*4882a593Smuzhiyun #define FROZEN 5 /* any state >= has device frozen */
484*4882a593Smuzhiyun #define FROZEN_NO_EVENT 5
485*4882a593Smuzhiyun #define FROZEN_WITH_EVENT 6
486*4882a593Smuzhiyun #define THAW_OTHERS 7
487*4882a593Smuzhiyun
488*4882a593Smuzhiyun typedef struct _GrabInfoRec {
489*4882a593Smuzhiyun TimeStamp grabTime;
490*4882a593Smuzhiyun Bool fromPassiveGrab; /* true if from passive grab */
491*4882a593Smuzhiyun Bool implicitGrab; /* implicit from ButtonPress */
492*4882a593Smuzhiyun GrabPtr unused; /* Kept for ABI stability, remove soon */
493*4882a593Smuzhiyun GrabPtr grab;
494*4882a593Smuzhiyun CARD8 activatingKey;
495*4882a593Smuzhiyun void (*ActivateGrab) (DeviceIntPtr /*device */ ,
496*4882a593Smuzhiyun GrabPtr /*grab */ ,
497*4882a593Smuzhiyun TimeStamp /*time */ ,
498*4882a593Smuzhiyun Bool /*autoGrab */ );
499*4882a593Smuzhiyun void (*DeactivateGrab) (DeviceIntPtr /*device */ );
500*4882a593Smuzhiyun struct {
501*4882a593Smuzhiyun Bool frozen;
502*4882a593Smuzhiyun int state;
503*4882a593Smuzhiyun GrabPtr other; /* if other grab has this frozen */
504*4882a593Smuzhiyun DeviceEvent *event; /* saved to be replayed */
505*4882a593Smuzhiyun } sync;
506*4882a593Smuzhiyun } GrabInfoRec, *GrabInfoPtr;
507*4882a593Smuzhiyun
508*4882a593Smuzhiyun typedef struct _SpriteInfoRec {
509*4882a593Smuzhiyun /* sprite must always point to a valid sprite. For devices sharing the
510*4882a593Smuzhiyun * sprite, let sprite point to a paired spriteOwner's sprite. */
511*4882a593Smuzhiyun SpritePtr sprite; /* sprite information */
512*4882a593Smuzhiyun Bool spriteOwner; /* True if device owns the sprite */
513*4882a593Smuzhiyun DeviceIntPtr paired; /* The paired device. Keyboard if
514*4882a593Smuzhiyun spriteOwner is TRUE, otherwise the
515*4882a593Smuzhiyun pointer that owns the sprite. */
516*4882a593Smuzhiyun
517*4882a593Smuzhiyun /* keep states for animated cursor */
518*4882a593Smuzhiyun struct {
519*4882a593Smuzhiyun CursorPtr pCursor;
520*4882a593Smuzhiyun ScreenPtr pScreen;
521*4882a593Smuzhiyun int elt;
522*4882a593Smuzhiyun } anim;
523*4882a593Smuzhiyun } SpriteInfoRec, *SpriteInfoPtr;
524*4882a593Smuzhiyun
525*4882a593Smuzhiyun /* device types */
526*4882a593Smuzhiyun #define MASTER_POINTER 1
527*4882a593Smuzhiyun #define MASTER_KEYBOARD 2
528*4882a593Smuzhiyun #define SLAVE 3
529*4882a593Smuzhiyun /* special types for GetMaster */
530*4882a593Smuzhiyun #define MASTER_ATTACHED 4 /* Master for this device */
531*4882a593Smuzhiyun #define KEYBOARD_OR_FLOAT 5 /* Keyboard master for this device or this device if floating */
532*4882a593Smuzhiyun #define POINTER_OR_FLOAT 6 /* Pointer master for this device or this device if floating */
533*4882a593Smuzhiyun
534*4882a593Smuzhiyun typedef struct _DeviceIntRec {
535*4882a593Smuzhiyun DeviceRec public;
536*4882a593Smuzhiyun DeviceIntPtr next;
537*4882a593Smuzhiyun Bool startup; /* true if needs to be turned on at
538*4882a593Smuzhiyun server initialization time */
539*4882a593Smuzhiyun DeviceProc deviceProc; /* proc(DevicePtr, DEVICE_xx). It is
540*4882a593Smuzhiyun used to initialize, turn on, or
541*4882a593Smuzhiyun turn off the device */
542*4882a593Smuzhiyun Bool inited; /* TRUE if INIT returns Success */
543*4882a593Smuzhiyun Bool enabled; /* TRUE if ON returns Success */
544*4882a593Smuzhiyun Bool coreEvents; /* TRUE if device also sends core */
545*4882a593Smuzhiyun GrabInfoRec deviceGrab; /* grab on the device */
546*4882a593Smuzhiyun int type; /* MASTER_POINTER, MASTER_KEYBOARD, SLAVE */
547*4882a593Smuzhiyun Atom xinput_type;
548*4882a593Smuzhiyun char *name;
549*4882a593Smuzhiyun int id;
550*4882a593Smuzhiyun KeyClassPtr key;
551*4882a593Smuzhiyun ValuatorClassPtr valuator;
552*4882a593Smuzhiyun TouchClassPtr touch;
553*4882a593Smuzhiyun ButtonClassPtr button;
554*4882a593Smuzhiyun FocusClassPtr focus;
555*4882a593Smuzhiyun ProximityClassPtr proximity;
556*4882a593Smuzhiyun KbdFeedbackPtr kbdfeed;
557*4882a593Smuzhiyun PtrFeedbackPtr ptrfeed;
558*4882a593Smuzhiyun IntegerFeedbackPtr intfeed;
559*4882a593Smuzhiyun StringFeedbackPtr stringfeed;
560*4882a593Smuzhiyun BellFeedbackPtr bell;
561*4882a593Smuzhiyun LedFeedbackPtr leds;
562*4882a593Smuzhiyun struct _XkbInterest *xkb_interest;
563*4882a593Smuzhiyun char *config_info; /* used by the hotplug layer */
564*4882a593Smuzhiyun ClassesPtr unused_classes; /* for master devices */
565*4882a593Smuzhiyun int saved_master_id; /* for slaves while grabbed */
566*4882a593Smuzhiyun PrivateRec *devPrivates;
567*4882a593Smuzhiyun DeviceUnwrapProc unwrapProc;
568*4882a593Smuzhiyun SpriteInfoPtr spriteInfo;
569*4882a593Smuzhiyun DeviceIntPtr master; /* master device */
570*4882a593Smuzhiyun DeviceIntPtr lastSlave; /* last slave device used */
571*4882a593Smuzhiyun
572*4882a593Smuzhiyun /* last valuator values recorded, not posted to client;
573*4882a593Smuzhiyun * for slave devices, valuators is in device coordinates, mapped to the
574*4882a593Smuzhiyun * desktop
575*4882a593Smuzhiyun * for master devices, valuators is in desktop coordinates.
576*4882a593Smuzhiyun * see dix/getevents.c
577*4882a593Smuzhiyun * remainder supports acceleration
578*4882a593Smuzhiyun */
579*4882a593Smuzhiyun struct {
580*4882a593Smuzhiyun double valuators[MAX_VALUATORS];
581*4882a593Smuzhiyun int numValuators;
582*4882a593Smuzhiyun DeviceIntPtr slave;
583*4882a593Smuzhiyun ValuatorMask *scroll;
584*4882a593Smuzhiyun int num_touches; /* size of the touches array */
585*4882a593Smuzhiyun DDXTouchPointInfoPtr touches;
586*4882a593Smuzhiyun } last;
587*4882a593Smuzhiyun
588*4882a593Smuzhiyun /* Input device property handling. */
589*4882a593Smuzhiyun struct {
590*4882a593Smuzhiyun XIPropertyPtr properties;
591*4882a593Smuzhiyun XIPropertyHandlerPtr handlers; /* NULL-terminated */
592*4882a593Smuzhiyun } properties;
593*4882a593Smuzhiyun
594*4882a593Smuzhiyun /* coordinate transformation matrix for relative movement. Matrix with
595*4882a593Smuzhiyun * the translation component dropped */
596*4882a593Smuzhiyun struct pixman_f_transform relative_transform;
597*4882a593Smuzhiyun /* scale matrix for absolute devices, this is the combined matrix of
598*4882a593Smuzhiyun [1/scale] . [transform] . [scale]. See DeviceSetTransform */
599*4882a593Smuzhiyun struct pixman_f_transform scale_and_transform;
600*4882a593Smuzhiyun
601*4882a593Smuzhiyun /* XTest related master device id */
602*4882a593Smuzhiyun int xtest_master_id;
603*4882a593Smuzhiyun
604*4882a593Smuzhiyun struct _SyncCounter *idle_counter;
605*4882a593Smuzhiyun } DeviceIntRec;
606*4882a593Smuzhiyun
607*4882a593Smuzhiyun typedef struct {
608*4882a593Smuzhiyun int numDevices; /* total number of devices */
609*4882a593Smuzhiyun DeviceIntPtr devices; /* all devices turned on */
610*4882a593Smuzhiyun DeviceIntPtr off_devices; /* all devices turned off */
611*4882a593Smuzhiyun DeviceIntPtr keyboard; /* the main one for the server */
612*4882a593Smuzhiyun DeviceIntPtr pointer;
613*4882a593Smuzhiyun DeviceIntPtr all_devices;
614*4882a593Smuzhiyun DeviceIntPtr all_master_devices;
615*4882a593Smuzhiyun } InputInfo;
616*4882a593Smuzhiyun
617*4882a593Smuzhiyun extern _X_EXPORT InputInfo inputInfo;
618*4882a593Smuzhiyun
619*4882a593Smuzhiyun /* for keeping the events for devices grabbed synchronously */
620*4882a593Smuzhiyun typedef struct _QdEvent *QdEventPtr;
621*4882a593Smuzhiyun typedef struct _QdEvent {
622*4882a593Smuzhiyun struct xorg_list next;
623*4882a593Smuzhiyun DeviceIntPtr device;
624*4882a593Smuzhiyun ScreenPtr pScreen; /* what screen the pointer was on */
625*4882a593Smuzhiyun unsigned long months; /* milliseconds is in the event */
626*4882a593Smuzhiyun InternalEvent *event;
627*4882a593Smuzhiyun } QdEventRec;
628*4882a593Smuzhiyun
629*4882a593Smuzhiyun /**
630*4882a593Smuzhiyun * syncEvents is the global structure for queued events.
631*4882a593Smuzhiyun *
632*4882a593Smuzhiyun * Devices can be frozen through GrabModeSync pointer grabs. If this is the
633*4882a593Smuzhiyun * case, events from these devices are added to "pending" instead of being
634*4882a593Smuzhiyun * processed normally. When the device is unfrozen, events in "pending" are
635*4882a593Smuzhiyun * replayed and processed as if they would come from the device directly.
636*4882a593Smuzhiyun */
637*4882a593Smuzhiyun typedef struct _EventSyncInfo {
638*4882a593Smuzhiyun struct xorg_list pending;
639*4882a593Smuzhiyun
640*4882a593Smuzhiyun /** The device to replay events for. Only set in AllowEvents(), in which
641*4882a593Smuzhiyun * case it is set to the device specified in the request. */
642*4882a593Smuzhiyun DeviceIntPtr replayDev; /* kludgy rock to put flag for */
643*4882a593Smuzhiyun
644*4882a593Smuzhiyun /**
645*4882a593Smuzhiyun * The window the events are supposed to be replayed on.
646*4882a593Smuzhiyun * This window may be set to the grab's window (but only when
647*4882a593Smuzhiyun * Replay{Pointer|Keyboard} is given in the XAllowEvents()
648*4882a593Smuzhiyun * request. */
649*4882a593Smuzhiyun WindowPtr replayWin; /* ComputeFreezes */
650*4882a593Smuzhiyun /**
651*4882a593Smuzhiyun * Flag to indicate whether we're in the process of
652*4882a593Smuzhiyun * replaying events. Only set in ComputeFreezes(). */
653*4882a593Smuzhiyun Bool playingEvents;
654*4882a593Smuzhiyun TimeStamp time;
655*4882a593Smuzhiyun } EventSyncInfoRec, *EventSyncInfoPtr;
656*4882a593Smuzhiyun
657*4882a593Smuzhiyun extern EventSyncInfoRec syncEvents;
658*4882a593Smuzhiyun
659*4882a593Smuzhiyun /**
660*4882a593Smuzhiyun * Given a sprite, returns the window at the bottom of the trace (i.e. the
661*4882a593Smuzhiyun * furthest window from the root).
662*4882a593Smuzhiyun */
663*4882a593Smuzhiyun static inline WindowPtr
DeepestSpriteWin(SpritePtr sprite)664*4882a593Smuzhiyun DeepestSpriteWin(SpritePtr sprite)
665*4882a593Smuzhiyun {
666*4882a593Smuzhiyun assert(sprite->spriteTraceGood > 0);
667*4882a593Smuzhiyun return sprite->spriteTrace[sprite->spriteTraceGood - 1];
668*4882a593Smuzhiyun }
669*4882a593Smuzhiyun
670*4882a593Smuzhiyun struct _XI2Mask {
671*4882a593Smuzhiyun unsigned char **masks; /* event mask in masks[deviceid][event type byte] */
672*4882a593Smuzhiyun size_t nmasks; /* number of masks */
673*4882a593Smuzhiyun size_t mask_size; /* size of each mask in bytes */
674*4882a593Smuzhiyun };
675*4882a593Smuzhiyun
676*4882a593Smuzhiyun #endif /* INPUTSTRUCT_H */
677