[PATCH wayland] server: add helper functions for wl_global

Derek Foreman derekf at osg.samsung.com
Mon Feb 23 08:28:48 PST 2015


On 23/02/15 10:02 AM, Jonny Lamb wrote:
> The intention here is to be able to find an existing wl_global using
> some search parameters and then get some information about it.

I'm not sure I see a need for this, but if there is need there should
also be documentation. :)

> ---
>  src/wayland-server.c | 33 +++++++++++++++++++++++++++++++++
>  src/wayland-server.h |  4 ++++
>  2 files changed, 37 insertions(+)
> 
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index 0558634..5dd6c71 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -945,6 +945,39 @@ wl_global_destroy(struct wl_global *global)
>  	free(global);
>  }
>  
> +WL_EXPORT void *
> +wl_global_get_data(struct wl_global *global)
> +{
> +	return global->data;
> +}
> +
> +WL_EXPORT struct wl_global *
> +wl_global_find(struct wl_display *display,
> +	const struct wl_interface *interface, uint32_t version,
> +	void *data, wl_global_bind_func_t bind)
> +{
> +	struct wl_global *global;
> +
> +	/* return with nothing if we have no search parameters */
> +	if (interface == NULL && version == 0 && data == NULL && bind == NULL)
> +		return NULL;
> +
> +	wl_list_for_each(global, &display->global_list, link) {
> +		if (interface != NULL && global->interface != interface)
> +			continue;
> +		if (version != 0 && global->version != version)
> +			continue;
> +		if (data != NULL && global->data != data)
> +			continue;
> +		if (bind != NULL && global->bind != bind)
> +			continue;
> +
> +		return global;
> +	}
> +
> +	return NULL;
> +}
> +
>  /** Get the current serial number
>   *
>   * \param display The display object
> diff --git a/src/wayland-server.h b/src/wayland-server.h
> index af2f03d..05449dc 100644
> --- a/src/wayland-server.h
> +++ b/src/wayland-server.h
> @@ -113,6 +113,10 @@ struct wl_global *wl_global_create(struct wl_display *display,
>  				   int version,
>  				   void *data, wl_global_bind_func_t bind);
>  void wl_global_destroy(struct wl_global *global);
> +void *wl_global_get_data(struct wl_global *global);
> +struct wl_global *wl_global_find(struct wl_display *display,
> +	const struct wl_interface *interface, uint32_t version,
> +	void *data, wl_global_bind_func_t bind);
>  
>  struct wl_client *wl_client_create(struct wl_display *display, int fd);
>  void wl_client_destroy(struct wl_client *client);
> 



More information about the wayland-devel mailing list