1
From 40cd6abb66787c79465cda03c17297a06d1cd848 Mon Sep 17 00:00:00 2001
2
From: Chase Douglas <chase.douglas@canonical.com>
3
Date: Fri, 2 Mar 2012 14:40:07 -0800
4
Subject: [PATCH 1/2] Xi: Fix TouchEnd to TouchUpdate change for one accepted
7
If there is only one listener of a touch, the listener is a grab, and is
8
accepted before the touch has ended, the current code will not end the
9
touch record when the touch does end.
11
This change adds a listener state for when a touch is accepted but has
12
not yet ended. We now keep the touch record alive in this state, but end
13
it when the touch ends.
15
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
17
Xi/exevents.c | 25 ++++++++++++++++---------
18
include/input.h | 3 ++-
19
2 files changed, 18 insertions(+), 10 deletions(-)
21
diff --git a/Xi/exevents.c b/Xi/exevents.c
22
index f390f67..d71e604 100644
25
@@ -1252,6 +1252,8 @@ ProcessTouchOwnershipEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
26
/* Owner accepted after receiving end */
27
if (ti->listeners[0].state == LISTENER_HAS_END)
28
TouchEndTouch(dev, ti);
30
+ ti->listeners[0].state = LISTENER_HAS_ACCEPTED;
31
} else { /* this is the very first ownership event for a grab */
32
DeliverTouchEvents(dev, ti, (InternalEvent*)ev, ev->resource);
34
@@ -1781,7 +1783,11 @@ DeliverTouchBeginEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev
36
if (has_ownershipmask)
37
TouchSendOwnershipEvent(dev, ti, 0, listener->listener);
38
- state = LISTENER_IS_OWNER;
40
+ if (!has_ownershipmask || listener->type == LISTENER_REGULAR)
41
+ state = LISTENER_HAS_ACCEPTED;
43
+ state = LISTENER_IS_OWNER;
45
listener->state = state;
47
@@ -1812,22 +1818,23 @@ DeliverTouchEndEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev,
48
listener->state = LISTENER_HAS_END;
49
} else if (TouchResourceIsOwner(ti, listener->listener))
51
+ Bool normal_end = !(ev->device_event.flags & TOUCH_ACCEPT);
53
/* FIXME: what about early acceptance */
54
- if (!(ev->device_event.flags & TOUCH_ACCEPT))
56
- if (listener->state != LISTENER_HAS_END)
57
- rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev);
58
- listener->state = LISTENER_HAS_END;
60
+ if (normal_end && listener->state != LISTENER_HAS_END)
61
+ rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev);
63
if ((ti->num_listeners > 1 ||
64
- (listener->type == LISTENER_GRAB &&
65
- xi2mask_isset(xi2mask, dev, XI_TouchOwnership))) &&
66
+ listener->state != LISTENER_HAS_ACCEPTED) &&
67
(ev->device_event.flags & (TOUCH_ACCEPT|TOUCH_REJECT)) == 0)
69
ev->any.type = ET_TouchUpdate;
70
ev->device_event.flags |= TOUCH_PENDING_END;
71
ti->pending_finish = TRUE;
75
+ listener->state = LISTENER_HAS_END;
79
diff --git a/include/input.h b/include/input.h
80
index b7825a7..1e9e0fd 100644
83
@@ -585,7 +585,8 @@ enum TouchListenerState{
84
LISTENER_AWAITING_OWNER, /**< Waiting for a TouchOwnership event */
85
LISTENER_EARLY_ACCEPT, /**< Waiting for ownership, has already
87
- LISTENER_IS_OWNER, /**< Is the current owner */
88
+ LISTENER_IS_OWNER, /**< Is the current owner, hasn't accepted */
89
+ LISTENER_HAS_ACCEPTED, /**< Is the current owner, has accepted */
90
LISTENER_HAS_END, /**< Has already received the end event */