1 /************************************************************
2 
3 Copyright (c) 1987  X Consortium
4 
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11 
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the 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 THE
18 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 
22 Except as contained in this notice, the name of the X Consortium shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from the X Consortium.
25 
26 
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28 
29                         All Rights Reserved
30 
31 Permission to use, copy, modify, and distribute this software and its
32 documentation for any purpose and without fee is hereby granted,
33 provided that the above copyright notice appear in all copies and that
34 both that copyright notice and this permission notice appear in
35 supporting documentation, and that the name of Digital not be
36 used in advertising or publicity pertaining to distribution of the
37 software without specific, written prior permission.
38 
39 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45 SOFTWARE.
46 
47 ********************************************************/
48 
49 /* $XConsortium: inputstr.h /main/28 1996/09/25 00:51:24 dpw $ */
50 
51 #ifndef INPUTSTRUCT_H
52 #define INPUTSTRUCT_H
53 
54 #include "input.h"
55 #include "window.h"
56 #include "dixstruct.h"
57 
58 #define BitIsOn(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
59 
60 #define SameClient(obj,client) \
61 	(CLIENT_BITS((obj)->resource) == (client)->clientAsMask)
62 
63 #define MAX_DEVICES	9
64 
65 #define EMASKSIZE	MAX_DEVICES
66 
67 /* Kludge: OtherClients and InputClients must be compatible, see code */
68 
69 typedef struct _OtherClients {
70     OtherClientsPtr	next;
71     XID			resource; /* id for putting into resource manager */
72     Mask		mask;
73 } OtherClients;
74 
75 typedef struct _InputClients {
76     InputClientsPtr	next;
77     XID			resource; /* id for putting into resource manager */
78     Mask		mask[EMASKSIZE];
79 } InputClients;
80 
81 typedef struct _OtherInputMasks {
82     Mask		deliverableEvents[EMASKSIZE];
83     Mask		inputEvents[EMASKSIZE];
84     Mask		dontPropagateMask[EMASKSIZE];
85     InputClientsPtr	inputClients;
86 } OtherInputMasks;
87 
88 /*
89  * The following structure gets used for both active and passive grabs. For
90  * active grabs some of the fields (e.g. modifiers) are not used. However,
91  * that is not much waste since there aren't many active grabs (one per
92  * keyboard/pointer device) going at once in the server.
93  */
94 
95 #define MasksPerDetailMask 8		/* 256 keycodes and 256 possible
96 						modifier combinations, but only
97 						3 buttons. */
98 
99   typedef struct _DetailRec {		/* Grab details may be bit masks */
100 	unsigned short exact;
101 	Mask *pMask;
102   } DetailRec;
103 
104   typedef struct _GrabRec {
105     GrabPtr		next;		/* for chain of passive grabs */
106     XID			resource;
107     DeviceIntPtr	device;
108     WindowPtr		window;
109     unsigned		ownerEvents:1;
110     unsigned		keyboardMode:1;
111     unsigned		pointerMode:1;
112     unsigned		coreGrab:1;	/* grab is on core device */
113     unsigned		coreMods:1;	/* modifiers are on core keyboard */
114     CARD8		type;		/* event type */
115     DetailRec		modifiersDetail;
116     DeviceIntPtr	modifierDevice;
117     DetailRec		detail;		/* key or button */
118     WindowPtr		confineTo;	/* always NULL for keyboards */
119     CursorPtr		cursor;		/* always NULL for keyboards */
120     Mask		eventMask;
121 } GrabRec;
122 
123 typedef struct _KeyClassRec {
124     CARD8		down[DOWN_LENGTH];
125     KeyCode 		*modifierKeyMap;
126     KeySymsRec		curKeySyms;
127     int			modifierKeyCount[8];
128     CARD8		modifierMap[MAP_LENGTH];
129     CARD8		maxKeysPerModifier;
130     unsigned short	state;
131     unsigned short	prev_state;
132 #ifdef XKB
133     struct _XkbSrvInfo *xkbInfo;
134 #endif
135 } KeyClassRec, *KeyClassPtr;
136 
137 typedef struct _AxisInfo {
138     int		resolution;
139     int		min_resolution;
140     int		max_resolution;
141     int		min_value;
142     int		max_value;
143 } AxisInfo, *AxisInfoPtr;
144 
145 typedef struct _ValuatorClassRec {
146     ValuatorMotionProcPtr GetMotionProc;
147     int		 	numMotionEvents;
148     WindowPtr    	motionHintWindow;
149     AxisInfoPtr 	axes;
150     unsigned short	numAxes;
151     int			*axisVal;
152     CARD8	 	mode;
153 } ValuatorClassRec, *ValuatorClassPtr;
154 
155 typedef struct _ButtonClassRec {
156     CARD8		numButtons;
157     CARD8		buttonsDown;	/* number of buttons currently down */
158     unsigned short	state;
159     Mask		motionMask;
160     CARD8		down[DOWN_LENGTH];
161     CARD8		map[MAP_LENGTH];
162 #ifdef XKB
163     union _XkbAction *	xkb_acts;
164 #endif
165 } ButtonClassRec, *ButtonClassPtr;
166 
167 typedef struct _FocusClassRec {
168     WindowPtr	win;
169     int		revert;
170     TimeStamp	time;
171     WindowPtr	*trace;
172     int		traceSize;
173     int		traceGood;
174 } FocusClassRec, *FocusClassPtr;
175 
176 typedef struct _ProximityClassRec {
177     char	pad;
178 } ProximityClassRec, *ProximityClassPtr;
179 
180 typedef struct _KbdFeedbackClassRec *KbdFeedbackPtr;
181 typedef struct _PtrFeedbackClassRec *PtrFeedbackPtr;
182 typedef struct _IntegerFeedbackClassRec *IntegerFeedbackPtr;
183 typedef struct _StringFeedbackClassRec *StringFeedbackPtr;
184 typedef struct _BellFeedbackClassRec *BellFeedbackPtr;
185 typedef struct _LedFeedbackClassRec *LedFeedbackPtr;
186 
187 typedef struct _KbdFeedbackClassRec {
188     BellProcPtr		BellProc;
189     KbdCtrlProcPtr	CtrlProc;
190     KeybdCtrl	 	ctrl;
191     KbdFeedbackPtr	next;
192 #ifdef XKB
193     struct _XkbSrvLedInfo *xkb_sli;
194 #endif
195 } KbdFeedbackClassRec;
196 
197 typedef struct _PtrFeedbackClassRec {
198     PtrCtrlProcPtr	CtrlProc;
199     PtrCtrl		ctrl;
200     PtrFeedbackPtr	next;
201 } PtrFeedbackClassRec;
202 
203 typedef struct _IntegerFeedbackClassRec {
204     IntegerCtrlProcPtr	CtrlProc;
205     IntegerCtrl	 	ctrl;
206     IntegerFeedbackPtr	next;
207 } IntegerFeedbackClassRec;
208 
209 typedef struct _StringFeedbackClassRec {
210     StringCtrlProcPtr	CtrlProc;
211     StringCtrl	 	ctrl;
212     StringFeedbackPtr	next;
213 } StringFeedbackClassRec;
214 
215 typedef struct _BellFeedbackClassRec {
216     BellProcPtr		BellProc;
217     BellCtrlProcPtr	CtrlProc;
218     BellCtrl	 	ctrl;
219     BellFeedbackPtr	next;
220 } BellFeedbackClassRec;
221 
222 typedef struct _LedFeedbackClassRec {
223     LedCtrlProcPtr	CtrlProc;
224     LedCtrl	 	ctrl;
225     LedFeedbackPtr	next;
226 #ifdef XKB
227     struct _XkbSrvLedInfo *xkb_sli;
228 #endif
229 } LedFeedbackClassRec;
230 
231 /* states for devices */
232 
233 #define NOT_GRABBED		0
234 #define THAWED			1
235 #define THAWED_BOTH		2	/* not a real state */
236 #define FREEZE_NEXT_EVENT	3
237 #define FREEZE_BOTH_NEXT_EVENT	4
238 #define FROZEN			5	/* any state >= has device frozen */
239 #define FROZEN_NO_EVENT		5
240 #define FROZEN_WITH_EVENT	6
241 #define THAW_OTHERS		7
242 
243 typedef struct _DeviceIntRec {
244     DeviceRec	public;
245     DeviceIntPtr next;
246     TimeStamp	grabTime;
247     Bool	startup;		/* true if needs to be turned on at
248 				          server intialization time */
249     DeviceProc	deviceProc;		/* proc(DevicePtr, DEVICE_xx). It is
250 					  used to initialize, turn on, or
251 					  turn off the device */
252     Bool	inited;			/* TRUE if INIT returns Success */
253     GrabPtr	grab;			/* the grabber - used by DIX */
254     struct {
255 	Bool		frozen;
256 	int		state;
257 	GrabPtr		other;		/* if other grab has this frozen */
258 	xEvent		*event;		/* saved to be replayed */
259 	int		evcount;
260     } sync;
261     Atom		type;
262     char		*name;
263     CARD8		id;
264     CARD8		activatingKey;
265     Bool		fromPassiveGrab;
266     GrabRec		activeGrab;
267     void		(*ActivateGrab) (
268 #if NeedNestedPrototypes
269 			DeviceIntPtr /*device*/,
270 			GrabPtr /*grab*/,
271 			TimeStamp /*time*/,
272 			Bool /*autoGrab*/
273 #endif
274 );
275     void		(*DeactivateGrab)(
276 #if NeedNestedPrototypes
277 			DeviceIntPtr /*device*/
278 #endif
279 );
280     KeyClassPtr		key;
281     ValuatorClassPtr	valuator;
282     ButtonClassPtr	button;
283     FocusClassPtr	focus;
284     ProximityClassPtr	proximity;
285     KbdFeedbackPtr	kbdfeed;
286     PtrFeedbackPtr	ptrfeed;
287     IntegerFeedbackPtr	intfeed;
288     StringFeedbackPtr	stringfeed;
289     BellFeedbackPtr	bell;
290     LedFeedbackPtr	leds;
291 #ifdef XKB
292     struct _XkbInterest *	xkb_interest;
293 #endif
294 } DeviceIntRec;
295 
296 typedef struct {
297     int			numDevices;	/* total number of devices */
298     DeviceIntPtr	devices;	/* all devices turned on */
299     DeviceIntPtr	off_devices;	/* all devices turned off */
300     DeviceIntPtr	keyboard;	/* the main one for the server */
301     DeviceIntPtr	pointer;
302 } InputInfo;
303 
304 extern InputInfo inputInfo;
305 
306 /* for keeping the events for devices grabbed synchronously */
307 typedef struct _QdEvent *QdEventPtr;
308 typedef struct _QdEvent {
309     QdEventPtr		next;
310     DeviceIntPtr	device;
311     ScreenPtr		pScreen;	/* what screen the pointer was on */
312     unsigned long	months;		/* milliseconds is in the event */
313     xEvent		*event;
314     int			evcount;
315 } QdEventRec;
316 
317 #endif /* INPUTSTRUCT_H */
318