diff options
-rw-r--r-- | include/swaybar/bar.h | 2 | ||||
-rw-r--r-- | include/swaybar/config.h | 2 | ||||
-rw-r--r-- | include/swaybar/status_line.h | 1 | ||||
-rw-r--r-- | swaybar/bar.c | 21 | ||||
-rw-r--r-- | swaybar/config.c | 6 | ||||
-rw-r--r-- | swaybar/i3bar.c | 3 | ||||
-rw-r--r-- | swaybar/ipc.c | 13 | ||||
-rw-r--r-- | swaybar/status_line.c | 14 |
8 files changed, 38 insertions, 24 deletions
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 0037190b..af478f33 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h | |||
@@ -79,4 +79,6 @@ void bar_setup(struct swaybar *bar, | |||
79 | void bar_run(struct swaybar *bar); | 79 | void bar_run(struct swaybar *bar); |
80 | void bar_teardown(struct swaybar *bar); | 80 | void bar_teardown(struct swaybar *bar); |
81 | 81 | ||
82 | void free_workspaces(struct wl_list *list); | ||
83 | |||
82 | #endif | 84 | #endif |
diff --git a/include/swaybar/config.h b/include/swaybar/config.h index 7f321df8..6739c28a 100644 --- a/include/swaybar/config.h +++ b/include/swaybar/config.h | |||
@@ -29,7 +29,7 @@ struct swaybar_config { | |||
29 | bool binding_mode_indicator; | 29 | bool binding_mode_indicator; |
30 | bool wrap_scroll; | 30 | bool wrap_scroll; |
31 | bool workspace_buttons; | 31 | bool workspace_buttons; |
32 | struct wl_list outputs; | 32 | struct wl_list outputs; // config_output::link |
33 | bool all_outputs; | 33 | bool all_outputs; |
34 | int height; | 34 | int height; |
35 | 35 | ||
diff --git a/include/swaybar/status_line.h b/include/swaybar/status_line.h index 3538f49c..bf12a842 100644 --- a/include/swaybar/status_line.h +++ b/include/swaybar/status_line.h | |||
@@ -73,5 +73,6 @@ void status_line_free(struct status_line *status); | |||
73 | bool i3bar_handle_readable(struct status_line *status); | 73 | bool i3bar_handle_readable(struct status_line *status); |
74 | void i3bar_block_send_click(struct status_line *status, | 74 | void i3bar_block_send_click(struct status_line *status, |
75 | struct i3bar_block *block, int x, int y, uint32_t button); | 75 | struct i3bar_block *block, int x, int y, uint32_t button); |
76 | void i3bar_block_free(struct i3bar_block *block); | ||
76 | 77 | ||
77 | #endif | 78 | #endif |
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 @@ | |||
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 | ||
36 | void 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 | |||
37 | static void swaybar_output_free(struct swaybar_output *output) { | 45 | static 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) { |
@@ -468,9 +471,7 @@ void bar_run(struct swaybar *bar) { | |||
468 | static void free_outputs(struct wl_list *list) { | 471 | static void free_outputs(struct wl_list *list) { |
469 | struct swaybar_output *output, *tmp; | 472 | struct swaybar_output *output, *tmp; |
470 | wl_list_for_each_safe(output, tmp, list, link) { | 473 | wl_list_for_each_safe(output, tmp, list, link) { |
471 | wl_list_remove(&output->link); | 474 | swaybar_output_free(output); |
472 | free(output->name); | ||
473 | free(output); | ||
474 | } | 475 | } |
475 | } | 476 | } |
476 | 477 | ||
diff --git a/swaybar/config.c b/swaybar/config.c index 9169ad27..db7b0db6 100644 --- a/swaybar/config.c +++ b/swaybar/config.c | |||
@@ -74,5 +74,11 @@ void free_config(struct swaybar_config *config) { | |||
74 | free(config->font); | 74 | free(config->font); |
75 | free(config->mode); | 75 | free(config->mode); |
76 | free(config->sep_symbol); | 76 | free(config->sep_symbol); |
77 | struct config_output *coutput, *tmp; | ||
78 | wl_list_for_each_safe(coutput, tmp, &config->outputs, link) { | ||
79 | wl_list_remove(&coutput->link); | ||
80 | free(coutput->name); | ||
81 | free(coutput); | ||
82 | } | ||
77 | free(config); | 83 | free(config); |
78 | } | 84 | } |
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c index dced13d2..141612a6 100644 --- a/swaybar/i3bar.c +++ b/swaybar/i3bar.c | |||
@@ -7,7 +7,7 @@ | |||
7 | #include "swaybar/config.h" | 7 | #include "swaybar/config.h" |
8 | #include "swaybar/status_line.h" | 8 | #include "swaybar/status_line.h" |
9 | 9 | ||
10 | static void i3bar_block_free(struct i3bar_block *block) { | 10 | void i3bar_block_free(struct i3bar_block *block) { |
11 | if (!block) { | 11 | if (!block) { |
12 | return; | 12 | return; |
13 | } | 13 | } |
@@ -18,6 +18,7 @@ static void i3bar_block_free(struct i3bar_block *block) { | |||
18 | free(block->name); | 18 | free(block->name); |
19 | free(block->instance); | 19 | free(block->instance); |
20 | free(block->color); | 20 | free(block->color); |
21 | free(block); | ||
21 | } | 22 | } |
22 | 23 | ||
23 | static bool i3bar_parse_json(struct status_line *status, const char *text) { | 24 | static bool i3bar_parse_json(struct status_line *status, const char *text) { |
diff --git a/swaybar/ipc.c b/swaybar/ipc.c index ed5d9a31..959fa095 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c | |||
@@ -216,15 +216,6 @@ static void ipc_parse_config( | |||
216 | json_object_put(bar_config); | 216 | json_object_put(bar_config); |
217 | } | 217 | } |
218 | 218 | ||
219 | static void free_workspaces(struct wl_list *list) { | ||
220 | struct swaybar_workspace *ws, *tmp; | ||
221 | wl_list_for_each_safe(ws, tmp, list, link) { | ||
222 | wl_list_remove(&ws->link); | ||
223 | free(ws->name); | ||
224 | free(ws); | ||
225 | } | ||
226 | } | ||
227 | |||
228 | void ipc_get_workspaces(struct swaybar *bar) { | 219 | void ipc_get_workspaces(struct swaybar *bar) { |
229 | bar->focused_output = NULL; | 220 | bar->focused_output = NULL; |
230 | struct swaybar_output *output; | 221 | struct swaybar_output *output; |
@@ -290,8 +281,8 @@ static void ipc_get_outputs(struct swaybar *bar) { | |||
290 | continue; | 281 | continue; |
291 | } | 282 | } |
292 | if (bar->config->all_outputs) { | 283 | if (bar->config->all_outputs) { |
293 | struct config_output *coutput = calloc( | 284 | struct config_output *coutput = |
294 | 1, sizeof(struct config_output)); | 285 | calloc(1, sizeof(struct config_output)); |
295 | coutput->name = strdup(name); | 286 | coutput->name = strdup(name); |
296 | coutput->index = i; | 287 | coutput->index = i; |
297 | wl_list_insert(&bar->config->outputs, &coutput->link); | 288 | wl_list_insert(&bar->config->outputs, &coutput->link); |
diff --git a/swaybar/status_line.c b/swaybar/status_line.c index 8d781ca3..e0e7414a 100644 --- a/swaybar/status_line.c +++ b/swaybar/status_line.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _POSIX_C_SOURCE 199309L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <fcntl.h> | 2 | #include <fcntl.h> |
3 | #include <json-c/json.h> | 3 | #include <json-c/json.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
@@ -126,5 +126,17 @@ void status_line_free(struct status_line *status) { | |||
126 | close(status->read_fd); | 126 | close(status->read_fd); |
127 | close(status->write_fd); | 127 | close(status->write_fd); |
128 | kill(status->pid, SIGTERM); | 128 | kill(status->pid, SIGTERM); |
129 | switch (status->protocol) { | ||
130 | case PROTOCOL_I3BAR:; | ||
131 | struct i3bar_block *block, *tmp; | ||
132 | wl_list_for_each_safe(block, tmp, &status->blocks, link) { | ||
133 | i3bar_block_free(block); | ||
134 | } | ||
135 | free(status->i3bar_state.buffer); | ||
136 | break; | ||
137 | default: | ||
138 | free(status->text_state.buffer); | ||
139 | break; | ||
140 | } | ||
129 | free(status); | 141 | free(status); |
130 | } | 142 | } |