gestures: average motion by active touches, not moved touches

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit b6f59d0e3b)
This commit is contained in:
Peter Hutterer 2016-01-25 11:19:58 +10:00
parent 815af6dec8
commit d06ed108b0

View file

@ -48,15 +48,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;
@ -64,11 +68,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;
} }