[PATCH libinput 08/12] Use typesafe coords in motion events
Peter Hutterer
peter.hutterer at who-t.net
Thu Mar 12 01:36:39 PDT 2015
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
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 3317797..ea31fb8 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -961,10 +961,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;
@@ -974,10 +972,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,
@@ -988,8 +986,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;
@@ -999,8 +996,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.1.0
More information about the wayland-devel
mailing list