Use typesafe coordinates in touch events

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Peter Hutterer 2015-03-11 10:48:54 +10:00
parent 2d54b550b7
commit a3c8d72625
3 changed files with 16 additions and 26 deletions

View 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);
}

View 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,

View 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,