[PATCH libinput 2/2] touchpad: only edge-scroll while the finger is in the edge area

Peter Hutterer peter.hutterer at who-t.net
Mon Jul 13 20:41:30 PDT 2015


When the touch leaves the area for edge scrolling after starting to scroll,
discard any movement. This signals to the user that they've left the area and
forces them to lift the finger to switch back to motion. If the finger moves
back into the area, scrolling continues.

https://bugs.freedesktop.org/show_bug.cgi?id=91323

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev-mt-touchpad-edge-scroll.c |  5 +++++
 test/touchpad.c                     | 26 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c
index 96fbca6..1b40693 100644
--- a/src/evdev-mt-touchpad-edge-scroll.c
+++ b/src/evdev-mt-touchpad-edge-scroll.c
@@ -362,6 +362,11 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
 		if (t->palm.state != PALM_NONE)
 			continue;
 
+		/* only scroll with the finger in the previous edge */
+		if (t->scroll.edge &&
+		    (tp_touch_get_edge(tp, t) & t->scroll.edge) == 0)
+			continue;
+
 		switch (t->scroll.edge) {
 			case EDGE_NONE:
 				if (t->scroll.direction != -1) {
diff --git a/test/touchpad.c b/test/touchpad.c
index 78c084e..d22108e 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -1914,6 +1914,31 @@ START_TEST(touchpad_edge_scroll_clickfinger_click_stops_scroll)
 }
 END_TEST
 
+START_TEST(touchpad_edge_scroll_into_area)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput *li = dev->libinput;
+
+	enable_edge_scroll(dev);
+	litest_drain_events(li);
+
+	/* move into area, move vertically, move back to edge */
+
+	litest_touch_down(dev, 0, 99, 20);
+	litest_touch_move_to(dev, 0, 99, 20, 99, 50, 10, 2);
+	litest_touch_move_to(dev, 0, 99, 50, 20, 50, 10, 2);
+	litest_assert_only_typed_events(li,
+					LIBINPUT_EVENT_POINTER_AXIS);
+	litest_touch_move_to(dev, 0, 20, 50, 20, 20, 10, 2);
+	litest_touch_move_to(dev, 0, 20, 20, 99, 20, 10, 2);
+	litest_assert_empty_queue(li);
+
+	litest_touch_move_to(dev, 0, 99, 20, 99, 50, 10, 2);
+	litest_assert_only_typed_events(li,
+					LIBINPUT_EVENT_POINTER_AXIS);
+}
+END_TEST
+
 static int
 touchpad_has_palm_detect_size(struct litest_device *dev)
 {
@@ -4189,6 +4214,7 @@ litest_setup_tests(void)
 	litest_add("touchpad:scroll", touchpad_edge_scroll_within_buttonareas, LITEST_CLICKPAD, LITEST_ANY);
 	litest_add("touchpad:scroll", touchpad_edge_scroll_buttonareas_click_stops_scroll, LITEST_CLICKPAD, LITEST_ANY);
 	litest_add("touchpad:scroll", touchpad_edge_scroll_clickfinger_click_stops_scroll, LITEST_CLICKPAD, LITEST_ANY);
+	litest_add("touchpad:scroll", touchpad_edge_scroll_into_area, LITEST_TOUCHPAD, LITEST_ANY);
 
 	litest_add("touchpad:palm", touchpad_palm_detect_at_edge, LITEST_TOUCHPAD, LITEST_ANY);
 	litest_add("touchpad:palm", touchpad_palm_detect_at_bottom_corners, LITEST_TOUCHPAD, LITEST_CLICKPAD);
-- 
2.4.3



More information about the wayland-devel mailing list