From 9956857ecfaa3c37733f725d56dc8bb2a8fe9a1a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 29 Apr 2015 11:40:40 +1000 Subject: [PATCH libinput 1/2] touchpad: add separate, shorter timeout for doubletap Initial tap timeout is 180ms, that's the time from finger down until the finger is released and set down again. For a doubletap, reduce the timeout to 100ms for the second tap to provide a more responsive gesture and reduce the chance of exceeding the caller's double-click timeouts. Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad-tap.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 24f2ac6..d09d788 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -37,6 +37,7 @@ #define CASE_RETURN_STRING(a) case a: return #a #define DEFAULT_TAP_TIMEOUT_PERIOD 180 +#define DEFAULT_DOUBLETAP_TIMEOUT_PERIOD 100 #define DEFAULT_TAP_MOVE_THRESHOLD TP_MM_TO_DPI_NORMALIZED(3) enum tap_event { @@ -129,6 +130,13 @@ tp_tap_set_timer(struct tp_dispatch *tp, uint64_t time) } static void +tp_tap_set_doubletap_timer(struct tp_dispatch *tp, uint64_t time) +{ + libinput_timer_set(&tp->tap.timer, + time + DEFAULT_DOUBLETAP_TIMEOUT_PERIOD); +} + +static void tp_tap_clear_timer(struct tp_dispatch *tp) { libinput_timer_cancel(&tp->tap.timer); @@ -224,7 +232,7 @@ tp_tap_tapped_handle_event(struct tp_dispatch *tp, break; case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_DRAGGING_OR_DOUBLETAP; - tp_tap_set_timer(tp, time); + tp_tap_set_doubletap_timer(tp, time); break; case TAP_EVENT_TIMEOUT: tp->tap.state = TAP_STATE_IDLE; -- 2.3.5