From 7ba87d7062ae7cbd7550dc60af07ec31d7c25530 Mon Sep 17 00:00:00 2001 From: "Tran Ba Khang(MS/EMC31-XC)" Date: Wed, 1 Feb 2023 17:14:53 +0700 Subject: [PATCH] libweston: support API to detect an unmapping commit of surface Add the weston_surface_is_unmapping() api, this will help the shell to detect the commit of a surface is unmapping or not. Suggested-by: Morgane Glidic Signed-off-by: Tran Ba Khang(MS/EMC31-XC) --- include/libweston/libweston.h | 5 ++++- libweston/compositor.c | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index f1032169..4cfe592d 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -1718,7 +1718,7 @@ struct weston_surface { */ const char *role_name; - bool is_mapped; + bool is_mapped, is_unmapping; bool is_opaque; /* An list of per seat pointer constraints. */ @@ -1994,6 +1994,9 @@ weston_view_schedule_repaint(struct weston_view *view); bool weston_surface_is_mapped(struct weston_surface *surface); +bool +weston_surface_is_unmapping(struct weston_surface *surface); + void weston_surface_set_size(struct weston_surface *surface, int32_t width, int32_t height); diff --git a/libweston/compositor.c b/libweston/compositor.c index c2533b4d..d608af9a 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -1806,6 +1806,18 @@ weston_surface_is_mapped(struct weston_surface *surface) return surface->is_mapped; } +/** Check if the weston_surface is emitting an unmapping commit + * + * @param surface The weston_surface. + * + * Returns true if the surface is emitting an unmapping commit. + */ +WL_EXPORT bool +weston_surface_is_unmapping(struct weston_surface *surface) +{ + return surface->is_unmapping; +} + static void surface_set_size(struct weston_surface *surface, int32_t width, int32_t height) { @@ -2570,8 +2582,11 @@ weston_surface_attach(struct weston_surface *surface, BUFFER_WILL_NOT_BE_ACCESSED); if (!buffer) { - if (weston_surface_is_mapped(surface)) + if (weston_surface_is_mapped(surface)) { weston_surface_unmap(surface); + /* This is the unmapping commit */ + surface->is_unmapping = true; + } } surface->compositor->renderer->attach(surface, buffer); @@ -4007,6 +4022,9 @@ weston_surface_commit_state(struct weston_surface *surface, weston_surface_set_desired_protection(surface, state->desired_protection); wl_signal_emit(&surface->commit_signal, surface); + + /* Surface is fully unmapped now */ + surface->is_unmapping = false; } static void