commit entire output config, or fail and rollback

The wlr-output-management protocol requires that either all of the
changes from an apply request be applied successfully, in which case a
"succeeded" event is sent, or all of the changes are reverted and a
"failed" event is sent.  As written, this could partially commit
changes, then fail.

Test the changes first (even for an "apply" event), then commit or
rollback as appropriate.
This commit is contained in:
Devin J. Pohly 2021-01-18 15:02:15 -06:00
parent 3747b3162e
commit ab03282295

13
dwl.c
View File

@ -1545,11 +1545,14 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
} }
} }
if (test) { if (!(ok = wlr_output_test(wlr_output)))
ok &= wlr_output_test(wlr_output); break;
wlr_output_rollback(wlr_output); }
} else wl_list_for_each(config_head, &config->heads, link) {
ok &= wlr_output_commit(wlr_output); if (ok && !test)
wlr_output_commit(config_head->state.output);
else
wlr_output_rollback(config_head->state.output);
} }
if (ok) if (ok)
wlr_output_configuration_v1_send_succeeded(config); wlr_output_configuration_v1_send_succeeded(config);