From 2d54b550b775352f230e24b4a86bd2c7f23d18b0 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 11 Mar 2015 10:43:18 +1000 Subject: [PATCH] Use typesafe coords in motion events Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad-gestures.c | 10 ++++------ src/evdev.c | 6 ++---- src/libinput-private.h | 9 +++------ src/libinput.c | 21 +++++++++------------ 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c index 1456731..f852ff5 100644 --- a/src/evdev-mt-touchpad-gestures.c +++ b/src/evdev-mt-touchpad-gestures.c @@ -89,8 +89,7 @@ tp_gesture_start(struct tp_dispatch *tp, uint64_t time) static void tp_gesture_post_pointer_motion(struct tp_dispatch *tp, uint64_t time) { - double dx_unaccel, dy_unaccel; - struct normalized_coords delta; + struct normalized_coords delta, unaccel; /* When a clickpad is clicked, combine motion of all active touches */ if (tp->buttons.is_clickpad && tp->buttons.state) @@ -98,13 +97,12 @@ tp_gesture_post_pointer_motion(struct tp_dispatch *tp, uint64_t time) else delta = tp_get_average_touches_delta(tp); - tp_filter_motion(tp, &delta.x, &delta.y, &dx_unaccel, &dy_unaccel, time); + tp_filter_motion(tp, &delta.x, &delta.y, &unaccel.x, &unaccel.y, time); if (delta.x != 0.0 || delta.y != 0.0 || - dx_unaccel != 0.0 || dy_unaccel != 0.0) { + unaccel.x != 0.0 || unaccel.y != 0.0) { pointer_notify_motion(&tp->device->base, time, - delta.x, delta.y, - dx_unaccel, dy_unaccel); + &delta, &unaccel); } } diff --git a/src/evdev.c b/src/evdev.c index 0a2f1f8..d1b0504 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -279,9 +279,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time) break; } - pointer_notify_motion(base, time, - accel.x, accel.y, - unaccel.x, unaccel.x); + pointer_notify_motion(base, time, &accel, &unaccel); break; case EVDEV_ABSOLUTE_MT_DOWN: if (!(device->seat_caps & EVDEV_DEVICE_TOUCH)) @@ -376,7 +374,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time) touch_notify_touch_motion(base, time, -1, seat_slot, x, y); } else if (device->seat_caps & EVDEV_DEVICE_POINTER) { - pointer_notify_motion_absolute(base, time, x, y); + pointer_notify_motion_absolute(base, time, &point); } break; case EVDEV_ABSOLUTE_TOUCH_UP: diff --git a/src/libinput-private.h b/src/libinput-private.h index d5fb696..a7e0b07 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -290,16 +290,13 @@ keyboard_notify_key(struct libinput_device *device, void pointer_notify_motion(struct libinput_device *device, uint64_t time, - double dx, - double dy, - double dx_unaccel, - double dy_unaccel); + const struct normalized_coords *delta, + const struct normalized_coords *unaccel); void pointer_notify_motion_absolute(struct libinput_device *device, uint64_t time, - double x, - double y); + const struct device_coords *point); void pointer_notify_button(struct libinput_device *device, diff --git a/src/libinput.c b/src/libinput.c index 55b654d..a7956d6 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -1098,10 +1098,8 @@ keyboard_notify_key(struct libinput_device *device, void pointer_notify_motion(struct libinput_device *device, uint64_t time, - double dx, - double dy, - double dx_unaccel, - double dy_unaccel) + const struct normalized_coords *delta, + const struct normalized_coords *unaccel) { struct libinput_event_pointer *motion_event; @@ -1111,10 +1109,10 @@ pointer_notify_motion(struct libinput_device *device, *motion_event = (struct libinput_event_pointer) { .time = time, - .x = dx, - .y = dy, - .dx_unaccel = dx_unaccel, - .dy_unaccel = dy_unaccel, + .x = delta->x, + .y = delta->y, + .dx_unaccel = unaccel->x, + .dy_unaccel = unaccel->y, }; post_device_event(device, time, @@ -1125,8 +1123,7 @@ pointer_notify_motion(struct libinput_device *device, void pointer_notify_motion_absolute(struct libinput_device *device, uint64_t time, - double x, - double y) + const struct device_coords *point) { struct libinput_event_pointer *motion_absolute_event; @@ -1136,8 +1133,8 @@ pointer_notify_motion_absolute(struct libinput_device *device, *motion_absolute_event = (struct libinput_event_pointer) { .time = time, - .x = x, - .y = y, + .x = point->x, + .y = point->y, }; post_device_event(device, time, -- 2.7.4