[PATCH] dix: Use event conversion routines in EventIsDeliverable
Peter Hutterer
peter.hutterer at who-t.net
Tue Aug 9 19:56:32 PDT 2011
Proximity events don't have an XI2 type and caused error messages in the
log when trying to get the event filter. Use this opportunity to clean up
the code, instead of manually setting the fields that GetEventFilter
requires use EventTo(XI2|XI|Core) instead.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
dix/events.c | 90 +++++++++++++++++++++++++++++++++------------------------
1 files changed, 52 insertions(+), 38 deletions(-)
diff --git a/dix/events.c b/dix/events.c
index 616d727..8edbba8 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2476,44 +2476,58 @@ EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win)
int filter = 0;
int type;
OtherInputMasks *inputMasks = wOtherInputMasks(win);
- xEvent ev;
-
- /* XXX: this makes me gag */
- type = GetXI2Type(event);
- ev.u.u.type = GenericEvent; /* GetEventFilter only cares about type and evtype*/
- ((xGenericEvent*)&ev)->extension = IReqCode;
- ((xGenericEvent*)&ev)->evtype = type;
- filter = GetEventFilter(dev, &ev);
- if (type && inputMasks &&
- ((inputMasks->xi2mask[XIAllDevices][type/8] & filter) ||
- ((inputMasks->xi2mask[XIAllMasterDevices][type/8] & filter) && IsMaster(dev)) ||
- (inputMasks->xi2mask[dev->id][type/8] & filter)))
- rc |= EVENT_XI2_MASK;
-
- type = GetXIType(event);
- ev.u.u.type = type;
- filter = GetEventFilter(dev, &ev);
-
- /* Check for XI mask */
- if (type && inputMasks &&
- (inputMasks->deliverableEvents[dev->id] & filter) &&
- (inputMasks->inputEvents[dev->id] & filter))
- rc |= EVENT_XI1_MASK;
-
- /* Check for XI DontPropagate mask */
- if (type && inputMasks &&
- (inputMasks->dontPropagateMask[dev->id] & filter))
- rc |= EVENT_DONT_PROPAGATE_MASK;
-
- /* Check for core mask */
- type = GetCoreType(event);
- if (type && (win->deliverableEvents & filter) &&
- ((wOtherEventMasks(win) | win->eventMask) & filter))
- rc |= EVENT_CORE_MASK;
-
- /* Check for core DontPropagate mask */
- if (type && (filter & wDontPropagateMask(win)))
- rc |= EVENT_DONT_PROPAGATE_MASK;
+ xEvent *ev = NULL;
+ int count;
+
+ if (EventToXI2(event, &ev) == Success)
+ {
+ type = GetXI2Type(event);
+ filter = GetEventFilter(dev, ev);
+ if (type && inputMasks &&
+ ((inputMasks->xi2mask[XIAllDevices][type/8] & filter) ||
+ ((inputMasks->xi2mask[XIAllMasterDevices][type/8] & filter) && IsMaster(dev)) ||
+ (inputMasks->xi2mask[dev->id][type/8] & filter)))
+ rc |= EVENT_XI2_MASK;
+ free(ev);
+ ev = NULL;
+ }
+
+ if (EventToXI(event, &ev, &count) == Success)
+ {
+ type = GetXIType(event);
+ filter = GetEventFilter(dev, ev);
+
+ /* Check for XI mask */
+ if (type && inputMasks &&
+ (inputMasks->deliverableEvents[dev->id] & filter) &&
+ (inputMasks->inputEvents[dev->id] & filter))
+ rc |= EVENT_XI1_MASK;
+
+ /* Check for XI DontPropagate mask */
+ if (type && inputMasks &&
+ (inputMasks->dontPropagateMask[dev->id] & filter))
+ rc |= EVENT_DONT_PROPAGATE_MASK;
+
+ free(ev);
+ ev = NULL;
+ }
+
+ if (EventToCore(event, &ev, &count) == Success)
+ {
+ type = GetCoreType(event);
+ filter = GetEventFilter(dev, ev);
+
+ /* Check for core mask */
+ if (type && (win->deliverableEvents & filter) &&
+ ((wOtherEventMasks(win) | win->eventMask) & filter))
+ rc |= EVENT_CORE_MASK;
+
+ /* Check for core DontPropagate mask */
+ if (type && (filter & wDontPropagateMask(win)))
+ rc |= EVENT_DONT_PROPAGATE_MASK;
+ free(ev);
+ ev = NULL;
+ }
return rc;
}
--
1.7.6
More information about the xorg-devel
mailing list