From 2f2e20f3a3107ad9fb7592c8e86d179a85535582 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 20 Jun 2022 12:44:36 +0100 Subject: [PATCH] weston_surface: Add map and unmap signals These signals are emitted when the surface becomes mapped or unmapped. Signed-off-by: Daniel Stone --- include/libweston/libweston.h | 7 +++++++ libweston/compositor.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 4752cace..a1f9e895 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -1883,6 +1883,13 @@ struct weston_surface { void *committed_private; int (*get_label)(struct weston_surface *surface, char *buf, size_t len); + /* + * Sent when the surface has been mapped and unmapped, respectively. + * The data argument is the weston_surface. + */ + struct wl_signal map_signal; + struct wl_signal unmap_signal; + /* Parent's list of its sub-surfaces, weston_subsurface:parent_link. * Contains also the parent itself as a dummy weston_subsurface, * if the list is not empty. diff --git a/libweston/compositor.c b/libweston/compositor.c index e2e91b07..8026a769 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -676,6 +676,8 @@ weston_surface_create(struct weston_compositor *compositor) wl_signal_init(&surface->destroy_signal); wl_signal_init(&surface->commit_signal); + wl_signal_init(&surface->map_signal); + wl_signal_init(&surface->unmap_signal); surface->compositor = compositor; surface->ref_count = 1; @@ -2122,6 +2124,7 @@ WL_EXPORT void weston_surface_map(struct weston_surface *surface) { surface->is_mapped = true; + weston_signal_emit_mutable(&surface->map_signal, surface); } WL_EXPORT void @@ -2133,6 +2136,7 @@ weston_surface_unmap(struct weston_surface *surface) wl_list_for_each(view, &surface->views, surface_link) weston_view_unmap(view); surface->output = NULL; + weston_signal_emit_mutable(&surface->unmap_signal, surface); } static void