diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-02-12 08:37:49 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-02-16 13:28:17 +1000 |
commit | 58f3127919ba5fcb3bb467b6913c28ee1127c82b (patch) | |
tree | 47db811fe9ab2fffa802b540c948d68270bd3648 | |
parent | 7057a9a97b9316b1de954d05451e04223fdd9fd8 (diff) |
Xi: remove dynamic mask assignment for XI events.
They end up being the same anyway on startup, so let's not have a dynamic mask
assignment mechanism and instead just hardcode them already.
Also unexport SelectForWindow and remove the valid_masks parameter. We can
check that before calling, since there's only one caller anyway.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | Xi/exevents.c | 6 | ||||
-rw-r--r-- | Xi/exglobals.h | 25 | ||||
-rw-r--r-- | Xi/extinit.c | 149 | ||||
-rw-r--r-- | Xi/selectev.c | 8 | ||||
-rw-r--r-- | include/exevents.h | 5 |
5 files changed, 71 insertions, 122 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index 34e9e7317..ad3d4290b 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1353,17 +1353,13 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, int SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client, - Mask mask, Mask exclusivemasks, Mask validmasks) + Mask mask, Mask exclusivemasks) { int mskidx = dev->id; int i, ret; Mask check; InputClientsPtr others; - if (mask & ~validmasks) { - client->errorValue = mask; - return BadValue; - } check = (mask & exclusivemasks); if (wOtherInputMasks(pWin)) { if (check & wOtherInputMasks(pWin)->inputEvents[mskidx]) { /* It is illegal for two different diff --git a/Xi/exglobals.h b/Xi/exglobals.h index 42a695356..182807318 100644 --- a/Xi/exglobals.h +++ b/Xi/exglobals.h @@ -43,18 +43,19 @@ extern int BadMode; extern int DeviceBusy; extern int BadClass; -extern Mask DevicePointerMotionMask; -extern Mask DevicePointerMotionHintMask; -extern Mask DeviceFocusChangeMask; -extern Mask DeviceStateNotifyMask; -extern Mask DeviceMappingNotifyMask; -extern Mask DeviceOwnerGrabButtonMask; -extern Mask DeviceButtonGrabMask; -extern Mask DeviceButtonMotionMask; -extern Mask DevicePresenceNotifyMask; -extern Mask DevicePropertyNotifyMask; -extern Mask DeviceEnterWindowMask; -extern Mask DeviceLeaveWindowMask; +/* Note: only the ones needed in files other than extinit.c are declared */ +extern const Mask DevicePointerMotionMask; +extern const Mask DevicePointerMotionHintMask; +extern const Mask DeviceFocusChangeMask; +extern const Mask DeviceStateNotifyMask; +extern const Mask DeviceMappingNotifyMask; +extern const Mask DeviceOwnerGrabButtonMask; +extern const Mask DeviceButtonGrabMask; +extern const Mask DeviceButtonMotionMask; +extern const Mask DevicePresenceNotifyMask; +extern const Mask DevicePropertyNotifyMask; +extern const Mask XIAllMasks; + extern Mask PropagateMask[]; extern int DeviceValuator; diff --git a/Xi/extinit.c b/Xi/extinit.c index a7a21ece8..78f216803 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -121,9 +121,37 @@ SOFTWARE. #include "xiproperty.h" -static Mask lastExtEventMask = 1; +/* Masks for XI events have to be aligned with core event (partially anyway). + * If DeviceButtonMotionMask is != ButtonMotionMask, event delivery + * breaks down. The device needs the dev->button->motionMask. If DBMM is + * the same as BMM, we can ensure that both core and device events can be + * delivered, without the need for extra structures in the DeviceIntRec. */ +const Mask DeviceKeyPressMask = KeyPressMask; +const Mask DeviceKeyReleaseMask = KeyReleaseMask; +const Mask DeviceButtonPressMask = ButtonPressMask; +const Mask DeviceButtonReleaseMask = ButtonReleaseMask; +const Mask DeviceProximityMask = (1L << 4); +const Mask DeviceStateNotifyMask = (1L << 5); +const Mask DevicePointerMotionMask = PointerMotionMask; +const Mask DevicePointerMotionHintMask = PointerMotionHintMask; +const Mask DeviceButton1MotionMask = Button1MotionMask; +const Mask DeviceButton2MotionMask = Button2MotionMask; +const Mask DeviceButton3MotionMask = Button3MotionMask; +const Mask DeviceButton4MotionMask = Button4MotionMask; +const Mask DeviceButton5MotionMask = Button5MotionMask; +const Mask DeviceButtonMotionMask = ButtonMotionMask; +const Mask DeviceFocusChangeMask = (1L << 14); +const Mask DeviceMappingNotifyMask = (1L << 15); +const Mask ChangeDeviceNotifyMask = (1L << 16); +const Mask DeviceButtonGrabMask = (1L << 17); +const Mask DeviceOwnerGrabButtonMask = (1L << 17); +const Mask DevicePresenceNotifyMask = (1L << 18); +const Mask DeviceEnterWindowMask = (1L << 18); +const Mask DeviceLeaveWindowMask = (1L << 19); +const Mask DevicePropertyNotifyMask = (1L << 20); +const Mask XIAllMasks = (1L << 21) - 1; + int ExtEventIndex; -Mask ExtValidMasks[EMASKSIZE]; Mask ExtExclusiveMasks[EMASKSIZE]; @@ -287,20 +315,6 @@ int BadMode = 2; int DeviceBusy = 3; int BadClass = 4; -Mask DevicePointerMotionMask; -Mask DevicePointerMotionHintMask; -Mask DeviceFocusChangeMask; -Mask DeviceStateNotifyMask; -static Mask ChangeDeviceNotifyMask; -Mask DeviceMappingNotifyMask; -Mask DeviceOwnerGrabButtonMask; -Mask DeviceButtonGrabMask; -Mask DeviceButtonMotionMask; -Mask DevicePresenceNotifyMask; -Mask DevicePropertyNotifyMask; -Mask DeviceEnterWindowMask; -Mask DeviceLeaveWindowMask; - int DeviceValuator; int DeviceKeyPress; int DeviceKeyRelease; @@ -675,28 +689,6 @@ AllowPropagateSuppress(Mask mask) /************************************************************************** * - * Return the next available extension event mask. - * - */ - -static Mask -GetNextExtEventMask(void) -{ - int i; - Mask mask = lastExtEventMask; - - if (lastExtEventMask == 0) { - FatalError("GetNextExtEventMask: no more events are available."); - } - lastExtEventMask <<= 1; - - for (i = 0; i < MAXDEVICES; i++) - ExtValidMasks[i] |= mask; - return mask; -} - -/************************************************************************** - * * Record an event mask where there is no unique corresponding event type. * We can't call SetMaskForEvent, since that would clobber the existing * mask for that event. MotionHint and ButtonMotion are examples. @@ -762,8 +754,6 @@ SetMaskForExtEvent(Mask mask, int event) static void FixExtensionEvents(ExtensionEntry * extEntry) { - Mask mask; - DeviceValuator = extEntry->eventBase; DeviceKeyPress = DeviceValuator + 1; DeviceKeyRelease = DeviceKeyPress + 1; @@ -797,88 +787,50 @@ FixExtensionEvents(ExtensionEntry * extEntry) DeviceBusy += extEntry->errorBase; BadClass += extEntry->errorBase; - mask = GetNextExtEventMask(); - SetMaskForExtEvent(mask, DeviceKeyPress); - AllowPropagateSuppress(mask); + SetMaskForExtEvent(DeviceKeyPressMask, DeviceKeyPress); + AllowPropagateSuppress(DeviceKeyPressMask); - mask = GetNextExtEventMask(); - SetMaskForExtEvent(mask, DeviceKeyRelease); - AllowPropagateSuppress(mask); + SetMaskForExtEvent(DeviceKeyReleaseMask, DeviceKeyRelease); + AllowPropagateSuppress(DeviceKeyReleaseMask); - mask = GetNextExtEventMask(); - SetMaskForExtEvent(mask, DeviceButtonPress); - AllowPropagateSuppress(mask); + SetMaskForExtEvent(DeviceButtonPressMask, DeviceButtonPress); + AllowPropagateSuppress(DeviceButtonPressMask); - mask = GetNextExtEventMask(); - SetMaskForExtEvent(mask, DeviceButtonRelease); - AllowPropagateSuppress(mask); + SetMaskForExtEvent(DeviceButtonReleaseMask, DeviceButtonRelease); + AllowPropagateSuppress(DeviceButtonReleaseMask); - mask = GetNextExtEventMask(); - SetMaskForExtEvent(mask, ProximityIn); - SetMaskForExtEvent(mask, ProximityOut); - AllowPropagateSuppress(mask); + SetMaskForExtEvent(DeviceProximityMask, ProximityIn); + SetMaskForExtEvent(DeviceProximityMask, ProximityOut); - mask = GetNextExtEventMask(); - DeviceStateNotifyMask = mask; - SetMaskForExtEvent(mask, DeviceStateNotify); + SetMaskForExtEvent(DeviceStateNotifyMask, DeviceStateNotify); - mask = GetNextExtEventMask(); - DevicePointerMotionMask = mask; - SetMaskForExtEvent(mask, DeviceMotionNotify); - AllowPropagateSuppress(mask); + SetMaskForExtEvent(DevicePointerMotionMask, DeviceMotionNotify); + AllowPropagateSuppress(DevicePointerMotionMask); - DevicePointerMotionHintMask = GetNextExtEventMask(); SetEventInfo(DevicePointerMotionHintMask, _devicePointerMotionHint); - SetEventInfo(GetNextExtEventMask(), _deviceButton1Motion); - SetEventInfo(GetNextExtEventMask(), _deviceButton2Motion); - SetEventInfo(GetNextExtEventMask(), _deviceButton3Motion); - SetEventInfo(GetNextExtEventMask(), _deviceButton4Motion); - SetEventInfo(GetNextExtEventMask(), _deviceButton5Motion); - - /* If DeviceButtonMotionMask is != ButtonMotionMask, event delivery - * breaks down. The device needs the dev->button->motionMask. If DBMM is - * the same as BMM, we can ensure that both core and device events can be - * delivered, without the need for extra structures in the DeviceIntRec. - */ - DeviceButtonMotionMask = GetNextExtEventMask(); + SetEventInfo(DeviceButton1MotionMask, _deviceButton1Motion); + SetEventInfo(DeviceButton2MotionMask, _deviceButton2Motion); + SetEventInfo(DeviceButton3MotionMask, _deviceButton3Motion); + SetEventInfo(DeviceButton4MotionMask, _deviceButton4Motion); + SetEventInfo(DeviceButton5MotionMask, _deviceButton5Motion); SetEventInfo(DeviceButtonMotionMask, _deviceButtonMotion); - if (DeviceButtonMotionMask != ButtonMotionMask) - { - /* This should never happen, but if it does, hide under the - * bed and cry for help. */ - ErrorF("[Xi] DeviceButtonMotionMask != ButtonMotionMask. Trouble!\n"); - } - DeviceFocusChangeMask = GetNextExtEventMask(); SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusIn); SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusOut); - mask = GetNextExtEventMask(); - SetMaskForExtEvent(mask, DeviceMappingNotify); - DeviceMappingNotifyMask = mask; - - mask = GetNextExtEventMask(); - SetMaskForExtEvent(mask, ChangeDeviceNotify); - ChangeDeviceNotifyMask = mask; + SetMaskForExtEvent(DeviceMappingNotifyMask, DeviceMappingNotify); + SetMaskForExtEvent(ChangeDeviceNotifyMask, ChangeDeviceNotify); - DeviceButtonGrabMask = GetNextExtEventMask(); SetEventInfo(DeviceButtonGrabMask, _deviceButtonGrab); SetExclusiveAccess(DeviceButtonGrabMask); - DeviceOwnerGrabButtonMask = GetNextExtEventMask(); SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton); - - DevicePresenceNotifyMask = GetNextExtEventMask(); SetEventInfo(DevicePresenceNotifyMask, _devicePresence); - - DevicePropertyNotifyMask = GetNextExtEventMask(); SetMaskForExtEvent(DevicePropertyNotifyMask, DevicePropertyNotify); - DeviceEnterWindowMask = GetNextExtEventMask(); SetMaskForExtEvent(DeviceEnterWindowMask, DeviceEnterNotify); AllowPropagateSuppress(DeviceEnterWindowMask); - DeviceLeaveWindowMask = GetNextExtEventMask(); SetMaskForExtEvent(DeviceLeaveWindowMask, DeviceLeaveNotify); AllowPropagateSuppress(DeviceLeaveWindowMask); @@ -910,7 +862,6 @@ RestoreExtensionEvents(void) EventInfo[i].type = 0; } ExtEventIndex = 0; - lastExtEventMask = 1; DeviceValuator = 0; DeviceKeyPress = 1; DeviceKeyRelease = 2; diff --git a/Xi/selectev.c b/Xi/selectev.c index c3fc88ed9..b785a8e45 100644 --- a/Xi/selectev.c +++ b/Xi/selectev.c @@ -66,7 +66,6 @@ SOFTWARE. #include "selectev.h" extern Mask ExtExclusiveMasks[]; -extern Mask ExtValidMasks[]; static int HandleDevicePresenceMask(ClientPtr client, WindowPtr win, @@ -173,10 +172,13 @@ ProcXSelectExtensionEvent(ClientPtr client) for (i = 0; i < EMASKSIZE; i++) if (tmp[i].dev != NULL) { + if (tmp[i].mask & ~XIAllMasks) { + client->errorValue = tmp[i].mask; + return BadValue; + } if ((ret = SelectForWindow((DeviceIntPtr) tmp[i].dev, pWin, client, - tmp[i].mask, ExtExclusiveMasks[i], - ExtValidMasks[i])) != Success) + tmp[i].mask, ExtExclusiveMasks[i]))!= Success) return ret; } diff --git a/include/exevents.h b/include/exevents.h index ff2922736..ab9690242 100644 --- a/include/exevents.h +++ b/include/exevents.h @@ -101,13 +101,12 @@ extern _X_EXPORT int GrabKey( BOOL /* ownerEvents */, Mask /* mask */); -extern _X_EXPORT int SelectForWindow( +extern int SelectForWindow( DeviceIntPtr /* dev */, WindowPtr /* pWin */, ClientPtr /* client */, Mask /* mask */, - Mask /* exclusivemasks */, - Mask /* validmasks */); + Mask /* exclusivemasks */); extern _X_EXPORT int AddExtensionClient ( WindowPtr /* pWin */, |