rework outputmgrapplyortest()

first disable requested monitors, then enable and/or change mode, x and y, etc.
This is mostly what sway does
This commit is contained in:
Leonardo Hernández Hernández 2022-08-10 23:57:03 -05:00 committed by Leonardo Hernández
parent 3431ac165d
commit b6e3fc1645

36
dwl.c
View file

@ -1583,11 +1583,27 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
struct wlr_output_configuration_head_v1 *config_head;
int ok = 1;
/* First disable outputs we need to disable */
wl_list_for_each(config_head, &config->heads, link) {
struct wlr_output *wlr_output = config_head->state.output;
if (!wlr_output->enabled || config_head->state.enabled)
continue;
wlr_output_enable(wlr_output, 0);
if (test) {
ok &= wlr_output_test(wlr_output);
wlr_output_rollback(wlr_output);
} else {
ok &= wlr_output_commit(wlr_output);
}
}
wlr_output_enable(wlr_output, config_head->state.enabled);
if (config_head->state.enabled) {
/* Then enable outputs that need to */
wl_list_for_each(config_head, &config->heads, link) {
struct wlr_output *wlr_output = config_head->state.output;
if (!config_head->state.enabled)
continue;
wlr_output_enable(wlr_output, 1);
if (config_head->state.mode)
wlr_output_set_mode(wlr_output, config_head->state.mode);
else
@ -1600,17 +1616,15 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
config_head->state.x, config_head->state.y);
wlr_output_set_transform(wlr_output, config_head->state.transform);
wlr_output_set_scale(wlr_output, config_head->state.scale);
if (test) {
ok &= wlr_output_test(wlr_output);
wlr_output_rollback(wlr_output);
} else {
ok &= wlr_output_commit(wlr_output);
}
}
if (!(ok = wlr_output_test(wlr_output)))
break;
}
wl_list_for_each(config_head, &config->heads, link) {
if (ok && !test)
wlr_output_commit(config_head->state.output);
else
wlr_output_rollback(config_head->state.output);
}
if (ok)
wlr_output_configuration_v1_send_succeeded(config);
else