aboutsummaryrefslogtreecommitdiff
path: root/swaybar
diff options
context:
space:
mode:
authorIan Fan <ianfan0@gmail.com>2018-10-12 20:18:04 +0100
committerIan Fan <ianfan0@gmail.com>2018-10-14 13:33:12 +0100
commit19f0bf38640f4da609782442c901366617aa27fa (patch)
tree0aa166b77546858f433237ff1533b7ea6b709feb /swaybar
parenta67fa8a05d010d488b821a7d6e91db5905f7a123 (diff)
downloadsway-19f0bf38640f4da609782442c901366617aa27fa.tar.xz
swaybar: add free_hotspots helper function
Diffstat (limited to 'swaybar')
-rw-r--r--swaybar/bar.c23
-rw-r--r--swaybar/render.c9
2 files changed, 14 insertions, 18 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index f2dab738..e6c5f2f1 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -35,6 +35,17 @@ static void bar_init(struct swaybar *bar) {
wl_list_init(&bar->outputs);
}
+void free_hotspots(struct wl_list *list) {
+ struct swaybar_hotspot *hotspot, *tmp;
+ wl_list_for_each_safe(hotspot, tmp, list, link) {
+ wl_list_remove(&hotspot->link);
+ if (hotspot->destroy) {
+ hotspot->destroy(hotspot->data);
+ }
+ free(hotspot);
+ }
+}
+
void free_workspaces(struct wl_list *list) {
struct swaybar_workspace *ws, *tmp;
wl_list_for_each_safe(ws, tmp, list, link) {
@@ -59,14 +70,8 @@ static void swaybar_output_free(struct swaybar_output *output) {
wl_output_destroy(output->output);
destroy_buffer(&output->buffers[0]);
destroy_buffer(&output->buffers[1]);
+ free_hotspots(&output->hotspots);
free_workspaces(&output->workspaces);
- struct swaybar_hotspot *hotspot, *hotspot_tmp;
- wl_list_for_each_safe(hotspot, hotspot_tmp, &output->hotspots, link) {
- if (hotspot->destroy) {
- hotspot->destroy(hotspot->data);
- }
- free(hotspot);
- }
wl_list_remove(&output->link);
free(output->name);
free(output);
@@ -75,9 +80,7 @@ static void swaybar_output_free(struct swaybar_output *output) {
static void set_output_dirty(struct swaybar_output *output) {
if (output->frame_scheduled) {
output->dirty = true;
- return;
- }
- if (output->surface) {
+ } else if (output->surface) {
render_frame(output);
}
}
diff --git a/swaybar/render.c b/swaybar/render.c
index dc31a5ea..2a06a79b 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -491,14 +491,7 @@ static const struct wl_callback_listener output_frame_listener = {
void render_frame(struct swaybar_output *output) {
assert(output->surface != NULL);
- struct swaybar_hotspot *hotspot, *tmp;
- wl_list_for_each_safe(hotspot, tmp, &output->hotspots, link) {
- if (hotspot->destroy) {
- hotspot->destroy(hotspot->data);
- }
- wl_list_remove(&hotspot->link);
- free(hotspot);
- }
+ free_hotspots(&output->hotspots);
cairo_surface_t *recorder = cairo_recording_surface_create(
CAIRO_CONTENT_COLOR_ALPHA, NULL);