[PATCH libinput 10/12] Split deltas/absolute coords in pointer events to separate fields
Peter Hutterer
peter.hutterer at who-t.net
Thu Mar 12 01:36:41 PDT 2015
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/libinput.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/src/libinput.c b/src/libinput.c
index 3b1d482..1a68069 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -57,8 +57,8 @@ struct libinput_event_keyboard {
struct libinput_event_pointer {
struct libinput_event base;
uint32_t time;
- double x;
- double y;
+ struct normalized_coords delta;
+ struct device_coords absolute;
double x_discrete;
double y_discrete;
double dx_unaccel;
@@ -297,13 +297,13 @@ libinput_event_pointer_get_time(struct libinput_event_pointer *event)
LIBINPUT_EXPORT double
libinput_event_pointer_get_dx(struct libinput_event_pointer *event)
{
- return event->x;
+ return event->delta.x;
}
LIBINPUT_EXPORT double
libinput_event_pointer_get_dy(struct libinput_event_pointer *event)
{
- return event->y;
+ return event->delta.y;
}
LIBINPUT_EXPORT double
@@ -326,7 +326,7 @@ libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event)
struct evdev_device *device =
(struct evdev_device *) event->base.device;
- return evdev_convert_to_mm(device->abs.absinfo_x, event->x);
+ return evdev_convert_to_mm(device->abs.absinfo_x, event->absolute.x);
}
LIBINPUT_EXPORT double
@@ -335,7 +335,7 @@ libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event)
struct evdev_device *device =
(struct evdev_device *) event->base.device;
- return evdev_convert_to_mm(device->abs.absinfo_y, event->y);
+ return evdev_convert_to_mm(device->abs.absinfo_y, event->absolute.y);
}
LIBINPUT_EXPORT double
@@ -346,7 +346,7 @@ libinput_event_pointer_get_absolute_x_transformed(
struct evdev_device *device =
(struct evdev_device *) event->base.device;
- return evdev_device_transform_x(device, event->x, width);
+ return evdev_device_transform_x(device, event->absolute.x, width);
}
LIBINPUT_EXPORT double
@@ -357,7 +357,7 @@ libinput_event_pointer_get_absolute_y_transformed(
struct evdev_device *device =
(struct evdev_device *) event->base.device;
- return evdev_device_transform_y(device, event->y, height);
+ return evdev_device_transform_y(device, event->absolute.y, height);
}
LIBINPUT_EXPORT uint32_t
@@ -405,10 +405,10 @@ libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event,
} else {
switch (axis) {
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
- value = event->x;
+ value = event->delta.x;
break;
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
- value = event->y;
+ value = event->delta.y;
break;
}
}
@@ -971,8 +971,7 @@ pointer_notify_motion(struct libinput_device *device,
*motion_event = (struct libinput_event_pointer) {
.time = time,
- .x = delta->x,
- .y = delta->y,
+ .delta = *delta,
.dx_unaccel = unaccel->x,
.dy_unaccel = unaccel->y,
};
@@ -995,8 +994,7 @@ pointer_notify_motion_absolute(struct libinput_device *device,
*motion_absolute_event = (struct libinput_event_pointer) {
.time = time,
- .x = point->x,
- .y = point->y,
+ .absolute = *point,
};
post_device_event(device, time,
@@ -1049,8 +1047,7 @@ pointer_notify_axis(struct libinput_device *device,
*axis_event = (struct libinput_event_pointer) {
.time = time,
- .x = delta->x,
- .y = delta->y,
+ .delta = *delta,
.source = source,
.axes = axes,
.x_discrete = x_discrete,
--
2.1.0
More information about the wayland-devel
mailing list