gestures: improve scroll responsiveness for vertically aligned touches
authorMatt Mayfield <mdmayfield@users.noreply.github.com>
Wed, 22 Aug 2018 02:12:33 +0000 (21:12 -0500)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 15 Jul 2019 03:08:47 +0000 (13:08 +1000)
Put some basic location checks in, if the fingers are next to each other and
vertically close, assume scroll over swipe.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>:
src/evdev-mt-touchpad-gestures.c
test/test-gestures.c

index d4133b5..12e00a3 100644 (file)
@@ -496,6 +496,17 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)
        if (first_mm < 1 && second_mm < 1)
                return GESTURE_STATE_UNKNOWN;
 
+       /* If both touches are within 7mm vertically and 40mm horizontally,
+        * assume scroll/swipe */
+       if (distance_mm.x < 40 && distance_mm.y < 7.0) {
+               if (tp->gesture.finger_count == 2) {
+                       tp_gesture_set_scroll_buildup(tp);
+                       return GESTURE_STATE_SCROLL;
+               } else if (tp->gesture.enabled) {
+                       return GESTURE_STATE_SWIPE;
+               }
+       }
+
        /* If one touch exceeds the outer threshold while the other has not
         * yet passed the inner threshold, this is not a valid gesture.
         * If thumb detection is enabled, and one of the touches is >20mm
index 76f80f3..ae2da79 100644 (file)
@@ -517,6 +517,17 @@ START_TEST(gestures_pinch)
                                            LIBINPUT_DEVICE_CAP_GESTURE))
                return;
 
+       /* If the device is too small to provide a finger spread wide enough
+        * to avoid the scroll bias, skip the test */
+       if (cardinal == E || cardinal == W) {
+               double w = 0, h = 0;
+               libinput_device_get_size(dev->libinput_device, &w, &h);
+               /* 0.6 because the code below gives us points like 20/y and
+                * 80/y. 45 because the threshold in the code is 40mm */
+               if (w * 0.6 < 45)
+                       return;
+       }
+
        dir_x = cardinals[cardinal][0];
        dir_y = cardinals[cardinal][1];
 
@@ -834,6 +845,17 @@ START_TEST(gestures_spread)
                                            LIBINPUT_DEVICE_CAP_GESTURE))
                return;
 
+       /* If the device is too small to provide a finger spread wide enough
+        * to avoid the scroll bias, skip the test */
+       if (cardinal == E || cardinal == W) {
+               double w = 0, h = 0;
+               libinput_device_get_size(dev->libinput_device, &w, &h);
+               /* 0.6 because the code below gives us points like 20/y and
+                * 80/y. 45 because the threshold in the code is 40mm */
+               if (w * 0.6 < 45)
+                       return;
+       }
+
        dir_x = cardinals[cardinal][0];
        dir_y = cardinals[cardinal][1];