summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-08-10 23:57:03 -0500
committerLeonardo Hernández <leohdz172@protonmail.com>2022-08-12 23:21:25 -0500
commitb6e3fc1645c5ac53277ab0dc20d7c266e1581b86 (patch)
tree03eb0153eaef6661b5c21ba3a53e89271e1b3d33
parent3431ac165dfa46fbee1e2857ffe9dd19c86c4050 (diff)
rework outputmgrapplyortest()
first disable requested monitors, then enable and/or change mode, x and y, etc. This is mostly what sway does
-rw-r--r--dwl.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/dwl.c b/dwl.c
index 039b8ff..7d53ab9 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1583,34 +1583,48 @@ 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;
-
- wlr_output_enable(wlr_output, config_head->state.enabled);
- if (config_head->state.enabled) {
- if (config_head->state.mode)
- wlr_output_set_mode(wlr_output, config_head->state.mode);
- else
- wlr_output_set_custom_mode(wlr_output,
- config_head->state.custom_mode.width,
- config_head->state.custom_mode.height,
- config_head->state.custom_mode.refresh);
-
- wlr_output_layout_move(output_layout, wlr_output,
- 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 (!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);
}
-
- if (!(ok = wlr_output_test(wlr_output)))
- break;
}
+
+ /* Then enable outputs that need to */
wl_list_for_each(config_head, &config->heads, link) {
- if (ok && !test)
- wlr_output_commit(config_head->state.output);
+ 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
- wlr_output_rollback(config_head->state.output);
+ wlr_output_set_custom_mode(wlr_output,
+ config_head->state.custom_mode.width,
+ config_head->state.custom_mode.height,
+ config_head->state.custom_mode.refresh);
+
+ wlr_output_layout_move(output_layout, wlr_output,
+ 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_configuration_v1_send_succeeded(config);
else