diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2015-06-10 09:54:06 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2015-06-11 07:19:25 +1000 |
commit | 105e725602791bd02ea800fd4298d3443c14ba58 (patch) | |
tree | e3fd4b00d85a8c4b572d01036d3e26c32621ea57 /src/filter.c | |
parent | d698f1b12fdf6a2fcc0103f338b944e3e6762c0b (diff) |
touchpad: restart the motion filter on touch begin
Our motion filter takes the last couple of vectors to calculate speed,
provided the direction stays the same and it is within a certain timeout. It
does not take into account lifting the finger, so the velocity on the first
event is off.
Real-world impact is mainly on scrolling. Before commit 289e4675
filter: enforce minimum velocity
the first motion on a scroll was accelerated by a factor of 0 and swallowed.
After 289e4675 the motion was calculated based on the timeout and a fraction
of the expected effect. Now the first scroll motion is based on the real
finger motion since setting the finger down and thus feels a bit more
responsive.
It also makes a couple of test cases using litest_assert_scroll() work again
since the miniumum motion is now as expected.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src/filter.c')
-rw-r--r-- | src/filter.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/filter.c b/src/filter.c index c54d866c..6d9b9c34 100644 --- a/src/filter.c +++ b/src/filter.c @@ -44,6 +44,13 @@ filter_dispatch(struct motion_filter *filter, } void +filter_restart(struct motion_filter *filter, + void *data, uint64_t time) +{ + filter->interface->restart(filter, data, time); +} + +void filter_destroy(struct motion_filter *filter) { if (!filter) @@ -274,6 +281,29 @@ accelerator_filter(struct motion_filter *filter, } static void +accelerator_restart(struct motion_filter *filter, + void *data, + uint64_t time) +{ + struct pointer_accelerator *accel = + (struct pointer_accelerator *) filter; + unsigned int offset; + struct pointer_tracker *tracker; + + for (offset = 1; offset < NUM_POINTER_TRACKERS; offset++) { + tracker = tracker_by_offset(accel, offset); + tracker->time = 0; + tracker->dir = 0; + tracker->delta.x = 0; + tracker->delta.y = 0; + } + + tracker = tracker_by_offset(accel, 0); + tracker->time = time; + tracker->dir = UNDEFINED_DIRECTION; +} + +static void accelerator_destroy(struct motion_filter *filter) { struct pointer_accelerator *accel = @@ -309,6 +339,7 @@ accelerator_set_speed(struct motion_filter *filter, struct motion_filter_interface accelerator_interface = { accelerator_filter, + accelerator_restart, accelerator_destroy, accelerator_set_speed, }; |