mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-05 16:58:04 +02:00
gestures: average motion by active touches, not moved touches
When two fingers move slowly, an event frame may only have one finger motion, followed by a frame with the other finger's motion. If we only divide by the number of dirty touches, the speed of the gesture increases whenever that happens. Reported-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
6ad303b3d3
commit
f8bcbc2dbb
1 changed files with 10 additions and 6 deletions
|
|
@ -49,15 +49,19 @@ static struct normalized_coords
|
||||||
tp_get_touches_delta(struct tp_dispatch *tp, bool average)
|
tp_get_touches_delta(struct tp_dispatch *tp, bool average)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
unsigned int i, nchanged = 0;
|
unsigned int i, nactive = 0;
|
||||||
struct normalized_coords normalized;
|
struct normalized_coords normalized;
|
||||||
struct normalized_coords delta = {0.0, 0.0};
|
struct normalized_coords delta = {0.0, 0.0};
|
||||||
|
|
||||||
for (i = 0; i < tp->num_slots; i++) {
|
for (i = 0; i < tp->num_slots; i++) {
|
||||||
t = &tp->touches[i];
|
t = &tp->touches[i];
|
||||||
|
|
||||||
if (tp_touch_active(tp, t) && t->dirty) {
|
if (!tp_touch_active(tp, t))
|
||||||
nchanged++;
|
continue;
|
||||||
|
|
||||||
|
nactive++;
|
||||||
|
|
||||||
|
if (t->dirty) {
|
||||||
normalized = tp_get_delta(t);
|
normalized = tp_get_delta(t);
|
||||||
|
|
||||||
delta.x += normalized.x;
|
delta.x += normalized.x;
|
||||||
|
|
@ -65,11 +69,11 @@ tp_get_touches_delta(struct tp_dispatch *tp, bool average)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!average || nchanged == 0)
|
if (!average || nactive == 0)
|
||||||
return delta;
|
return delta;
|
||||||
|
|
||||||
delta.x /= nchanged;
|
delta.x /= nactive;
|
||||||
delta.y /= nchanged;
|
delta.y /= nactive;
|
||||||
|
|
||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue