From 86bd9bad66cb63ac957a3fe363ac718c7c1a060f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 15 Feb 2016 17:02:45 +1000 Subject: [PATCH] touchpad: move the tapping exclusion zone to the top edge of the button We previously used the half-way mark of the touchpad's y axis to decide where to ignore tapping. Move this down to the top edge of the software buttons instead. Users may tap with a finger in the software button areas, on the rest of the touchpad it's unlikely that they tap within 5% of the edge. On touchpads with physical buttons or if clickfinger is enabled, the no-tapping zone extends to the bottom of the touchpad. This required splitting the tests into clickfinger, softbuttons and hardbuttons. https://bugs.freedesktop.org/show_bug.cgi?id=93947 Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede (cherry picked from commit 79139ebcd1cc81eecdd2d0dc6f006fbec4c2c6f2) --- src/evdev-mt-touchpad.c | 11 +++---- src/evdev-mt-touchpad.h | 1 - test/touchpad.c | 72 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 72 insertions(+), 12 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index d921936f..321ae822 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -530,9 +530,9 @@ tp_palm_tap_is_palm(struct tp_dispatch *tp, struct tp_touch *t) t->point.x < tp->palm.right_edge) return false; - /* We're inside the left/right palm edge and in the northern half of - * the touchpad - this tap is a palm */ - if (t->point.y < tp->palm.vert_center) { + /* We're inside the left/right palm edge and not in one of the + * software button areas */ + if (t->point.y < tp->buttons.bottom_area.top_edge) { log_debug(tp_libinput_context(tp), "palm: palm-tap detected\n"); return true; @@ -1812,14 +1812,12 @@ static int tp_init_palmdetect(struct tp_dispatch *tp, struct evdev_device *device) { - int width, height; + int width; tp->palm.right_edge = INT_MAX; tp->palm.left_edge = INT_MIN; - tp->palm.vert_center = INT_MIN; width = device->abs.dimensions.x; - height = device->abs.dimensions.y; /* Wacom doesn't have internal touchpads, * Apple touchpads are always big enough to warrant palm detection */ @@ -1834,7 +1832,6 @@ tp_init_palmdetect(struct tp_dispatch *tp, /* palm edges are 5% of the width on each side */ tp->palm.right_edge = device->abs.absinfo_x->maximum - width * 0.05; tp->palm.left_edge = device->abs.absinfo_x->minimum + width * 0.05; - tp->palm.vert_center = device->abs.absinfo_y->minimum + height/2; tp->palm.monitor_trackpoint = true; diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index a1a22919..1cd12c1a 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -320,7 +320,6 @@ struct tp_dispatch { struct { int32_t right_edge; /* in device coordinates */ int32_t left_edge; /* in device coordinates */ - int32_t vert_center; /* in device coordinates */ bool trackpoint_active; struct libinput_event_listener trackpoint_listener; diff --git a/test/touchpad.c b/test/touchpad.c index 7ff3a96d..a1b3355c 100644 --- a/test/touchpad.c +++ b/test/touchpad.c @@ -1031,7 +1031,7 @@ START_TEST(touchpad_palm_detect_no_palm_moving_into_edges) } END_TEST -START_TEST(touchpad_palm_detect_tap) +START_TEST(touchpad_palm_detect_tap_hardbuttons) { struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; @@ -1051,7 +1051,38 @@ START_TEST(touchpad_palm_detect_tap) litest_touch_up(dev, 0); litest_assert_empty_queue(li); - litest_touch_down(dev, 0, 5, 90); + litest_touch_down(dev, 0, 5, 99); + litest_touch_up(dev, 0); + litest_assert_empty_queue(li); + + litest_touch_down(dev, 0, 95, 99); + litest_touch_up(dev, 0); + litest_assert_empty_queue(li); +} +END_TEST + +START_TEST(touchpad_palm_detect_tap_softbuttons) +{ + struct litest_device *dev = litest_current_device(); + struct libinput *li = dev->libinput; + + if (!touchpad_has_palm_detect_size(dev)) + return; + + litest_enable_tap(dev->libinput_device); + litest_enable_buttonareas(dev); + + litest_drain_events(li); + + litest_touch_down(dev, 0, 95, 5); + litest_touch_up(dev, 0); + litest_assert_empty_queue(li); + + litest_touch_down(dev, 0, 5, 5); + litest_touch_up(dev, 0); + litest_assert_empty_queue(li); + + litest_touch_down(dev, 0, 5, 99); litest_touch_up(dev, 0); litest_assert_button_event(li, BTN_LEFT, @@ -1061,7 +1092,7 @@ START_TEST(touchpad_palm_detect_tap) LIBINPUT_BUTTON_STATE_RELEASED); litest_assert_empty_queue(li); - litest_touch_down(dev, 0, 95, 90); + litest_touch_down(dev, 0, 95, 99); litest_touch_up(dev, 0); litest_assert_button_event(li, BTN_LEFT, @@ -1073,6 +1104,37 @@ START_TEST(touchpad_palm_detect_tap) } END_TEST +START_TEST(touchpad_palm_detect_tap_clickfinger) +{ + struct litest_device *dev = litest_current_device(); + struct libinput *li = dev->libinput; + + if (!touchpad_has_palm_detect_size(dev)) + return; + + litest_enable_tap(dev->libinput_device); + litest_enable_clickfinger(dev); + + litest_drain_events(li); + + litest_touch_down(dev, 0, 95, 5); + litest_touch_up(dev, 0); + litest_assert_empty_queue(li); + + litest_touch_down(dev, 0, 5, 5); + litest_touch_up(dev, 0); + litest_assert_empty_queue(li); + + litest_touch_down(dev, 0, 5, 99); + litest_touch_up(dev, 0); + litest_assert_empty_queue(li); + + litest_touch_down(dev, 0, 95, 99); + litest_touch_up(dev, 0); + litest_assert_empty_queue(li); +} +END_TEST + START_TEST(touchpad_left_handed) { struct litest_device *dev = litest_current_device(); @@ -3933,7 +3995,9 @@ litest_setup_tests(void) litest_add("touchpad:palm", touchpad_palm_detect_palm_becomes_pointer, LITEST_TOUCHPAD, LITEST_ANY); litest_add("touchpad:palm", touchpad_palm_detect_palm_stays_palm, LITEST_TOUCHPAD, LITEST_ANY); litest_add("touchpad:palm", touchpad_palm_detect_no_palm_moving_into_edges, LITEST_TOUCHPAD, LITEST_ANY); - litest_add("touchpad:palm", touchpad_palm_detect_tap, LITEST_TOUCHPAD, LITEST_ANY); + litest_add("touchpad:palm", touchpad_palm_detect_tap_hardbuttons, LITEST_TOUCHPAD, LITEST_CLICKPAD); + litest_add("touchpad:palm", touchpad_palm_detect_tap_softbuttons, LITEST_CLICKPAD, LITEST_ANY); + litest_add("touchpad:palm", touchpad_palm_detect_tap_clickfinger, LITEST_CLICKPAD, LITEST_ANY); litest_add("touchpad:palm", touchpad_no_palm_detect_at_edge_for_edge_scrolling, LITEST_TOUCHPAD, LITEST_CLICKPAD); litest_add("touchpad:left-handed", touchpad_left_handed, LITEST_TOUCHPAD|LITEST_BUTTON, LITEST_CLICKPAD);