touchpad: don't enable top palm detection on touchpads <= 55mm high
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 12 Mar 2018 23:33:57 +0000 (09:33 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 9 Apr 2018 01:23:38 +0000 (11:23 +1000)
Tiny enough as it is, let's not take usable space away.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit d786b55daa99c6f891da05ec91617eccdc843333)

src/evdev-mt-touchpad.c
test/test-touchpad.c

index c803b1dc554eb665fa81968622073c3ddde30e94..d6e1e4f97806c13156b345765b17dc128e74d60d 100644 (file)
@@ -2786,7 +2786,7 @@ tp_init_palmdetect_edge(struct tp_dispatch *tp,
        edges = evdev_device_mm_to_units(device, &mm);
        tp->palm.right_edge = edges.x;
 
-       if (!tp->buttons.has_topbuttons) {
+       if (!tp->buttons.has_topbuttons && height > 55) {
                /* top edge is 5% of the height */
                mm.y = height * 0.05;
                edges = evdev_device_mm_to_units(device, &mm);
index 427fc13ccb46ce124580010d7e8258c415d270f2..4759bfb68c67e308bbd7700c54862c5b81950b3c 100644 (file)
@@ -953,7 +953,7 @@ START_TEST(touchpad_edge_scroll_into_area)
 }
 END_TEST
 
-static int
+static bool
 touchpad_has_palm_detect_size(struct litest_device *dev)
 {
        double width, height;
@@ -975,6 +975,20 @@ touchpad_has_palm_detect_size(struct litest_device *dev)
        return rc == 0 && width >= 70;
 }
 
+static bool
+touchpad_has_top_palm_detect_size(struct litest_device *dev)
+{
+       double width, height;
+       int rc;
+
+       if (!touchpad_has_palm_detect_size(dev))
+               return false;
+
+       rc = libinput_device_get_size(dev->libinput_device, &width, &height);
+
+       return rc == 0 && height > 55;
+}
+
 START_TEST(touchpad_palm_detect_at_edge)
 {
        struct litest_device *dev = litest_current_device();
@@ -1009,7 +1023,7 @@ START_TEST(touchpad_palm_detect_at_top)
        struct litest_device *dev = litest_current_device();
        struct libinput *li = dev->libinput;
 
-       if (!touchpad_has_palm_detect_size(dev))
+       if (!touchpad_has_top_palm_detect_size(dev))
                return;
 
        litest_disable_tap(dev->libinput_device);
@@ -1131,7 +1145,7 @@ START_TEST(touchpad_palm_detect_top_palm_stays_palm)
        struct litest_device *dev = litest_current_device();
        struct libinput *li = dev->libinput;
 
-       if (!touchpad_has_palm_detect_size(dev))
+       if (!touchpad_has_top_palm_detect_size(dev))
                return;
 
        litest_disable_tap(dev->libinput_device);
@@ -1178,7 +1192,7 @@ START_TEST(touchpad_palm_detect_top_palm_becomes_pointer)
        struct litest_device *dev = litest_current_device();
        struct libinput *li = dev->libinput;
 
-       if (!touchpad_has_palm_detect_size(dev))
+       if (!touchpad_has_top_palm_detect_size(dev))
                return;
 
        litest_disable_tap(dev->libinput_device);
@@ -1231,7 +1245,7 @@ START_TEST(touchpad_palm_detect_no_palm_moving_into_top)
        struct litest_device *dev = litest_current_device();
        struct libinput *li = dev->libinput;
 
-       if (!touchpad_has_palm_detect_size(dev))
+       if (!touchpad_has_top_palm_detect_size(dev))
                return;
 
        litest_disable_tap(dev->libinput_device);
@@ -1260,7 +1274,7 @@ START_TEST(touchpad_palm_detect_no_tap_top_edge)
        struct litest_device *dev = litest_current_device();
        struct libinput *li = dev->libinput;
 
-       if (!touchpad_has_palm_detect_size(dev))
+       if (!touchpad_has_top_palm_detect_size(dev))
                return;
 
        litest_enable_tap(dev->libinput_device);