aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/bar.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r--swaybar/bar.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index 231c1ad7..5e4ebd97 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -51,10 +51,6 @@ static void swaybar_output_free(struct swaybar_output *output) {
51 if (output->surface != NULL) { 51 if (output->surface != NULL) {
52 wl_surface_destroy(output->surface); 52 wl_surface_destroy(output->surface);
53 } 53 }
54 if (output->input_region != NULL) {
55 wl_region_destroy(output->input_region);
56 }
57 zxdg_output_v1_destroy(output->xdg_output);
58 wl_output_destroy(output->output); 54 wl_output_destroy(output->output);
59 destroy_buffer(&output->buffers[0]); 55 destroy_buffer(&output->buffers[0]);
60 destroy_buffer(&output->buffers[1]); 56 destroy_buffer(&output->buffers[1]);
@@ -90,7 +86,7 @@ static void layer_surface_closed(void *_output,
90 swaybar_output_free(output); 86 swaybar_output_free(output);
91} 87}
92 88
93struct zwlr_layer_surface_v1_listener layer_surface_listener = { 89static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
94 .configure = layer_surface_configure, 90 .configure = layer_surface_configure,
95 .closed = layer_surface_closed, 91 .closed = layer_surface_closed,
96}; 92};
@@ -114,10 +110,9 @@ static void add_layer_surface(struct swaybar_output *output) {
114 110
115 if (overlay) { 111 if (overlay) {
116 // Empty input region 112 // Empty input region
117 output->input_region = wl_compositor_create_region(bar->compositor); 113 struct wl_region *region = wl_compositor_create_region(bar->compositor);
118 assert(output->input_region); 114 wl_surface_set_input_region(output->surface, region);
119 115 wl_region_destroy(region);
120 wl_surface_set_input_region(output->surface, output->input_region);
121 } 116 }
122 117
123 zwlr_layer_surface_v1_set_anchor(output->layer_surface, config->position); 118 zwlr_layer_surface_v1_set_anchor(output->layer_surface, config->position);
@@ -172,7 +167,7 @@ bool determine_bar_visibility(struct swaybar *bar, bool moving_layer) {
172 if (bar->status) { 167 if (bar->status) {
173 sway_log(SWAY_DEBUG, "Sending %s signal to status command", 168 sway_log(SWAY_DEBUG, "Sending %s signal to status command",
174 visible ? "cont" : "stop"); 169 visible ? "cont" : "stop");
175 kill(bar->status->pid, visible ? 170 kill(-bar->status->pid, visible ?
176 bar->status->cont_signal : bar->status->stop_signal); 171 bar->status->cont_signal : bar->status->stop_signal);
177 } 172 }
178 } 173 }
@@ -230,7 +225,7 @@ static void output_scale(void *data, struct wl_output *wl_output,
230 } 225 }
231} 226}
232 227
233struct wl_output_listener output_listener = { 228static const struct wl_output_listener output_listener = {
234 .geometry = output_geometry, 229 .geometry = output_geometry,
235 .mode = output_mode, 230 .mode = output_mode,
236 .done = output_done, 231 .done = output_done,
@@ -307,7 +302,7 @@ static void xdg_output_handle_description(void *data,
307 } 302 }
308} 303}
309 304
310struct zxdg_output_v1_listener xdg_output_listener = { 305static const struct zxdg_output_v1_listener xdg_output_listener = {
311 .logical_position = xdg_output_handle_logical_position, 306 .logical_position = xdg_output_handle_logical_position,
312 .logical_size = xdg_output_handle_logical_size, 307 .logical_size = xdg_output_handle_logical_size,
313 .done = xdg_output_handle_done, 308 .done = xdg_output_handle_done,
@@ -461,13 +456,28 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
461 456
462static void display_in(int fd, short mask, void *data) { 457static void display_in(int fd, short mask, void *data) {
463 struct swaybar *bar = data; 458 struct swaybar *bar = data;
459 if (mask & (POLLHUP | POLLERR)) {
460 if (mask & POLLERR) {
461 sway_log(SWAY_ERROR, "Wayland display poll error");
462 }
463 bar->running = false;
464 return;
465 }
464 if (wl_display_dispatch(bar->display) == -1) { 466 if (wl_display_dispatch(bar->display) == -1) {
467 sway_log(SWAY_ERROR, "wl_display_dispatch failed");
465 bar->running = false; 468 bar->running = false;
466 } 469 }
467} 470}
468 471
469static void ipc_in(int fd, short mask, void *data) { 472static void ipc_in(int fd, short mask, void *data) {
470 struct swaybar *bar = data; 473 struct swaybar *bar = data;
474 if (mask & (POLLHUP | POLLERR)) {
475 if (mask & POLLERR) {
476 sway_log(SWAY_ERROR, "IPC poll error");
477 }
478 bar->running = false;
479 return;
480 }
471 if (handle_ipc_readable(bar)) { 481 if (handle_ipc_readable(bar)) {
472 set_bar_dirty(bar); 482 set_bar_dirty(bar);
473 } 483 }