aboutsummaryrefslogtreecommitdiffstats
path: root/swaynag/swaynag.c
diff options
context:
space:
mode:
authorLibravatar Manuel Stoeckl <code@mstoeckl.com>2023-01-08 09:21:30 -0500
committerLibravatar Simon Zeni <simon@bl4ckb0ne.ca>2023-01-16 10:47:42 -0500
commit5e73acb431258d81a01709fbd28da2e151bd3bd3 (patch)
tree94b773c7ff37dfe45c6e99cfaecff98927bf0b8b /swaynag/swaynag.c
parentinput: enable user xkb configs with cap_sys_nice (diff)
downloadsway-5e73acb431258d81a01709fbd28da2e151bd3bd3.tar.gz
sway-5e73acb431258d81a01709fbd28da2e151bd3bd3.tar.zst
sway-5e73acb431258d81a01709fbd28da2e151bd3bd3.zip
swaynag: call swaynag_destroy on clean exit
And fix the fallout of the swaynag_destroy having evolved without being tested: * wl_display_disconnect was called too early * `button_close` and `swaynag.details.button_details` needed to be heap allocated, since they are added to swaynag.buttons, and all entries of swaynag.buttons are freed in swaynag_destroy * To keep things simpler, disconnect the lifetime of the 'Toggle details' button text config setting from the button itself.
Diffstat (limited to 'swaynag/swaynag.c')
-rw-r--r--swaynag/swaynag.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c
index 5620155d..08e26127 100644
--- a/swaynag/swaynag.c
+++ b/swaynag/swaynag.c
@@ -483,10 +483,6 @@ void swaynag_run(struct swaynag *swaynag) {
483 && wl_display_dispatch(swaynag->display) != -1) { 483 && wl_display_dispatch(swaynag->display) != -1) {
484 // This is intentionally left blank 484 // This is intentionally left blank
485 } 485 }
486
487 if (swaynag->display) {
488 wl_display_disconnect(swaynag->display);
489 }
490} 486}
491 487
492void swaynag_destroy(struct swaynag *swaynag) { 488void swaynag_destroy(struct swaynag *swaynag) {
@@ -501,6 +497,7 @@ void swaynag_destroy(struct swaynag *swaynag) {
501 } 497 }
502 list_free(swaynag->buttons); 498 list_free(swaynag->buttons);
503 free(swaynag->details.message); 499 free(swaynag->details.message);
500 free(swaynag->details.details_text);
504 free(swaynag->details.button_up.text); 501 free(swaynag->details.button_up.text);
505 free(swaynag->details.button_down.text); 502 free(swaynag->details.button_down.text);
506 503
@@ -541,4 +538,8 @@ void swaynag_destroy(struct swaynag *swaynag) {
541 if (swaynag->shm) { 538 if (swaynag->shm) {
542 wl_shm_destroy(swaynag->shm); 539 wl_shm_destroy(swaynag->shm);
543 } 540 }
541
542 if (swaynag->display) {
543 wl_display_disconnect(swaynag->display);
544 }
544} 545}