From 58427e08a4a36ce9e213e4b4fe5249d5db2c764d Mon Sep 17 00:00:00 2001 From: Chase Douglas Date: Wed, 7 Mar 2012 16:06:26 -0800 Subject: Xi: Fix TouchEnd to TouchUpdate change for one accepted grab If there is only one listener of a touch, the listener is a grab, and is accepted before the touch has ended, the current code will not end the touch record when the touch does end. This change adds a listener state for when a touch is accepted but has not yet ended. We now keep the touch record alive in this state, but end it when the touch ends. Signed-off-by: Chase Douglas Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- Xi/exevents.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'Xi') diff --git a/Xi/exevents.c b/Xi/exevents.c index a690a193d..f681a8b6f 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1210,6 +1210,8 @@ ProcessTouchOwnershipEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, /* Owner accepted after receiving end */ if (ti->listeners[0].state == LISTENER_HAS_END) TouchEndTouch(dev, ti); + else + ti->listeners[0].state = LISTENER_HAS_ACCEPTED; } else { /* this is the very first ownership event for a grab */ DeliverTouchEvents(dev, ti, (InternalEvent *) ev, ev->resource); @@ -1730,7 +1732,11 @@ DeliverTouchBeginEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, else { if (has_ownershipmask) TouchSendOwnershipEvent(dev, ti, 0, listener->listener); - state = LISTENER_IS_OWNER; + + if (!has_ownershipmask || listener->type == LISTENER_REGULAR) + state = LISTENER_HAS_ACCEPTED; + else + state = LISTENER_IS_OWNER; } listener->state = state; @@ -1759,20 +1765,22 @@ DeliverTouchEndEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev, listener->state = LISTENER_HAS_END; } else if (TouchResourceIsOwner(ti, listener->listener)) { + Bool normal_end = !(ev->device_event.flags & TOUCH_ACCEPT); + /* FIXME: what about early acceptance */ - if (!(ev->device_event.flags & TOUCH_ACCEPT)) { - if (listener->state != LISTENER_HAS_END) - rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev); - listener->state = LISTENER_HAS_END; - } + if (normal_end && listener->state != LISTENER_HAS_END) + rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev); + if ((ti->num_listeners > 1 || - (listener->type == LISTENER_GRAB && - xi2mask_isset(xi2mask, dev, XI_TouchOwnership))) && + listener->state != LISTENER_HAS_ACCEPTED) && (ev->device_event.flags & (TOUCH_ACCEPT | TOUCH_REJECT)) == 0) { ev->any.type = ET_TouchUpdate; ev->device_event.flags |= TOUCH_PENDING_END; ti->pending_finish = TRUE; } + + if (normal_end) + listener->state = LISTENER_HAS_END; } out: -- cgit v1.2.3