[weston,v6,2/2] window : compare version and call appropriate destructor

Submitted by kabeer.khan@samsung.com on Oct. 20, 2014, 6:25 a.m.

Details

Message ID 1413786329-2648-1-git-send-email-kabeer.khan@samsung.com
State Accepted
Headers show

Not browsing as part of any series.

Commit Message

kabeer.khan@samsung.com Oct. 20, 2014, 6:25 a.m.
From: kabeer khan <kabeer.khan@samsung.com>

Signed-off-by: kabeer khan <kabeer.khan@samsung.com>
---
 clients/window.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/clients/window.c b/clients/window.c
index 139c7f9..c8ed9a2 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -133,6 +133,7 @@  struct display {
 
 	int has_rgb565;
 	int seat_version;
+	int data_device_manager_version;
 };
 
 struct window_output {
@@ -5148,9 +5149,12 @@  input_destroy(struct input *input)
 	if (input->selection_offer)
 		data_offer_destroy(input->selection_offer);
 
-	if (input->data_device)
-		wl_data_device_destroy(input->data_device);
-
+	if (input->data_device) {
+		if(input->display->data_device_manager_version >= 2)
+			wl_data_device_release(input->data_device);
+		else
+			wl_data_device_destroy(input->data_device);
+	}
 	if (input->display->seat_version >= 3) {
 		if (input->pointer)
 			wl_pointer_release(input->pointer);
@@ -5234,9 +5238,10 @@  registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
 		d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
 		wl_shm_add_listener(d->shm, &shm_listener, d);
 	} else if (strcmp(interface, "wl_data_device_manager") == 0) {
+		d->data_device_manager_version = MIN(version, 2);
 		d->data_device_manager =
-			wl_registry_bind(registry, id,
-					 &wl_data_device_manager_interface, 1);
+			wl_registry_bind(registry, id, 
+					 &wl_data_device_manager_interface, d->data_device_manager_version);
 	} else if (strcmp(interface, "xdg_shell") == 0) {
 		d->xdg_shell = wl_registry_bind(registry, id,
 						&xdg_shell_interface, 1);

Comments

2014-10-20 9:25 GMT+03:00  <kabeer.khan@samsung.com>:
> From: kabeer khan <kabeer.khan@samsung.com>
>
> Signed-off-by: kabeer khan <kabeer.khan@samsung.com>
> ---
>  clients/window.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/clients/window.c b/clients/window.c
> index 139c7f9..c8ed9a2 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -133,6 +133,7 @@ struct display {
>
>         int has_rgb565;
>         int seat_version;
> +       int data_device_manager_version;
>  };
>
>  struct window_output {
> @@ -5148,9 +5149,12 @@ input_destroy(struct input *input)
>         if (input->selection_offer)
>                 data_offer_destroy(input->selection_offer);
>
> -       if (input->data_device)
> -               wl_data_device_destroy(input->data_device);
> -
> +       if (input->data_device) {
> +               if(input->display->data_device_manager_version >= 2)
> +                       wl_data_device_release(input->data_device);
> +               else
> +                       wl_data_device_destroy(input->data_device);
> +       }
>         if (input->display->seat_version >= 3) {
>                 if (input->pointer)
>                         wl_pointer_release(input->pointer);
> @@ -5234,9 +5238,10 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
>                 d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
>                 wl_shm_add_listener(d->shm, &shm_listener, d);
>         } else if (strcmp(interface, "wl_data_device_manager") == 0) {
> +               d->data_device_manager_version = MIN(version, 2);
>                 d->data_device_manager =
> -                       wl_registry_bind(registry, id,
> -                                        &wl_data_device_manager_interface, 1);
> +                       wl_registry_bind(registry, id,
> +                                        &wl_data_device_manager_interface, d->data_device_manager_version);

The version used here should be MIN(d->data_device_manager_version, version)


>         } else if (strcmp(interface, "xdg_shell") == 0) {
>                 d->xdg_shell = wl_registry_bind(registry, id,
>                                                 &xdg_shell_interface, 1);
> --
> 2.1.0
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
On 10/20/2014 01:01 AM, Giulio Camuffo wrote:

>> +               d->data_device_manager_version = MIN(version, 2);
>>                  d->data_device_manager =
>> -                       wl_registry_bind(registry, id,
>> -                                        &wl_data_device_manager_interface, 1);
>> +                       wl_registry_bind(registry, id,
>> +                                        &wl_data_device_manager_interface, d->data_device_manager_version);
>
> The version used here should be MIN(d->data_device_manager_version, version)

Looks to me like that value was set to MIN(2, version) in the top line 
of this patch so that is going to be the same value.
On Mon, 20 Oct 2014 11:55:29 +0530
kabeer.khan@samsung.com wrote:

> From: kabeer khan <kabeer.khan@samsung.com>
> 
> Signed-off-by: kabeer khan <kabeer.khan@samsung.com>
> ---
>  clients/window.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/clients/window.c b/clients/window.c
> index 139c7f9..c8ed9a2 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -133,6 +133,7 @@ struct display {
>  
>  	int has_rgb565;
>  	int seat_version;
> +	int data_device_manager_version;
>  };
>  
>  struct window_output {
> @@ -5148,9 +5149,12 @@ input_destroy(struct input *input)
>  	if (input->selection_offer)
>  		data_offer_destroy(input->selection_offer);
>  
> -	if (input->data_device)
> -		wl_data_device_destroy(input->data_device);
> -
> +	if (input->data_device) {
> +		if(input->display->data_device_manager_version >= 2)
> +			wl_data_device_release(input->data_device);
> +		else
> +			wl_data_device_destroy(input->data_device);
> +	}
>  	if (input->display->seat_version >= 3) {
>  		if (input->pointer)
>  			wl_pointer_release(input->pointer);
> @@ -5234,9 +5238,10 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
>  		d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
>  		wl_shm_add_listener(d->shm, &shm_listener, d);
>  	} else if (strcmp(interface, "wl_data_device_manager") == 0) {
> +		d->data_device_manager_version = MIN(version, 2);
>  		d->data_device_manager =
> -			wl_registry_bind(registry, id,
> -					 &wl_data_device_manager_interface, 1);
> +			wl_registry_bind(registry, id, 
> +					 &wl_data_device_manager_interface, d->data_device_manager_version);

I removed a trailing space and split the long line.

>  	} else if (strcmp(interface, "xdg_shell") == 0) {
>  		d->xdg_shell = wl_registry_bind(registry, id,
>  						&xdg_shell_interface, 1);

Pushed with the above changes.


Thanks,
pq