aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-05-03 23:26:18 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-05-11 13:34:47 -0400
commit184663c98fe316b20818b4f2d60b1b502c2a55e8 (patch)
tree983ee70377704f1940f0f242ce89fdf472989ebe
parentFix xdg-decoration unconfigured if set before first commit (diff)
downloadsway-184663c98fe316b20818b4f2d60b1b502c2a55e8.tar.gz
sway-184663c98fe316b20818b4f2d60b1b502c2a55e8.tar.zst
sway-184663c98fe316b20818b4f2d60b1b502c2a55e8.zip
Destroy swaybg client on reload
When reloading, this destroys the old config's swaybg client before spawning the new config's swaybg. This fixes a race condition where the old config's swaybg client's destroy was being called after the new config's swaybg client was being spawned. This was causing the reference to the new swaybg client to be removed and never destroyed. This also modifies handle_swaybg_client_destroy to grab the config reference using wl_container_of on the listener since the swaybg client may be the old config swaybg client and should be used instead of the global config instance
-rw-r--r--sway/config.c4
-rw-r--r--sway/config/output.c8
2 files changed, 9 insertions, 3 deletions
diff --git a/sway/config.c b/sway/config.c
index 64093aca..4f92b403 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -441,6 +441,10 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
441 config->reloading = true; 441 config->reloading = true;
442 config->active = true; 442 config->active = true;
443 443
444 if (old_config->swaybg_client != NULL) {
445 wl_client_destroy(old_config->swaybg_client);
446 }
447
444 if (old_config->swaynag_config_errors.client != NULL) { 448 if (old_config->swaynag_config_errors.client != NULL) {
445 wl_client_destroy(old_config->swaynag_config_errors.client); 449 wl_client_destroy(old_config->swaynag_config_errors.client);
446 } 450 }
diff --git a/sway/config/output.c b/sway/config/output.c
index fb8a9ee5..0022485b 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -482,9 +482,11 @@ void free_output_config(struct output_config *oc) {
482 482
483static void handle_swaybg_client_destroy(struct wl_listener *listener, 483static void handle_swaybg_client_destroy(struct wl_listener *listener,
484 void *data) { 484 void *data) {
485 wl_list_remove(&config->swaybg_client_destroy.link); 485 struct sway_config *sway_config =
486 wl_list_init(&config->swaybg_client_destroy.link); 486 wl_container_of(listener, sway_config, swaybg_client_destroy);
487 config->swaybg_client = NULL; 487 wl_list_remove(&sway_config->swaybg_client_destroy.link);
488 wl_list_init(&sway_config->swaybg_client_destroy.link);
489 sway_config->swaybg_client = NULL;
488} 490}
489 491
490static bool _spawn_swaybg(char **command) { 492static bool _spawn_swaybg(char **command) {