[PATCH libinput gestures 1/4] gestures: check for valid types on the gesture event API
Peter Hutterer
peter.hutterer at who-t.net
Thu May 21 19:03:54 PDT 2015
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/libinput.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/src/libinput.c b/src/libinput.c
index 1c50284..0346578 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -665,30 +665,68 @@ libinput_event_touch_get_y(struct libinput_event_touch *event)
LIBINPUT_EXPORT uint32_t
libinput_event_gesture_get_time(struct libinput_event_gesture *event)
{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0,
+ LIBINPUT_EVENT_GESTURE_PINCH_START,
+ LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
+ LIBINPUT_EVENT_GESTURE_PINCH_END,
+ LIBINPUT_EVENT_GESTURE_SWIPE_START,
+ LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
+ LIBINPUT_EVENT_GESTURE_SWIPE_END);
+
return event->time;
}
LIBINPUT_EXPORT int
libinput_event_gesture_get_finger_count(struct libinput_event_gesture *event)
{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0,
+ LIBINPUT_EVENT_GESTURE_PINCH_START,
+ LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
+ LIBINPUT_EVENT_GESTURE_PINCH_END,
+ LIBINPUT_EVENT_GESTURE_SWIPE_START,
+ LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
+ LIBINPUT_EVENT_GESTURE_SWIPE_END);
+
return event->finger_count;
}
LIBINPUT_EXPORT int
libinput_event_gesture_get_cancelled(struct libinput_event_gesture *event)
{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0,
+ LIBINPUT_EVENT_GESTURE_PINCH_END,
+ LIBINPUT_EVENT_GESTURE_SWIPE_END);
+
return event->cancelled;
}
LIBINPUT_EXPORT double
libinput_event_gesture_get_dx(struct libinput_event_gesture *event)
{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0.0,
+ LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
+ LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE);
+
return event->delta.x;
}
LIBINPUT_EXPORT double
libinput_event_gesture_get_dy(struct libinput_event_gesture *event)
{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0.0,
+ LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
+ LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE);
+
return event->delta.y;
}
@@ -696,6 +734,12 @@ LIBINPUT_EXPORT double
libinput_event_gesture_get_dx_unaccelerated(
struct libinput_event_gesture *event)
{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0.0,
+ LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
+ LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE);
+
return event->delta_unaccel.x;
}
@@ -703,18 +747,34 @@ LIBINPUT_EXPORT double
libinput_event_gesture_get_dy_unaccelerated(
struct libinput_event_gesture *event)
{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0.0,
+ LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
+ LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE);
+
return event->delta_unaccel.y;
}
LIBINPUT_EXPORT double
libinput_event_gesture_get_scale(struct libinput_event_gesture *event)
{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0.0,
+ LIBINPUT_EVENT_GESTURE_PINCH_UPDATE);
+
return event->scale;
}
LIBINPUT_EXPORT double
libinput_event_gesture_get_angle(struct libinput_event_gesture *event)
{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0.0,
+ LIBINPUT_EVENT_GESTURE_PINCH_UPDATE);
+
return event->angle;
}
--
2.3.5
More information about the wayland-devel
mailing list