aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-02-16 16:14:27 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-02-18 15:11:48 -0500
commit19586ab768ad2a79cb8342d34e16b25105bc36bd (patch)
treed3e04758fdae3d5a9c452d5326afcbdc26af8fb1
parenttray: fix memory leaks (diff)
downloadsway-19586ab768ad2a79cb8342d34e16b25105bc36bd.tar.gz
sway-19586ab768ad2a79cb8342d34e16b25105bc36bd.tar.zst
sway-19586ab768ad2a79cb8342d34e16b25105bc36bd.zip
Fix reload freeze when not modsetting current mode
This fixes the issue of the display freezing on reload with wlroots#1545. On master, all output configs are applied on reload. This may cause an output to have its config applied up to three times, instead of just once. The three cases are: output name, output identifier, and wildcard. Not only is this inefficient, but it can cause swaybg to be spawned and immediately killed. However, swaybg requires two roundtrips of wl_display (to obtain needed globals) before it enters its normal event loop. Modesetting will roundtrip the wl_display. Without modesetting, waitpid for killing swaybg could block infinitely due to swaybg being blocked by wl_display_roundtrip. This only configured an output once. It either uses the wildcard config or creates an empty wildcard config and applies that. This also fixes a bug where an output would not be reset when there is no output config to apply to it.
-rw-r--r--include/sway/config.h2
-rw-r--r--sway/config.c5
-rw-r--r--sway/config/output.c11
3 files changed, 15 insertions, 3 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index 43ea7778..54cdcc90 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -586,6 +586,8 @@ struct output_config *store_output_config(struct output_config *oc);
586 586
587void apply_output_config_to_outputs(struct output_config *oc); 587void apply_output_config_to_outputs(struct output_config *oc);
588 588
589void reset_outputs(void);
590
589void free_output_config(struct output_config *oc); 591void free_output_config(struct output_config *oc);
590 592
591int workspace_output_cmp_workspace(const void *a, const void *b); 593int workspace_output_cmp_workspace(const void *a, const void *b);
diff --git a/sway/config.c b/sway/config.c
index cd2d18a2..206ca95c 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -471,9 +471,8 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
471 } 471 }
472 472
473 if (is_active) { 473 if (is_active) {
474 for (int i = 0; i < config->output_configs->length; i++) { 474 reset_outputs();
475 apply_output_config_to_outputs(config->output_configs->items[i]); 475
476 }
477 config->reloading = false; 476 config->reloading = false;
478 if (config->swaynag_config_errors.pid > 0) { 477 if (config->swaynag_config_errors.pid > 0) {
479 swaynag_show(&config->swaynag_config_errors); 478 swaynag_show(&config->swaynag_config_errors);
diff --git a/sway/config/output.c b/sway/config/output.c
index f1a06379..0f238715 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -391,6 +391,17 @@ void apply_output_config_to_outputs(struct output_config *oc) {
391 } 391 }
392} 392}
393 393
394void reset_outputs(void) {
395 struct output_config *oc = NULL;
396 int i = list_seq_find(config->output_configs, output_name_cmp, "*");
397 if (i >= 0) {
398 oc = config->output_configs->items[i];
399 } else {
400 oc = store_output_config(new_output_config("*"));
401 }
402 apply_output_config_to_outputs(oc);
403}
404
394void free_output_config(struct output_config *oc) { 405void free_output_config(struct output_config *oc) {
395 if (!oc) { 406 if (!oc) {
396 return; 407 return;