[PATCH] touchpad: Make sure we don't underflow tap_finger_count

Rui Matos tiagomatos at gmail.com
Wed Apr 29 10:18:55 PDT 2015

If a touch begins before tap gets enabled we underflow
tap_finger_count when the touch ends.

This happens in practice when enabling tapping on a GUI with a
touchpad click.

Signed-off-by: Rui Matos <tiagomatos at gmail.com>

This patch seems enough to fix the issue in my testing but I'm not
familiar with the state machine so it might not be the best solution.

 src/evdev-mt-touchpad-tap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index 0f25e26..0feff70 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -659,7 +659,8 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
 				tp_tap_handle_event(tp, t, TAP_EVENT_MOTION, time);
 		} else if (t->state == TOUCH_END) {
-			tp->tap.tap_finger_count--;
+			if (tp->tap.tap_finger_count > 0)
+				tp->tap.tap_finger_count--;
 			tp_tap_handle_event(tp, t, TAP_EVENT_RELEASE, time);
 			t->tap.state = TAP_TOUCH_STATE_IDLE;
 		} else if (tp->tap.state != TAP_STATE_IDLE &&

More information about the wayland-devel mailing list