diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2015-06-03 14:27:43 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2015-06-03 14:43:58 +1000 |
commit | 8af1f4b08536ca2d74950026eb4d210142dbf6fc (patch) | |
tree | d5b1575a3aa500ba1e1a76908f1f5886692173b3 | |
parent | df83144457176e454953d2a580a8f28e73f4a677 (diff) |
touchpad: on non-resolution touchpads, use 30% as maximum clickfinger spread
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | src/evdev-mt-touchpad-buttons.c | 35 | ||||
-rw-r--r-- | 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 469f0fa5..5786ea8b 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; + + /* 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 diff --git a/test/touchpad.c b/test/touchpad.c index d9daf434..692698ce 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); |