From 2faf491f6119d9c03a8b43096be12f89c9698c6d Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 12 Jul 2023 18:48:34 +0100 Subject: [PATCH] surface: Add weston_surface_is_mapping() The counterpart to weston_surface_is_unmapping(). This is valid for the duration of processing the surface commit. Signed-off-by: Daniel Stone --- include/libweston/libweston.h | 5 ++++- libweston/compositor.c | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index bb7bb27c7..dd1f76ec6 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -1927,7 +1927,7 @@ struct weston_surface { */ const char *role_name; - bool is_mapped, is_unmapping; + bool is_mapped, is_unmapping, is_mapping; bool is_opaque; /* An list of per seat pointer constraints. */ @@ -2244,6 +2244,9 @@ weston_view_schedule_repaint(struct weston_view *view); bool weston_surface_is_mapped(struct weston_surface *surface); +bool +weston_surface_is_mapping(struct weston_surface *surface); + bool weston_surface_is_unmapping(struct weston_surface *surface); diff --git a/libweston/compositor.c b/libweston/compositor.c index 3bc6000f7..906ec8d89 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -2139,6 +2139,18 @@ weston_surface_is_mapped(struct weston_surface *surface) return surface->is_mapped; } +/** Check if the weston_surface is emitting an mapping commit + * + * @param surface The weston_surface. + * + * Returns true if the surface is emitting an mapping commit. + */ +WL_EXPORT bool +weston_surface_is_mapping(struct weston_surface *surface) +{ + return surface->is_mapping; +} + /** Check if the weston_surface is emitting an unmapping commit * * @param surface The weston_surface. @@ -2362,6 +2374,7 @@ weston_surface_map(struct weston_surface *surface) if (weston_surface_is_mapped(surface)) return; + surface->is_mapping = true; surface->is_mapped = true; surface->compositor->view_list_needs_rebuild = true; weston_signal_emit_mutable(&surface->map_signal, surface); @@ -4481,8 +4494,9 @@ weston_surface_commit_state(struct weston_surface *surface, wl_signal_emit(&surface->commit_signal, surface); - /* Surface is fully unmapped now */ + /* Surface is now quiescent */ surface->is_unmapping = false; + surface->is_mapping = false; state->status = WESTON_SURFACE_CLEAN; return status;