Mir

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

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 2817
Proposed branch: lp:~vanvugt/mir/fix-1480654
Merge into: lp:mir
Diff against target: 87 lines (+39/-15)
2 files modified
src/server/input/surface_input_dispatcher.cpp (+18/-15)
tests/unit-tests/input/test_surface_input_dispatcher.cpp (+21/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1480654
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Andreas Pokorny (community) Needs Information
Kevin DuBois (community) Approve
Review via email: mp+267009@code.launchpad.net

Commit message

Fix delayed shifting of touch focus when switching apps by gesture
(LP: #1480654).

If your shell (correctly) consumes finger-up events at the end of an
app switch gesture, or if you get none at all (LP: #1481570), then
the old window was still getting touch events even after it's no longer
visible. This branch ensures that the start of the next gesture always
goes to the new window immediately, and never accidentally to the
previous one (a regression introduced in r2652).

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

The code changes look plausible (and certainly address the usecase mentioned).

However, they make the code and comments disagree. (Cue rant on superfluous comments that restate the code.)

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm

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

hum I am unsure now. The other bugfix gave me the impression that we have to deal with multi-finger up events. Or with gesture-end events that for some reason contain more than one finger. But the logic inside this class still only reacts on pointer_count == 1?

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Alan: What comments disagree with what?

Andreas: Good observation. That's a pre-existing problem/feature I was thinking about addressing separately. It appears racarr has designed a lot of the newer input logic with the Android input semantics only in mind. That is he assumes that N-fingers down happens in N separate events (one per finger). That might be true for Android input right now, but it's an assumption we're going to have to polish out later. I could have started on it here, but it's not directly related to the bug fix and other locations need the same fix. So do it separately.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Before anyone asks, I possibly don't expect this to be the only fix required to fully resolve LP: #1480654. It seems likely other fixes in QtMir/Unity/etc may be required. I will do full stack testing today to confirm. Although the outcome of that testing does not change the need for this Mir fix.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

On Thursday, 6 August 2015 04:08:48 BST, Daniel van Vugt wrote:
> Alan: What comments disagree with what?

The comments describing "owner vs non-owner" logic and the code with new
gesture vs owner vs non-owner logic.

--
Sent using Dekko from my Ubuntu device

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I still don't see what comment is wrong or misleading. Can you point it out?

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> I still don't see what comment is wrong or misleading. Can you point it out?

    "// Either we have a gesture owner or a gesture is just beginning"

This is obsolete: the code now first identifies a new gesture before even considering a gesture owner.

    "// In this case where there is no gesture owner"...

Refers to code that executes with (and without) a gesture owner.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Oh, you're talking about one comment not shown in the diff, and another comment I have not touched at all. I think only the second one needs updating but am happy to fix both.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

It isn't about whether the comments appear in the diff: You changed the logic the comments describe.

28 + // We will only deliver events if they signify the start of a new

is still a bit misleading - we also deliver events (a few lines later) if there's a gesture owner.

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

That's true, but when read in the full context of the file it's more clear that comment refers to the block of code below it (not shown in the diff). Admittedly, yes, it's not totally correct to say that for the overall function.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Yeah, it's mostly the word "only" that misleads.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/input/surface_input_dispatcher.cpp'
2--- src/server/input/surface_input_dispatcher.cpp 2015-07-23 02:39:20 +0000
3+++ src/server/input/surface_input_dispatcher.cpp 2015-08-06 09:05:17 +0000
4@@ -310,26 +310,18 @@
5 bool mi::SurfaceInputDispatcher::dispatch_touch(MirInputDeviceId id, MirTouchEvent const* tev)
6 {
7 std::lock_guard<std::mutex> lg(dispatcher_mutex);
8- // Either we have a gesture owner or a gesture is just beginning
9
10 auto point_count = mir_touch_event_point_count(tev);
11
12 auto& touch_state = ensure_touch_state(id);
13- if (touch_state.gesture_owner)
14- {
15- deliver(touch_state.gesture_owner, tev);
16- if (point_count == 1 && mir_touch_event_action(tev, 0) == mir_touch_action_up)
17- {
18- // Last touch is coming up. Gesture is over.
19- touch_state.gesture_owner = nullptr;
20- }
21- return true;
22- }
23
24- // In this case where there is no gesture owner we will only deliver events if they signify the start of a new
25- // gesture (as detected by this conditional). This prevents gesture ownership from transfering in the event
26- // a gesture receiver closes mid gesture (e.g. when a surface closes mid swipe we do not want the surface under
27- // to receive events).
28+ // We will only deliver events if they signify the start of a new
29+ // gesture (as detected by this conditional). This prevents gesture
30+ // ownership from transfering in the event a gesture receiver closes mid
31+ // gesture (e.g. when a surface closes mid swipe we do not want the
32+ // surface under to receive events). This also allows a gesture to continue
33+ // outside of the target surface, providing it started in the target
34+ // surface.
35 if (point_count == 1 && mir_touch_event_action(tev, 0) == mir_touch_action_down)
36 {
37 geom::Point event_x_y = { mir_touch_event_axis_value(tev, 0, mir_touch_axis_x),
38@@ -343,6 +335,17 @@
39 return true;
40 }
41 }
42+
43+ if (touch_state.gesture_owner)
44+ {
45+ deliver(touch_state.gesture_owner, tev);
46+ if (point_count == 1 && mir_touch_event_action(tev, 0) == mir_touch_action_up)
47+ {
48+ // Last touch is coming up. Gesture is over.
49+ touch_state.gesture_owner = nullptr;
50+ }
51+ return true;
52+ }
53
54 return false;
55 }
56
57=== modified file 'tests/unit-tests/input/test_surface_input_dispatcher.cpp'
58--- tests/unit-tests/input/test_surface_input_dispatcher.cpp 2015-06-25 03:00:08 +0000
59+++ tests/unit-tests/input/test_surface_input_dispatcher.cpp 2015-08-06 09:05:17 +0000
60@@ -603,6 +603,27 @@
61 EXPECT_TRUE(dispatcher.dispatch(*toucher.release_at({2, 2})));
62 }
63
64+TEST_F(SurfaceInputDispatcher, touch_target_switches_on_finger_down)
65+{ // Regression test for LP: #1480654
66+ using namespace ::testing;
67+
68+ auto left_surface = scene.add_surface({{0, 0}, {1, 1}});
69+ auto right_surface = scene.add_surface({{5, 5}, {1, 1}});
70+
71+ InSequence seq;
72+
73+ EXPECT_CALL(*left_surface, consume(_)).Times(1);
74+ // Note: No TouchUpEvent expected
75+ EXPECT_CALL(*right_surface, consume(_)).Times(1);
76+
77+ dispatcher.start();
78+
79+ FakeToucher toucher;
80+ EXPECT_TRUE(dispatcher.dispatch(*toucher.touch_at({0, 0})));
81+ // Note: No touch release event produced
82+ EXPECT_TRUE(dispatcher.dispatch(*toucher.touch_at({5, 5})));
83+}
84+
85 TEST_F(SurfaceInputDispatcher, touch_gestures_terminated_by_device_reset)
86 {
87 using namespace ::testing;

Subscribers

People subscribed via source and target branches