[PATCH libinput v2 6/9] touchpad: Add tap suspend / resume

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


While e.g. disabling the touchpad while the trackpoint is used, we want to
stop sending tap (or scroll or motion) events. We cannot use tp_clear_state at
this time as that will also release any touchpad buttons pressed, breaking
dragging with the trackpoint using the touchpad or clickpad buttons.

Calling tp_release_all_taps() and then ensuring that we do not call
tp_tap_handle_state as long as the trackpoint is in use, is enough to disable
taps when the trackpoint is in use.

However when the trackpoint stops being used, we cannot simply start calling
tp_tap_handle_state() again, we first need to sync the tap.state to the current
reality, specifically if fingers are down it must be TAP_STATE_DEAD, so that
their releases do not trigger the log_bug_libinput on a release in
tp_tap_idle_handle_event.

Directly messing with tap.state from outside evdev-mt-touchpad-tap.c is not
good, so add tp_tap_suspend and tp_tap_resume functions for this.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/evdev-mt-touchpad-tap.c | 18 ++++++++++++++++++
 src/evdev-mt-touchpad.h     |  7 +++++++
 2 files changed, 25 insertions(+)

diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index 3b10d6d..61c0139 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -546,6 +546,9 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
 	struct tp_touch *t;
 	int filter_motion = 0;
 
+	if (tp->tap.suspended)
+		return 0;
+
 	/* Handle queued button pressed events from clickpads. For touchpads
 	 * with separate physical buttons, ignore button pressed events so they
 	 * don't interfere with tapping. */
@@ -711,3 +714,18 @@ tp_release_all_taps(struct tp_dispatch *tp, uint64_t now)
 
 	tp->tap.state = tp->nfingers_down ? TAP_STATE_DEAD : TAP_STATE_IDLE;
 }
+
+void
+tp_tap_suspend(struct tp_dispatch *tp, uint64_t time)
+{
+	tp->tap.suspended = true;
+	tp_release_all_taps(tp, time);
+}
+
+void
+tp_tap_resume(struct tp_dispatch *tp, uint64_t time)
+{
+	tp->tap.suspended = false;
+	/* Must restart in DEAD if fingers are down atm */
+	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 30bc2f6..cc04dc9 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -211,6 +211,7 @@ struct tp_dispatch {
 	struct {
 		struct libinput_device_config_tap config;
 		bool enabled;
+		bool suspended;
 		struct libinput_timer timer;
 		enum tp_tap_state state;
 		uint32_t buttons_pressed;
@@ -281,4 +282,10 @@ void
 tp_release_all_taps(struct tp_dispatch *tp,
 		    uint64_t time);
 
+void
+tp_tap_suspend(struct tp_dispatch *tp, uint64_t time);
+
+void
+tp_tap_resume(struct tp_dispatch *tp, uint64_t time);
+
 #endif
-- 
2.1.0



More information about the wayland-devel mailing list