[PATCH 2/3 v3] wayland-server: Add functions to wl_global

Olivier Fourdan ofourdan at redhat.com
Mon Aug 8 08:10:51 UTC 2016


When using a wl_global, a server may need to retrieve the associated
wl_interface and user data.

Add a couple of convenient functions wl_global_get_interface() and
wl_global_get_user_data() for this purpose.

Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
---
 v3: split out as its own commit

 src/wayland-server-core.h |  6 ++++++
 src/wayland-server.c      | 12 ++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
index b70d85f..2e4e989 100644
--- a/src/wayland-server-core.h
+++ b/src/wayland-server-core.h
@@ -174,6 +174,12 @@ wl_display_set_filter_global(struct wl_display *display,
 			     wl_display_filter_global_func_t filter,
 			     void *data);
 
+const struct wl_interface *
+wl_global_get_interface(const struct wl_global *global);
+
+void *
+wl_global_get_user_data(const struct wl_global *global);
+
 struct wl_client *
 wl_client_create(struct wl_display *display, int fd);
 
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 480af23..9109d98 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -1049,6 +1049,18 @@ wl_global_destroy(struct wl_global *global)
 	free(global);
 }
 
+WL_EXPORT const struct wl_interface *
+wl_global_get_interface(const struct wl_global *global)
+{
+	return global->interface;
+}
+
+WL_EXPORT void *
+wl_global_get_user_data(const struct wl_global *global)
+{
+	return global->data;
+}
+
 /** Get the current serial number
  *
  * \param display The display object
-- 
2.7.4



More information about the wayland-devel mailing list