backend, output: send commit events after applying all in wlr_backend_commit()

We were iterating over involved outputs, applying the new state and
sending the commit event for each one. This resulted in commit
events being fired while we weren't done applying the new state for
all outputs.

Fix this by first applying all of the states, then firing all of
the events.

Closes: https://github.com/swaywm/sway/issues/8829
This commit is contained in:
Simon Ser 2025-08-12 19:00:11 +02:00
parent 07e92fb868
commit 7392b3313a
3 changed files with 9 additions and 0 deletions

View file

@ -485,5 +485,10 @@ bool wlr_backend_commit(struct wlr_backend *backend,
output_apply_commit(state->output, &state->base); output_apply_commit(state->output, &state->base);
} }
for (size_t i = 0; i < states_len; i++) {
const struct wlr_backend_output_state *state = &states[i];
output_send_commit_event(state->output, &state->base);
}
return true; return true;
} }

View file

@ -27,6 +27,7 @@ void output_defer_present(struct wlr_output *output, struct wlr_output_event_pre
bool output_prepare_commit(struct wlr_output *output, const struct wlr_output_state *state); bool output_prepare_commit(struct wlr_output *output, const struct wlr_output_state *state);
void output_apply_commit(struct wlr_output *output, const struct wlr_output_state *state); void output_apply_commit(struct wlr_output *output, const struct wlr_output_state *state);
void output_send_commit_event(struct wlr_output *output, const struct wlr_output_state *state);
void output_state_get_buffer_src_box(const struct wlr_output_state *state, void output_state_get_buffer_src_box(const struct wlr_output_state *state,
struct wlr_fbox *out); struct wlr_fbox *out);

View file

@ -759,7 +759,9 @@ void output_apply_commit(struct wlr_output *output, const struct wlr_output_stat
} }
output_apply_state(output, state); output_apply_state(output, state);
}
void output_send_commit_event(struct wlr_output *output, const struct wlr_output_state *state) {
struct timespec now; struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
struct wlr_output_event_commit event = { struct wlr_output_event_commit event = {
@ -801,6 +803,7 @@ bool wlr_output_commit_state(struct wlr_output *output,
} }
output_apply_commit(output, &pending); output_apply_commit(output, &pending);
output_send_commit_event(output, &pending);
if (new_back_buffer) { if (new_back_buffer) {
wlr_buffer_unlock(pending.buffer); wlr_buffer_unlock(pending.buffer);