1706f2543Smrg/************************************************************
2706f2543Smrg
3706f2543SmrgCopyright 1987, 1998  The Open Group
4706f2543Smrg
5706f2543SmrgPermission to use, copy, modify, distribute, and sell this software and its
6706f2543Smrgdocumentation for any purpose is hereby granted without fee, provided that
7706f2543Smrgthe above copyright notice appear in all copies and that both that
8706f2543Smrgcopyright notice and this permission notice appear in supporting
9706f2543Smrgdocumentation.
10706f2543Smrg
11706f2543SmrgThe above copyright notice and this permission notice shall be included in
12706f2543Smrgall copies or substantial portions of the Software.
13706f2543Smrg
14706f2543SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15706f2543SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16706f2543SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17706f2543SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18706f2543SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19706f2543SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20706f2543Smrg
21706f2543SmrgExcept as contained in this notice, the name of The Open Group shall not be
22706f2543Smrgused in advertising or otherwise to promote the sale, use or other dealings
23706f2543Smrgin this Software without prior written authorization from The Open Group.
24706f2543Smrg
25706f2543Smrg
26706f2543SmrgCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
27706f2543Smrg
28706f2543Smrg                        All Rights Reserved
29706f2543Smrg
30706f2543SmrgPermission to use, copy, modify, and distribute this software and its
31706f2543Smrgdocumentation for any purpose and without fee is hereby granted,
32706f2543Smrgprovided that the above copyright notice appear in all copies and that
33706f2543Smrgboth that copyright notice and this permission notice appear in
34706f2543Smrgsupporting documentation, and that the name of Digital not be
35706f2543Smrgused in advertising or publicity pertaining to distribution of the
36706f2543Smrgsoftware without specific, written prior permission.
37706f2543Smrg
38706f2543SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39706f2543SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40706f2543SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41706f2543SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42706f2543SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43706f2543SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44706f2543SmrgSOFTWARE.
45706f2543Smrg
46706f2543Smrg********************************************************/
47706f2543Smrg
48706f2543Smrg
49706f2543Smrg#ifndef INPUTSTRUCT_H
50706f2543Smrg#define INPUTSTRUCT_H
51706f2543Smrg
52706f2543Smrg#include <pixman.h>
53706f2543Smrg#include "input.h"
54706f2543Smrg#include "window.h"
55706f2543Smrg#include "dixstruct.h"
56706f2543Smrg#include "cursorstr.h"
57706f2543Smrg#include "geext.h"
58706f2543Smrg#include "privates.h"
59706f2543Smrg
60706f2543Smrg#define BitIsOn(ptr, bit) (!!(((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7))))
61706f2543Smrg#define SetBit(ptr, bit)  (((BYTE *) (ptr))[(bit)>>3] |= (1 << ((bit) & 7)))
62706f2543Smrg#define ClearBit(ptr, bit) (((BYTE *)(ptr))[(bit)>>3] &= ~(1 << ((bit) & 7)))
63706f2543Smrgextern _X_EXPORT int CountBits(const uint8_t *mask, int len);
64706f2543Smrg
65706f2543Smrg#define SameClient(obj,client) \
66706f2543Smrg	(CLIENT_BITS((obj)->resource) == (client)->clientAsMask)
67706f2543Smrg
68706f2543Smrg#define EMASKSIZE	MAXDEVICES + 2
69706f2543Smrg
70706f2543Smrg/* This is the last XI2 event supported by the server. If you add
71706f2543Smrg * events to the protocol, the server will not support these events until
72706f2543Smrg * this number here is bumped.
73706f2543Smrg */
74706f2543Smrg#define XI2LASTEVENT    17 /* XI_RawMotion */
75706f2543Smrg#define XI2MASKSIZE     ((XI2LASTEVENT + 7)/8) /* no of bits for masks */
76706f2543Smrg
77706f2543Smrg/**
78706f2543Smrg * This struct stores the core event mask for each client except the client
79706f2543Smrg * that created the window.
80706f2543Smrg *
81706f2543Smrg * Each window that has events selected from other clients has at least one of
82706f2543Smrg * these masks. If multiple clients selected for events on the same window,
83706f2543Smrg * these masks are in a linked list.
84706f2543Smrg *
85706f2543Smrg * The event mask for the client that created the window is stored in
86706f2543Smrg * win->eventMask instead.
87706f2543Smrg *
88706f2543Smrg * The resource id is simply a fake client ID to associate this mask with a
89706f2543Smrg * client.
90706f2543Smrg *
91706f2543Smrg * Kludge: OtherClients and InputClients must be compatible, see code.
92706f2543Smrg */
93706f2543Smrgtypedef struct _OtherClients {
94706f2543Smrg    OtherClientsPtr	next; /**< Pointer to the next mask */
95706f2543Smrg    XID			resource; /**< id for putting into resource manager */
96706f2543Smrg    Mask		mask; /**< Core event mask */
97706f2543Smrg} OtherClients;
98706f2543Smrg
99706f2543Smrg/**
100706f2543Smrg * This struct stores the XI event mask for each client.
101706f2543Smrg *
102706f2543Smrg * Each window that has events selected has at least one of these masks. If
103706f2543Smrg * multiple client selected for events on the same window, these masks are in
104706f2543Smrg * a linked list.
105706f2543Smrg */
106706f2543Smrgtypedef struct _InputClients {
107706f2543Smrg    InputClientsPtr	next; /**< Pointer to the next mask */
108706f2543Smrg    XID			resource; /**< id for putting into resource manager */
109706f2543Smrg    Mask		mask[EMASKSIZE]; /**< Actual XI event mask, deviceid is index */
110706f2543Smrg    /** XI2 event masks. One per device, each bit is a mask of (1 << type) */
111706f2543Smrg    unsigned char       xi2mask[EMASKSIZE][XI2MASKSIZE];
112706f2543Smrg} InputClients;
113706f2543Smrg
114706f2543Smrg/**
115706f2543Smrg * Combined XI event masks from all devices.
116706f2543Smrg *
117706f2543Smrg * This is the XI equivalent of the deliverableEvents, eventMask and
118706f2543Smrg * dontPropagate mask of the WindowRec (or WindowOptRec).
119706f2543Smrg *
120706f2543Smrg * A window that has an XI client selecting for events has exactly one
121706f2543Smrg * OtherInputMasks struct and exactly one InputClients struct hanging off
122706f2543Smrg * inputClients. Each further client appends to the inputClients list.
123706f2543Smrg * Each Mask field is per-device, with the device id as the index.
124706f2543Smrg * Exception: for non-device events (Presence events), the MAXDEVICES
125706f2543Smrg * deviceid is used.
126706f2543Smrg */
127706f2543Smrgtypedef struct _OtherInputMasks {
128706f2543Smrg    /**
129706f2543Smrg     * Bitwise OR of all masks by all clients and the window's parent's masks.
130706f2543Smrg     */
131706f2543Smrg    Mask		deliverableEvents[EMASKSIZE];
132706f2543Smrg    /**
133706f2543Smrg     * Bitwise OR of all masks by all clients on this window.
134706f2543Smrg     */
135706f2543Smrg    Mask		inputEvents[EMASKSIZE];
136706f2543Smrg    /** The do-not-propagate masks for each device. */
137706f2543Smrg    Mask		dontPropagateMask[EMASKSIZE];
138706f2543Smrg    /** The clients that selected for events */
139706f2543Smrg    InputClientsPtr	inputClients;
140706f2543Smrg    /* XI2 event masks. One per device, each bit is a mask of (1 << type) */
141706f2543Smrg    unsigned char       xi2mask[EMASKSIZE][XI2MASKSIZE];
142706f2543Smrg} OtherInputMasks;
143706f2543Smrg
144706f2543Smrg/*
145706f2543Smrg * The following structure gets used for both active and passive grabs. For
146706f2543Smrg * active grabs some of the fields (e.g. modifiers) are not used. However,
147706f2543Smrg * that is not much waste since there aren't many active grabs (one per
148706f2543Smrg * keyboard/pointer device) going at once in the server.
149706f2543Smrg */
150706f2543Smrg
151706f2543Smrg#define MasksPerDetailMask 8		/* 256 keycodes and 256 possible
152706f2543Smrg                                           modifier combinations, but only
153706f2543Smrg                                           3 buttons. */
154706f2543Smrg
155706f2543Smrgtypedef struct _DetailRec {		/* Grab details may be bit masks */
156706f2543Smrg    unsigned int        exact;
157706f2543Smrg    Mask                *pMask;
158706f2543Smrg} DetailRec;
159706f2543Smrg
160706f2543Smrgtypedef enum {
161706f2543Smrg    GRABTYPE_CORE,
162706f2543Smrg    GRABTYPE_XI,
163706f2543Smrg    GRABTYPE_XI2
164706f2543Smrg} GrabType;
165706f2543Smrg
166706f2543Smrgunion _GrabMask {
167706f2543Smrg    Mask core;
168706f2543Smrg    Mask xi;
169706f2543Smrg    char xi2mask[EMASKSIZE][XI2MASKSIZE];
170706f2543Smrg};
171706f2543Smrg
172706f2543Smrg/**
173706f2543Smrg * Central struct for device grabs.
174706f2543Smrg * The same struct is used for both core grabs and device grabs, with
175706f2543Smrg * different fields being set.
176706f2543Smrg * If the grab is a core grab (GrabPointer/GrabKeyboard), then the eventMask
177706f2543Smrg * is a combination of standard event masks (i.e. PointerMotionMask |
178706f2543Smrg * ButtonPressMask).
179706f2543Smrg * If the grab is a device grab (GrabDevice), then the eventMask is a
180706f2543Smrg * combination of event masks for a given XI event type (see SetEventInfo).
181706f2543Smrg *
182706f2543Smrg * If the grab is a result of a ButtonPress, then eventMask is the core mask
183706f2543Smrg * and deviceMask is set to the XI event mask for the grab.
184706f2543Smrg */
185706f2543Smrgtypedef struct _GrabRec {
186706f2543Smrg    GrabPtr		next;		/* for chain of passive grabs */
187706f2543Smrg    XID			resource;
188706f2543Smrg    DeviceIntPtr	device;
189706f2543Smrg    WindowPtr		window;
190706f2543Smrg    unsigned		ownerEvents:1;
191706f2543Smrg    unsigned		keyboardMode:1;
192706f2543Smrg    unsigned		pointerMode:1;
193706f2543Smrg    GrabType		grabtype;
194706f2543Smrg    CARD8		type;		/* event type */
195706f2543Smrg    DetailRec		modifiersDetail;
196706f2543Smrg    DeviceIntPtr	modifierDevice;
197706f2543Smrg    DetailRec		detail;		/* key or button */
198706f2543Smrg    WindowPtr		confineTo;	/* always NULL for keyboards */
199706f2543Smrg    CursorPtr		cursor;		/* always NULL for keyboards */
200706f2543Smrg    Mask		eventMask;
201706f2543Smrg    Mask                deviceMask;
202706f2543Smrg    /* XI2 event masks. One per device, each bit is a mask of (1 << type) */
203706f2543Smrg    unsigned char       xi2mask[EMASKSIZE][XI2MASKSIZE];
204706f2543Smrg} GrabRec;
205706f2543Smrg
206706f2543Smrg/**
207706f2543Smrg * Sprite information for a device.
208706f2543Smrg */
209706f2543Smrgtypedef struct _SpriteRec {
210706f2543Smrg    CursorPtr	current;
211706f2543Smrg    BoxRec	hotLimits;	/* logical constraints of hot spot */
212706f2543Smrg    Bool	confined;	/* confined to screen */
213706f2543Smrg    RegionPtr	hotShape;	/* additional logical shape constraint */
214706f2543Smrg    BoxRec	physLimits;	/* physical constraints of hot spot */
215706f2543Smrg    WindowPtr	win;		/* window of logical position */
216706f2543Smrg    HotSpot	hot;		/* logical pointer position */
217706f2543Smrg    HotSpot	hotPhys;	/* physical pointer position */
218706f2543Smrg#ifdef PANORAMIX
219706f2543Smrg    ScreenPtr	screen;		/* all others are in Screen 0 coordinates */
220706f2543Smrg    RegionRec   Reg1;	        /* Region 1 for confining motion */
221706f2543Smrg    RegionRec   Reg2;		/* Region 2 for confining virtual motion */
222706f2543Smrg    WindowPtr   windows[MAXSCREENS];
223706f2543Smrg    WindowPtr	confineWin;	/* confine window */
224706f2543Smrg#endif
225706f2543Smrg    /* The window trace information is used at dix/events.c to avoid having
226706f2543Smrg     * to compute all the windows between the root and the current pointer
227706f2543Smrg     * window each time a button or key goes down. The grabs on each of those
228706f2543Smrg     * windows must be checked.
229706f2543Smrg     * spriteTraces should only be used at dix/events.c! */
230706f2543Smrg    WindowPtr *spriteTrace;
231706f2543Smrg    int spriteTraceSize;
232706f2543Smrg    int spriteTraceGood;
233706f2543Smrg
234706f2543Smrg    /* Due to delays between event generation and event processing, it is
235706f2543Smrg     * possible that the pointer has crossed screen boundaries between the
236706f2543Smrg     * time in which it begins generating events and the time when
237706f2543Smrg     * those events are processed.
238706f2543Smrg     *
239706f2543Smrg     * pEnqueueScreen: screen the pointer was on when the event was generated
240706f2543Smrg     * pDequeueScreen: screen the pointer was on when the event is processed
241706f2543Smrg     */
242706f2543Smrg    ScreenPtr pEnqueueScreen;
243706f2543Smrg    ScreenPtr pDequeueScreen;
244706f2543Smrg
245706f2543Smrg} SpriteRec;
246706f2543Smrg
247706f2543Smrgtypedef struct _KeyClassRec {
248706f2543Smrg    int			sourceid;
249706f2543Smrg    CARD8		down[DOWN_LENGTH];
250706f2543Smrg    CARD8		postdown[DOWN_LENGTH];
251706f2543Smrg    int                 modifierKeyCount[8];
252706f2543Smrg    struct _XkbSrvInfo *xkbInfo;
253706f2543Smrg} KeyClassRec, *KeyClassPtr;
254706f2543Smrg
255706f2543Smrgtypedef struct _AxisInfo {
256706f2543Smrg    int		resolution;
257706f2543Smrg    int		min_resolution;
258706f2543Smrg    int		max_resolution;
259706f2543Smrg    int		min_value;
260706f2543Smrg    int		max_value;
261706f2543Smrg    Atom	label;
262706f2543Smrg    CARD8	mode;
263706f2543Smrg} AxisInfo, *AxisInfoPtr;
264706f2543Smrg
265706f2543Smrgtypedef struct _ValuatorAccelerationRec {
266706f2543Smrg    int                         number;
267706f2543Smrg    PointerAccelSchemeProc      AccelSchemeProc;
268706f2543Smrg    void                       *accelData; /* at disposal of AccelScheme */
269706f2543Smrg    DeviceCallbackProc          AccelCleanupProc;
270706f2543Smrg} ValuatorAccelerationRec, *ValuatorAccelerationPtr;
271706f2543Smrg
272706f2543Smrgtypedef struct _ValuatorClassRec {
273706f2543Smrg    int                   sourceid;
274706f2543Smrg    int		 	  numMotionEvents;
275706f2543Smrg    int                   first_motion;
276706f2543Smrg    int                   last_motion;
277706f2543Smrg    void                  *motion; /* motion history buffer. Different layout
278706f2543Smrg                                      for MDs and SDs!*/
279706f2543Smrg    WindowPtr             motionHintWindow;
280706f2543Smrg
281706f2543Smrg    AxisInfoPtr 	  axes;
282706f2543Smrg    unsigned short	  numAxes;
283706f2543Smrg    double		  *axisVal; /* always absolute, but device-coord system */
284706f2543Smrg    ValuatorAccelerationRec	accelScheme;
285706f2543Smrg} ValuatorClassRec;
286706f2543Smrg
287706f2543Smrgtypedef struct _ButtonClassRec {
288706f2543Smrg    int			sourceid;
289706f2543Smrg    CARD8		numButtons;
290706f2543Smrg    CARD8		buttonsDown;	/* number of buttons currently down
291706f2543Smrg                                           This counts logical buttons, not
292706f2543Smrg					   physical ones, i.e if some buttons
293706f2543Smrg					   are mapped to 0, they're not counted
294706f2543Smrg					   here */
295706f2543Smrg    unsigned short	state;
296706f2543Smrg    Mask		motionMask;
297706f2543Smrg    CARD8		down[DOWN_LENGTH];
298706f2543Smrg    CARD8		postdown[DOWN_LENGTH];
299706f2543Smrg    CARD8		map[MAP_LENGTH];
300706f2543Smrg    union _XkbAction    *xkb_acts;
301706f2543Smrg    Atom		labels[MAX_BUTTONS];
302706f2543Smrg} ButtonClassRec, *ButtonClassPtr;
303706f2543Smrg
304706f2543Smrgtypedef struct _FocusClassRec {
305706f2543Smrg    int		sourceid;
306706f2543Smrg    WindowPtr	win; /* May be set to a int constant (e.g. PointerRootWin)! */
307706f2543Smrg    int		revert;
308706f2543Smrg    TimeStamp	time;
309706f2543Smrg    WindowPtr	*trace;
310706f2543Smrg    int		traceSize;
311706f2543Smrg    int		traceGood;
312706f2543Smrg} FocusClassRec, *FocusClassPtr;
313706f2543Smrg
314706f2543Smrgtypedef struct _ProximityClassRec {
315706f2543Smrg    int		sourceid;
316706f2543Smrg    char	in_proximity;
317706f2543Smrg} ProximityClassRec, *ProximityClassPtr;
318706f2543Smrg
319706f2543Smrgtypedef struct _AbsoluteClassRec {
320706f2543Smrg    int         sourceid;
321706f2543Smrg    /* Calibration. */
322706f2543Smrg    int         min_x;
323706f2543Smrg    int         max_x;
324706f2543Smrg    int         min_y;
325706f2543Smrg    int         max_y;
326706f2543Smrg    int         flip_x;
327706f2543Smrg    int         flip_y;
328706f2543Smrg    int		rotation;
329706f2543Smrg    int         button_threshold;
330706f2543Smrg
331706f2543Smrg    /* Area. */
332706f2543Smrg    int         offset_x;
333706f2543Smrg    int         offset_y;
334706f2543Smrg    int         width;
335706f2543Smrg    int         height;
336706f2543Smrg    int         screen;
337706f2543Smrg    XID		following;
338706f2543Smrg} AbsoluteClassRec, *AbsoluteClassPtr;
339706f2543Smrg
340706f2543Smrgtypedef struct _KbdFeedbackClassRec *KbdFeedbackPtr;
341706f2543Smrgtypedef struct _PtrFeedbackClassRec *PtrFeedbackPtr;
342706f2543Smrgtypedef struct _IntegerFeedbackClassRec *IntegerFeedbackPtr;
343706f2543Smrgtypedef struct _StringFeedbackClassRec *StringFeedbackPtr;
344706f2543Smrgtypedef struct _BellFeedbackClassRec *BellFeedbackPtr;
345706f2543Smrgtypedef struct _LedFeedbackClassRec *LedFeedbackPtr;
346706f2543Smrg
347706f2543Smrgtypedef struct _KbdFeedbackClassRec {
348706f2543Smrg    BellProcPtr		BellProc;
349706f2543Smrg    KbdCtrlProcPtr	CtrlProc;
350706f2543Smrg    KeybdCtrl	 	ctrl;
351706f2543Smrg    KbdFeedbackPtr	next;
352706f2543Smrg    struct _XkbSrvLedInfo *xkb_sli;
353706f2543Smrg} KbdFeedbackClassRec;
354706f2543Smrg
355706f2543Smrgtypedef struct _PtrFeedbackClassRec {
356706f2543Smrg    PtrCtrlProcPtr	CtrlProc;
357706f2543Smrg    PtrCtrl		ctrl;
358706f2543Smrg    PtrFeedbackPtr	next;
359706f2543Smrg} PtrFeedbackClassRec;
360706f2543Smrg
361706f2543Smrgtypedef struct _IntegerFeedbackClassRec {
362706f2543Smrg    IntegerCtrlProcPtr	CtrlProc;
363706f2543Smrg    IntegerCtrl	 	ctrl;
364706f2543Smrg    IntegerFeedbackPtr	next;
365706f2543Smrg} IntegerFeedbackClassRec;
366706f2543Smrg
367706f2543Smrgtypedef struct _StringFeedbackClassRec {
368706f2543Smrg    StringCtrlProcPtr	CtrlProc;
369706f2543Smrg    StringCtrl	 	ctrl;
370706f2543Smrg    StringFeedbackPtr	next;
371706f2543Smrg} StringFeedbackClassRec;
372706f2543Smrg
373706f2543Smrgtypedef struct _BellFeedbackClassRec {
374706f2543Smrg    BellProcPtr		BellProc;
375706f2543Smrg    BellCtrlProcPtr	CtrlProc;
376706f2543Smrg    BellCtrl	 	ctrl;
377706f2543Smrg    BellFeedbackPtr	next;
378706f2543Smrg} BellFeedbackClassRec;
379706f2543Smrg
380706f2543Smrgtypedef struct _LedFeedbackClassRec {
381706f2543Smrg    LedCtrlProcPtr	CtrlProc;
382706f2543Smrg    LedCtrl	 	ctrl;
383706f2543Smrg    LedFeedbackPtr	next;
384706f2543Smrg    struct _XkbSrvLedInfo *xkb_sli;
385706f2543Smrg} LedFeedbackClassRec;
386706f2543Smrg
387706f2543Smrg
388706f2543Smrgtypedef struct _ClassesRec {
389706f2543Smrg    KeyClassPtr		key;
390706f2543Smrg    ValuatorClassPtr	valuator;
391706f2543Smrg    ButtonClassPtr	button;
392706f2543Smrg    FocusClassPtr	focus;
393706f2543Smrg    ProximityClassPtr	proximity;
394706f2543Smrg    AbsoluteClassPtr    absolute;
395706f2543Smrg    KbdFeedbackPtr	kbdfeed;
396706f2543Smrg    PtrFeedbackPtr	ptrfeed;
397706f2543Smrg    IntegerFeedbackPtr	intfeed;
398706f2543Smrg    StringFeedbackPtr	stringfeed;
399706f2543Smrg    BellFeedbackPtr	bell;
400706f2543Smrg    LedFeedbackPtr	leds;
401706f2543Smrg} ClassesRec;
402706f2543Smrg
403706f2543Smrg
404706f2543Smrg/* Device properties */
405706f2543Smrgtypedef struct _XIPropertyValue
406706f2543Smrg{
407706f2543Smrg    Atom                type;           /* ignored by server */
408706f2543Smrg    short               format;         /* format of data for swapping - 8,16,32 */
409706f2543Smrg    long                size;           /* size of data in (format/8) bytes */
410706f2543Smrg    pointer             data;           /* private to client */
411706f2543Smrg} XIPropertyValueRec;
412706f2543Smrg
413706f2543Smrgtypedef struct _XIProperty
414706f2543Smrg{
415706f2543Smrg    struct _XIProperty   *next;
416706f2543Smrg    Atom                  propertyName;
417706f2543Smrg    BOOL                  deletable;    /* clients can delete this prop? */
418706f2543Smrg    XIPropertyValueRec    value;
419706f2543Smrg} XIPropertyRec;
420706f2543Smrg
421706f2543Smrgtypedef XIPropertyRec      *XIPropertyPtr;
422706f2543Smrgtypedef XIPropertyValueRec *XIPropertyValuePtr;
423706f2543Smrg
424706f2543Smrg
425706f2543Smrgtypedef struct _XIPropertyHandler
426706f2543Smrg{
427706f2543Smrg    struct _XIPropertyHandler* next;
428706f2543Smrg    long id;
429706f2543Smrg    int (*SetProperty) (DeviceIntPtr dev,
430706f2543Smrg                        Atom property,
431706f2543Smrg                        XIPropertyValuePtr prop,
432706f2543Smrg                        BOOL checkonly);
433706f2543Smrg    int (*GetProperty) (DeviceIntPtr dev,
434706f2543Smrg                        Atom property);
435706f2543Smrg    int (*DeleteProperty) (DeviceIntPtr dev,
436706f2543Smrg                           Atom property);
437706f2543Smrg} XIPropertyHandler, *XIPropertyHandlerPtr;
438706f2543Smrg
439706f2543Smrg/* states for devices */
440706f2543Smrg
441706f2543Smrg#define NOT_GRABBED		0
442706f2543Smrg#define THAWED			1
443706f2543Smrg#define THAWED_BOTH		2	/* not a real state */
444706f2543Smrg#define FREEZE_NEXT_EVENT	3
445706f2543Smrg#define FREEZE_BOTH_NEXT_EVENT	4
446706f2543Smrg#define FROZEN			5	/* any state >= has device frozen */
447706f2543Smrg#define FROZEN_NO_EVENT		5
448706f2543Smrg#define FROZEN_WITH_EVENT	6
449706f2543Smrg#define THAW_OTHERS		7
450706f2543Smrg
451706f2543Smrg
452706f2543Smrgtypedef struct _GrabInfoRec {
453706f2543Smrg    TimeStamp	    grabTime;
454706f2543Smrg    Bool            fromPassiveGrab;    /* true if from passive grab */
455706f2543Smrg    Bool            implicitGrab;       /* implicit from ButtonPress */
456706f2543Smrg    GrabRec         activeGrab;
457706f2543Smrg    GrabPtr         grab;
458706f2543Smrg    CARD8           activatingKey;
459706f2543Smrg    void	    (*ActivateGrab) (
460706f2543Smrg                    DeviceIntPtr /*device*/,
461706f2543Smrg                    GrabPtr /*grab*/,
462706f2543Smrg                    TimeStamp /*time*/,
463706f2543Smrg                    Bool /*autoGrab*/);
464706f2543Smrg    void	    (*DeactivateGrab)(
465706f2543Smrg                    DeviceIntPtr /*device*/);
466706f2543Smrg    struct {
467706f2543Smrg	Bool		frozen;
468706f2543Smrg	int		state;
469706f2543Smrg	GrabPtr		other;		/* if other grab has this frozen */
470706f2543Smrg	DeviceEvent	*event;		/* saved to be replayed */
471706f2543Smrg    } sync;
472706f2543Smrg} GrabInfoRec, *GrabInfoPtr;
473706f2543Smrg
474706f2543Smrgtypedef struct _SpriteInfoRec {
475706f2543Smrg    /* sprite must always point to a valid sprite. For devices sharing the
476706f2543Smrg     * sprite, let sprite point to a paired spriteOwner's sprite. */
477706f2543Smrg    SpritePtr           sprite;      /* sprite information */
478706f2543Smrg    Bool                spriteOwner; /* True if device owns the sprite */
479706f2543Smrg    DeviceIntPtr        paired;      /* The paired device. Keyboard if
480706f2543Smrg                                        spriteOwner is TRUE, otherwise the
481706f2543Smrg                                        pointer that owns the sprite. */
482706f2543Smrg
483706f2543Smrg    /* keep states for animated cursor */
484706f2543Smrg    struct {
485706f2543Smrg        CursorPtr       pCursor;
486706f2543Smrg        ScreenPtr       pScreen;
487706f2543Smrg        int             elt;
488706f2543Smrg        CARD32          time;
489706f2543Smrg    } anim;
490706f2543Smrg} SpriteInfoRec, *SpriteInfoPtr;
491706f2543Smrg
492706f2543Smrg/* device types */
493706f2543Smrg#define MASTER_POINTER          1
494706f2543Smrg#define MASTER_KEYBOARD         2
495706f2543Smrg#define SLAVE                   3
496706f2543Smrg
497706f2543Smrgtypedef struct _DeviceIntRec {
498706f2543Smrg    DeviceRec	public;
499706f2543Smrg    DeviceIntPtr next;
500706f2543Smrg    Bool	startup;		/* true if needs to be turned on at
501706f2543Smrg				          server intialization time */
502706f2543Smrg    DeviceProc	deviceProc;		/* proc(DevicePtr, DEVICE_xx). It is
503706f2543Smrg					  used to initialize, turn on, or
504706f2543Smrg					  turn off the device */
505706f2543Smrg    Bool	inited;			/* TRUE if INIT returns Success */
506706f2543Smrg    Bool        enabled;                /* TRUE if ON returns Success */
507706f2543Smrg    Bool        coreEvents;             /* TRUE if device also sends core */
508706f2543Smrg    GrabInfoRec deviceGrab;             /* grab on the device */
509706f2543Smrg    int         type;                   /* MASTER_POINTER, MASTER_KEYBOARD, SLAVE */
510706f2543Smrg    Atom		xinput_type;
511706f2543Smrg    char		*name;
512706f2543Smrg    int			id;
513706f2543Smrg    KeyClassPtr		key;
514706f2543Smrg    ValuatorClassPtr	valuator;
515706f2543Smrg    ButtonClassPtr	button;
516706f2543Smrg    FocusClassPtr	focus;
517706f2543Smrg    ProximityClassPtr	proximity;
518706f2543Smrg    AbsoluteClassPtr    absolute;
519706f2543Smrg    KbdFeedbackPtr	kbdfeed;
520706f2543Smrg    PtrFeedbackPtr	ptrfeed;
521706f2543Smrg    IntegerFeedbackPtr	intfeed;
522706f2543Smrg    StringFeedbackPtr	stringfeed;
523706f2543Smrg    BellFeedbackPtr	bell;
524706f2543Smrg    LedFeedbackPtr	leds;
525706f2543Smrg    struct _XkbInterest *xkb_interest;
526706f2543Smrg    char                *config_info; /* used by the hotplug layer */
527706f2543Smrg    ClassesPtr		unused_classes; /* for master devices */
528706f2543Smrg    int			saved_master_id;	/* for slaves while grabbed */
529706f2543Smrg    PrivateRec		*devPrivates;
530706f2543Smrg    DeviceUnwrapProc    unwrapProc;
531706f2543Smrg    SpriteInfoPtr       spriteInfo;
532706f2543Smrg    union {
533706f2543Smrg        DeviceIntPtr        master;     /* master device */
534706f2543Smrg        DeviceIntPtr        lastSlave;  /* last slave device used */
535706f2543Smrg    } u;
536706f2543Smrg
537706f2543Smrg    /* last valuator values recorded, not posted to client;
538706f2543Smrg     * for slave devices, valuators is in device coordinates
539706f2543Smrg     * for master devices, valuators is in screen coordinates
540706f2543Smrg     * see dix/getevents.c
541706f2543Smrg     * remainder supports acceleration
542706f2543Smrg     */
543706f2543Smrg    struct {
544706f2543Smrg        int             valuators[MAX_VALUATORS];
545706f2543Smrg        float           remainder[MAX_VALUATORS];
546706f2543Smrg        int             numValuators;
547706f2543Smrg        DeviceIntPtr    slave;
548706f2543Smrg    } last;
549706f2543Smrg
550706f2543Smrg    /* Input device property handling. */
551706f2543Smrg    struct {
552706f2543Smrg        XIPropertyPtr   properties;
553706f2543Smrg        XIPropertyHandlerPtr handlers; /* NULL-terminated */
554706f2543Smrg    } properties;
555706f2543Smrg
556706f2543Smrg    /* coordinate transformation matrix for absolute input devices */
557706f2543Smrg    struct pixman_f_transform transform;
558706f2543Smrg
559706f2543Smrg    /* XTest related master device id */
560706f2543Smrg    int xtest_master_id;
561706f2543Smrg} DeviceIntRec;
562706f2543Smrg
563706f2543Smrgtypedef struct {
564706f2543Smrg    int			numDevices;	/* total number of devices */
565706f2543Smrg    DeviceIntPtr	devices;	/* all devices turned on */
566706f2543Smrg    DeviceIntPtr	off_devices;	/* all devices turned off */
567706f2543Smrg    DeviceIntPtr	keyboard;	/* the main one for the server */
568706f2543Smrg    DeviceIntPtr	pointer;
569706f2543Smrg    DeviceIntPtr	all_devices;
570706f2543Smrg    DeviceIntPtr	all_master_devices;
571706f2543Smrg} InputInfo;
572706f2543Smrg
573706f2543Smrgextern _X_EXPORT InputInfo inputInfo;
574706f2543Smrg
575706f2543Smrg/* for keeping the events for devices grabbed synchronously */
576706f2543Smrgtypedef struct _QdEvent *QdEventPtr;
577706f2543Smrgtypedef struct _QdEvent {
578706f2543Smrg    QdEventPtr		next;
579706f2543Smrg    DeviceIntPtr	device;
580706f2543Smrg    ScreenPtr		pScreen;	/* what screen the pointer was on */
581706f2543Smrg    unsigned long	months;		/* milliseconds is in the event */
582706f2543Smrg    InternalEvent	*event;
583706f2543Smrg} QdEventRec;
584706f2543Smrg
585706f2543Smrg/**
586706f2543Smrg * syncEvents is the global structure for queued events.
587706f2543Smrg *
588706f2543Smrg * Devices can be frozen through GrabModeSync pointer grabs. If this is the
589706f2543Smrg * case, events from these devices are added to "pending" instead of being
590706f2543Smrg * processed normally. When the device is unfrozen, events in "pending" are
591706f2543Smrg * replayed and processed as if they would come from the device directly.
592706f2543Smrg */
593706f2543Smrgtypedef struct _EventSyncInfo {
594706f2543Smrg    QdEventPtr          pending, /**<  list of queued events */
595706f2543Smrg                        *pendtail; /**< last event in list */
596706f2543Smrg    /** The device to replay events for. Only set in AllowEvents(), in which
597706f2543Smrg     * case it is set to the device specified in the request. */
598706f2543Smrg    DeviceIntPtr        replayDev;      /* kludgy rock to put flag for */
599706f2543Smrg
600706f2543Smrg    /**
601706f2543Smrg     * The window the events are supposed to be replayed on.
602706f2543Smrg     * This window may be set to the grab's window (but only when
603706f2543Smrg     * Replay{Pointer|Keyboard} is given in the XAllowEvents()
604706f2543Smrg     * request. */
605706f2543Smrg    WindowPtr           replayWin;      /*   ComputeFreezes            */
606706f2543Smrg    /**
607706f2543Smrg     * Flag to indicate whether we're in the process of
608706f2543Smrg     * replaying events. Only set in ComputeFreezes(). */
609706f2543Smrg    Bool                playingEvents;
610706f2543Smrg    TimeStamp           time;
611706f2543Smrg} EventSyncInfoRec, *EventSyncInfoPtr;
612706f2543Smrg
613706f2543Smrgextern EventSyncInfoRec syncEvents;
614706f2543Smrg
615706f2543Smrg#endif /* INPUTSTRUCT_H */
616