From b801c31b0c27952612c63c2ef39673fb111fff23 Mon Sep 17 00:00:00 2001 From: Velimir Lisec Date: Thu, 30 Apr 2015 00:13:51 +0200 Subject: [PATCH 1/2] End the drag by tapping Currently for the tap-and-drag gesture to end user has to wait for a timeout to expire. Make it possible to end the drag gesture by just tapping. Signed-off-by: Velimir Lisec --- src/evdev-mt-touchpad-tap.c | 36 ++++++++++++++++++++++++++++++++++-- src/evdev-mt-touchpad.h | 1 + 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 9443adb..011abde 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -73,6 +73,7 @@ tap_state_to_str(enum tp_tap_state state) { CASE_RETURN_STRING(TAP_STATE_DRAGGING); CASE_RETURN_STRING(TAP_STATE_DRAGGING_WAIT); CASE_RETURN_STRING(TAP_STATE_DRAGGING_OR_DOUBLETAP); + CASE_RETURN_STRING(TAP_STATE_DRAGGING_OR_TAP); CASE_RETURN_STRING(TAP_STATE_DRAGGING_2); CASE_RETURN_STRING(TAP_STATE_MULTITAP); CASE_RETURN_STRING(TAP_STATE_MULTITAP_DOWN); @@ -402,8 +403,8 @@ tp_tap_dragging_wait_handle_event(struct tp_dispatch *tp, switch (event) { case TAP_EVENT_TOUCH: - tp->tap.state = TAP_STATE_DRAGGING; - tp_tap_clear_timer(tp); + tp->tap.state = TAP_STATE_DRAGGING_OR_TAP; + tp_tap_set_timer(tp, time); break; case TAP_EVENT_RELEASE: case TAP_EVENT_MOTION: @@ -420,6 +421,32 @@ tp_tap_dragging_wait_handle_event(struct tp_dispatch *tp, } static void +tp_tap_dragging_tap_handle_event(struct tp_dispatch *tp, + struct tp_touch *t, + enum tap_event event, uint64_t time) +{ + + switch (event) { + case TAP_EVENT_TOUCH: + tp->tap.state = TAP_STATE_DRAGGING_2; + tp_tap_clear_timer(tp); + break; + case TAP_EVENT_RELEASE: + tp->tap.state = TAP_STATE_IDLE; + tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED); + break; + case TAP_EVENT_MOTION: + case TAP_EVENT_TIMEOUT: + tp->tap.state = TAP_STATE_DRAGGING; + break; + case TAP_EVENT_BUTTON: + tp->tap.state = TAP_STATE_DEAD; + tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED); + break; + } +} + +static void tp_tap_dragging2_handle_event(struct tp_dispatch *tp, struct tp_touch *t, enum tap_event event, uint64_t time) @@ -582,6 +609,9 @@ tp_tap_handle_event(struct tp_dispatch *tp, case TAP_STATE_DRAGGING_WAIT: tp_tap_dragging_wait_handle_event(tp, t, event, time); break; + case TAP_STATE_DRAGGING_OR_TAP: + tp_tap_dragging_tap_handle_event(tp, t, event, time); + break; case TAP_STATE_DRAGGING_2: tp_tap_dragging2_handle_event(tp, t, event, time); break; @@ -688,6 +718,7 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time) case TAP_STATE_TOUCH: case TAP_STATE_TAPPED: case TAP_STATE_DRAGGING_OR_DOUBLETAP: + case TAP_STATE_DRAGGING_OR_TAP: case TAP_STATE_TOUCH_2: case TAP_STATE_TOUCH_3: case TAP_STATE_MULTITAP_DOWN: @@ -867,6 +898,7 @@ tp_tap_dragging(struct tp_dispatch *tp) case TAP_STATE_DRAGGING: case TAP_STATE_DRAGGING_2: case TAP_STATE_DRAGGING_WAIT: + case TAP_STATE_DRAGGING_OR_TAP: return true; default: return false; diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 97b17cd..98d3446 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -94,6 +94,7 @@ enum tp_tap_state { TAP_STATE_TOUCH_3, TAP_STATE_TOUCH_3_HOLD, TAP_STATE_DRAGGING_OR_DOUBLETAP, + TAP_STATE_DRAGGING_OR_TAP, TAP_STATE_DRAGGING, TAP_STATE_DRAGGING_WAIT, TAP_STATE_DRAGGING_2, -- 1.9.1