[PATCH v2 2/2] Implement data_device interface destructor

Pekka Paalanen ppaalanen at gmail.com
Tue Aug 26 04:56:30 PDT 2014


On Fri, 22 Aug 2014 19:17:55 +0530
kabeer.khan at samsung.com wrote:

> From: kabeer <kabeer.khan at samsung.com>
> 
> window: use data_device interface destructor
> data-device: implement data_device_release destructor
> 
> Signed-off-by: kabeer <kabeer.khan at samsung.com>
> ---
>  clients/window.c  |    2 +-
>  src/data-device.c |    6 ++++++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/clients/window.c b/clients/window.c
> index 5d64022..001cfb8 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -5049,7 +5049,7 @@ input_destroy(struct input *input)
>  		data_offer_destroy(input->selection_offer);
>  
>  	if (input->data_device)
> -		wl_data_device_destroy(input->data_device);
> +		wl_data_device_release(input->data_device);

You should check the interface version here, that the release request
is actually implemented in the compositor. You need to store the
version when you bind to the wl_data_device_manager global, and check
it here.

>  
>  	if (input->display->seat_version >= 3) {
>  		if (input->pointer)
> diff --git a/src/data-device.c b/src/data-device.c
> index 75fc60c..9dca58b 100644
> --- a/src/data-device.c
> +++ b/src/data-device.c
> @@ -761,10 +761,16 @@ data_device_set_selection(struct wl_client *client,
>  				  wl_resource_get_user_data(source_resource),
>  				  serial);
>  }
> +static void
> +data_device_release(struct wl_client *client, struct wl_resource *resource)
> +{
> +       wl_resource_destroy(resource);
> +}
>  
>  static const struct wl_data_device_interface data_device_interface = {
>  	data_device_start_drag,
>  	data_device_set_selection,
> +	data_device_release
>  };
>  
>  static void

You are missing all the interface version bumps. wl_data_device_manager
needs to be advertised with the new version in the compositor. In the
client, the advertised version needs to be checked, and bound with
min(advertised_version, my_supported_version).

All this is to let things still work if the compositor does not
implement the new version. Someone might be running the Weston demos on
some other compositor.


Thanks,
pq


More information about the wayland-devel mailing list