On Wed, 10 Aug 2011 12:56:32 +1000, Peter Hutterer <[email protected]> wrote:
> 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. Seems like this would look neater if it wasn't allocating events just to be able to use the GetEventFilter function. This is on top of your patch; I haven't tested it at all, but does it look like a reasonable thing to do? From 74793f4c6d4ceb5675f5de18c9774ecc5f5a32b7 Mon Sep 17 00:00:00 2001 From: Keith Packard <[email protected]> Date: Tue, 9 Aug 2011 20:45:52 -0700 Subject: [PATCH] dix: Eliminate event conversions in EventIsDeliverable The only need for the event was to compute the filter, and that can be computed directly from the event type instead of converting the event into the wire format and passing it to GetEventFilter. Signed-off-by: Keith Packard <[email protected]> --- dix/events.c | 55 ++++++++++++++++++++++++++++++++----------------------- 1 files changed, 32 insertions(+), 23 deletions(-) diff --git a/dix/events.c b/dix/events.c index a9913a7..43f0cfb 100644 --- a/dix/events.c +++ b/dix/events.c @@ -408,6 +408,24 @@ static const Mask default_filter[128] = CantBeFiltered /* MappingNotify */ }; +static inline Mask +GetEventFilterMask(DeviceIntPtr dev, int evtype) +{ + return filters[dev ? dev->id : 0][evtype]; +} + +static inline Mask +GetXI2EventFilterMask(int evtype) +{ + return (1 << (evtype % 8)); +} + +static inline int +GetXI2EventFilterOffset(int evtype) +{ + return (evtype / 8); +} + /** * For the given event, return the matching event filter. This filter may then * be AND'ed with the selected event mask. @@ -429,9 +447,9 @@ GetEventFilter(DeviceIntPtr dev, xEvent *event) int evtype = 0; if (event->u.u.type != GenericEvent) - return filters[dev ? dev->id : 0][event->u.u.type]; + return GetEventFilterMask(dev, event->u.u.type); else if ((evtype = xi2_get_type(event))) - return (1 << (evtype % 8)); + return GetXI2EventFilterMask(evtype); ErrorF("[dix] Unknown event type %d. No filter\n", event->u.u.type); return 0; } @@ -465,7 +483,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 = evtype / 8; + int byte = GetXI2EventFilterOffset(evtype); return (other->xi2mask[dev->id][byte] | other->xi2mask[XIAllDevices][byte] | (IsMaster(dev)? other->xi2mask[XIAllMasterDevices][byte] : 0)); @@ -2478,26 +2496,22 @@ EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win) int filter = 0; int type; OtherInputMasks *inputMasks = wOtherInputMasks(win); - xEvent *ev = NULL; - int count; - if (EventToXI2(event, &ev) == Success) + if ((type = GetXI2Type(event)) != 0) { - type = GetXI2Type(event); - filter = GetEventFilter(dev, ev); + int byte = GetXI2EventFilterOffset(type); + filter = GetXI2EventFilterMask(type); + if (type && inputMasks && - ((inputMasks->xi2mask[XIAllDevices][type/8] & filter) || - ((inputMasks->xi2mask[XIAllMasterDevices][type/8] & filter) && IsMaster(dev)) || - (inputMasks->xi2mask[dev->id][type/8] & filter))) + ((inputMasks->xi2mask[XIAllDevices][byte] & filter) || + ((inputMasks->xi2mask[XIAllMasterDevices][byte] & filter) && IsMaster(dev)) || + (inputMasks->xi2mask[dev->id][byte] & filter))) rc |= EVENT_XI2_MASK; - free(ev); - ev = NULL; } - if (EventToXI(event, &ev, &count) == Success) + if ((type = GetXIType(event)) != 0) { - type = GetXIType(event); - filter = GetEventFilter(dev, ev); + filter = GetEventFilterMask(dev, type); /* Check for XI mask */ if (type && inputMasks && @@ -2510,14 +2524,11 @@ EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win) (inputMasks->dontPropagateMask[dev->id] & filter)) rc |= EVENT_DONT_PROPAGATE_MASK; - free(ev); - ev = NULL; } - if (EventToCore(event, &ev, &count) == Success) + if ((type = GetCoreType(event)) != 0) { - type = GetCoreType(event); - filter = GetEventFilter(dev, ev); + filter = GetEventFilterMask(dev, type); /* Check for core mask */ if (type && (win->deliverableEvents & filter) && @@ -2527,8 +2538,6 @@ EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win) /* Check for core DontPropagate mask */ if (type && (filter & wDontPropagateMask(win))) rc |= EVENT_DONT_PROPAGATE_MASK; - free(ev); - ev = NULL; } return rc; -- 1.7.5.4 -- [email protected]
pgpcVpQhlbdTn.pgp
Description: PGP signature
_______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
