diff options
author | Andri Yngvason <andri@yngvason.is> | 2022-11-21 22:08:15 +0000 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-02-11 12:19:56 +0000 |
commit | d16d39f74a98eb727319c6c026ba4b82054e6269 (patch) | |
tree | 1c35a3c470ef903da71a6e3016615758b79a803c | |
parent | d443241635cf86e4fdb91a781ec702bc8828d703 (diff) | |
download | wayland-d16d39f74a98eb727319c6c026ba4b82054e6269.tar.gz |
wayland-server: Add method to get global name
This is useful for protocol designs where globals need to be referenced
in some manner.
Signed-off-by: Andri Yngvason <andri@yngvason.is>
-rw-r--r-- | src/wayland-server-core.h | 4 | ||||
-rw-r--r-- | src/wayland-server.c | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h index d9917a0..df95821 100644 --- a/src/wayland-server-core.h +++ b/src/wayland-server-core.h @@ -280,6 +280,10 @@ const struct wl_interface * wl_global_get_interface(const struct wl_global *global); uint32_t +wl_global_get_name(const struct wl_global *global, + const struct wl_client *client); + +uint32_t wl_global_get_version(const struct wl_global *global); struct wl_display * diff --git a/src/wayland-server.c b/src/wayland-server.c index 0e15da3..d51acc6 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -1369,6 +1369,23 @@ wl_global_get_interface(const struct wl_global *global) return global->interface; } +/** Get the name of the global. + * + * \param global The global object. + * \param client Client for which to look up the global. + * \return The name of the global, or 0 if the global is not visible to the + * client. + * + * \memberof wl_global + * \since 1.22 + */ +WL_EXPORT uint32_t +wl_global_get_name(const struct wl_global *global, + const struct wl_client *client) +{ + return wl_global_is_visible(client, global) ? global->name : 0; +} + /** Get the version of the given global. * * \param global The global object. |