wlr_output: wlr_output_commit{,_state} returns a struct wlr_output_commit

This commit is contained in:
Alexander Orzechowski 2023-08-23 22:43:39 -04:00
parent 544e678be0
commit 7332acc922
2 changed files with 11 additions and 10 deletions

View file

@ -469,7 +469,7 @@ bool wlr_output_test(struct wlr_output *output);
* *
* On failure, the pending changes are rolled back. * 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. * 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 * 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, * 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 * Note: wlr_output_state_finish() would typically be called after the state
* has been committed. * 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); const struct wlr_output_state *state);
/** /**
* Manually schedules a `frame` event. If a `frame` event is already pending, * Manually schedules a `frame` event. If a `frame` event is already pending,

View file

@ -786,7 +786,7 @@ void wlr_output_commit_init(struct wlr_output_commit *commit,
commit->output = output; 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) { const struct wlr_output_state *state) {
uint32_t unchanged = output_compare_state(output, 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)) { if (!output_basic_test(output, &pending)) {
wlr_log(WLR_ERROR, "Basic output test failed for %s", output->name); wlr_log(WLR_ERROR, "Basic output test failed for %s", output->name);
return false; return NULL;
} }
bool new_back_buffer = false; bool new_back_buffer = false;
if (!output_ensure_buffer(output, &pending, &new_back_buffer)) { if (!output_ensure_buffer(output, &pending, &new_back_buffer)) {
return false; return NULL;
} }
if ((pending.committed & WLR_OUTPUT_STATE_BUFFER) && if ((pending.committed & WLR_OUTPUT_STATE_BUFFER) &&
@ -851,10 +851,10 @@ bool wlr_output_commit_state(struct wlr_output *output,
output->not_committed = false; 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 // Make sure the pending state is cleared before the output is committed
struct wlr_output_state state = {0}; struct wlr_output_state state = {0};
output_state_move(&state, &output->pending); output_state_move(&state, &output->pending);
@ -868,9 +868,9 @@ bool wlr_output_commit(struct wlr_output *output) {
output_clear_back_buffer(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); wlr_output_state_finish(&state);
return ok; return commit;
} }
void wlr_output_rollback(struct wlr_output *output) { void wlr_output_rollback(struct wlr_output *output) {