Use typesafe coordinates in touch events
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 11 Mar 2015 00:48:54 +0000 (10:48 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 16 Mar 2015 23:02:12 +0000 (09:02 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
src/evdev.c
src/libinput-private.h
src/libinput.c

index d1b0504..cab7e85 100644 (file)
@@ -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);
                }
index a7e0b07..91bfc37 100644 (file)
@@ -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,
index a7956d6..6dac12b 100644 (file)
@@ -111,8 +111,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
@@ -588,7 +587,7 @@ libinput_event_touch_get_x(struct libinput_event_touch *event)
                           LIBINPUT_EVENT_TOUCH_DOWN,
                           LIBINPUT_EVENT_TOUCH_MOTION);
 
-       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
@@ -604,7 +603,7 @@ libinput_event_touch_get_x_transformed(struct libinput_event_touch *event,
                           LIBINPUT_EVENT_TOUCH_DOWN,
                           LIBINPUT_EVENT_TOUCH_MOTION);
 
-       return evdev_device_transform_x(device, event->x, width);
+       return evdev_device_transform_x(device, event->point.x, width);
 }
 
 LIBINPUT_EXPORT double
@@ -620,7 +619,7 @@ libinput_event_touch_get_y_transformed(struct libinput_event_touch *event,
                           LIBINPUT_EVENT_TOUCH_DOWN,
                           LIBINPUT_EVENT_TOUCH_MOTION);
 
-       return evdev_device_transform_y(device, event->y, height);
+       return evdev_device_transform_y(device, event->point.y, height);
 }
 
 LIBINPUT_EXPORT double
@@ -635,7 +634,7 @@ libinput_event_touch_get_y(struct libinput_event_touch *event)
                           LIBINPUT_EVENT_TOUCH_DOWN,
                           LIBINPUT_EVENT_TOUCH_MOTION);
 
-       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 *
@@ -1205,8 +1204,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;
 
@@ -1218,8 +1216,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,
@@ -1232,8 +1229,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;
 
@@ -1245,8 +1241,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,