weston_surface: Add map and unmap signals

These signals are emitted when the surface becomes mapped or unmapped.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2022-06-20 12:44:36 +01:00
parent 47180ad253
commit 2f2e20f3a3
2 changed files with 11 additions and 0 deletions

View File

@ -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.

View File

@ -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