From 206a4bf441e98b02fa09fefceebffcde1b017793 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 13 Jul 2015 12:56:39 +1000 Subject: [PATCH 1/2] touchpad: make the edge-scroll edge 7mm wide Rather than magic percentages of the touchpad axis ranges, make it a fixed size of 7mm. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad-edge-scroll.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index aa9197f0..bb3890c1 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -285,30 +285,11 @@ int tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device) { struct tp_touch *t; - int width, height; int edge_width, edge_height; - width = device->abs.dimensions.x; - height = device->abs.dimensions.y; - - switch (tp->model) { - case MODEL_ALPS: - edge_width = width * .15; - edge_height = height * .15; - break; - case MODEL_APPLETOUCH: /* unibody are all clickpads, so N/A */ - edge_width = width * .085; - edge_height = height * .085; - break; - default: - /* For elantech and synaptics, note for lenovo #40 series, - * e.g. the T440s min/max are the absolute edges, not the - * recommended ones as usual with synaptics. - */ - edge_width = width * .04; - edge_height = height * .054; - break; - } + /* 7mm edge size */ + edge_width = device->abs.absinfo_x->resolution * 7; + edge_height = device->abs.absinfo_y->resolution * 7; tp->scroll.right_edge = device->abs.absinfo_x->maximum - edge_width; tp->scroll.bottom_edge = device->abs.absinfo_y->maximum - edge_height; From d3b9302187b207f3e71ef1865bfee65b06d03671 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 13 Jul 2015 14:14:42 +1000 Subject: [PATCH 2/2] touchpad: only edge-scroll while the finger is in the edge area 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 Reviewed-by: Hans de Goede --- 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 bb3890c1..928f6029 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -360,6 +360,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 0f6e46c6..1d0ce4d4 100644 --- a/test/touchpad.c +++ b/test/touchpad.c @@ -2098,6 +2098,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) { @@ -4385,6 +4410,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);