1
/* $Xorg: extinit.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
3
/************************************************************
5
Copyright 1989, 1998 The Open Group
7
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
the above copyright notice appear in all copies and that both that
10
copyright notice and this permission notice appear in supporting
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from The Open Group.
27
Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
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 Hewlett-Packard not be
36
used in advertising or publicity pertaining to distribution of the
37
software without specific, written prior permission.
39
HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41
HEWLETT-PACKARD 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
47
********************************************************/
48
/* $XFree86: xc/programs/Xserver/Xi/extinit.c,v 3.6 2001/12/14 19:58:55 dawes Exp $ */
50
/********************************************************************
52
* Dispatch routines and initialization routines for the X input extension.
60
#ifdef HAVE_DIX_CONFIG_H
61
#include <dix-config.h>
65
#include <X11/Xproto.h>
67
#include "gcstruct.h" /* pointer for extnsionst.h*/
68
#include "extnsionst.h" /* extension entry */
69
#include <X11/extensions/XI.h>
70
#include <X11/extensions/XIproto.h>
72
#include "dixevents.h"
75
#include "exglobals.h"
78
/* modules local to Xi */
100
#include "grabdevk.h"
101
#include "gtmotion.h"
105
#include "selectev.h"
106
#include "sendexev.h"
110
#include "setfocus.h"
114
#include "ungrdevb.h"
115
#include "ungrdevk.h"
117
static Mask lastExtEventMask = 1;
119
Mask ExtValidMasks[EMASKSIZE];
120
Mask ExtExclusiveMasks[EMASKSIZE];
126
}dev_type [] = {{0,XI_KEYBOARD},
145
CARD8 event_base [numInputClasses];
146
XExtEventInfo EventInfo[32];
148
/*****************************************************************
150
* Globals referenced elsewhere in the server.
161
Mask DevicePointerMotionMask;
162
Mask DevicePointerMotionHintMask;
163
Mask DeviceFocusChangeMask;
164
Mask DeviceStateNotifyMask;
165
Mask ChangeDeviceNotifyMask;
166
Mask DeviceMappingNotifyMask;
167
Mask DeviceOwnerGrabButtonMask;
168
Mask DeviceButtonGrabMask;
169
Mask DeviceButtonMotionMask;
173
int DeviceKeyRelease;
174
int DeviceButtonPress;
175
int DeviceButtonRelease;
176
int DeviceMotionNotify;
181
int DeviceStateNotify;
182
int DeviceKeyStateNotify;
183
int DeviceButtonStateNotify;
184
int DeviceMappingNotify;
185
int ChangeDeviceNotify;
189
/*****************************************************************
191
* Externs defined elsewhere in the X server.
195
extern XExtensionVersion AllExtensionVersions[];
197
Mask PropagateMask[MAX_DEVICES];
199
/*****************************************************************
201
* Declarations of local routines.
205
static XExtensionVersion thisversion =
207
XI_Add_XChangeDeviceControl_Major,
208
XI_Add_XChangeDeviceControl_Minor};
210
/**********************************************************************
212
* IExtensionInit - initialize the input extension.
214
* Called from InitExtensions in main() or from QueryExtension() if the
215
* extension is dynamically loaded.
217
* This extension has several events and errors.
222
XInputExtensionInit()
224
ExtensionEntry *extEntry;
226
extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch,
227
SProcIDispatch, IResetProc, StandardMinorOpcode);
230
IReqCode = extEntry->base;
231
AllExtensionVersions[IReqCode-128] = thisversion;
232
MakeDeviceTypeAtoms ();
233
RT_INPUTCLIENT = CreateNewResourceType((DeleteType)InputClientGone);
234
FixExtensionEvents (extEntry);
235
ReplySwapVector[IReqCode] = (ReplySwapPtr)SReplyIDispatch;
236
EventSwapVector[DeviceValuator] = SEventIDispatch;
237
EventSwapVector[DeviceKeyPress] = SEventIDispatch;
238
EventSwapVector[DeviceKeyRelease] = SEventIDispatch;
239
EventSwapVector[DeviceButtonPress] = SEventIDispatch;
240
EventSwapVector[DeviceButtonRelease] = SEventIDispatch;
241
EventSwapVector[DeviceMotionNotify] = SEventIDispatch;
242
EventSwapVector[DeviceFocusIn] = SEventIDispatch;
243
EventSwapVector[DeviceFocusOut] = SEventIDispatch;
244
EventSwapVector[ProximityIn] = SEventIDispatch;
245
EventSwapVector[ProximityOut] = SEventIDispatch;
246
EventSwapVector[DeviceStateNotify] = SEventIDispatch;
247
EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch;
248
EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch;
249
EventSwapVector[DeviceMappingNotify] = SEventIDispatch;
250
EventSwapVector[ChangeDeviceNotify] = SEventIDispatch;
254
FatalError("IExtensionInit: AddExtensions failed\n");
258
/*************************************************************************
260
* ProcIDispatch - main dispatch routine for requests to this extension.
261
* This routine is used if server and client have the same byte ordering.
266
ProcIDispatch (client)
267
register ClientPtr client;
270
if (stuff->data == X_GetExtensionVersion)
271
return(ProcXGetExtensionVersion(client));
272
if (stuff->data == X_ListInputDevices)
273
return(ProcXListInputDevices(client));
274
else if (stuff->data == X_OpenDevice)
275
return(ProcXOpenDevice(client));
276
else if (stuff->data == X_CloseDevice)
277
return(ProcXCloseDevice(client));
278
else if (stuff->data == X_SetDeviceMode)
279
return(ProcXSetDeviceMode(client));
280
else if (stuff->data == X_SelectExtensionEvent)
281
return(ProcXSelectExtensionEvent(client));
282
else if (stuff->data == X_GetSelectedExtensionEvents)
283
return(ProcXGetSelectedExtensionEvents(client));
284
else if (stuff->data == X_ChangeDeviceDontPropagateList)
285
return(ProcXChangeDeviceDontPropagateList(client));
286
else if (stuff->data == X_GetDeviceDontPropagateList)
287
return(ProcXGetDeviceDontPropagateList(client));
288
else if (stuff->data == X_GetDeviceMotionEvents)
289
return(ProcXGetDeviceMotionEvents(client));
290
else if (stuff->data == X_ChangeKeyboardDevice)
291
return(ProcXChangeKeyboardDevice(client));
292
else if (stuff->data == X_ChangePointerDevice)
293
return(ProcXChangePointerDevice(client));
294
else if (stuff->data == X_GrabDevice)
295
return(ProcXGrabDevice(client));
296
else if (stuff->data == X_UngrabDevice)
297
return(ProcXUngrabDevice(client));
298
else if (stuff->data == X_GrabDeviceKey)
299
return(ProcXGrabDeviceKey(client));
300
else if (stuff->data == X_UngrabDeviceKey)
301
return(ProcXUngrabDeviceKey(client));
302
else if (stuff->data == X_GrabDeviceButton)
303
return(ProcXGrabDeviceButton(client));
304
else if (stuff->data == X_UngrabDeviceButton)
305
return(ProcXUngrabDeviceButton(client));
306
else if (stuff->data == X_AllowDeviceEvents)
307
return(ProcXAllowDeviceEvents(client));
308
else if (stuff->data == X_GetDeviceFocus)
309
return(ProcXGetDeviceFocus(client));
310
else if (stuff->data == X_SetDeviceFocus)
311
return(ProcXSetDeviceFocus(client));
312
else if (stuff->data == X_GetFeedbackControl)
313
return(ProcXGetFeedbackControl(client));
314
else if (stuff->data == X_ChangeFeedbackControl)
315
return(ProcXChangeFeedbackControl(client));
316
else if (stuff->data == X_GetDeviceKeyMapping)
317
return(ProcXGetDeviceKeyMapping(client));
318
else if (stuff->data == X_ChangeDeviceKeyMapping)
319
return(ProcXChangeDeviceKeyMapping(client));
320
else if (stuff->data == X_GetDeviceModifierMapping)
321
return(ProcXGetDeviceModifierMapping(client));
322
else if (stuff->data == X_SetDeviceModifierMapping)
323
return(ProcXSetDeviceModifierMapping(client));
324
else if (stuff->data == X_GetDeviceButtonMapping)
325
return(ProcXGetDeviceButtonMapping(client));
326
else if (stuff->data == X_SetDeviceButtonMapping)
327
return(ProcXSetDeviceButtonMapping(client));
328
else if (stuff->data == X_QueryDeviceState)
329
return(ProcXQueryDeviceState(client));
330
else if (stuff->data == X_SendExtensionEvent)
331
return(ProcXSendExtensionEvent(client));
332
else if (stuff->data == X_DeviceBell)
333
return(ProcXDeviceBell(client));
334
else if (stuff->data == X_SetDeviceValuators)
335
return(ProcXSetDeviceValuators(client));
336
else if (stuff->data == X_GetDeviceControl)
337
return(ProcXGetDeviceControl(client));
338
else if (stuff->data == X_ChangeDeviceControl)
339
return(ProcXChangeDeviceControl(client));
342
SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
347
/*******************************************************************************
351
* Main swapped dispatch routine for requests to this extension.
352
* This routine is used if server and client do not have the same byte ordering.
357
SProcIDispatch(client)
358
register ClientPtr client;
361
if (stuff->data == X_GetExtensionVersion)
362
return(SProcXGetExtensionVersion(client));
363
if (stuff->data == X_ListInputDevices)
364
return(SProcXListInputDevices(client));
365
else if (stuff->data == X_OpenDevice)
366
return(SProcXOpenDevice(client));
367
else if (stuff->data == X_CloseDevice)
368
return(SProcXCloseDevice(client));
369
else if (stuff->data == X_SetDeviceMode)
370
return(SProcXSetDeviceMode(client));
371
else if (stuff->data == X_SelectExtensionEvent)
372
return(SProcXSelectExtensionEvent(client));
373
else if (stuff->data == X_GetSelectedExtensionEvents)
374
return(SProcXGetSelectedExtensionEvents(client));
375
else if (stuff->data == X_ChangeDeviceDontPropagateList)
376
return(SProcXChangeDeviceDontPropagateList(client));
377
else if (stuff->data == X_GetDeviceDontPropagateList)
378
return(SProcXGetDeviceDontPropagateList(client));
379
else if (stuff->data == X_GetDeviceMotionEvents)
380
return(SProcXGetDeviceMotionEvents(client));
381
else if (stuff->data == X_ChangeKeyboardDevice)
382
return(SProcXChangeKeyboardDevice(client));
383
else if (stuff->data == X_ChangePointerDevice)
384
return(SProcXChangePointerDevice(client));
385
else if (stuff->data == X_GrabDevice)
386
return(SProcXGrabDevice(client));
387
else if (stuff->data == X_UngrabDevice)
388
return(SProcXUngrabDevice(client));
389
else if (stuff->data == X_GrabDeviceKey)
390
return(SProcXGrabDeviceKey(client));
391
else if (stuff->data == X_UngrabDeviceKey)
392
return(SProcXUngrabDeviceKey(client));
393
else if (stuff->data == X_GrabDeviceButton)
394
return(SProcXGrabDeviceButton(client));
395
else if (stuff->data == X_UngrabDeviceButton)
396
return(SProcXUngrabDeviceButton(client));
397
else if (stuff->data == X_AllowDeviceEvents)
398
return(SProcXAllowDeviceEvents(client));
399
else if (stuff->data == X_GetDeviceFocus)
400
return(SProcXGetDeviceFocus(client));
401
else if (stuff->data == X_SetDeviceFocus)
402
return(SProcXSetDeviceFocus(client));
403
else if (stuff->data == X_GetFeedbackControl)
404
return(SProcXGetFeedbackControl(client));
405
else if (stuff->data == X_ChangeFeedbackControl)
406
return(SProcXChangeFeedbackControl(client));
407
else if (stuff->data == X_GetDeviceKeyMapping)
408
return(SProcXGetDeviceKeyMapping(client));
409
else if (stuff->data == X_ChangeDeviceKeyMapping)
410
return(SProcXChangeDeviceKeyMapping(client));
411
else if (stuff->data == X_GetDeviceModifierMapping)
412
return(SProcXGetDeviceModifierMapping(client));
413
else if (stuff->data == X_SetDeviceModifierMapping)
414
return(SProcXSetDeviceModifierMapping(client));
415
else if (stuff->data == X_GetDeviceButtonMapping)
416
return(SProcXGetDeviceButtonMapping(client));
417
else if (stuff->data == X_SetDeviceButtonMapping)
418
return(SProcXSetDeviceButtonMapping(client));
419
else if (stuff->data == X_QueryDeviceState)
420
return(SProcXQueryDeviceState(client));
421
else if (stuff->data == X_SendExtensionEvent)
422
return(SProcXSendExtensionEvent(client));
423
else if (stuff->data == X_DeviceBell)
424
return(SProcXDeviceBell(client));
425
else if (stuff->data == X_SetDeviceValuators)
426
return(SProcXSetDeviceValuators(client));
427
else if (stuff->data == X_GetDeviceControl)
428
return(SProcXGetDeviceControl(client));
429
else if (stuff->data == X_ChangeDeviceControl)
430
return(SProcXChangeDeviceControl(client));
433
SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
438
/**********************************************************************
441
* Swap any replies defined in this extension.
445
/* FIXME: this would be more concise and readable in ANSI C */
446
#define DISPATCH(code) \
447
if (rep->RepType == X_##code) \
448
SRepX##code (client, len, (x##code##Reply *) rep)
451
SReplyIDispatch (client, len, rep)
454
xGrabDeviceReply *rep; /* All we look at is the type field */
455
{ /* This is common to all replies */
456
if (rep->RepType == X_GetExtensionVersion)
457
SRepXGetExtensionVersion (client, len, (xGetExtensionVersionReply *)rep);
458
else if (rep->RepType == X_ListInputDevices)
459
SRepXListInputDevices (client, len, (xListInputDevicesReply *)rep);
460
else if (rep->RepType == X_OpenDevice)
461
SRepXOpenDevice (client, len, (xOpenDeviceReply *)rep);
462
else if (rep->RepType == X_SetDeviceMode)
463
SRepXSetDeviceMode (client, len, (xSetDeviceModeReply *) rep);
464
else if (rep->RepType == X_GetSelectedExtensionEvents)
465
SRepXGetSelectedExtensionEvents (client, len, (xGetSelectedExtensionEventsReply *) rep);
466
else if (rep->RepType == X_GetDeviceDontPropagateList)
467
SRepXGetDeviceDontPropagateList (client, len, (xGetDeviceDontPropagateListReply *)rep);
468
else if (rep->RepType == X_GetDeviceMotionEvents)
469
SRepXGetDeviceMotionEvents (client, len, (xGetDeviceMotionEventsReply *) rep);
470
else if (rep->RepType == X_ChangeKeyboardDevice)
471
SRepXChangeKeyboardDevice (client, len, (xChangeKeyboardDeviceReply *) rep);
472
else if (rep->RepType == X_ChangePointerDevice)
473
SRepXChangePointerDevice (client, len, (xChangePointerDeviceReply *)rep);
474
else if (rep->RepType == X_GrabDevice)
475
SRepXGrabDevice (client, len, (xGrabDeviceReply *)rep);
476
else if (rep->RepType == X_GetDeviceFocus)
477
SRepXGetDeviceFocus (client, len, (xGetDeviceFocusReply *)rep);
478
else if (rep->RepType == X_GetFeedbackControl)
479
SRepXGetFeedbackControl (client, len, (xGetFeedbackControlReply *)rep);
480
else if (rep->RepType == X_GetDeviceKeyMapping)
481
SRepXGetDeviceKeyMapping (client, len, (xGetDeviceKeyMappingReply *)rep);
482
else if (rep->RepType == X_GetDeviceModifierMapping)
483
SRepXGetDeviceModifierMapping (client, len, (xGetDeviceModifierMappingReply *)rep);
484
else if (rep->RepType == X_SetDeviceModifierMapping)
485
SRepXSetDeviceModifierMapping (client, len, (xSetDeviceModifierMappingReply *)rep);
486
else if (rep->RepType == X_GetDeviceButtonMapping)
487
SRepXGetDeviceButtonMapping (client, len, (xGetDeviceButtonMappingReply *)rep);
488
else if (rep->RepType == X_SetDeviceButtonMapping)
489
SRepXSetDeviceButtonMapping (client, len, (xSetDeviceButtonMappingReply *)rep);
490
else if (rep->RepType == X_QueryDeviceState)
491
SRepXQueryDeviceState (client, len, (xQueryDeviceStateReply *)rep);
492
else if (rep->RepType == X_SetDeviceValuators)
493
SRepXSetDeviceValuators (client, len, (xSetDeviceValuatorsReply *)rep);
494
else if (rep->RepType == X_GetDeviceControl)
495
SRepXGetDeviceControl (client, len, (xGetDeviceControlReply *)rep);
496
else if (rep->RepType == X_ChangeDeviceControl)
497
SRepXChangeDeviceControl (client, len, (xChangeDeviceControlReply *)rep);
500
FatalError("XINPUT confused sending swapped reply");
504
/*****************************************************************************
508
* Swap any events defined in this extension.
510
#define DO_SWAP(func,type) func ((type *)from, (type *)to)
513
SEventIDispatch (from, to)
517
int type = from->u.u.type & 0177;
519
if (type == DeviceValuator)
520
DO_SWAP(SEventDeviceValuator, deviceValuator);
521
else if (type == DeviceKeyPress)
523
SKeyButtonPtrEvent (from, to);
524
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
526
else if (type == DeviceKeyRelease)
528
SKeyButtonPtrEvent (from, to);
529
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
531
else if (type == DeviceButtonPress)
533
SKeyButtonPtrEvent (from, to);
534
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
536
else if (type == DeviceButtonRelease)
538
SKeyButtonPtrEvent (from, to);
539
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
541
else if (type == DeviceMotionNotify)
543
SKeyButtonPtrEvent (from, to);
544
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
546
else if (type == DeviceFocusIn)
547
DO_SWAP(SEventFocus, deviceFocus);
548
else if (type == DeviceFocusOut)
549
DO_SWAP(SEventFocus, deviceFocus);
550
else if (type == ProximityIn)
552
SKeyButtonPtrEvent (from, to);
553
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
555
else if (type == ProximityOut)
557
SKeyButtonPtrEvent (from, to);
558
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
560
else if (type == DeviceStateNotify)
561
DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify);
562
else if (type == DeviceKeyStateNotify)
563
DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify);
564
else if (type == DeviceButtonStateNotify)
565
DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify);
566
else if (type == DeviceMappingNotify)
567
DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify);
568
else if (type == ChangeDeviceNotify)
569
DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify);
572
FatalError("XInputExtension: Impossible event!\n");
576
/************************************************************************
578
* This function swaps the DeviceValuator event.
583
SEventDeviceValuator (from, to)
584
deviceValuator *from;
592
swaps(&to->sequenceNumber,n);
593
swaps(&to->device_state,n);
597
swapl((ip+i),n); /* macro - braces are required */
602
SEventFocus (from, to)
609
swaps(&to->sequenceNumber,n);
611
swapl(&to->window, n);
615
SDeviceStateNotifyEvent (from, to)
616
deviceStateNotify *from;
617
deviceStateNotify *to;
624
swaps(&to->sequenceNumber,n);
629
swapl((ip+i),n); /* macro - braces are required */
634
SDeviceKeyStateNotifyEvent (from, to)
635
deviceKeyStateNotify *from;
636
deviceKeyStateNotify *to;
641
swaps(&to->sequenceNumber,n);
645
SDeviceButtonStateNotifyEvent (from, to)
646
deviceButtonStateNotify *from;
647
deviceButtonStateNotify *to;
652
swaps(&to->sequenceNumber,n);
656
SChangeDeviceNotifyEvent (from, to)
657
changeDeviceNotify *from;
658
changeDeviceNotify *to;
663
swaps(&to->sequenceNumber,n);
668
SDeviceMappingNotifyEvent (from, to)
669
deviceMappingNotify *from;
670
deviceMappingNotify *to;
675
swaps(&to->sequenceNumber,n);
679
/************************************************************************
681
* This function sets up extension event types and masks.
686
FixExtensionEvents (extEntry)
687
ExtensionEntry *extEntry;
691
DeviceValuator = extEntry->eventBase;
692
DeviceKeyPress = DeviceValuator + 1;
693
DeviceKeyRelease = DeviceKeyPress + 1;
694
DeviceButtonPress = DeviceKeyRelease + 1;
695
DeviceButtonRelease = DeviceButtonPress + 1;
696
DeviceMotionNotify = DeviceButtonRelease + 1;
697
DeviceFocusIn = DeviceMotionNotify + 1;
698
DeviceFocusOut = DeviceFocusIn + 1;
699
ProximityIn = DeviceFocusOut + 1;
700
ProximityOut = ProximityIn + 1;
701
DeviceStateNotify = ProximityOut + 1;
702
DeviceMappingNotify = DeviceStateNotify + 1;
703
ChangeDeviceNotify = DeviceMappingNotify + 1;
704
DeviceKeyStateNotify = ChangeDeviceNotify + 1;
705
DeviceButtonStateNotify = DeviceKeyStateNotify + 1;
707
event_base[KeyClass] = DeviceKeyPress;
708
event_base[ButtonClass] = DeviceButtonPress;
709
event_base[ValuatorClass] = DeviceMotionNotify;
710
event_base[ProximityClass] = ProximityIn;
711
event_base[FocusClass] = DeviceFocusIn;
712
event_base[OtherClass] = DeviceStateNotify;
714
BadDevice += extEntry->errorBase;
715
BadEvent += extEntry->errorBase;
716
BadMode += extEntry->errorBase;
717
DeviceBusy += extEntry->errorBase;
718
BadClass += extEntry->errorBase;
720
mask = GetNextExtEventMask ();
721
SetMaskForExtEvent (mask, DeviceKeyPress);
722
AllowPropagateSuppress (mask);
724
mask = GetNextExtEventMask ();
725
SetMaskForExtEvent (mask, DeviceKeyRelease);
726
AllowPropagateSuppress (mask);
728
mask = GetNextExtEventMask ();
729
SetMaskForExtEvent (mask, DeviceButtonPress);
730
AllowPropagateSuppress (mask);
732
mask = GetNextExtEventMask ();
733
SetMaskForExtEvent (mask, DeviceButtonRelease);
734
AllowPropagateSuppress (mask);
736
mask = GetNextExtEventMask ();
737
SetMaskForExtEvent (mask, ProximityIn);
738
SetMaskForExtEvent (mask, ProximityOut);
739
AllowPropagateSuppress (mask);
741
mask = GetNextExtEventMask ();
742
DeviceStateNotifyMask = mask;
743
SetMaskForExtEvent (mask, DeviceStateNotify);
745
mask = GetNextExtEventMask ();
746
DevicePointerMotionMask = mask;
747
SetMaskForExtEvent (mask, DeviceMotionNotify);
748
AllowPropagateSuppress (mask);
750
DevicePointerMotionHintMask = GetNextExtEventMask();
751
SetEventInfo (DevicePointerMotionHintMask, _devicePointerMotionHint);
752
SetEventInfo (GetNextExtEventMask(), _deviceButton1Motion);
753
SetEventInfo (GetNextExtEventMask(), _deviceButton2Motion);
754
SetEventInfo (GetNextExtEventMask(), _deviceButton3Motion);
755
SetEventInfo (GetNextExtEventMask(), _deviceButton4Motion);
756
SetEventInfo (GetNextExtEventMask(), _deviceButton5Motion);
757
DeviceButtonMotionMask = GetNextExtEventMask();
758
SetEventInfo (DeviceButtonMotionMask, _deviceButtonMotion);
760
DeviceFocusChangeMask = GetNextExtEventMask ();
761
SetMaskForExtEvent (DeviceFocusChangeMask, DeviceFocusIn);
762
SetMaskForExtEvent (DeviceFocusChangeMask, DeviceFocusOut);
764
mask = GetNextExtEventMask ();
765
SetMaskForExtEvent (mask, DeviceMappingNotify);
766
DeviceMappingNotifyMask = mask;
768
mask = GetNextExtEventMask ();
769
SetMaskForExtEvent (mask, ChangeDeviceNotify);
770
ChangeDeviceNotifyMask = mask;
772
DeviceButtonGrabMask = GetNextExtEventMask();
773
SetEventInfo (DeviceButtonGrabMask, _deviceButtonGrab);
774
SetExclusiveAccess (DeviceButtonGrabMask);
776
DeviceOwnerGrabButtonMask = GetNextExtEventMask();
777
SetEventInfo (DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton);
778
SetEventInfo (0, _noExtensionEvent);
781
/************************************************************************
783
* This function restores extension event types and masks to their
789
RestoreExtensionEvents ()
795
for (i=0; i<ExtEventIndex-1; i++)
797
if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128))
798
SetMaskForEvent(0,EventInfo[i].type);
799
EventInfo[i].mask = 0;
800
EventInfo[i].type = 0;
803
lastExtEventMask = 1;
806
DeviceKeyRelease = 2;
807
DeviceButtonPress = 3;
808
DeviceButtonRelease = 4;
809
DeviceMotionNotify = 5;
814
DeviceStateNotify = 10;
815
DeviceMappingNotify = 11;
816
ChangeDeviceNotify = 12;
817
DeviceKeyStateNotify = 13;
818
DeviceButtonStateNotify = 13;
828
/***********************************************************************
831
* Remove reply-swapping routine.
832
* Remove event-swapping routine.
838
ExtensionEntry *unused;
841
ReplySwapVector[IReqCode] = ReplyNotSwappd;
842
EventSwapVector[DeviceValuator] = NotImplemented;
843
EventSwapVector[DeviceKeyPress] = NotImplemented;
844
EventSwapVector[DeviceKeyRelease] = NotImplemented;
845
EventSwapVector[DeviceButtonPress] = NotImplemented;
846
EventSwapVector[DeviceButtonRelease] = NotImplemented;
847
EventSwapVector[DeviceMotionNotify] = NotImplemented;
848
EventSwapVector[DeviceFocusIn] = NotImplemented;
849
EventSwapVector[DeviceFocusOut] = NotImplemented;
850
EventSwapVector[ProximityIn] = NotImplemented;
851
EventSwapVector[ProximityOut] = NotImplemented;
852
EventSwapVector[DeviceStateNotify] = NotImplemented;
853
EventSwapVector[DeviceKeyStateNotify] = NotImplemented;
854
EventSwapVector[DeviceButtonStateNotify] = NotImplemented;
855
EventSwapVector[DeviceMappingNotify] = NotImplemented;
856
EventSwapVector[ChangeDeviceNotify] = NotImplemented;
857
RestoreExtensionEvents ();
860
/***********************************************************************
862
* Assign an id and type to an input device.
867
AssignTypeAndName (dev, type, name)
873
dev->name = (char *) xalloc(strlen(name)+1);
874
strcpy (dev->name, name);
877
/***********************************************************************
879
* Make device type atoms.
884
MakeDeviceTypeAtoms ()
888
for (i=0; i<NUMTYPES; i++)
890
MakeAtom (dev_type[i].name, strlen(dev_type[i].name), 1);
893
/**************************************************************************
895
* Return a DeviceIntPtr corresponding to a specified device id.
896
* This will not return the pointer or keyboard, or devices that are not on.
906
for (dev=inputInfo.devices; dev; dev=dev->next)
910
if (id == inputInfo.pointer->id || id == inputInfo.keyboard->id)
918
/**************************************************************************
920
* Allow the specified event to be restricted to being selected by one
922
* The default is to allow more than one client to select the event.
927
SetExclusiveAccess (mask)
932
for (i=0; i<MAX_DEVICES; i++)
933
ExtExclusiveMasks[i] |= mask;
936
/**************************************************************************
938
* Allow the specified event to have its propagation suppressed.
939
* The default is to not allow suppression of propagation.
944
AllowPropagateSuppress (mask)
949
for (i=0; i<MAX_DEVICES; i++)
950
PropagateMask[i] |= mask;
953
/**************************************************************************
955
* Return the next available extension event mask.
960
GetNextExtEventMask ()
963
Mask mask = lastExtEventMask;
965
if (lastExtEventMask == 0)
967
FatalError("GetNextExtEventMask: no more events are available.");
969
lastExtEventMask <<= 1;
971
for (i=0; i<MAX_DEVICES; i++)
972
ExtValidMasks[i] |= mask;
976
/**************************************************************************
978
* Assign the specified mask to the specified event.
983
SetMaskForExtEvent(mask, event)
988
EventInfo[ExtEventIndex].mask = mask;
989
EventInfo[ExtEventIndex++].type = event;
991
if ((event < LASTEvent) || (event >= 128))
992
FatalError("MaskForExtensionEvent: bogus event number");
993
SetMaskForEvent(mask,event);
996
/**************************************************************************
998
* Record an event mask where there is no unique corresponding event type.
999
* We can't call SetMaskForEvent, since that would clobber the existing
1000
* mask for that event. MotionHint and ButtonMotion are examples.
1002
* Since extension event types will never be less than 64, we can use
1003
* 0-63 in the EventInfo array as the "type" to be used to look up this
1004
* mask. This means that the corresponding macros such as
1005
* DevicePointerMotionHint must have access to the same constants.
1010
SetEventInfo(mask, constant)
1014
EventInfo[ExtEventIndex].mask = mask;
1015
EventInfo[ExtEventIndex++].type = constant;