[PATCH libinput 4/4] touchpad: on non-resolution touchpads, use 30% as maximum clickfinger spread
Peter Hutterer
peter.hutterer at who-t.net
Tue Jun 2 22:51:58 PDT 2015
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev-mt-touchpad-buttons.c | 35 +++++++++++++++++++++++------------
test/touchpad.c | 2 +-
2 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index 469f0fa..5786ea8 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -789,27 +789,38 @@ tp_check_clickfinger_distance(struct tp_dispatch *tp,
struct tp_touch *t1,
struct tp_touch *t2)
{
- int res_x, res_y;
double x, y;
if (!t1 || !t2)
return 0;
+ x = abs(t1->point.x - t2->point.x);
+ y = abs(t1->point.y - t2->point.y);
+
/* no resolution, so let's assume they're close enough together */
- if (tp->device->abs.fake_resolution)
- return 1;
+ if (tp->device->abs.fake_resolution) {
+ int w, h;
- res_x = tp->device->abs.absinfo_x->resolution;
- res_y = tp->device->abs.absinfo_y->resolution;
+ /* Use a maximum of 30% of the touchpad width or height if
+ * we dont' have resolution. */
+ w = tp->device->abs.absinfo_x->maximum -
+ tp->device->abs.absinfo_x->minimum;
+ h = tp->device->abs.absinfo_y->maximum -
+ tp->device->abs.absinfo_y->minimum;
- x = abs(t1->point.x - t2->point.x)/res_x;
- y = abs(t1->point.y - t2->point.y)/res_y;
+ return (x < w * 0.3 && y < h * 0.3) ? 1 : 0;
+ } else {
+ /* maximum spread is 40mm horiz, 20mm vert. Anything wider than that
+ * is probably a gesture. The y spread is small so we ignore clicks
+ * with thumbs at the bottom of the touchpad while the pointer
+ * moving finger is still on the pad */
+
+ x /= tp->device->abs.absinfo_x->resolution;
+ y /= tp->device->abs.absinfo_y->resolution;
+
+ return (x < 40 && y < 20) ? 1 : 0;
+ }
- /* maximum spread is 40mm horiz, 20mm vert. Anything wider than that
- * is probably a gesture. The y spread is small so we ignore clicks
- * with thumbs at the bottom of the touchpad while the pointer
- * moving finger is still on the pad */
- return (x < 40 && y < 20) ? 1 : 0;
}
static uint32_t
diff --git a/test/touchpad.c b/test/touchpad.c
index d9daf43..692698c 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -5129,7 +5129,7 @@ litest_setup_tests(void)
litest_add("touchpad:clickfinger", touchpad_1fg_clickfinger, LITEST_CLICKPAD, LITEST_ANY);
litest_add("touchpad:clickfinger", touchpad_1fg_clickfinger_no_touch, LITEST_CLICKPAD, LITEST_ANY);
litest_add("touchpad:clickfinger", touchpad_2fg_clickfinger, LITEST_CLICKPAD, LITEST_ANY);
- litest_add("touchpad:clickfinger", touchpad_2fg_clickfinger_distance, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
+ litest_add("touchpad:clickfinger", touchpad_2fg_clickfinger_distance, LITEST_CLICKPAD, LITEST_ANY);
litest_add("touchpad:clickfinger", touchpad_clickfinger_to_area_method, LITEST_CLICKPAD, LITEST_ANY);
litest_add("touchpad:clickfinger",
touchpad_clickfinger_to_area_method_while_down, LITEST_CLICKPAD, LITEST_ANY);
--
2.4.1
More information about the wayland-devel
mailing list