Merge lp:~chasedouglas/grail/fix-hold-reject into lp:grail

Proposed by Chase Douglas
Status: Merged
Merged at revision: 226
Proposed branch: lp:~chasedouglas/grail/fix-hold-reject
Merge into: lp:grail
Prerequisite: lp:~chasedouglas/grail/reject-test
Diff against target: 105 lines (+22/-12)
6 files modified
src/v3/atomic-recognizer.cpp (+9/-1)
src/v3/atomic-recognizer.h (+2/-0)
src/v3/recognizer.cpp (+0/-9)
src/v3/recognizer.h (+0/-1)
src/v3/regular-recognizer.cpp (+9/-1)
src/v3/regular-recognizer.h (+2/-0)
To merge this branch: bzr merge lp:~chasedouglas/grail/fix-hold-reject
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
Thomas Voß (community) Needs Information
Review via email: mp+100621@code.launchpad.net

Description of the change

Ensure touches are rejected after all possible gestures are exhausted rather than when the touch ends.

To post a comment you must log in.
Revision history for this message
Thomas Voß (thomas-voss) wrote :

Is there a reason why touch-deletion code is duplicated for both recognizers? Could you move the code up the inheritance hierarchy?

Apart from that: Looks good to me.

review: Needs Information
Revision history for this message
Chase Douglas (chasedouglas) wrote :

Yes, it could probably be moved up for the most part. The main reason it's not already is that the atomic recognizer has to maintain an extra list of touches: new_touches_.

There are multiple ways of skinning this cat:

* Create one big virtual function in recognizer.cpp, and have atomic-recognizer override it as it is currently written.

* Create virtual functions for each touch state.

* Something else?

I haven't really taken the time to think much about it. It would be an unnecessary code change, and at this point in the cycle we need to minimize such changes.

226. By Chase Douglas

Delete subscription in test fixture TearDown() method

The subscription is "owned" by the test fixture, so it should be deleted
by it, not by the test itself.

Revision history for this message
Stephen M. Webb (bregma) wrote :

Looks simple enough, should break the touch hold at the right time.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/v3/atomic-recognizer.cpp'
2--- src/v3/atomic-recognizer.cpp 2012-03-27 15:48:25 +0000
3+++ src/v3/atomic-recognizer.cpp 2012-04-03 18:13:20 +0000
4@@ -191,10 +191,18 @@
5 case UFTouchStateEnd: {
6 auto it = all_touches_.find(frame_touch_get_id(touch));
7 if (it != all_touches_.end()) {
8- const SharedTouch& grail_touch = it->second;
9+ if (it->second.expired()) {
10+ ERASE_TOUCH(it->first, all_touches_);
11+ break;
12+ }
13+
14+ const SharedTouch& grail_touch = it->second.lock();
15
16 grail_touch->Update(touch);
17
18+ if (grail_touch->ended())
19+ ERASE_TOUCH(grail_touch->id(), all_touches_);
20+
21 if (grail_touch->pending_end() || grail_touch->ended()) {
22 ERASE_TOUCH(grail_touch->id(), new_touches_);
23 ERASE_TOUCH(grail_touch->id(), free_touches_);
24
25=== modified file 'src/v3/atomic-recognizer.h'
26--- src/v3/atomic-recognizer.h 2012-03-27 15:46:44 +0000
27+++ src/v3/atomic-recognizer.h 2012-04-03 18:13:20 +0000
28@@ -43,6 +43,8 @@
29 void FindGesturesToAccept(uint64_t event_time);
30 virtual uint64_t NextTimeout();
31
32+ std::map<UFTouchId, std::weak_ptr<Touch>> all_touches_;
33+
34 /* Touches that have begun but not yet been matched against subscriptions
35 (for the creation of new gestures) or used to update existing gestures. */
36 TouchMap new_touches_;
37
38=== modified file 'src/v3/recognizer.cpp'
39--- src/v3/recognizer.cpp 2012-03-26 21:54:35 +0000
40+++ src/v3/recognizer.cpp 2012-04-03 18:13:20 +0000
41@@ -217,15 +217,6 @@
42 RejectGesture(gesture);
43 }
44 }
45-
46- /* Delete all ended touches */
47- for (auto it = all_touches_.begin(); it != all_touches_.end(); ) {
48- const auto& pair = *it++;
49- const SharedTouch& touch = pair.second;
50-
51- if (touch->ended())
52- all_touches_.erase(touch->id());
53- }
54 }
55
56 /**
57
58=== modified file 'src/v3/recognizer.h'
59--- src/v3/recognizer.h 2012-03-26 21:54:35 +0000
60+++ src/v3/recognizer.h 2012-04-03 18:13:20 +0000
61@@ -99,7 +99,6 @@
62 std::set<SharedGesture> unaccepted_gestures_;
63 std::set<SharedGesture> accepted_gestures_;
64 TouchMap free_touches_;
65- TouchMap all_touches_;
66
67 unsigned int num_subscriptions_;
68
69
70=== modified file 'src/v3/regular-recognizer.cpp'
71--- src/v3/regular-recognizer.cpp 2012-03-27 15:52:30 +0000
72+++ src/v3/regular-recognizer.cpp 2012-04-03 18:13:20 +0000
73@@ -128,10 +128,18 @@
74 case UFTouchStateEnd: {
75 auto it = all_touches_.find(frame_touch_get_id(touch));
76 if (it != all_touches_.end()) {
77- const SharedTouch& grail_touch = it->second;
78+ if (it->second.expired()) {
79+ ERASE_TOUCH(it->first, all_touches_);
80+ break;
81+ }
82+
83+ const SharedTouch& grail_touch = it->second.lock();
84
85 grail_touch->Update(touch);
86
87+ if (grail_touch->ended())
88+ ERASE_TOUCH(grail_touch->id(), all_touches_);
89+
90 if (grail_touch->pending_end() || grail_touch->ended())
91 ERASE_TOUCH(grail_touch->id(), free_touches_);
92 }
93
94=== modified file 'src/v3/regular-recognizer.h'
95--- src/v3/regular-recognizer.h 2012-03-27 15:46:44 +0000
96+++ src/v3/regular-recognizer.h 2012-04-03 18:13:20 +0000
97@@ -44,6 +44,8 @@
98 void MatchThreeTouchGestures(const SharedTouch& touch);
99 void MatchFourTouchGestures(const SharedTouch& touch);
100 void MatchFiveTouchGestures(const SharedTouch& touch);
101+
102+ std::map<UFTouchId, std::weak_ptr<Touch>> all_touches_;
103 };
104
105 } // namespace grail

Subscribers

People subscribed via source and target branches