[PATCH] wl-server: add wl_client_get_object_for_interface

Philipp Brüschweiler blei42 at gmail.com
Mon Aug 13 05:38:27 PDT 2012


Consider this retracted.

Cheers,
Philipp

On Sat, Aug 11, 2012 at 12:15 PM, Philipp Brüschweiler <blei42 at gmail.com> wrote:
> This method makes it possible to get access to an object assigned to a
> client that implements a certain interface and has a certain data.
> ---
>  src/wayland-server.c | 34 ++++++++++++++++++++++++++++++++++
>  src/wayland-server.h |  4 ++++
>  2 Dateien geändert, 38 Zeilen hinzugefügt(+)
>
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index 88e8433..55b2f04 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -412,6 +412,40 @@ wl_client_get_object(struct wl_client *client, uint32_t id)
>         return wl_map_lookup(&client->objects, id);
>  }
>
> +struct wl_client_get_object_data {
> +       const struct wl_interface *interface;
> +       void *data;
> +       struct wl_resource *result;
> +};
> +
> +static void
> +wl_client_get_object_for_interface_helper(void *element, void *data)
> +{
> +       struct wl_resource *resource = element;
> +       struct wl_client_get_object_data *search_data = data;
> +
> +       if (resource->object.interface == search_data->interface
> +           && resource->data == search_data->data)
> +               search_data->result = resource;
> +}
> +
> +WL_EXPORT struct wl_resource *
> +wl_client_get_object_for_interface(struct wl_client *client,
> +                                  const struct wl_interface *interface,
> +                                  void *data)
> +{
> +       struct wl_client_get_object_data search_data;
> +       search_data.interface = interface;
> +       search_data.data = data;
> +       search_data.result = NULL;
> +
> +       wl_map_for_each(&client->objects,
> +                       wl_client_get_object_for_interface_helper,
> +                       &search_data);
> +
> +       return search_data.result;
> +}
> +
>  WL_EXPORT void
>  wl_resource_post_no_memory(struct wl_resource *resource)
>  {
> diff --git a/src/wayland-server.h b/src/wayland-server.h
> index f092145..9d743bc 100644
> --- a/src/wayland-server.h
> +++ b/src/wayland-server.h
> @@ -123,6 +123,10 @@ wl_client_new_object(struct wl_client *client,
>                      const void *implementation, void *data);
>  struct wl_resource *
>  wl_client_get_object(struct wl_client *client, uint32_t id);
> +struct wl_resource *
> +wl_client_get_object_for_interface(struct wl_client *client,
> +                                  const struct wl_interface *interface,
> +                                  void *data);
>
>  struct wl_listener {
>         struct wl_list link;
> --
> 1.7.11.4
>


More information about the wayland-devel mailing list