diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index aa9197f0..928f6029 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; @@ -379,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 cae85e9e..f9cdbdec 100644 --- a/test/touchpad.c +++ b/test/touchpad.c @@ -2105,6 +2105,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) { @@ -4506,6 +4531,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);