[PATCH libinput gestures 1/4] gestures: check for valid types on the gesture event API

Hans de Goede hdegoede at redhat.com
Fri May 22 00:38:14 PDT 2015


Hi,

On 22-05-15 04:03, Peter Hutterer wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

The entire series looks good to me: Reviewed-by: Hans de Goede <hdegoede at redhat.com>

Regards,

Hans


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


More information about the wayland-devel mailing list