[PATCH weston v3 5/5] clients: Add pointer pinch gesture support to weston-image
Jonas Ådahl
jadahl at gmail.com
Sat Aug 1 23:40:04 PDT 2015
On Fri, Jul 31, 2015 at 03:59:55PM +0200, Carlos Garnacho wrote:
> It will allow zooming in/out the loaded image.
>
> Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
Reviewed-by: Jonas Ådahl <jadahl at gmail.com>
> ---
> clients/image.c | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/clients/image.c b/clients/image.c
> index d28f221..b4339b8 100644
> --- a/clients/image.c
> +++ b/clients/image.c
> @@ -61,6 +61,7 @@ struct image {
>
> bool initialized;
> cairo_matrix_t matrix;
> + float last_scale;
> };
>
> static double
> @@ -330,6 +331,35 @@ axis_handler(struct widget *widget, struct input *input, uint32_t time,
> }
>
> static void
> +pinch_begin_handler(struct widget *widget,
> + struct input *input,
> + uint32_t time,
> + uint32_t n_fingers,
> + void *data)
> +{
> + struct image *image = data;
> +
> + image->last_scale = 1;
> +}
> +
> +static void
> +pinch_update_handler(struct widget *widget,
> + struct input *input,
> + uint32_t time,
> + float dx,
> + float dy,
> + float scale,
> + float rotation_delta,
> + void *data)
> +{
> + struct image *image = data;
> +
> + zoom(image, scale / image->last_scale);
> + window_schedule_redraw(image->window);
> + image->last_scale = scale;
> +}
> +
> +static void
> fullscreen_handler(struct window *window, void *data)
> {
> struct image *image = data;
> @@ -400,6 +430,11 @@ image_create(struct display *display, const char *filename,
> widget_set_button_handler(image->widget, button_handler);
> widget_set_axis_handler(image->widget, axis_handler);
> window_set_key_handler(image->window, key_handler);
> + widget_set_pointer_gesture_pinch_begin_handler(image->widget,
> + pinch_begin_handler);
> + widget_set_pointer_gesture_pinch_update_handler(image->widget,
> + pinch_update_handler);
> +
> widget_schedule_resize(image->widget, 500, 400);
>
> return image;
> --
> 2.4.3
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list