mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-25 01:10:08 +01:00
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 <peter.hutterer@who-t.net>:
This commit is contained in:
parent
7b9a6a94a3
commit
e97f054917
2 changed files with 33 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue