diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index eda62e4d..b572a9fb 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -390,7 +390,8 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time) } normalized = tp_get_delta(t); - normalized = tp_filter_motion(tp, &normalized, time); + /* scroll is not accelerated */ + normalized = tp_filter_motion_unaccelerated(tp, &normalized, time); switch (t->scroll.edge_state) { case EDGE_SCROLL_TOUCH_STATE_NONE: diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c index d82a6fb9..cc26e2a9 100644 --- a/src/evdev-mt-touchpad-gestures.c +++ b/src/evdev-mt-touchpad-gestures.c @@ -328,7 +328,8 @@ tp_gesture_twofinger_handle_state_scroll(struct tp_dispatch *tp, uint64_t time) delta = tp_get_average_touches_delta(tp); } - delta = tp_filter_motion(tp, &delta, time); + /* scroll is not accelerated */ + delta = tp_filter_motion_unaccelerated(tp, &delta, time); if (normalized_is_zero(delta)) return GESTURE_2FG_STATE_SCROLL; diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index a32a771c..aeb6c314 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -71,6 +71,18 @@ tp_filter_motion(struct tp_dispatch *tp, unaccelerated, tp, time); } +struct normalized_coords +tp_filter_motion_unaccelerated(struct tp_dispatch *tp, + const struct normalized_coords *unaccelerated, + uint64_t time) +{ + if (normalized_is_zero(*unaccelerated)) + return *unaccelerated; + + return filter_dispatch_constant(tp->device->pointer.filter, + unaccelerated, tp, time); +} + static inline void tp_motion_history_push(struct tp_touch *t) { diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 3bd84258..5f87c3f3 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -395,6 +395,10 @@ struct normalized_coords tp_filter_motion(struct tp_dispatch *tp, const struct normalized_coords *unaccelerated, uint64_t time); +struct normalized_coords +tp_filter_motion_unaccelerated(struct tp_dispatch *tp, + const struct normalized_coords *unaccelerated, + uint64_t time); int tp_touch_active(struct tp_dispatch *tp, struct tp_touch *t); diff --git a/src/filter.c b/src/filter.c index 674b439b..5df50d38 100644 --- a/src/filter.c +++ b/src/filter.c @@ -420,6 +420,19 @@ accelerator_filter_x230(struct motion_filter *filter, return accelerated; } +static struct normalized_coords +touchpad_constant_filter(struct motion_filter *filter, + const struct normalized_coords *unaccelerated, + void *data, uint64_t time) +{ + struct normalized_coords normalized; + + normalized.x = TP_MAGIC_SLOWDOWN * unaccelerated->x; + normalized.y = TP_MAGIC_SLOWDOWN * unaccelerated->y; + + return normalized; +} + static void accelerator_restart(struct motion_filter *filter, void *data, @@ -757,6 +770,14 @@ create_pointer_accelerator_filter_linear_low_dpi(int dpi) return &filter->base; } +struct motion_filter_interface accelerator_interface_touchpad = { + .filter = accelerator_filter, + .filter_constant = touchpad_constant_filter, + .restart = accelerator_restart, + .destroy = accelerator_destroy, + .set_speed = accelerator_set_speed, +}; + struct motion_filter * create_pointer_accelerator_filter_touchpad(int dpi) { @@ -766,7 +787,7 @@ create_pointer_accelerator_filter_touchpad(int dpi) if (!filter) return NULL; - filter->base.interface = &accelerator_interface; + filter->base.interface = &accelerator_interface_touchpad; filter->profile = touchpad_accel_profile_linear; return &filter->base;