summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-01-25 11:19:58 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-01-27 09:51:05 +1000
commitf8bcbc2dbb8cbbd5f1dea614238fcaa0c4cb2da0 (patch)
tree7c285f8cbae0fc1c0b6565e6e1a9c2e5750bb750 /src
parent6ad303b3d3da9109409a161df48131682dd519c9 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/evdev-mt-touchpad-gestures.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
index 8fe0bb85..dc8d6060 100644
--- a/src/evdev-mt-touchpad-gestures.c
+++ b/src/evdev-mt-touchpad-gestures.c
@@ -49,15 +49,19 @@ static struct normalized_coords
tp_get_touches_delta(struct tp_dispatch *tp, bool average)
{
struct tp_touch *t;
- unsigned int i, nchanged = 0;
+ unsigned int i, nactive = 0;
struct normalized_coords normalized;
struct normalized_coords delta = {0.0, 0.0};
for (i = 0; i < tp->num_slots; i++) {
t = &tp->touches[i];
- if (tp_touch_active(tp, t) && t->dirty) {
- nchanged++;
+ if (!tp_touch_active(tp, t))
+ continue;
+
+ nactive++;
+
+ if (t->dirty) {
normalized = tp_get_delta(t);
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;
- delta.x /= nchanged;
- delta.y /= nchanged;
+ delta.x /= nactive;
+ delta.y /= nactive;
return delta;
}