aboutsummaryrefslogtreecommitdiff
path: root/swaybar/bar.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r--swaybar/bar.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index b4c0698f..5b8028e5 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -25,7 +25,6 @@
#include "ipc-client.h"
#include "list.h"
#include "log.h"
-#include "pango.h"
#include "pool-buffer.h"
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
@@ -34,6 +33,15 @@ static void bar_init(struct swaybar *bar) {
wl_list_init(&bar->outputs);
}
+void free_workspaces(struct wl_list *list) {
+ struct swaybar_workspace *ws, *tmp;
+ wl_list_for_each_safe(ws, tmp, list, link) {
+ wl_list_remove(&ws->link);
+ free(ws->name);
+ free(ws);
+ }
+}
+
static void swaybar_output_free(struct swaybar_output *output) {
if (!output) {
return;
@@ -44,12 +52,7 @@ static void swaybar_output_free(struct swaybar_output *output) {
wl_output_destroy(output->output);
destroy_buffer(&output->buffers[0]);
destroy_buffer(&output->buffers[1]);
- struct swaybar_workspace *ws, *ws_tmp;
- wl_list_for_each_safe(ws, ws_tmp, &output->workspaces, link) {
- wl_list_remove(&ws->link);
- free(ws->name);
- free(ws);
- }
+ free_workspaces(&output->workspaces);
struct swaybar_hotspot *hotspot, *hotspot_tmp;
wl_list_for_each_safe(hotspot, hotspot_tmp, &output->hotspots, link) {
if (hotspot->destroy) {
@@ -468,9 +471,7 @@ void bar_run(struct swaybar *bar) {
static void free_outputs(struct wl_list *list) {
struct swaybar_output *output, *tmp;
wl_list_for_each_safe(output, tmp, list, link) {
- wl_list_remove(&output->link);
- free(output->name);
- free(output);
+ swaybar_output_free(output);
}
}