aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Primak <vyivel@posteo.net>2021-10-06 10:55:23 +0300
committerSimon Ser <contact@emersion.fr>2021-10-06 10:15:49 +0200
commitcdaab820201d6aff7ed44da35595df65b9739bea (patch)
treee836c1ba2039d4a6350f31984390ee456a7e4057
parent28248dd83b5b50929fce625838cc4ea29c1e0c40 (diff)
layer-shell: move NULL buffer check to role precommit handler
This will allow compositor to access the current buffer before unmapping.
-rw-r--r--types/wlr_layer_shell_v1.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/types/wlr_layer_shell_v1.c b/types/wlr_layer_shell_v1.c
index 82894c87..4495472a 100644
--- a/types/wlr_layer_shell_v1.c
+++ b/types/wlr_layer_shell_v1.c
@@ -339,15 +339,28 @@ static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
surface->mapped = true;
wlr_signal_emit_safe(&surface->events.map, surface);
}
- if (surface->configured && !wlr_surface_has_buffer(surface->surface) &&
- surface->mapped) {
- layer_surface_unmap(surface);
+}
+
+static void layer_surface_role_precommit(struct wlr_surface *wlr_surface) {
+ struct wlr_layer_surface_v1 *surface =
+ wlr_layer_surface_v1_from_wlr_surface(wlr_surface);
+ if (surface == NULL) {
+ return;
+ }
+
+ if (wlr_surface->pending.committed & WLR_SURFACE_STATE_BUFFER &&
+ wlr_surface->pending.buffer == NULL) {
+ // This is a NULL commit
+ if (surface->configured && surface->mapped) {
+ layer_surface_unmap(surface);
+ }
}
}
static const struct wlr_surface_role layer_surface_role = {
.name = "zwlr_layer_surface_v1",
.commit = layer_surface_role_commit,
+ .precommit = layer_surface_role_precommit,
};
static void handle_surface_destroyed(struct wl_listener *listener,