[PATCH libinput 01/11] touchpad: skip thumb detection for touchpads smaller than 50mm

Peter Hutterer peter.hutterer at who-t.net
Tue Jul 21 22:09:21 PDT 2015


Gets a bit cramped if you're trying to rest the thumb on a touchpad that
small.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev-mt-touchpad.c |  8 ++++++++
 test/touchpad.c         | 10 +++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 35d0d85..19669fe 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -1497,6 +1497,7 @@ tp_init_thumb(struct tp_dispatch *tp)
 {
 	struct evdev_device *device = tp->device;
 	const struct input_absinfo *abs;
+	double w = 0.0, h = 0.0;
 
 	abs = libevdev_get_abs_info(device->evdev, ABS_MT_PRESSURE);
 	if (!abs)
@@ -1505,6 +1506,13 @@ tp_init_thumb(struct tp_dispatch *tp)
 	if (abs->maximum - abs->minimum < 255)
 		return 0;
 
+	/* if the touchpad is less than 50mm high, skip thumb detection.
+	 * it's too small to meaningfully interact with a thumb on the
+	 * touchpad */
+	evdev_device_get_size(device, &w, &h);
+	if (h < 50)
+		return 0;
+
 	/* The touchpads we looked at so far have a clear thumb threshold of
 	 * ~100, you don't reach that with a normal finger interaction.
 	 * Note: "thumb" means massive touch that should not interact, not
diff --git a/test/touchpad.c b/test/touchpad.c
index 64bdd44..eb083c9 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -3904,7 +3904,15 @@ END_TEST
 static int
 has_thumb_detect(struct litest_device *dev)
 {
-	return libevdev_has_event_code(dev->evdev, EV_ABS, ABS_MT_PRESSURE);
+	double w, h;
+
+	if (!libevdev_has_event_code(dev->evdev, EV_ABS, ABS_MT_PRESSURE))
+		return 0;
+
+	if (libinput_device_get_size(dev->libinput_device, &w, &h) != 0)
+		return 0;
+
+	return h >= 50.0;
 }
 
 START_TEST(touchpad_thumb_begin_no_motion)
-- 
2.4.3



More information about the wayland-devel mailing list