[PATCH libinput 2/2] Change tp_filter_motion to normalized_coords
Peter Hutterer
peter.hutterer at who-t.net
Tue Mar 24 15:17:03 PDT 2015
On Tue, Mar 24, 2015 at 04:51:35PM +0100, Hans de Goede wrote:
> Change tp_filter_motion to use normalized_coords, rather then having it take
> separate x and y values.
>
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
weird. I remember writing this patch but apparently it went down the wrong
dark branch and got mugged. anyway.
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> for both - I wouldn't
mind if you split the gesture bits out and push the rest straight to master.
Cheers,
Peter
> ---
> src/evdev-mt-touchpad-edge-scroll.c | 3 +--
> src/evdev-mt-touchpad-gestures.c | 8 ++++----
> src/evdev-mt-touchpad.c | 29 ++++++-----------------------
> src/evdev-mt-touchpad.h | 5 ++---
> 4 files changed, 13 insertions(+), 32 deletions(-)
>
> diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c
> index b83f462..a68d062 100644
> --- a/src/evdev-mt-touchpad-edge-scroll.c
> +++ b/src/evdev-mt-touchpad-edge-scroll.c
> @@ -349,8 +349,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
> }
>
> normalized = tp_get_delta(t);
> - tp_filter_motion(tp, &normalized.x, &normalized.y,
> - NULL, NULL, time);
> + normalized = tp_filter_motion(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 aba5873..7dbf4c4 100644
> --- a/src/evdev-mt-touchpad-gestures.c
> +++ b/src/evdev-mt-touchpad-gestures.c
> @@ -93,11 +93,11 @@ tp_gesture_post_pointer_motion(struct tp_dispatch *tp, uint64_t time)
>
> /* When a clickpad is clicked, combine motion of all active touches */
> if (tp->buttons.is_clickpad && tp->buttons.state)
> - delta = tp_get_combined_touches_delta(tp);
> + unaccel = tp_get_combined_touches_delta(tp);
> else
> - delta = tp_get_average_touches_delta(tp);
> + unaccel = tp_get_average_touches_delta(tp);
>
> - tp_filter_motion(tp, &delta.x, &delta.y, &unaccel.x, &unaccel.y, time);
> + delta = tp_filter_motion(tp, &unaccel, time);
>
> if (!normalized_is_zero(delta) || !normalized_is_zero(unaccel)) {
> pointer_notify_motion(&tp->device->base, time,
> @@ -111,7 +111,7 @@ tp_gesture_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
> struct normalized_coords delta;
>
> delta = tp_get_average_touches_delta(tp);
> - tp_filter_motion(tp, &delta.x, &delta.y, NULL, NULL, time);
> + delta = tp_filter_motion(tp, &delta, time);
>
> if (normalized_is_zero(delta))
> return;
> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> index 2078bd7..afc9178 100644
> --- a/src/evdev-mt-touchpad.c
> +++ b/src/evdev-mt-touchpad.c
> @@ -58,33 +58,16 @@ tp_motion_history_offset(struct tp_touch *t, int offset)
> return &t->history.samples[offset_index];
> }
>
> -void
> +struct normalized_coords
> tp_filter_motion(struct tp_dispatch *tp,
> - double *dx, double *dy,
> - double *dx_unaccel, double *dy_unaccel,
> + const struct normalized_coords *unaccelerated,
> uint64_t time)
> {
> - struct normalized_coords unaccelerated;
> - struct normalized_coords accelerated;
> -
> - unaccelerated.x = *dx;
> - unaccelerated.y = *dy;
> -
> - if (!normalized_is_zero(unaccelerated))
> - accelerated = filter_dispatch(tp->device->pointer.filter,
> - &unaccelerated,
> - tp,
> - time);
> - else
> - accelerated = unaccelerated;
> -
> - if (dx_unaccel)
> - *dx_unaccel = unaccelerated.x;
> - if (dy_unaccel)
> - *dy_unaccel = unaccelerated.y;
> + if (normalized_is_zero(*unaccelerated))
> + return *unaccelerated;
>
> - *dx = accelerated.x;
> - *dy = accelerated.y;
> + return filter_dispatch(tp->device->pointer.filter,
> + unaccelerated, tp, time);
> }
>
> static inline void
> diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
> index 0c6d87e..5d52723 100644
> --- a/src/evdev-mt-touchpad.h
> +++ b/src/evdev-mt-touchpad.h
> @@ -288,10 +288,9 @@ tp_normalize_delta(struct tp_dispatch *tp, struct delta_coords delta)
> struct normalized_coords
> tp_get_delta(struct tp_touch *t);
>
> -void
> +struct normalized_coords
> tp_filter_motion(struct tp_dispatch *tp,
> - double *dx, double *dy,
> - double *dx_unaccel, double *dy_unaccel,
> + const struct normalized_coords *unaccelerated,
> uint64_t time);
>
> int
> --
> 2.3.1
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
More information about the wayland-devel
mailing list