[PATCH libinput 7/8] touchpad: When disabling a TOPBUTTONPAD, leave the top buttons enabled

Hans de Goede hdegoede at redhat.com
Tue Sep 16 07:22:41 PDT 2014


On a TOPBUTTONPAD, we can't disable the touchpad altogether - the trackstick
relies on the touchpad's top software buttons.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/evdev-mt-touchpad-buttons.c |  4 ++++
 src/evdev-mt-touchpad.c         | 25 +++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index 0fdabde..865346b 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -695,6 +695,10 @@ tp_notify_softbutton(struct tp_dispatch *tp,
 		return;
 	}
 
+	/* Ignore button events not for the trackpoint while suspended */
+	if (tp->device->suspended)
+		return;
+
 	evdev_pointer_notify_button(tp->device, time, button, state);
 }
 
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index edd1f97..9e568ad 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -523,6 +523,12 @@ tp_post_events(struct tp_dispatch *tp, uint64_t time)
 	double dx, dy;
 	int consumed = 0;
 
+	/* Only post (top) button events while suspended */
+	if (tp->device->suspended) {
+		tp_post_button_events(tp, time);
+		return;
+	}
+
 	consumed |= tp_tap_handle_state(tp, time);
 	consumed |= tp_post_button_events(tp, time);
 
@@ -632,13 +638,28 @@ static void
 tp_suspend(struct tp_dispatch *tp, struct evdev_device *device)
 {
 	tp_clear_state(tp, device);
-	evdev_device_suspend(device);
+
+	/* On devices with top softwarebuttons we don't actually suspend the
+	 * device, to keep the "trackpoint" buttons working. tp_post_events()
+	 * will only send events for the trackpoint while suspended.
+	 */
+	if (tp->buttons.has_topbuttons) {
+		evdev_notify_suspended_device(device);
+	} else {
+		evdev_device_suspend(device);
+	}
 }
 
 static void
 tp_resume(struct tp_dispatch *tp, struct evdev_device *device)
 {
-	evdev_device_resume(device);
+	if (tp->buttons.has_topbuttons) {
+		/* tap state-machine is offline while suspended, reset state */
+		tp_clear_state(tp, device);
+		evdev_notify_resumed_device(device);
+	} else {
+		evdev_device_resume(device);
+	}
 }
 
 static void
-- 
2.1.0



More information about the wayland-devel mailing list