[PATCH libinput v2 5/9] touchpad: Rewrite / fix tp_release_all_taps

Hans de Goede hdegoede at redhat.com
Sun Sep 28 04:21:04 PDT 2014


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 <hdegoede at redhat.com>
---
 src/evdev-mt-touchpad-tap.c | 14 +++++++++++++-
 src/evdev-mt-touchpad.h     |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index 8f055fc..3b10d6d 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,12 @@ 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 ef316f1..30bc2f6 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 {
-- 
2.1.0



More information about the wayland-devel mailing list