From 7332acc922ab543950af274ad14aea3268eee1ec Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Wed, 23 Aug 2023 22:43:39 -0400 Subject: [PATCH] wlr_output: wlr_output_commit{,_state} returns a struct wlr_output_commit --- include/wlr/types/wlr_output.h | 7 ++++--- types/output/output.c | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index b0d5e27e0..adc58fcb4 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -469,7 +469,7 @@ bool wlr_output_test(struct wlr_output *output); * * On failure, the pending changes are rolled back. */ -bool wlr_output_commit(struct wlr_output *output); +struct wlr_output_commit *wlr_output_commit(struct wlr_output *output); /** * Discard the pending output state. */ @@ -486,12 +486,13 @@ bool wlr_output_test_state(struct wlr_output *output, /** * Attempts to apply the state to this output. This function may fail for any * reason and return false. If failed, none of the state would have been applied, - * this function is atomic. If the commit succeeded, true is returned. + * this function is atomic. If the commit succeeded, an wlr_output_commit struct + * is returned. If the commit failed, NULL is returned. * * Note: wlr_output_state_finish() would typically be called after the state * has been committed. */ -bool wlr_output_commit_state(struct wlr_output *output, +struct wlr_output_commit *wlr_output_commit_state(struct wlr_output *output, const struct wlr_output_state *state); /** * Manually schedules a `frame` event. If a `frame` event is already pending, diff --git a/types/output/output.c b/types/output/output.c index 174e81595..2394efe2a 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -786,7 +786,7 @@ void wlr_output_commit_init(struct wlr_output_commit *commit, commit->output = output; } -bool wlr_output_commit_state(struct wlr_output *output, +struct wlr_output_commit *wlr_output_commit_state(struct wlr_output *output, const struct wlr_output_state *state) { uint32_t unchanged = output_compare_state(output, state); @@ -797,12 +797,12 @@ bool wlr_output_commit_state(struct wlr_output *output, if (!output_basic_test(output, &pending)) { wlr_log(WLR_ERROR, "Basic output test failed for %s", output->name); - return false; + return NULL; } bool new_back_buffer = false; if (!output_ensure_buffer(output, &pending, &new_back_buffer)) { - return false; + return NULL; } if ((pending.committed & WLR_OUTPUT_STATE_BUFFER) && @@ -851,10 +851,10 @@ bool wlr_output_commit_state(struct wlr_output *output, output->not_committed = false; - return true; + return commit; } -bool wlr_output_commit(struct wlr_output *output) { +struct wlr_output_commit *wlr_output_commit(struct wlr_output *output) { // Make sure the pending state is cleared before the output is committed struct wlr_output_state state = {0}; output_state_move(&state, &output->pending); @@ -868,9 +868,9 @@ bool wlr_output_commit(struct wlr_output *output) { output_clear_back_buffer(output); } - bool ok = wlr_output_commit_state(output, &state); + struct wlr_output_commit *commit = wlr_output_commit_state(output, &state); wlr_output_state_finish(&state); - return ok; + return commit; } void wlr_output_rollback(struct wlr_output *output) {