aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/bar.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r--swaybar/bar.c55
1 files changed, 35 insertions, 20 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index 231c1ad7..021fc3bd 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,
@@ -367,6 +362,9 @@ static void handle_global(void *data, struct wl_registry *registry,
367 } else if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) { 362 } else if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) {
368 bar->xdg_output_manager = wl_registry_bind(registry, name, 363 bar->xdg_output_manager = wl_registry_bind(registry, name,
369 &zxdg_output_manager_v1_interface, 2); 364 &zxdg_output_manager_v1_interface, 2);
365 } else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) {
366 bar->cursor_shape_manager = wl_registry_bind(registry, name,
367 &wp_cursor_shape_manager_v1_interface, 1);
370 } 368 }
371} 369}
372 370
@@ -430,15 +428,17 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
430 // Second roundtrip for xdg-output 428 // Second roundtrip for xdg-output
431 wl_display_roundtrip(bar->display); 429 wl_display_roundtrip(bar->display);
432 430
433 struct swaybar_seat *seat; 431 if (!bar->cursor_shape_manager) {
434 wl_list_for_each(seat, &bar->seats, link) { 432 struct swaybar_seat *seat;
435 struct swaybar_pointer *pointer = &seat->pointer; 433 wl_list_for_each(seat, &bar->seats, link) {
436 if (!pointer) { 434 struct swaybar_pointer *pointer = &seat->pointer;
437 continue; 435 if (!pointer) {
436 continue;
437 }
438 pointer->cursor_surface =
439 wl_compositor_create_surface(bar->compositor);
440 assert(pointer->cursor_surface);
438 } 441 }
439 pointer->cursor_surface =
440 wl_compositor_create_surface(bar->compositor);
441 assert(pointer->cursor_surface);
442 } 442 }
443 443
444 if (bar->config->status_command) { 444 if (bar->config->status_command) {
@@ -461,13 +461,28 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
461 461
462static void display_in(int fd, short mask, void *data) { 462static void display_in(int fd, short mask, void *data) {
463 struct swaybar *bar = data; 463 struct swaybar *bar = data;
464 if (mask & (POLLHUP | POLLERR)) {
465 if (mask & POLLERR) {
466 sway_log(SWAY_ERROR, "Wayland display poll error");
467 }
468 bar->running = false;
469 return;
470 }
464 if (wl_display_dispatch(bar->display) == -1) { 471 if (wl_display_dispatch(bar->display) == -1) {
472 sway_log(SWAY_ERROR, "wl_display_dispatch failed");
465 bar->running = false; 473 bar->running = false;
466 } 474 }
467} 475}
468 476
469static void ipc_in(int fd, short mask, void *data) { 477static void ipc_in(int fd, short mask, void *data) {
470 struct swaybar *bar = data; 478 struct swaybar *bar = data;
479 if (mask & (POLLHUP | POLLERR)) {
480 if (mask & POLLERR) {
481 sway_log(SWAY_ERROR, "IPC poll error");
482 }
483 bar->running = false;
484 return;
485 }
471 if (handle_ipc_readable(bar)) { 486 if (handle_ipc_readable(bar)) {
472 set_bar_dirty(bar); 487 set_bar_dirty(bar);
473 } 488 }