Scrolling is much more common than a 2fg spread gesture, so if the finger
position indicates that the fingers are next to each other, switch to
scrolling immediately.

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

Signed-off-by: Peter Hutterer <[email protected]>
---
 src/evdev-mt-touchpad-gestures.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
index dc8d606..a9d7fa1 100644
--- a/src/evdev-mt-touchpad-gestures.c
+++ b/src/evdev-mt-touchpad-gestures.c
@@ -325,8 +325,9 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, 
uint64_t time)
        struct tp_touch *first = tp->gesture.touches[0],
                        *second = tp->gesture.touches[1];
        int dir1, dir2;
-       int yres = tp->device->abs.absinfo_y->resolution;
-       int vert_distance;
+       int yres = tp->device->abs.absinfo_y->resolution,
+           xres = tp->device->abs.absinfo_x->resolution;
+       int vert_distance, horiz_distance;
 
        /* for two-finger gestures, if the fingers stay unmoving for a
         * while, assume (slow) scroll */
@@ -338,10 +339,16 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, 
uint64_t time)
 
        /* Else check if one finger is > 20mm below the others */
        vert_distance = abs(first->point.y - second->point.y);
+       horiz_distance = abs(first->point.x - second->point.x);
        if (vert_distance > 20 * yres &&
            tp->gesture.enabled) {
                tp_gesture_init_pinch(tp);
                return GESTURE_STATE_PINCH;
+       /* Else if the fingers are within 20x5mm of each other */
+       } else if (vert_distance < 5 * yres &&
+                  horiz_distance < 20 * xres) {
+               tp_gesture_set_scroll_buildup(tp);
+               return GESTURE_STATE_SCROLL;
        }
 
        /* Else wait for both fingers to have moved */
-- 
2.5.0

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to