[PATCH libinput 09/12] Use typesafe coordinates in touch events

Peter Hutterer peter.hutterer at who-t.net
Thu Mar 12 01:36:40 PDT 2015


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c            | 13 +++++--------
 src/libinput-private.h |  6 ++----
 src/libinput.c         | 23 +++++++++--------------
 3 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index d1b0504..cab7e85 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -239,7 +239,6 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
 {
 	struct libinput *libinput = device->base.seat->libinput;
 	struct motion_params motion;
-	int32_t x, y;
 	int slot;
 	int seat_slot;
 	struct libinput_device *base = &device->base;
@@ -304,7 +303,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
 		transform_absolute(device, &point);
 
 		touch_notify_touch_down(base, time, slot, seat_slot,
-					point.x, point.y);
+					&point);
 		break;
 	case EVDEV_ABSOLUTE_MT_MOTION:
 		if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
@@ -318,7 +317,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
 
 		transform_absolute(device, &point);
 		touch_notify_touch_motion(base, time, slot, seat_slot,
-					  point.x, point.y);
+					  &point);
 		break;
 	case EVDEV_ABSOLUTE_MT_UP:
 		if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
@@ -357,14 +356,11 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
 		point = device->abs.point;
 		transform_absolute(device, &point);
 
-		touch_notify_touch_down(base, time, -1, seat_slot,
-					point.x, point.y);
+		touch_notify_touch_down(base, time, -1, seat_slot, &point);
 		break;
 	case EVDEV_ABSOLUTE_MOTION:
 		point = device->abs.point;
 		transform_absolute(device, &point);
-		x = point.x;
-		y = point.y;
 
 		if (device->seat_caps & EVDEV_DEVICE_TOUCH) {
 			seat_slot = device->abs.seat_slot;
@@ -372,7 +368,8 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
 			if (seat_slot == -1)
 				break;
 
-			touch_notify_touch_motion(base, time, -1, seat_slot, x, y);
+			touch_notify_touch_motion(base, time, -1, seat_slot,
+						  &point);
 		} else if (device->seat_caps & EVDEV_DEVICE_POINTER) {
 			pointer_notify_motion_absolute(base, time, &point);
 		}
diff --git a/src/libinput-private.h b/src/libinput-private.h
index a7e0b07..91bfc37 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -318,16 +318,14 @@ touch_notify_touch_down(struct libinput_device *device,
 			uint64_t time,
 			int32_t slot,
 			int32_t seat_slot,
-			double x,
-			double y);
+			const struct device_coords *point);
 
 void
 touch_notify_touch_motion(struct libinput_device *device,
 			  uint64_t time,
 			  int32_t slot,
 			  int32_t seat_slot,
-			  double x,
-			  double y);
+			  const struct device_coords *point);
 
 void
 touch_notify_touch_up(struct libinput_device *device,
diff --git a/src/libinput.c b/src/libinput.c
index ea31fb8..3b1d482 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -75,8 +75,7 @@ struct libinput_event_touch {
 	uint32_t time;
 	int32_t slot;
 	int32_t seat_slot;
-	double x;
-	double y;
+	struct device_coords point;
 };
 
 static void
@@ -469,7 +468,7 @@ libinput_event_touch_get_x(struct libinput_event_touch *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->point.x);
 }
 
 LIBINPUT_EXPORT double
@@ -479,7 +478,7 @@ libinput_event_touch_get_x_transformed(struct libinput_event_touch *event,
 	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->point.x, width);
 }
 
 LIBINPUT_EXPORT double
@@ -489,7 +488,7 @@ libinput_event_touch_get_y_transformed(struct libinput_event_touch *event,
 	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->point.y, height);
 }
 
 LIBINPUT_EXPORT double
@@ -498,7 +497,7 @@ libinput_event_touch_get_y(struct libinput_event_touch *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->point.y);
 }
 
 struct libinput_source *
@@ -1068,8 +1067,7 @@ touch_notify_touch_down(struct libinput_device *device,
 			uint64_t time,
 			int32_t slot,
 			int32_t seat_slot,
-			double x,
-			double y)
+			const struct device_coords *point)
 {
 	struct libinput_event_touch *touch_event;
 
@@ -1081,8 +1079,7 @@ touch_notify_touch_down(struct libinput_device *device,
 		.time = time,
 		.slot = slot,
 		.seat_slot = seat_slot,
-		.x = x,
-		.y = y,
+		.point = *point,
 	};
 
 	post_device_event(device, time,
@@ -1095,8 +1092,7 @@ touch_notify_touch_motion(struct libinput_device *device,
 			  uint64_t time,
 			  int32_t slot,
 			  int32_t seat_slot,
-			  double x,
-			  double y)
+			  const struct device_coords *point)
 {
 	struct libinput_event_touch *touch_event;
 
@@ -1108,8 +1104,7 @@ touch_notify_touch_motion(struct libinput_device *device,
 		.time = time,
 		.slot = slot,
 		.seat_slot = seat_slot,
-		.x = x,
-		.y = y,
+		.point = *point,
 	};
 
 	post_device_event(device, time,
-- 
2.1.0



More information about the wayland-devel mailing list