From: Matt Mayfield Date: Wed, 22 Aug 2018 02:12:33 +0000 (-0500) Subject: gestures: improve scroll responsiveness for vertically aligned touches X-Git-Tag: 1.13.901~1^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e97f0549173a07aa6ebd19ca19f842b8d3ac994c;p=platform%2Fupstream%2Flibinput.git gestures: improve scroll responsiveness for vertically aligned touches Put some basic location checks in, if the fingers are next to each other and vertically close, assume scroll over swipe. Signed-off-by: Peter Hutterer : --- diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c index d4133b5..12e00a3 100644 --- a/src/evdev-mt-touchpad-gestures.c +++ b/src/evdev-mt-touchpad-gestures.c @@ -496,6 +496,17 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time) if (first_mm < 1 && second_mm < 1) return GESTURE_STATE_UNKNOWN; + /* If both touches are within 7mm vertically and 40mm horizontally, + * assume scroll/swipe */ + if (distance_mm.x < 40 && distance_mm.y < 7.0) { + if (tp->gesture.finger_count == 2) { + tp_gesture_set_scroll_buildup(tp); + return GESTURE_STATE_SCROLL; + } else if (tp->gesture.enabled) { + return GESTURE_STATE_SWIPE; + } + } + /* If one touch exceeds the outer threshold while the other has not * yet passed the inner threshold, this is not a valid gesture. * If thumb detection is enabled, and one of the touches is >20mm diff --git a/test/test-gestures.c b/test/test-gestures.c index 76f80f3..ae2da79 100644 --- a/test/test-gestures.c +++ b/test/test-gestures.c @@ -517,6 +517,17 @@ START_TEST(gestures_pinch) LIBINPUT_DEVICE_CAP_GESTURE)) return; + /* If the device is too small to provide a finger spread wide enough + * to avoid the scroll bias, skip the test */ + if (cardinal == E || cardinal == W) { + double w = 0, h = 0; + libinput_device_get_size(dev->libinput_device, &w, &h); + /* 0.6 because the code below gives us points like 20/y and + * 80/y. 45 because the threshold in the code is 40mm */ + if (w * 0.6 < 45) + return; + } + dir_x = cardinals[cardinal][0]; dir_y = cardinals[cardinal][1]; @@ -834,6 +845,17 @@ START_TEST(gestures_spread) LIBINPUT_DEVICE_CAP_GESTURE)) return; + /* If the device is too small to provide a finger spread wide enough + * to avoid the scroll bias, skip the test */ + if (cardinal == E || cardinal == W) { + double w = 0, h = 0; + libinput_device_get_size(dev->libinput_device, &w, &h); + /* 0.6 because the code below gives us points like 20/y and + * 80/y. 45 because the threshold in the code is 40mm */ + if (w * 0.6 < 45) + return; + } + dir_x = cardinals[cardinal][0]; dir_y = cardinals[cardinal][1];