[PATCH] dix: Abstract XI2 filter mask lookup through GetXI2EventMaskByte
Peter Hutterer
peter.hutterer at who-t.net
Wed Aug 10 17:13:09 PDT 2011
Each time we need to get the XI2 event mask, we end up using (device->id |
XIAllDevices | XIAllMasterDevices). Abstract that away.
This commit also fixes a half-bug where GetWindowXI2Mask() would return the
XIAllDevices | XIAllMasterDevices mask as non-zero even when it is not set
for the current event mask. This would have only result in the event being
filtered later though.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
dix/events.c | 37 +++++++++++++++++++------------------
1 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/dix/events.c b/dix/events.c
index 6c4b6ef..1a84514 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -455,6 +455,20 @@ GetEventFilter(DeviceIntPtr dev, xEvent *event)
}
/**
+ * Return the single byte of the device's XI2 mask that contains the mask
+ * for the event_type.
+ */
+static int
+GetXI2MaskByte(unsigned char xi2mask[][XI2MASKSIZE], DeviceIntPtr dev, int event_type)
+{
+ int byte = GetXI2EventFilterOffset(event_type);
+ return xi2mask[dev->id][byte] |
+ xi2mask[XIAllDevices][byte] |
+ (IsMaster(dev) ? xi2mask[XIAllMasterDevices][byte] : 0);
+}
+
+
+/**
* Return the windows complete XI2 mask for the given XI2 event type.
*/
Mask
@@ -470,9 +484,7 @@ GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
evtype = ((xGenericEvent*)ev)->evtype;
filter = GetEventFilter(dev, ev);
- return ((inputMasks->xi2mask[dev->id][evtype/8] & filter) ||
- inputMasks->xi2mask[XIAllDevices][evtype/8] ||
- (inputMasks->xi2mask[XIAllMasterDevices][evtype/8] && IsMaster(dev)));
+ return (GetXI2MaskByte(inputMasks->xi2mask, dev, evtype) & filter);
}
Mask
@@ -483,10 +495,7 @@ GetEventMask(DeviceIntPtr dev, xEvent *event, InputClients* other)
/* XI2 filters are only ever 8 bit, so let's return a 8 bit mask */
if ((evtype = xi2_get_type(event)))
{
- int byte = GetXI2EventFilterOffset(evtype);
- return (other->xi2mask[dev->id][byte] |
- other->xi2mask[XIAllDevices][byte] |
- (IsMaster(dev)? other->xi2mask[XIAllMasterDevices][byte] : 0));
+ return GetXI2MaskByte(other->xi2mask, dev, evtype);
} else if (core_get_type(event) != 0)
return other->mask[XIAllDevices];
else
@@ -2497,13 +2506,9 @@ EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win)
if ((type = GetXI2Type(event)) != 0)
{
- int byte = GetXI2EventFilterOffset(type);
filter = GetXI2EventFilterMask(type);
- if (type && inputMasks &&
- ((inputMasks->xi2mask[XIAllDevices][byte] & filter) ||
- ((inputMasks->xi2mask[XIAllMasterDevices][byte] & filter) && IsMaster(dev)) ||
- (inputMasks->xi2mask[dev->id][byte] & filter)))
+ if (type && inputMasks && (GetXI2MaskByte(inputMasks->xi2mask, dev, type) & filter))
rc |= EVENT_XI2_MASK;
}
@@ -4078,9 +4083,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
if (rc == Success)
{
int evtype = xi2_get_type(xi2);
- mask = grab->xi2mask[XIAllDevices][evtype/8] |
- grab->xi2mask[XIAllMasterDevices][evtype/8] |
- grab->xi2mask[thisDev->id][evtype/8];
+ mask = GetXI2MaskByte(grab->xi2mask, thisDev, evtype);
/* try XI2 event */
FixUpEventFromWindow(pSprite, xi2, grab->window, None, TRUE);
/* XXX: XACE */
@@ -4559,9 +4562,7 @@ DeviceEnterLeaveEvent(
if (grab)
{
Mask mask;
- mask = grab->xi2mask[XIAllDevices][type/8] |
- grab->xi2mask[XIAllMasterDevices][type/8] |
- grab->xi2mask[mouse->id][type/8];
+ mask = GetXI2MaskByte(grab->xi2mask, mouse, type);
TryClientEvents(rClient(grab), mouse, (xEvent*)event, 1, mask,
filter, grab);
} else {
--
1.7.6
More information about the xorg-devel
mailing list