diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2014-10-14 18:52:56 +0100 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2015-02-18 15:55:51 +0100 |
commit | 51ef0505a699454a3c44fd5565277a1f1c6e8d71 (patch) | |
tree | ed2ec0b63faa6e37204c8b47a699ae8a496953dd | |
parent | f3a5ca999e7efabc873bd2ee1d5fbe07e1e73ddd (diff) |
server: add helper functions for wl_globalwl-global-extras
The intention here is to be able to find an existing wl_global using
some search parameters and then get some information about it.
-rw-r--r-- | src/wayland-server.c | 33 | ||||
-rw-r--r-- | src/wayland-server.h | 4 |
2 files changed, 37 insertions, 0 deletions
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); |