aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config/output.c
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2020-07-10 18:04:45 +0200
committerLibravatar Simon Ser <contact@emersion.fr>2020-07-15 19:27:12 +0200
commitd5f5885c941d9f74f131734b253133108c759e20 (patch)
tree59b5e3e01b63e7a8a8d5c794f776dc24913565b5 /sway/config/output.c
parentReload command now matches i3's implementation (diff)
downloadsway-d5f5885c941d9f74f131734b253133108c759e20.tar.gz
sway-d5f5885c941d9f74f131734b253133108c759e20.tar.zst
sway-d5f5885c941d9f74f131734b253133108c759e20.zip
config/output: don't change output state before commit
Previously, we called output_disable prior to wlr_output_commit. This mutates Sway's output state before the output commit actually succeeds. This results in Sway's state getting out-of-sync with wlroots'. An alternative fix [1] was to revert the changes made by output_disable in case of failure. This is a little complicated. Instead, this patch makes it so Sway's internal state is never changed before a successful wlr_output commit. We had two output flags: enabled and configured. However enabled was set prior to the output becoming enabled, and was used to prevent the output event handlers (specifically, the mode handler) from calling apply_output_config again (infinite loop). Rename enabled to enabling and use it exclusively for this purpose. Rename configure to enabled, because that's what it really means. [1]: https://github.com/swaywm/sway/pull/5521 Closes: https://github.com/swaywm/sway/issues/5483 (cherry picked from commit 5432f00adfdd8375fb422ad9033253d17f04efc7)
Diffstat (limited to 'sway/config/output.c')
-rw-r--r--sway/config/output.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 68aafbe1..b59cabd4 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -397,17 +397,8 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
397 397
398 struct wlr_output *wlr_output = output->wlr_output; 398 struct wlr_output *wlr_output = output->wlr_output;
399 399
400 bool was_enabled = output->enabled; 400 // Flag to prevent the output mode event handler from calling us
401 if (oc && !oc->enabled) { 401 output->enabling = (!oc || oc->enabled);
402 // Output is configured to be disabled
403 sway_log(SWAY_DEBUG, "Disabling output %s", oc->name);
404 if (output->enabled) {
405 output_disable(output);
406 wlr_output_layout_remove(root->output_layout, wlr_output);
407 }
408 } else {
409 output->enabled = true;
410 }
411 402
412 queue_output_config(oc, output); 403 queue_output_config(oc, output);
413 404
@@ -421,11 +412,18 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
421 // Leave the output disabled for now and try again when the output gets 412 // Leave the output disabled for now and try again when the output gets
422 // the mode we asked for. 413 // the mode we asked for.
423 sway_log(SWAY_ERROR, "Failed to commit output %s", wlr_output->name); 414 sway_log(SWAY_ERROR, "Failed to commit output %s", wlr_output->name);
424 output->enabled = was_enabled; 415 output->enabling = false;
425 return false; 416 return false;
426 } 417 }
427 418
419 output->enabling = false;
420
428 if (oc && !oc->enabled) { 421 if (oc && !oc->enabled) {
422 sway_log(SWAY_DEBUG, "Disabling output %s", oc->name);
423 if (output->enabled) {
424 output_disable(output);
425 wlr_output_layout_remove(root->output_layout, wlr_output);
426 }
429 return true; 427 return true;
430 } 428 }
431 429
@@ -468,8 +466,8 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
468 output->width = output_box->width; 466 output->width = output_box->width;
469 output->height = output_box->height; 467 output->height = output_box->height;
470 468
471 if (!output->configured) { 469 if (!output->enabled) {
472 output_configure(output); 470 output_enable(output);
473 } 471 }
474 472
475 if (oc && oc->max_render_time >= 0) { 473 if (oc && oc->max_render_time >= 0) {