aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/bar.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r--swaybar/bar.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index d407db4f..5b8028e5 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -25,7 +25,6 @@
25#include "ipc-client.h" 25#include "ipc-client.h"
26#include "list.h" 26#include "list.h"
27#include "log.h" 27#include "log.h"
28#include "pango.h"
29#include "pool-buffer.h" 28#include "pool-buffer.h"
30#include "wlr-layer-shell-unstable-v1-client-protocol.h" 29#include "wlr-layer-shell-unstable-v1-client-protocol.h"
31 30
@@ -34,6 +33,15 @@ static void bar_init(struct swaybar *bar) {
34 wl_list_init(&bar->outputs); 33 wl_list_init(&bar->outputs);
35} 34}
36 35
36void free_workspaces(struct wl_list *list) {
37 struct swaybar_workspace *ws, *tmp;
38 wl_list_for_each_safe(ws, tmp, list, link) {
39 wl_list_remove(&ws->link);
40 free(ws->name);
41 free(ws);
42 }
43}
44
37static void swaybar_output_free(struct swaybar_output *output) { 45static void swaybar_output_free(struct swaybar_output *output) {
38 if (!output) { 46 if (!output) {
39 return; 47 return;
@@ -44,12 +52,7 @@ static void swaybar_output_free(struct swaybar_output *output) {
44 wl_output_destroy(output->output); 52 wl_output_destroy(output->output);
45 destroy_buffer(&output->buffers[0]); 53 destroy_buffer(&output->buffers[0]);
46 destroy_buffer(&output->buffers[1]); 54 destroy_buffer(&output->buffers[1]);
47 struct swaybar_workspace *ws, *ws_tmp; 55 free_workspaces(&output->workspaces);
48 wl_list_for_each_safe(ws, ws_tmp, &output->workspaces, link) {
49 wl_list_remove(&ws->link);
50 free(ws->name);
51 free(ws);
52 }
53 struct swaybar_hotspot *hotspot, *hotspot_tmp; 56 struct swaybar_hotspot *hotspot, *hotspot_tmp;
54 wl_list_for_each_safe(hotspot, hotspot_tmp, &output->hotspots, link) { 57 wl_list_for_each_safe(hotspot, hotspot_tmp, &output->hotspots, link) {
55 if (hotspot->destroy) { 58 if (hotspot->destroy) {
@@ -162,9 +165,11 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
162 return; 165 return;
163 } 166 }
164 167
168 // last doesn't actually need initialization,
169 // but gcc (7.3.1) is too dumb to figure it out
165 struct swaybar_workspace *first = NULL; 170 struct swaybar_workspace *first = NULL;
166 struct swaybar_workspace *active = NULL; 171 struct swaybar_workspace *active = NULL;
167 struct swaybar_workspace *last; 172 struct swaybar_workspace *last = NULL;
168 173
169 struct swaybar_workspace *iter; 174 struct swaybar_workspace *iter;
170 wl_list_for_each(iter, &output->workspaces, link) { 175 wl_list_for_each(iter, &output->workspaces, link) {
@@ -466,9 +471,7 @@ void bar_run(struct swaybar *bar) {
466static void free_outputs(struct wl_list *list) { 471static void free_outputs(struct wl_list *list) {
467 struct swaybar_output *output, *tmp; 472 struct swaybar_output *output, *tmp;
468 wl_list_for_each_safe(output, tmp, list, link) { 473 wl_list_for_each_safe(output, tmp, list, link) {
469 wl_list_remove(&output->link); 474 swaybar_output_free(output);
470 free(output->name);
471 free(output);
472 } 475 }
473} 476}
474 477