diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 4752cacef..a1f9e8951 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 e2e91b071..8026a7699 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