mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 04:48:02 +02:00
gestures: make the gesture movement threshold depending on finger count
Increase the mm move threshold for 3 and 4 finger gestures to 2 and 3 mm, respectively. In multi-finger gestures it's common to have minor movement while all fingers are being put down or before the conscious movement starts. This can trigger invalid gesture detection (e.g. a pinch instead of a swipe). Increase the movement threshold to make sure we have sufficient input data. No changes to 2-finger movements. https://bugs.freedesktop.org/show_bug.cgi?id=96687 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
5436c2feaa
commit
4923c404e8
2 changed files with 11 additions and 8 deletions
|
|
@ -182,12 +182,15 @@ tp_gesture_get_active_touches(const struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
tp_gesture_get_direction(struct tp_dispatch *tp, struct tp_touch *touch)
|
tp_gesture_get_direction(struct tp_dispatch *tp, struct tp_touch *touch,
|
||||||
|
unsigned int nfingers)
|
||||||
{
|
{
|
||||||
struct normalized_coords normalized;
|
struct normalized_coords normalized;
|
||||||
struct device_float_coords delta;
|
struct device_float_coords delta;
|
||||||
double move_threshold = TP_MM_TO_DPI_NORMALIZED(1);
|
double move_threshold = TP_MM_TO_DPI_NORMALIZED(1);
|
||||||
|
|
||||||
|
move_threshold *= (nfingers - 1);
|
||||||
|
|
||||||
delta = device_delta(touch->point, touch->gesture.initial);
|
delta = device_delta(touch->point, touch->gesture.initial);
|
||||||
|
|
||||||
normalized = tp_normalize_delta(tp, delta);
|
normalized = tp_normalize_delta(tp, delta);
|
||||||
|
|
@ -347,8 +350,8 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Else wait for both fingers to have moved */
|
/* Else wait for both fingers to have moved */
|
||||||
dir1 = tp_gesture_get_direction(tp, first);
|
dir1 = tp_gesture_get_direction(tp, first, tp->gesture.finger_count);
|
||||||
dir2 = tp_gesture_get_direction(tp, second);
|
dir2 = tp_gesture_get_direction(tp, second, tp->gesture.finger_count);
|
||||||
if (dir1 == UNDEFINED_DIRECTION || dir2 == UNDEFINED_DIRECTION)
|
if (dir1 == UNDEFINED_DIRECTION || dir2 == UNDEFINED_DIRECTION)
|
||||||
return GESTURE_STATE_UNKNOWN;
|
return GESTURE_STATE_UNKNOWN;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -961,13 +961,13 @@ START_TEST(gestures_pinch_4fg_btntool)
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
litest_push_event_frame(dev);
|
litest_push_event_frame(dev);
|
||||||
if (dir_x > 0.0)
|
if (dir_x > 0.0)
|
||||||
dir_x -= 2;
|
dir_x -= 3;
|
||||||
else if (dir_x < 0.0)
|
else if (dir_x < 0.0)
|
||||||
dir_x += 2;
|
dir_x += 3;
|
||||||
if (dir_y > 0.0)
|
if (dir_y > 0.0)
|
||||||
dir_y -= 2;
|
dir_y -= 3;
|
||||||
else if (dir_y < 0.0)
|
else if (dir_y < 0.0)
|
||||||
dir_y += 2;
|
dir_y += 3;
|
||||||
litest_touch_move(dev,
|
litest_touch_move(dev,
|
||||||
0,
|
0,
|
||||||
50 + dir_x,
|
50 + dir_x,
|
||||||
|
|
@ -1004,7 +1004,7 @@ START_TEST(gestures_pinch_4fg_btntool)
|
||||||
ck_assert(scale < oldscale);
|
ck_assert(scale < oldscale);
|
||||||
|
|
||||||
angle = libinput_event_gesture_get_angle_delta(gevent);
|
angle = libinput_event_gesture_get_angle_delta(gevent);
|
||||||
ck_assert_double_le(fabs(angle), 1.0);
|
ck_assert_double_le(fabs(angle), 1.5);
|
||||||
|
|
||||||
libinput_event_destroy(event);
|
libinput_event_destroy(event);
|
||||||
libinput_dispatch(li);
|
libinput_dispatch(li);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue