aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2020-02-11 14:17:33 +0100
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2020-02-11 20:52:02 -0500
commitf5fa0c7124dde3438a22550aae017f824d20c93b (patch)
tree4da13f1062a73c8b6db9c31f795fc31df3379fe3
parentCall apply_output_config instead of output_enable (diff)
downloadsway-f5fa0c7124dde3438a22550aae017f824d20c93b.tar.gz
sway-f5fa0c7124dde3438a22550aae017f824d20c93b.tar.zst
sway-f5fa0c7124dde3438a22550aae017f824d20c93b.zip
Stop calling apply_output_config from output_enable
The only output_enable caller is now apply_output_config. Stop calling apply_output_config from output_enable to simplify the code and avoid the back-and-forth between these two functions. output_enable is now the symmetric of output_disable: it just marks the output as enabled and performs bookkeeping (e.g. creating teh default workspace). It is called from apply_output_config after the output commit, so that it can read the current output state and act accordingly. This change also allows us to avoid an extraneous wlr_output_commit. References: https://github.com/swaywm/sway/issues/4921
-rw-r--r--include/sway/output.h2
-rw-r--r--sway/config/output.c12
-rw-r--r--sway/tree/output.c11
3 files changed, 7 insertions, 18 deletions
diff --git a/include/sway/output.h b/include/sway/output.h
index b1c74258..53e77420 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -101,7 +101,7 @@ struct sway_output *all_output_by_name_or_id(const char *name_or_id);
101 101
102void output_sort_workspaces(struct sway_output *output); 102void output_sort_workspaces(struct sway_output *output);
103 103
104bool output_enable(struct sway_output *output, struct output_config *oc); 104void output_enable(struct sway_output *output);
105 105
106void output_disable(struct sway_output *output); 106void output_disable(struct sway_output *output);
107 107
diff --git a/sway/config/output.c b/sway/config/output.c
index e1925c93..73d62aff 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -343,14 +343,6 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
343 } 343 }
344 wlr_output_enable(wlr_output, false); 344 wlr_output_enable(wlr_output, false);
345 return wlr_output_commit(wlr_output); 345 return wlr_output_commit(wlr_output);
346 } else if (!output->enabled) {
347 // Output is not enabled. Enable it, output_enable will call us again.
348 if (!oc || oc->dpms_state != DPMS_OFF) {
349 sway_log(SWAY_DEBUG, "Enabling output %s", oc->name);
350 wlr_output_enable(wlr_output, true);
351 wlr_output_commit(wlr_output);
352 }
353 return output_enable(output, oc);
354 } 346 }
355 347
356 if (!oc || oc->dpms_state != DPMS_OFF) { 348 if (!oc || oc->dpms_state != DPMS_OFF) {
@@ -440,6 +432,10 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
440 output->width = output_box->width; 432 output->width = output_box->width;
441 output->height = output_box->height; 433 output->height = output_box->height;
442 434
435 if ((!oc || oc->enabled) && !output->enabled) {
436 output_enable(output);
437 }
438
443 if (oc && oc->dpms_state == DPMS_OFF) { 439 if (oc && oc->dpms_state == DPMS_OFF) {
444 sway_log(SWAY_DEBUG, "Turning off output %s", oc->name); 440 sway_log(SWAY_DEBUG, "Turning off output %s", oc->name);
445 wlr_output_enable(wlr_output, false); 441 wlr_output_enable(wlr_output, false);
diff --git a/sway/tree/output.c b/sway/tree/output.c
index d2ede1f2..6f4146cd 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -105,9 +105,9 @@ struct sway_output *output_create(struct wlr_output *wlr_output) {
105 return output; 105 return output;
106} 106}
107 107
108bool output_enable(struct sway_output *output, struct output_config *oc) { 108void output_enable(struct sway_output *output) {
109 if (!sway_assert(!output->enabled, "output is already enabled")) { 109 if (!sway_assert(!output->enabled, "output is already enabled")) {
110 return false; 110 return;
111 } 111 }
112 struct wlr_output *wlr_output = output->wlr_output; 112 struct wlr_output *wlr_output = output->wlr_output;
113 size_t len = sizeof(output->layers) / sizeof(output->layers[0]); 113 size_t len = sizeof(output->layers) / sizeof(output->layers[0]);
@@ -116,11 +116,6 @@ bool output_enable(struct sway_output *output, struct output_config *oc) {
116 } 116 }
117 117
118 output->enabled = true; 118 output->enabled = true;
119 if (!apply_output_config(oc, output)) {
120 output->enabled = false;
121 return false;
122 }
123
124 output->configured = true; 119 output->configured = true;
125 list_add(root->outputs, output); 120 list_add(root->outputs, output);
126 121
@@ -156,8 +151,6 @@ bool output_enable(struct sway_output *output, struct output_config *oc) {
156 151
157 arrange_layers(output); 152 arrange_layers(output);
158 arrange_root(); 153 arrange_root();
159
160 return true;
161} 154}
162 155
163static void evacuate_sticky(struct sway_workspace *old_ws, 156static void evacuate_sticky(struct sway_workspace *old_ws,