touchpad: on non-resolution touchpads, use 30% as maximum clickfinger spread
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 3 Jun 2015 04:27:43 +0000 (14:27 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 3 Jun 2015 04:43:58 +0000 (14:43 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
src/evdev-mt-touchpad-buttons.c
test/touchpad.c

index 469f0fa..5786ea8 100644 (file)
@@ -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;
+
+               /* 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;
 
-       res_x = tp->device->abs.absinfo_x->resolution;
-       res_y = tp->device->abs.absinfo_y->resolution;
+               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;
 
-       x = abs(t1->point.x - t2->point.x)/res_x;
-       y = abs(t1->point.y - t2->point.y)/res_y;
+               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
index d9daf43..692698c 100644 (file)
@@ -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);