Merge lp:~chasedouglas/grail/gesture-end-fix into lp:grail

Proposed by Chase Douglas
Status: Merged
Merged at revision: 200
Proposed branch: lp:~chasedouglas/grail/gesture-end-fix
Merge into: lp:grail
Prerequisite: lp:~chasedouglas/grail/atomic-timeout-fix
Diff against target: 176 lines (+44/-7)
5 files modified
src/v3/gesture.cpp (+13/-5)
src/v3/gesture.h (+1/-0)
src/v3/slice.cpp (+5/-2)
src/v3/slice.h (+2/-0)
test/x11/twodrag.cpp (+23/-0)
To merge this branch: bzr merge lp:~chasedouglas/grail/gesture-end-fix
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve
Review via email: mp+98026@code.launchpad.net

Description of the change

Fix gesture end handling. Grail now treats physical gesture ending
separately from logical gesture ending. This resolves the bug where tap
gestures end and then further update and end events are erroneously sent.

To post a comment you must log in.
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Looks ok.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/v3/gesture.cpp'
2--- src/v3/gesture.cpp 2012-03-14 20:12:00 +0000
3+++ src/v3/gesture.cpp 2012-03-16 23:32:20 +0000
4@@ -104,7 +104,7 @@
5 * Update a gesture with the passed in frame event and list of modified touches
6 */
7 void Gesture::Update(UFEvent frame_event, TouchSet& modified_touches) {
8- if (ended_) {
9+ if (IsPhysicallyEnded()) {
10 /* The new event may have given us ownership of all the touches, in which
11 * case we need to send all gesture slices to the client */
12 if (IsActive())
13@@ -194,16 +194,23 @@
14
15 /* If the gesture ended and nothing was recognized or all the gesture slices
16 * have been sent, end the gesture */
17- if (last_slice_->state() == UGGestureStateEnd &&
18+ if (IsPhysicallyEnded() &&
19 (!recognized_ || IsConstructionFinished())) {
20+ UGSlice* slice = new UGSlice(last_slice_, true);
21+ slices_.push(SharedUGSlice(slice));
22+ FlushSlices();
23 ended_ = true;
24 last_slice_.reset();
25 }
26
27- if (ended_ && !recognized_)
28+ if (IsPhysicallyEnded() && !recognized_)
29 canceled_ = true;
30 }
31
32+bool Gesture::IsPhysicallyEnded() const {
33+ return (ended_ || (last_slice_ && last_slice_->physically_ended()));
34+}
35+
36 /**
37 * @internal
38 * Check if the gesture is active
39@@ -243,7 +250,7 @@
40
41 /* Create a new gesture slice to tell the client that construction has
42 * finished */
43- UGSlice* slice = new UGSlice(last_slice_);
44+ UGSlice* slice = new UGSlice(last_slice_, IsPhysicallyEnded());
45 if (!slice)
46 return;
47
48@@ -256,7 +263,7 @@
49 FlushSlices();
50
51 /* If we construction has finished on an ended gesture, we're done with it */
52- if (last_slice_->state() == UGGestureStateEnd) {
53+ if (IsPhysicallyEnded()) {
54 ended_ = true;
55 last_slice_.reset();
56 }
57@@ -378,6 +385,7 @@
58 while (!slices_.empty())
59 slices_.pop();
60 last_slice_.reset();
61+ ended_ = true;
62 }
63
64 /**
65
66=== modified file 'src/v3/gesture.h'
67--- src/v3/gesture.h 2012-03-14 20:12:00 +0000
68+++ src/v3/gesture.h 2012-03-16 23:32:20 +0000
69@@ -47,6 +47,7 @@
70 void Update(UFEvent event, TouchSet& touches);
71 bool IsActive() const;
72 bool IsConstructionFinished() const;
73+ bool IsPhysicallyEnded() const;
74 void FinishConstruction();
75 uint64_t Timeout() const;
76 float AngleForTouch(UFTouchId touch_id) const;
77
78=== modified file 'src/v3/slice.cpp'
79--- src/v3/slice.cpp 2012-03-06 14:13:04 +0000
80+++ src/v3/slice.cpp 2012-03-16 23:32:20 +0000
81@@ -55,6 +55,7 @@
82 touches_(touches),
83 time_(frame_event_get_time(event)),
84 state_(UGGestureStateBegin),
85+ physically_ended_(false),
86 original_center_x_(0),
87 original_center_y_(0),
88 original_radius_(0),
89@@ -96,6 +97,7 @@
90 touches_(prev->touches_),
91 time_(frame_event_get_time(event_)),
92 state_(end ? UGGestureStateEnd : UGGestureStateUpdate),
93+ physically_ended_(end ? true : prev->physically_ended_),
94 original_center_x_(prev->original_center_x_),
95 original_center_y_(prev->original_center_y_),
96 original_radius_(prev->original_radius_),
97@@ -131,6 +133,7 @@
98 touches_(touches),
99 time_(frame_event_get_time(event)),
100 state_(UGGestureStateUpdate),
101+ physically_ended_(prev->physically_ended_),
102 original_center_x_(prev->original_center_x_),
103 original_center_y_(prev->original_center_y_),
104 original_radius_(prev->original_radius_),
105@@ -414,7 +417,7 @@
106 unsigned int touches_min = subscription->touches_min();
107 if ((!touches_min && num_active_touches < touches_start) ||
108 (touches_min && num_active_touches < touches_min))
109- state_ = UGGestureStateEnd;
110+ physically_ended_ = true;
111 }
112
113 /**
114@@ -477,7 +480,7 @@
115 CumulativeTime() < subscription.tap().timeout &&
116 CumulativeDrag2() < (subscription.tap().threshold *
117 subscription.tap().threshold) &&
118- state_ == UGGestureStateEnd)
119+ physically_ended_)
120 recognized_ |= UGGestureTypeTap;
121
122 if (subscription.mask() & UGGestureTypeTouch)
123
124=== modified file 'src/v3/slice.h'
125--- src/v3/slice.h 2012-01-21 00:00:16 +0000
126+++ src/v3/slice.h 2012-03-16 23:32:20 +0000
127@@ -55,6 +55,7 @@
128 const TouchSet& touches() { return touches_; }
129 const UFFrame& frame() { return frame_; }
130 UGGestureState state() const { return state_; }
131+ bool physically_ended() const { return physically_ended_; }
132 void set_state(UGGestureState state) { state_ = state; }
133 bool construction_finished() const { return construction_finished_; }
134 void set_construction_finished() { construction_finished_ = true; }
135@@ -70,6 +71,7 @@
136 TouchSet touches_;
137 uint64_t time_;
138 UGGestureState state_;
139+ bool physically_ended_;
140 float original_center_x_;
141 float original_center_y_;
142 float original_radius_;
143
144=== modified file 'test/x11/twodrag.cpp'
145--- test/x11/twodrag.cpp 2012-03-16 23:32:20 +0000
146+++ test/x11/twodrag.cpp 2012-03-16 23:32:20 +0000
147@@ -317,6 +317,29 @@
148 Slice slice = {
149 false, /* skip */
150 0, /* UGSlicePropertyID */
151+ UGGestureStateUpdate, /* UGSlicePropertyState */
152+ UGGestureTypeDrag, /* UGSlicePropertyRecognized */
153+ 2, /* UGSlicePropertyNumTouches */
154+ 506.98666, /* UGSlicePropertyOriginalCenterX */
155+ 189.12, /* UGSlicePropertyOriginalCenterY */
156+ 59.668739, /* UGSlicePropertyOriginalRadius */
157+ {{ 1, 0, 0 },
158+ { 0, 1, 0 },
159+ { 0, 0, 1 }}, /* UGSlicePropertyTransform */
160+ {{ 1.034080, 0.073854253, -12.853333 },
161+ { -0.073854253, 1.034080, 397.119995 },
162+ { 0, 0, 1 }}, /* UGSlicePropertyCumulativeTransform */
163+ 0, /* UGSlicePropertyCenterOfRotationX */
164+ 0, /* UGSlicePropertyCenterOfRotationY */
165+ true, /* UGSlicePropertyConstructionFinished */
166+ };
167+ events.push_back(slice);
168+ }
169+
170+ {
171+ Slice slice = {
172+ false, /* skip */
173+ 0, /* UGSlicePropertyID */
174 UGGestureStateEnd, /* UGSlicePropertyState */
175 UGGestureTypeDrag, /* UGSlicePropertyRecognized */
176 2, /* UGSlicePropertyNumTouches */

Subscribers

People subscribed via source and target branches