[PATCH] Add wl_display_remove_global.

Kristian Høgsberg krh at bitplanet.net
Mon Jun 20 12:46:03 PDT 2011


2011/6/14 Laszlo Agocs <laszlo.p.agocs at nokia.com>:
>
> Hi Kristian,
>
> True, I forgot about the client-side global list. Attached is a revised
> patch.

Thanks, I committed this (with a few whitespace and codestyle
adjustments), since it brings copy/paste and dnd back for now.
However, reviewing the patch, brought back some of the issues I had
when I did the protocol and I'd like to tweak how dnd and selections
work a bit.  The core of the problem is that announcing the drag or
selection offer as a global is a bit of a hack.  It's not meant to be
an object that's available to all clients.

Now that we have the display.bind request, the server can know whether
a client (if it has bound to the wl_shell object).  In that case, we
can just send out an event with the selection offer object, which will
be equvalent to the end result of the global + create_proxy + bind
sequence we do now.

Also, I want to split the dnd and selection from wl_shell, as wl_shell
isn't something I'm willing to commit to in the short term (ie it's
experimental).  So I'm looking at the protocol changed that I've
attached.  The idea is that if you support dnd, you'll bind to the
wl_dnd global object, which will then let you initiate dnd (by
creating the wl_drag_source) and it will indicate to the server that
you can handle the server sending you wl_drag_offer objects.  Similar
for wl_selection.

Kristian

> Regards,
> Laszlo
>
> On 06/10/2011 05:55 PM, ext Kristian Høgsberg wrote:
>>
>> Hi Laszlo,
>>
>> Thanks, this is definitely needed.  However,  we'll also need to send
>> an event to all clients to indicate that the object is no longer
>> available, so they can take it out of their global list.  That is, the
>> opposite of display_handle_global:
>>
>>
>> http://cgit.freedesktop.org/wayland/wayland/tree/wayland/wayland-client.c#n234
>>
>> Kristian
>>
>> On Fri, Jun 10, 2011 at 6:43 AM, Laszlo Agocs<laszlo.p.agocs at nokia.com>
>>  wrote:
>>>
>>>  From 9306be3637fd36aca936cfd797298a8e22c88c56 Mon Sep 17 00:00:00 2001
>>> From: Laszlo Agocs<laszlo.p.agocs at nokia.com>
>>> Date: Fri, 10 Jun 2011 11:17:51 +0200
>>> Subject: [PATCH] Add wl_display_remove_global.
>>>
>>> Change 4453ba084aae5a00318b9dfdeda95e8eaa17494c disallows using
>>> post_global with objects not on the global list. Therefore selection
>>> and drag offers have to be added to the global list from now on.
>>> However these may often get replaced by a newer object and thus need a
>>> way to remove a global from the global list.
>>> ---
>>>  wayland/wayland-server.c |   18 ++++++++++++++++++
>>>  wayland/wayland-server.h |    3 +++
>>>  2 files changed, 21 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c
>>> index 886ec69..043343a 100644
>>> --- a/wayland/wayland-server.c
>>> +++ b/wayland/wayland-server.c
>>> @@ -656,6 +656,24 @@ wl_display_add_global(struct wl_display *display,
>>>        return 0;
>>>  }
>>>
>>> +WL_EXPORT int
>>> +wl_display_remove_global(struct wl_display *display,
>>> +                         struct wl_object *object)
>>> +{
>>> +    struct wl_global *global = NULL, *p;
>>> +    wl_list_for_each(p,&display->global_list, link)
>>> +        if (p->object == object) {
>>> +            global = p;
>>> +            break;
>>> +        }
>>> +    if (global) {
>>> +        wl_list_remove(&global->link);
>>> +        free(global);
>>> +        return 0;
>>> +    }
>>> +    return -1;
>>> +}
>>> +
>>>  WL_EXPORT void
>>>  wl_display_post_frame(struct wl_display *display, struct wl_surface
>>> *surface,
>>>                      uint32_t time)
>>> diff --git a/wayland/wayland-server.h b/wayland/wayland-server.h
>>> index 6a042cd..d1c655a 100644
>>> --- a/wayland/wayland-server.h
>>> +++ b/wayland/wayland-server.h
>>> @@ -93,6 +93,9 @@ int wl_display_add_global(struct wl_display *display,
>>>                          struct wl_object *object,
>>>                          wl_global_bind_func_t func);
>>>
>>> +int wl_display_remove_global(struct wl_display *display,
>>> +                             struct wl_object *object);
>>> +
>>>  struct wl_client *wl_client_create(struct wl_display *display, int fd);
>>>  void wl_client_destroy(struct wl_client *client);
>>>  void wl_client_post_error(struct wl_client *client, struct wl_object
>>> *object,
>>> --
>>> 1.7.1
>>>
>>>
>>> _______________________________________________
>>> wayland-devel mailing list
>>> wayland-devel at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>>>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dnd-selection-change.patch
Type: text/x-patch
Size: 2684 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20110620/58e0cc44/attachment.bin>


More information about the wayland-devel mailing list