Mir

Merge lp:~vanvugt/mir/fix-1481570 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Kevin DuBois
Approved revision: no longer in the source branch.
Merged at revision: 2815
Proposed branch: lp:~vanvugt/mir/fix-1481570
Merge into: lp:mir
Diff against target: 82 lines (+59/-2)
2 files modified
src/server/input/android/input_translator.cpp (+10/-2)
tests/unit-tests/input/android/test_input_translator.cpp (+49/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1481570
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve
Andreas Pokorny (community) Approve
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+267000@code.launchpad.net

Commit message

Fix incorrect detection of end-of-gesture (AMOTION_EVENT_ACTION_UP).
Since this regression was introduced in r2591 Mir would often not
report the end of a multi-finger gesture, ending with just
mir_touch_action_change instead of mir_touch_action_up.
(LP: #1481570)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I don't know this input stack well enough to confirm the logic, but looks OK

review: Approve
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

That should not happen with the old android event structures, since those allowed only a single finger up or down per event... But I guess we no longer have that restriction. So the change of the logic looks good.

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/input/android/input_translator.cpp'
2--- src/server/input/android/input_translator.cpp 2015-07-23 02:39:20 +0000
3+++ src/server/input/android/input_translator.cpp 2015-08-05 07:55:44 +0000
4@@ -139,8 +139,16 @@
5 auto masked_action = action & AMOTION_EVENT_ACTION_MASK;
6 for (unsigned i = 0; i < args->pointerCount; i++)
7 {
8- auto action = (i == index_with_action) ? mia::mir_touch_action_from_masked_android(masked_action) :
9- mir_touch_action_change;
10+ MirTouchAction action;
11+ if (masked_action == AMOTION_EVENT_ACTION_UP)
12+ action = mir_touch_action_up; // irrespective of index
13+ else if (masked_action == AMOTION_EVENT_ACTION_DOWN)
14+ action = mir_touch_action_down; // irrespective of index
15+ else if (i == index_with_action)
16+ action = mir_touch_action_from_masked_android(masked_action);
17+ else
18+ action = mir_touch_action_change;
19+
20 mev::add_touch(*mir_event, args->pointerProperties[i].id, action,
21 mia::mir_tool_type_from_android(args->pointerProperties[i].toolType),
22 args->pointerCoords[i].getX(),
23
24=== modified file 'tests/unit-tests/input/android/test_input_translator.cpp'
25--- tests/unit-tests/input/android/test_input_translator.cpp 2015-07-23 02:39:20 +0000
26+++ tests/unit-tests/input/android/test_input_translator.cpp 2015-08-05 07:55:44 +0000
27@@ -125,6 +125,55 @@
28 translator.notifyMotion(&motion);
29 }
30
31+MATCHER(EndOfTouchGesture, "")
32+{
33+ MirEvent const& ev = arg;
34+ if (mir_event_get_type(&ev) != mir_event_type_input)
35+ return false;
36+
37+ auto iev = mir_event_get_input_event(&ev);
38+ if (mir_input_event_get_type(iev) != mir_input_event_type_touch)
39+ return false;
40+
41+ auto tev = mir_input_event_get_touch_event(iev);
42+ if (mir_touch_event_point_count(tev) < 1)
43+ return false;
44+
45+ return mir_touch_event_action(tev, 0) == mir_touch_action_up;
46+}
47+
48+TEST_F(InputTranslator, translates_multifinger_release_correctly)
49+{ // Regression test for LP: #1481570
50+ using namespace ::testing;
51+
52+ EXPECT_CALL(dispatcher, dispatch(EndOfTouchGesture()))
53+ .Times(1);
54+
55+ /*
56+ * Android often provides old indices on AMOTION_EVENT_ACTION_UP.
57+ * But that doesn't matter at all because AMOTION_EVENT_ACTION_UP means
58+ * that all fingers were released. (LP: #1481570).
59+ */
60+ int32_t const invalid_id = 7;
61+ int32_t const end_of_gesture = AMOTION_EVENT_ACTION_UP
62+ | (invalid_id << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
63+
64+ /*
65+ * A multifinger test with only one finger? Yep, that's right. That's
66+ * what we see in production. A dummy single finger event used to indicate
67+ * all fingers (regardless of number) were released.
68+ */
69+ properties[0].id = 1;
70+ properties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
71+
72+ droidinput::NotifyMotionArgs motion(
73+ some_time, device_id, source_id, 0, end_of_gesture,
74+ no_flags, meta_state, button_state, edge_flags, 1, properties,
75+ coords, x_precision, y_precision, later_time);
76+
77+ translator.notifyMotion(&motion);
78+}
79+
80 TEST_F(InputTranslator, ignores_motion_with_duplicated_pointerids)
81 {
82 using namespace ::testing;

Subscribers

People subscribed via source and target branches