From a1298580cc4ba5fab25be4d043e4f5879c4eb9ba Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Wed, 14 Aug 2024 18:22:41 +0300 Subject: [PATCH] compositor: add surface role map hook --- include/wlr/types/wlr_compositor.h | 7 +++++++ types/wlr_compositor.c | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/include/wlr/types/wlr_compositor.h b/include/wlr/types/wlr_compositor.h index 174869f4..d0d25b7a 100644 --- a/include/wlr/types/wlr_compositor.h +++ b/include/wlr/types/wlr_compositor.h @@ -97,6 +97,13 @@ struct wlr_surface_role { * such object exists. */ void (*commit)(struct wlr_surface *surface); + /** + * Called when the surface is mapped. May be NULL. + * + * If the role is represented by an object, this is only called if + * such object exists. + */ + void (*map)(struct wlr_surface *surface); /** * Called when the surface is unmapped. May be NULL. * diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c index 9aee912e..081af353 100644 --- a/types/wlr_compositor.c +++ b/types/wlr_compositor.c @@ -828,6 +828,11 @@ void wlr_surface_map(struct wlr_surface *surface) { subsurface_consider_map(subsurface); } + if (surface->role != NULL && surface->role->map != NULL && + (surface->role_resource != NULL || surface->role->no_object)) { + surface->role->map(surface); + } + wl_signal_emit_mutable(&surface->events.map, NULL); }