[PATCH libinput 7/9] touchpad: save the active clickfinger button

Peter Hutterer peter.hutterer at who-t.net
Thu Mar 27 23:23:56 PDT 2014


To avoid having a button left press and a button right release if the number
of fingers changes.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev-mt-touchpad-buttons.c | 22 +++++++++++++---------
 src/evdev-mt-touchpad.h         |  1 +
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index 8946fc7..c3c97b0 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -75,23 +75,27 @@ tp_post_clickfinger_buttons(struct tp_dispatch *tp, uint32_t time)
 	if (current == old)
 		return 0;
 
-	switch (tp->nfingers_down) {
+	if (current) {
+		switch (tp->nfingers_down) {
 		case 1: button = BTN_LEFT; break;
 		case 2: button = BTN_RIGHT; break;
 		case 3: button = BTN_MIDDLE; break;
 		default:
 			return 0;
-	}
-
-	if (current)
+		}
+		tp->buttons.active = button;
 		state = LIBINPUT_POINTER_BUTTON_STATE_PRESSED;
-	else
+	} else {
+		button = tp->buttons.active;
+		tp->buttons.active = 0;
 		state = LIBINPUT_POINTER_BUTTON_STATE_RELEASED;
+	}
 
-	pointer_notify_button(&tp->device->base,
-			      time,
-			      button,
-			      state);
+	if (button)
+		pointer_notify_button(&tp->device->base,
+				      time,
+				      button,
+				      state);
 	return 1;
 }
 
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 0879776..1dee663 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -138,6 +138,7 @@ struct tp_dispatch {
 		uint32_t state;
 		uint32_t old_state;
 		uint32_t motion_dist;		/* for pinned touches */
+		unsigned int active;		/* currently active button, for release event */
 	} buttons;				/* physical buttons */
 
 	struct {
-- 
1.8.5.3



More information about the wayland-devel mailing list