aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-07-02 11:49:53 +0200
committerSimon Ser <contact@emersion.fr>2021-07-05 10:20:19 +0200
commitc7018a45b7ff0fada06a1f825e168e845fa30209 (patch)
tree4ab46fdd63eb624454c63439f50a446ab06afaa5
parent0a522cb79885667e1ca3cafd0b6581ba8a3e92d1 (diff)
downloadwlroots-c7018a45b7ff0fada06a1f825e168e845fa30209.tar.xz
surface: allow locking pending state in commit handler
We were bumping the pending sequence number after emitting the commit event, so commit handlers were seeing inconsistent state where current.seq == pending.seq. This prevents commit handlers from immediately locking the pending state. Fix this by bumping the pending sequence number before firing the commit event.
-rw-r--r--types/wlr_surface.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/types/wlr_surface.c b/types/wlr_surface.c
index 512449f2..555859d9 100644
--- a/types/wlr_surface.c
+++ b/types/wlr_surface.c
@@ -415,6 +415,8 @@ static void surface_cache_pending(struct wlr_surface *surface) {
surface_state_move(cached, &surface->pending);
wl_list_insert(surface->cached.prev, &cached->cached_state_link);
+
+ surface->pending.seq++;
}
static void surface_commit_state(struct wlr_surface *surface,
@@ -459,6 +461,12 @@ static void surface_commit_state(struct wlr_surface *surface,
}
}
+ // If we're committing the pending state, bump the pending sequence number
+ // here, to allow commit listeners to lock the new pending state.
+ if (next == &surface->pending) {
+ surface->pending.seq++;
+ }
+
if (surface->role && surface->role->commit) {
surface->role->commit(surface);
}
@@ -473,13 +481,11 @@ static void surface_commit_pending(struct wlr_surface *surface) {
surface->role->precommit(surface);
}
- uint32_t next_seq = surface->pending.seq + 1;
if (surface->pending.cached_state_locks > 0 || !wl_list_empty(&surface->cached)) {
surface_cache_pending(surface);
} else {
surface_commit_state(surface, &surface->pending);
}
- surface->pending.seq = next_seq;
}
static bool subsurface_is_synchronized(struct wlr_subsurface *subsurface) {