[PATCH] weston: release keyboard/touch/pointer objects

Jonas Ã…dahl jadahl at gmail.com
Wed Oct 7 20:14:40 PDT 2015


On Tue, Oct 06, 2015 at 10:59:32AM +0200, David FORT wrote:
> This patch adds the missing calls to release when the seat has capabilities
> changes. It also fixes a missing release of the touch object.
> ---
>  clients/window.c | 23 +++++++++++++++++++----
>  1 file changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/clients/window.c b/clients/window.c
> index 47a79aa..7469259 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -79,6 +79,10 @@ typedef void *EGLContext;
>  #include "ivi-application-client-protocol.h"
>  #define IVI_SURFACE_ID 9000
>  
> +#define WL_KEYBOARD_RELEASE_SINCE_VERSION 3
> +#define WL_POINTER_RELEASE_SINCE_VERSION 3
> +#define WL_TOUCH_RELEASE_SINCE_VERSION 3

The code below looks good, but I don't think we should define macros
prefixed with WL_ since that'd be something wayland might do.
I just sent a patch (CC:ed you on it) that makes scanner.c generate
these for us, just sa we do with events. If we don't go with generating
the _SINCE_VERSION macros for requests, then you should probably prefix
them in some way.


Jonas

> +
>  struct shm_pool;
>  
>  struct global {
> @@ -3256,7 +3260,10 @@ seat_handle_capabilities(void *data, struct wl_seat *seat,
>  		wl_pointer_add_listener(input->pointer, &pointer_listener,
>  					input);
>  	} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
> -		wl_pointer_destroy(input->pointer);
> +		if (input->display->seat_version >= WL_POINTER_RELEASE_SINCE_VERSION)
> +			wl_pointer_release(input->pointer);
> +		else
> +			wl_pointer_destroy(input->pointer);
>  		input->pointer = NULL;
>  	}
>  
> @@ -3266,7 +3273,10 @@ seat_handle_capabilities(void *data, struct wl_seat *seat,
>  		wl_keyboard_add_listener(input->keyboard, &keyboard_listener,
>  					 input);
>  	} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
> -		wl_keyboard_destroy(input->keyboard);
> +		if (input->display->seat_version >= WL_KEYBOARD_RELEASE_SINCE_VERSION)
> +			wl_keyboard_release(input->keyboard);
> +		else
> +			wl_keyboard_destroy(input->keyboard);
>  		input->keyboard = NULL;
>  	}
>  
> @@ -3275,7 +3285,10 @@ seat_handle_capabilities(void *data, struct wl_seat *seat,
>  		wl_touch_set_user_data(input->touch, input);
>  		wl_touch_add_listener(input->touch, &touch_listener, input);
>  	} else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) {
> -		wl_touch_destroy(input->touch);
> +		if (input->display->seat_version >= WL_TOUCH_RELEASE_SINCE_VERSION)
> +			wl_touch_release(input->touch);
> +		else
> +			wl_touch_destroy(input->touch);
>  		input->touch = NULL;
>  	}
>  }
> @@ -5269,7 +5282,9 @@ input_destroy(struct input *input)
>  		else
>  			wl_data_device_destroy(input->data_device);
>  	}
> -	if (input->display->seat_version >= 3) {
> +	if (input->display->seat_version >= WL_POINTER_RELEASE_SINCE_VERSION) {
> +		if (input->touch)
> +			wl_touch_release(input->touch);
>  		if (input->pointer)
>  			wl_pointer_release(input->pointer);
>  		if (input->keyboard)
> -- 
> 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