From 7dc2ea22edcb433634df77c0eb7ff9b303a0b4ce Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 28 Sep 2014 13:21:04 +0200 Subject: [PATCH] touchpad: Rewrite / fix tp_release_all_taps Before this commit tp_release_all_taps would call tp_tap_handle_timeout, which is a nop when in state DRAGGING. tp_clear_state then releases all touches and calls touchpad_handle_state which moves the state to DRAGGING_WAIT, and the button 1 release will only be done after the tap-timeout, rather then directly as it should on tp_clear_state. This commit fixes this by instead of calling tp_tap_handle_timeout, directly releasing pressed buttons and switching to state DEAD or IDLE depending on fingers_down. Besides fixing this issue, this rewrite also makes it possible to use tp_release_all_taps outside of tp_clear_state, which will be used to add tap suspend / resume functionality in a follow up commit. Signed-off-by: Hans de Goede Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad-tap.c | 15 ++++++++++++++- src/evdev-mt-touchpad.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 8f055fc1..b2894e08 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -113,6 +113,11 @@ tp_tap_notify(struct tp_dispatch *tp, return; } + if (state == LIBINPUT_BUTTON_STATE_PRESSED) + tp->tap.buttons_pressed |= (1 << nfingers); + else + tp->tap.buttons_pressed &= ~(1 << nfingers); + evdev_pointer_notify_button(tp->device, time, button, @@ -697,5 +702,13 @@ tp_destroy_tap(struct tp_dispatch *tp) void tp_release_all_taps(struct tp_dispatch *tp, uint64_t now) { - tp_tap_handle_timeout(now, tp); + int i; + + for (i = 1; i <= 3; i++) { + if (tp->tap.buttons_pressed & (1 << i)) + tp_tap_notify(tp, NULL, now, i, + LIBINPUT_BUTTON_STATE_RELEASED); + } + + tp->tap.state = tp->nfingers_down ? TAP_STATE_DEAD : TAP_STATE_IDLE; } diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index ef316f17..30bc2f6f 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -213,6 +213,7 @@ struct tp_dispatch { bool enabled; struct libinput_timer timer; enum tp_tap_state state; + uint32_t buttons_pressed; } tap; struct {