1
/************************************************************
3
Copyright 1987, 1998 The Open Group
5
Permission to use, copy, modify, distribute, and sell this software and its
6
documentation for any purpose is hereby granted without fee, provided that
7
the above copyright notice appear in all copies and that both that
8
copyright notice and this permission notice appear in supporting
11
The above copyright notice and this permission notice shall be included in
12
all copies or substantial portions of the Software.
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
Except as contained in this notice, the name of The Open Group shall not be
22
used in advertising or otherwise to promote the sale, use or other dealings
23
in this Software without prior written authorization from The Open Group.
26
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
30
Permission to use, copy, modify, and distribute this software and its
31
documentation for any purpose and without fee is hereby granted,
32
provided that the above copyright notice appear in all copies and that
33
both that copyright notice and this permission notice appear in
34
supporting documentation, and that the name of Digital not be
35
used in advertising or publicity pertaining to distribution of the
36
software without specific, written prior permission.
38
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46
********************************************************/
52
#include "screenint.h"
54
#include <X11/Xproto.h>
55
#include "window.h" /* for WindowPtr */
60
#define DEVICE_CLOSE 3
62
#define POINTER_RELATIVE (1 << 1)
63
#define POINTER_ABSOLUTE (1 << 2)
64
#define POINTER_ACCELERATE (1 << 3)
65
#define POINTER_SCREEN (1 << 4) /* Data in screen coordinates */
67
/*int constants for pointer acceleration schemes*/
68
#define PtrAccelNoOp 0
69
#define PtrAccelPredictable 1
70
#define PtrAccelLightweight 2
71
#define PtrAccelDefault PtrAccelPredictable
73
#define MAX_VALUATORS 36
74
/* Maximum number of valuators, divided by six, rounded up, to get number
76
#define MAX_VALUATOR_EVENTS 6
78
#define NO_AXIS_LIMITS -1
80
#define MAP_LENGTH 256
81
#define DOWN_LENGTH 32 /* 256/8 => number of bytes to hold 256 bits */
82
#define NullGrab ((GrabPtr)NULL)
83
#define PointerRootWin ((WindowPtr)PointerRoot)
84
#define NoneWin ((WindowPtr)None)
85
#define NullDevice ((DevicePtr)NULL)
87
#ifndef FollowKeyboard
88
#define FollowKeyboard 3
90
#ifndef FollowKeyboardWin
91
#define FollowKeyboardWin ((WindowPtr) FollowKeyboard)
93
#ifndef RevertToFollowKeyboard
94
#define RevertToFollowKeyboard 3
97
/* Used for enter/leave and focus in/out semaphores */
98
#define SEMAPHORE_FIELD_SET(win, dev, field) \
99
(win)->field[(dev)->id/8] |= (1 << ((dev)->id % 8)); \
101
#define SEMAPHORE_FIELD_UNSET(win, dev, field) \
102
(win)->field[(dev)->id/8] &= ~(1 << ((dev)->id % 8));
104
#define FOCUS_SEMAPHORE_SET(win, dev) \
105
SEMAPHORE_FIELD_SET(win, dev, focusinout);
107
#define FOCUS_SEMAPHORE_UNSET(win, dev) \
108
SEMAPHORE_FIELD_UNSET(win, dev, focusinout);
110
#define FOCUS_SEMAPHORE_ISSET(win, dev) \
111
(win)->focusinout[(dev)->id/8] & (1 << ((dev)->id % 8))
113
typedef unsigned long Leds;
114
typedef struct _OtherClients *OtherClientsPtr;
115
typedef struct _InputClients *InputClientsPtr;
116
typedef struct _DeviceIntRec *DeviceIntPtr;
117
typedef struct _ClassesRec *ClassesPtr;
119
typedef struct _EventList {
121
int evlen; /* length of allocated memory for event in bytes. This is not
122
the actual length of the event. The event's actual length is
123
32 for standard events or 32 +
124
((xGenericEvent*)event)->length * 4 for GenericEvents */
125
} EventList, *EventListPtr;
127
/* The DIX stores incoming input events in this list */
128
extern EventListPtr InputEventList;
129
extern int InputEventListLen;
131
typedef int (*DeviceProc)(
132
DeviceIntPtr /*device*/,
135
typedef void (*ProcessInputProc)(
136
xEventPtr /*events*/,
137
DeviceIntPtr /*device*/,
140
typedef Bool (*DeviceHandleProc)(
141
DeviceIntPtr /*device*/,
145
typedef void (*DeviceUnwrapProc)(
146
DeviceIntPtr /*device*/,
147
DeviceHandleProc /*proc*/,
151
/* pointer acceleration handling */
152
typedef void (*PointerAccelSchemeProc)(
153
DeviceIntPtr /*pDev*/,
154
int /*first_valuator*/,
155
int /*num_valuators*/,
159
typedef void (*DeviceCallbackProc)(
160
DeviceIntPtr /*pDev*/);
162
typedef struct _DeviceRec {
163
pointer devicePrivate;
164
ProcessInputProc processInputProc; /* current */
165
ProcessInputProc realInputProc; /* deliver */
166
ProcessInputProc enqueueInputProc; /* enqueue */
167
Bool on; /* used by DDX to keep state */
168
} DeviceRec, *DevicePtr;
171
int click, bell, bell_pitch, bell_duration;
173
unsigned char autoRepeats[32];
183
} KeySymsRec, *KeySymsPtr;
186
int num, den, threshold;
191
int resolution, min_value, max_value;
192
int integer_displayed;
197
int max_symbols, num_symbols_supported;
198
int num_symbols_displayed;
199
KeySym *symbols_supported;
200
KeySym *symbols_displayed;
205
int percent, pitch, duration;
215
extern KeybdCtrl defaultKeyboardControl;
216
extern PtrCtrl defaultPointerControl;
218
typedef struct _InputOption {
221
struct _InputOption *next;
224
extern void InitCoreDevices(void);
226
extern DeviceIntPtr AddInputDevice(
227
ClientPtr /*client*/,
228
DeviceProc /*deviceProc*/,
231
extern Bool EnableDevice(
232
DeviceIntPtr /*device*/);
234
extern Bool ActivateDevice(
235
DeviceIntPtr /*device*/);
237
extern Bool DisableDevice(
238
DeviceIntPtr /*device*/);
240
extern int InitAndStartDevices(void);
242
extern void CloseDownDevices(void);
244
extern void UndisplayDevices(void);
246
extern int RemoveDevice(
247
DeviceIntPtr /*dev*/);
249
extern int NumMotionEvents(void);
251
extern void RegisterPointerDevice(
252
DeviceIntPtr /*device*/);
254
extern void RegisterKeyboardDevice(
255
DeviceIntPtr /*device*/);
257
extern int dixLookupDevice(
258
DeviceIntPtr * /* dev */,
260
ClientPtr /* client */,
261
Mask /* access_mode */);
263
extern void QueryMinMaxKeyCodes(
264
KeyCode* /*minCode*/,
265
KeyCode* /*maxCode*/);
267
extern Bool SetKeySymsMap(
271
extern Bool InitKeyClassDeviceStruct(
272
DeviceIntPtr /*device*/,
273
KeySymsPtr /*pKeySyms*/,
274
CARD8 /*pModifiers*/[]);
276
extern Bool InitButtonClassDeviceStruct(
277
DeviceIntPtr /*device*/,
281
extern Bool InitValuatorClassDeviceStruct(
282
DeviceIntPtr /*device*/,
284
int /*numMotionEvents*/,
287
extern Bool InitPointerAccelerationScheme(
288
DeviceIntPtr /*dev*/,
291
extern Bool InitAbsoluteClassDeviceStruct(
292
DeviceIntPtr /*device*/);
294
extern Bool InitFocusClassDeviceStruct(
295
DeviceIntPtr /*device*/);
297
typedef void (*BellProcPtr)(
299
DeviceIntPtr /*device*/,
303
typedef void (*KbdCtrlProcPtr)(
304
DeviceIntPtr /*device*/,
305
KeybdCtrl * /*ctrl*/);
307
extern Bool InitKbdFeedbackClassDeviceStruct(
308
DeviceIntPtr /*device*/,
309
BellProcPtr /*bellProc*/,
310
KbdCtrlProcPtr /*controlProc*/);
312
typedef void (*PtrCtrlProcPtr)(
313
DeviceIntPtr /*device*/,
316
extern Bool InitPtrFeedbackClassDeviceStruct(
317
DeviceIntPtr /*device*/,
318
PtrCtrlProcPtr /*controlProc*/);
320
typedef void (*StringCtrlProcPtr)(
321
DeviceIntPtr /*device*/,
322
StringCtrl * /*ctrl*/);
324
extern Bool InitStringFeedbackClassDeviceStruct(
325
DeviceIntPtr /*device*/,
326
StringCtrlProcPtr /*controlProc*/,
328
int /*num_symbols_supported*/,
329
KeySym* /*symbols*/);
331
typedef void (*BellCtrlProcPtr)(
332
DeviceIntPtr /*device*/,
333
BellCtrl * /*ctrl*/);
335
extern Bool InitBellFeedbackClassDeviceStruct(
336
DeviceIntPtr /*device*/,
337
BellProcPtr /*bellProc*/,
338
BellCtrlProcPtr /*controlProc*/);
340
typedef void (*LedCtrlProcPtr)(
341
DeviceIntPtr /*device*/,
344
extern Bool InitLedFeedbackClassDeviceStruct(
345
DeviceIntPtr /*device*/,
346
LedCtrlProcPtr /*controlProc*/);
348
typedef void (*IntegerCtrlProcPtr)(
349
DeviceIntPtr /*device*/,
350
IntegerCtrl * /*ctrl*/);
353
extern Bool InitIntegerFeedbackClassDeviceStruct(
354
DeviceIntPtr /*device*/,
355
IntegerCtrlProcPtr /*controlProc*/);
357
extern Bool InitPointerDeviceStruct(
358
DevicePtr /*device*/,
361
PtrCtrlProcPtr /*controlProc*/,
362
int /*numMotionEvents*/,
365
extern Bool InitKeyboardDeviceStruct(
366
DevicePtr /*device*/,
367
KeySymsPtr /*pKeySyms*/,
368
CARD8 /*pModifiers*/[],
369
BellProcPtr /*bellProc*/,
370
KbdCtrlProcPtr /*controlProc*/);
372
extern void SendMappingNotify(
373
DeviceIntPtr /* pDev */,
374
unsigned int /*request*/,
375
unsigned int /*firstKeyCode*/,
376
unsigned int /*count*/,
377
ClientPtr /* client */);
379
extern Bool BadDeviceMap(
386
extern Bool AllModifierKeysAreUp(
387
DeviceIntPtr /*device*/,
393
extern void NoteLedState(
394
DeviceIntPtr /*keybd*/,
398
extern void MaybeStopHint(
399
DeviceIntPtr /*device*/,
400
ClientPtr /*client*/);
402
extern void ProcessPointerEvent(
404
DeviceIntPtr /*mouse*/,
407
extern void ProcessKeyboardEvent(
409
DeviceIntPtr /*keybd*/,
413
extern void CoreProcessPointerEvent(
415
DeviceIntPtr /*mouse*/,
416
int /*count*/) _X_DEPRECATED;
418
extern _X_DEPRECATED void CoreProcessKeyboardEvent(
420
DeviceIntPtr /*keybd*/,
421
int /*count*/) _X_DEPRECATED;
424
extern Bool LegalModifier(
425
unsigned int /*key*/,
426
DeviceIntPtr /*pDev*/);
428
extern void ProcessInputEvents(void);
430
extern void InitInput(
434
extern int GetMaximumEventsNum(void);
436
extern int GetEventList(EventListPtr* list);
437
extern EventListPtr InitEventList(int num_events);
438
extern void SetMinimumEventSize(EventListPtr list,
441
extern void FreeEventList(EventListPtr list, int num_events);
443
extern void CreateClassesChangedEvent(EventListPtr event,
446
extern int GetPointerEvents(
456
extern int GetKeyboardEvents(
462
extern int GetKeyboardValuatorEvents(
471
extern int GetProximityEvents(
479
extern void PostSyntheticMotion(
486
extern int GetMotionHistorySize(
489
extern void AllocateMotionHistory(
492
extern int GetMotionHistory(
500
extern int AttachDevice(ClientPtr client,
502
DeviceIntPtr master);
504
extern DeviceIntPtr GetPairedDevice(DeviceIntPtr kbd);
506
extern int AllocMasterDevice(ClientPtr client,
509
DeviceIntPtr* keybd);
510
extern void DeepCopyDeviceClasses(DeviceIntPtr from,
513
/* Implemented by the DDX. */
514
extern int NewInputDeviceRequest(
515
InputOption *options,
517
extern void DeleteInputDeviceRequest(
520
extern void DDXRingBell(