From 8cad6f7b826546e4faa2d366aed898b5651f73b4 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 6 May 2025 23:48:57 +0200 Subject: [PATCH] server: add wl_resource_get_interface() This is useful for the wayland bindings/scanner I'm working on for a dynamically typed language. Signed-off-by: Isaac Freund --- src/wayland-server-core.h | 3 +++ src/wayland-server.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h index 005a3249..c2dcc218 100644 --- a/src/wayland-server-core.h +++ b/src/wayland-server-core.h @@ -621,6 +621,9 @@ wl_resource_instance_of(struct wl_resource *resource, const char * wl_resource_get_class(const struct wl_resource *resource); +const struct wl_interface * +wl_resource_get_interface(struct wl_resource *resource); + void wl_resource_add_destroy_listener(struct wl_resource *resource, struct wl_listener *listener); diff --git a/src/wayland-server.c b/src/wayland-server.c index e5805669..fb99eb23 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -905,6 +905,20 @@ wl_resource_get_class(const struct wl_resource *resource) return resource->object.interface->name; } +/** Get the interface of a resource object + * + * \param resource The resource object + * \return The interface of the object associated with the resource + * + * \memberof wl_resource + * \since 1.24 + */ +WL_EXPORT const struct wl_interface * +wl_resource_get_interface(struct wl_resource *resource) +{ + return resource->object.interface; +} + /** * Add a listener to be called at the beginning of wl_client destruction *