gestures: fix disambiguation between two finger pinch and scroll
authorJosé Expósito <jose.exposito89@gmail.com>
Mon, 24 Jan 2022 17:55:20 +0000 (18:55 +0100)
committerJosé Expósito <jose.exposito89@gmail.com>
Thu, 27 Jan 2022 07:35:30 +0000 (08:35 +0100)
The changes introduced in b5b6f835af2e99b6a4e64fb0174ab551ed141763 to
add support for hold gestures introduced a regression:

The mechanism that was in place to improve the disambiguation between
two finger pinch and scroll during the beginning of the gesture stopped
working and instead a bug warning was printed on the log.

Fix the regression by allowing to go from the scroll state to the pinch
state.

Fix #726

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
src/evdev-mt-touchpad-gestures.c

index bf25942..08c9361 100644 (file)
@@ -734,13 +734,17 @@ tp_gesture_handle_event_on_state_scroll(struct tp_dispatch *tp,
                libinput_timer_cancel(&tp->gesture.hold_timer);
                tp->gesture.state = GESTURE_STATE_NONE;
                break;
+       case GESTURE_EVENT_PINCH:
+               tp_gesture_init_pinch(tp);
+               tp_gesture_cancel(tp, time);
+               tp->gesture.state = GESTURE_STATE_PINCH;
+               break;
        case GESTURE_EVENT_HOLD_AND_MOTION:
        case GESTURE_EVENT_FINGER_DETECTED:
        case GESTURE_EVENT_HOLD_TIMEOUT:
        case GESTURE_EVENT_POINTER_MOTION:
        case GESTURE_EVENT_SCROLL:
        case GESTURE_EVENT_SWIPE:
-       case GESTURE_EVENT_PINCH:
                log_gesture_bug(tp, event);
                break;
        }
@@ -1166,7 +1170,6 @@ tp_gesture_handle_state_scroll(struct tp_dispatch *tp, uint64_t time)
         */
        if (time < (tp->gesture.initial_time + DEFAULT_GESTURE_PINCH_TIMEOUT) &&
            tp_gesture_is_pinch(tp)) {
-               tp_gesture_cancel(tp, time);
                tp_gesture_handle_event(tp, GESTURE_EVENT_PINCH, time);
                return;
        }