[PATCH v1] Added touch support to wayland backend

Peter Hutterer peter.hutterer at who-t.net
Sun Jan 11 15:56:20 PST 2015


On Wed, Dec 17, 2014 at 04:11:56PM +0200, Imran Zaman wrote:
> Nested westons (with wayland backend as child weston) is one possible
> use case for the needed touch support.
> 
> Signed-off-by: Imran Zaman <imran.zaman at gmail.com>

Have a look at these patches:
http://lists.freedesktop.org/archives/wayland-devel/2014-May/014648.html
they seem to address the same thing but do a bit more, and Jason had a few
comments on them. I suspect the same comments still apply.

(bug ref is https://bugs.freedesktop.org/show_bug.cgi?id=77769)

Cheers,
   Peter


> ---
>  src/compositor-wayland.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
> 
> diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
> index 65bce39..f125210 100644
> --- a/src/compositor-wayland.c
> +++ b/src/compositor-wayland.c
> @@ -1581,6 +1581,53 @@ static const struct wl_keyboard_listener keyboard_listener = {
>  };
>  
>  static void
> +input_handle_touch_down(void *data, struct wl_touch *wl_touch,
> +		        uint32_t serial, uint32_t time,
> +		        struct wl_surface *surface, int32_t id, wl_fixed_t x_w,
> +		        wl_fixed_t y_w)
> +{
> +	struct wayland_input *input = data;
> +	notify_touch(&input->base, time, id, x_w, y_w, WL_TOUCH_DOWN);
> +}
> +
> +static void
> +input_handle_touch_up(void *data, struct wl_touch *wl_touch,
> +		      uint32_t serial, uint32_t time, int32_t id)
> +{
> +	struct wayland_input *input = data;
> +	notify_touch(&input->base, time, id, 0, 0, WL_TOUCH_UP);
> +}
> +
> +static void
> +input_handle_touch_motion(void *data, struct wl_touch *wl_touch,
> +			  uint32_t time, int32_t id, wl_fixed_t x_w,
> +			  wl_fixed_t y_w)
> +{
> +	struct wayland_input *input = data;
> +	notify_touch(&input->base, time, id, x_w, y_w, WL_TOUCH_MOTION);
> +}
> +
> +static void
> +input_handle_touch_frame(void *data, struct wl_touch *wl_touch)
> +{
> +	struct wayland_input *input = data;
> +	notify_touch_frame(&input->base);
> +}
> +
> +static void
> +input_handle_touch_cancel(void *data, struct wl_touch *wl_touch)
> +{
> +}
> +
> +static const struct wl_touch_listener touch_listener = {
> +		input_handle_touch_down,
> +		input_handle_touch_up,
> +		input_handle_touch_motion,
> +		input_handle_touch_frame,
> +		input_handle_touch_cancel,
> +};
> +
> +static void
>  input_handle_capabilities(void *data, struct wl_seat *seat,
>  		          enum wl_seat_capability caps)
>  {
> @@ -1606,6 +1653,18 @@ input_handle_capabilities(void *data, struct wl_seat *seat,
>  		wl_keyboard_destroy(input->parent.keyboard);
>  		input->parent.keyboard = NULL;
>  	}
> +
> +	if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !input->parent.touch) {
> +		input->parent.touch = wl_seat_get_touch(seat);
> +		weston_seat_init_touch (&input->base);
> +		wl_touch_set_user_data(input->parent.touch, input);
> +		wl_touch_add_listener(input->parent.touch,
> +				&touch_listener, input);
> +	} else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->parent.touch) {
> +		weston_seat_release_touch (&input->base);
> +		wl_touch_destroy(input->parent.touch);
> +		input->parent.touch = NULL;
> +	}
>  }
>  
>  static void
> -- 
> 1.9.1
> 
> _______________________________________________
> 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