diff --git a/Xi/exevents.c b/Xi/exevents.c index ad3d4290b..af98bac04 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -83,8 +83,6 @@ SOFTWARE. Mod3Mask | Mod4Mask | Mod5Mask ) #define AllButtonsMask ( \ Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask ) -#define Motion_Filter(class) (DevicePointerMotionMask | \ - (class)->state | (class)->motionMask) Bool ShouldFreeInputMasks(WindowPtr /* pWin */ , Bool /* ignoreSelectedEvents */ @@ -832,6 +830,7 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count) device->valuator->motionHintWindow = NullWindow; *kptr &= ~bit; } else if (xE->u.u.type == DeviceButtonPress) { + Mask mask; if (!b) return DONT_PROCESS; @@ -847,8 +846,15 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count) b->motionMask = DeviceButtonMotionMask; if (b->map[key] <= 5) b->state |= (Button1Mask >> 1) << b->map[key]; - SetMaskForEvent(device->id, Motion_Filter(b), DeviceMotionNotify); + + /* Add state and motionMask to the filter for this event */ + mask = DevicePointerMotionMask | b->state | b->motionMask; + SetMaskForEvent(device->id, mask, DeviceMotionNotify); + mask = PointerMotionMask | b->state | b->motionMask; + SetMaskForEvent(device->id, mask, MotionNotify); } else if (xE->u.u.type == DeviceButtonRelease) { + Mask mask; + if (!b) return DONT_PROCESS; @@ -879,7 +885,12 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count) b->motionMask = 0; if (b->map[key] <= 5) b->state &= ~((Button1Mask >> 1) << b->map[key]); - SetMaskForEvent(device->id, Motion_Filter(b), DeviceMotionNotify); + + /* Add state and motionMask to the filter for this event */ + mask = DevicePointerMotionMask | b->state | b->motionMask; + SetMaskForEvent(device->id, mask, DeviceMotionNotify); + mask = PointerMotionMask | b->state | b->motionMask; + SetMaskForEvent(device->id, mask, MotionNotify); } else if (xE->u.u.type == ProximityIn) device->valuator->mode &= ~OutOfProximity; else if (xE->u.u.type == ProximityOut) diff --git a/dix/events.c b/dix/events.c index 598dc7514..ae566c539 100644 --- a/dix/events.c +++ b/dix/events.c @@ -190,13 +190,6 @@ typedef const char *string; * See DeliverEventsToWindow(). */ #define ImplicitGrabMask (1 << 7) -/* - * The following relies on the fact that the ButtonMotionMasks are equal - * to the corresponding ButtonMasks from the current modifier/button state. - */ -#define Motion_Filter(class) (PointerMotionMask | \ - (class)->state | (class)->motionMask) - #define WID(w) ((w) ? ((w)->drawable.id) : 0) @@ -571,20 +564,26 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev, #endif /* PANORAMIX */ +/** + * Modifies the filter for the given protocol event type to the given masks. + * + * There's only two callers: UpdateDeviceState() and XI's SetMaskForExtEvent(). + * The latter initialises masks for the matching XI events, it's a once-off + * setting. + * UDS however changes the mask for MotionNotify and DeviceMotionNotify each + * time a button is pressed to include the matching ButtonXMotion mask in the + * filter. + * + * @param[in] deviceid The device to modify the filter for. + * @param[in] mask The new filter mask. + * @param[in] event Protocol event type. + */ void SetMaskForEvent(int deviceid, Mask mask, int event) { - int coretype; if (deviceid < 0 || deviceid > MAXDEVICES) FatalError("SetMaskForEvent: bogus device id"); - if ((event < LASTEvent) || (event >= 128)) - FatalError("SetMaskForEvent: bogus event number"); filters[deviceid][event] = mask; - - /* Need to change the mask for the core events too */ - coretype = XItoCoreType(event); - if (coretype) - filters[deviceid][coretype] = mask; } void @@ -4618,6 +4617,8 @@ InitEvents(void) inputInfo.keyboard = (DeviceIntPtr)NULL; inputInfo.pointer = (DeviceIntPtr)NULL; lastEventMask = OwnerGrabButtonMask; + /* The mask for pointer motion events may have changed in the last server + * generation. See comment above definition of filters. */ filters[0][PointerMotionMask] = MotionNotify; for (i = 1; i < MAXDEVICES; i++) { diff --git a/include/dix.h b/include/dix.h index 8d6b9ff44..204dcf296 100644 --- a/include/dix.h +++ b/include/dix.h @@ -304,7 +304,7 @@ extern _X_EXPORT void SetVendorString(char *string); /* events.c */ -extern _X_EXPORT void SetMaskForEvent( +extern void SetMaskForEvent( int /* deviceid */, Mask /* mask */, int /* event */);