[PATCH libinput 2/2] touchpad: reduce unpin threshold to 1.5mm

Peter Hutterer peter.hutterer at who-t.net
Tue Jul 21 00:20:04 PDT 2015


3mm is too large, it makes the touchpad feel sluggish. We already take fuzz
into account through the hysteresis and the real issue we have with the
pointer moving on a click is _before_ the BTN_LEFT event comes in, not after.

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

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 35d0d85..f45d6bb 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -438,8 +438,8 @@ tp_unpin_finger(struct tp_dispatch *tp, struct tp_touch *t)
 	ydist = abs(t->point.y - t->pinned.center.y);
 	ydist *= tp->buttons.motion_dist.y_scale_coeff;
 
-	/* 3mm movement -> unpin */
-	if (hypot(xdist, ydist) >= 3.0) {
+	/* 1.5mm movement -> unpin */
+	if (hypot(xdist, ydist) >= 1.5) {
 		t->pinned.is_pinned = false;
 		return;
 	}
diff --git a/test/touchpad.c b/test/touchpad.c
index 64bdd44..28a46bd 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -840,12 +840,19 @@ START_TEST(clickpad_finger_pin)
 	struct libinput *li = dev->libinput;
 	struct libevdev *evdev = dev->evdev;
 	const struct input_absinfo *abs;
+	double w, h;
+	double dist;
 
 	abs = libevdev_get_abs_info(evdev, ABS_MT_POSITION_X);
 	ck_assert_notnull(abs);
 	if (abs->resolution == 0)
 		return;
 
+	if (libinput_device_get_size(dev->libinput_device, &w, &h) != 0)
+		return;
+
+	dist = 100.0/max(w, h);
+
 	litest_drain_events(li);
 
 	/* make sure the movement generates pointer events when
@@ -859,9 +866,9 @@ START_TEST(clickpad_finger_pin)
 	litest_button_click(dev, BTN_LEFT, true);
 	litest_drain_events(li);
 
-	litest_touch_move_to(dev, 0, 50, 50, 51, 51, 10, 1);
-	litest_touch_move_to(dev, 0, 51, 51, 49, 49, 10, 1);
-	litest_touch_move_to(dev, 0, 49, 49, 50, 50, 10, 1);
+	litest_touch_move_to(dev, 0, 50, 50, 50 + dist, 50 + dist, 10, 1);
+	litest_touch_move_to(dev, 0, 50 + dist, 50 + dist, 50, 50, 10, 1);
+	litest_touch_move_to(dev, 0, 50, 50, 50 - dist, 50 - dist, 10, 1);
 
 	litest_assert_empty_queue(li);
 
@@ -869,9 +876,9 @@ START_TEST(clickpad_finger_pin)
 	litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_BUTTON);
 
 	/* still pinned after release */
-	litest_touch_move_to(dev, 0, 50, 50, 51, 51, 10, 1);
-	litest_touch_move_to(dev, 0, 51, 51, 49, 49, 10, 1);
-	litest_touch_move_to(dev, 0, 49, 49, 50, 50, 10, 1);
+	litest_touch_move_to(dev, 0, 50, 50, 50 + dist, 50 + dist, 10, 1);
+	litest_touch_move_to(dev, 0, 50 + dist, 50 + dist, 50, 50, 10, 1);
+	litest_touch_move_to(dev, 0, 50, 50, 50 - dist, 50 - dist, 10, 1);
 
 	litest_assert_empty_queue(li);
 
-- 
2.4.3



More information about the wayland-devel mailing list