diff options
author | Simon Ser <contact@emersion.fr> | 2022-11-11 16:32:21 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-11-24 21:55:24 +0000 |
commit | 1978a91717758ae118acdee936c96afbc46e85ca (patch) | |
tree | bbe81977ab528312a253aff7eb684ed4f548de12 | |
parent | 359df5ef84b7259a5fc82a0adf3aae551245fc15 (diff) |
compositor: release current buffer after commit event
Some compositors may want to access the original buffer in their
commit handler.
-rw-r--r-- | types/wlr_compositor.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c index 3362777f..1f85e4ae 100644 --- a/types/wlr_compositor.c +++ b/types/wlr_compositor.c @@ -373,9 +373,6 @@ static void surface_apply_damage(struct wlr_surface *surface) { struct wlr_client_buffer *buffer = wlr_client_buffer_create( surface->current.buffer, surface->renderer); - wlr_buffer_unlock(surface->current.buffer); - surface->current.buffer = NULL; - if (buffer == NULL) { wlr_log(WLR_ERROR, "Failed to upload buffer"); return; @@ -495,6 +492,12 @@ static void surface_commit_state(struct wlr_surface *surface, } wl_signal_emit_mutable(&surface->events.commit, surface); + + // Release the buffer after emitting the commit event, so that listeners can + // access it. Don't leave the buffer locked so that wl_shm buffers can be + // released immediately on commit when they are uploaded to the GPU. + wlr_buffer_unlock(surface->current.buffer); + surface->current.buffer = NULL; } static void surface_handle_commit(struct wl_client *client, |