diff options
author | 2018-12-31 15:43:23 -0500 | |
---|---|---|
committer | 2018-12-31 15:43:23 -0500 | |
commit | 3d7c20f062bebe39199d3872e5b64d5e8d61d100 (patch) | |
tree | 93b8ddb51873cae14db8d5f07db74ca96236f184 /swaybar/bar.c | |
parent | Apply implicit fallback seat config (diff) | |
parent | swaybar: use KDE's SNI IconThemePath property (diff) | |
download | sway-3d7c20f062bebe39199d3872e5b64d5e8d61d100.tar.gz sway-3d7c20f062bebe39199d3872e5b64d5e8d61d100.tar.zst sway-3d7c20f062bebe39199d3872e5b64d5e8d61d100.zip |
Merge pull request #3249 from ianyfan/tray
Swaybar tray
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r-- | swaybar/bar.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index 53e798bc..7aed4dca 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <wayland-client.h> | 11 | #include <wayland-client.h> |
12 | #include <wayland-cursor.h> | 12 | #include <wayland-cursor.h> |
13 | #include <wlr/util/log.h> | 13 | #include <wlr/util/log.h> |
14 | #include "config.h" | ||
14 | #include "swaybar/bar.h" | 15 | #include "swaybar/bar.h" |
15 | #include "swaybar/config.h" | 16 | #include "swaybar/config.h" |
16 | #include "swaybar/i3bar.h" | 17 | #include "swaybar/i3bar.h" |
@@ -18,6 +19,9 @@ | |||
18 | #include "swaybar/ipc.h" | 19 | #include "swaybar/ipc.h" |
19 | #include "swaybar/status_line.h" | 20 | #include "swaybar/status_line.h" |
20 | #include "swaybar/render.h" | 21 | #include "swaybar/render.h" |
22 | #if HAVE_TRAY | ||
23 | #include "swaybar/tray/tray.h" | ||
24 | #endif | ||
21 | #include "ipc-client.h" | 25 | #include "ipc-client.h" |
22 | #include "list.h" | 26 | #include "list.h" |
23 | #include "log.h" | 27 | #include "log.h" |
@@ -120,7 +124,7 @@ static void destroy_layer_surface(struct swaybar_output *output) { | |||
120 | output->frame_scheduled = false; | 124 | output->frame_scheduled = false; |
121 | } | 125 | } |
122 | 126 | ||
123 | static void set_bar_dirty(struct swaybar *bar) { | 127 | void set_bar_dirty(struct swaybar *bar) { |
124 | struct swaybar_output *output; | 128 | struct swaybar_output *output; |
125 | wl_list_for_each(output, &bar->outputs, link) { | 129 | wl_list_for_each(output, &bar->outputs, link) { |
126 | set_output_dirty(output); | 130 | set_output_dirty(output); |
@@ -211,12 +215,16 @@ struct wl_output_listener output_listener = { | |||
211 | 215 | ||
212 | static void xdg_output_handle_logical_position(void *data, | 216 | static void xdg_output_handle_logical_position(void *data, |
213 | struct zxdg_output_v1 *xdg_output, int32_t x, int32_t y) { | 217 | struct zxdg_output_v1 *xdg_output, int32_t x, int32_t y) { |
214 | // Who cares | 218 | struct swaybar_output *output = data; |
219 | output->output_x = x; | ||
220 | output->output_y = y; | ||
215 | } | 221 | } |
216 | 222 | ||
217 | static void xdg_output_handle_logical_size(void *data, | 223 | static void xdg_output_handle_logical_size(void *data, |
218 | struct zxdg_output_v1 *xdg_output, int32_t width, int32_t height) { | 224 | struct zxdg_output_v1 *xdg_output, int32_t width, int32_t height) { |
219 | // Who cares | 225 | struct swaybar_output *output = data; |
226 | output->output_height = height; | ||
227 | output->output_width = width; | ||
220 | } | 228 | } |
221 | 229 | ||
222 | static void xdg_output_handle_done(void *data, | 230 | static void xdg_output_handle_done(void *data, |
@@ -362,6 +370,12 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) { | |||
362 | pointer->cursor_surface = wl_compositor_create_surface(bar->compositor); | 370 | pointer->cursor_surface = wl_compositor_create_surface(bar->compositor); |
363 | assert(pointer->cursor_surface); | 371 | assert(pointer->cursor_surface); |
364 | 372 | ||
373 | #if HAVE_TRAY | ||
374 | if (!bar->config->tray_hidden) { | ||
375 | bar->tray = create_tray(bar); | ||
376 | } | ||
377 | #endif | ||
378 | |||
365 | if (bar->config->workspace_buttons) { | 379 | if (bar->config->workspace_buttons) { |
366 | ipc_get_workspaces(bar); | 380 | ipc_get_workspaces(bar); |
367 | } | 381 | } |
@@ -403,6 +417,11 @@ void bar_run(struct swaybar *bar) { | |||
403 | loop_add_fd(bar->eventloop, bar->status->read_fd, POLLIN, | 417 | loop_add_fd(bar->eventloop, bar->status->read_fd, POLLIN, |
404 | status_in, bar); | 418 | status_in, bar); |
405 | } | 419 | } |
420 | #if HAVE_TRAY | ||
421 | if (bar->tray) { | ||
422 | loop_add_fd(bar->eventloop, bar->tray->fd, POLLIN, tray_in, bar->tray->bus); | ||
423 | } | ||
424 | #endif | ||
406 | while (1) { | 425 | while (1) { |
407 | errno = 0; | 426 | errno = 0; |
408 | if (wl_display_flush(bar->display) == -1 && errno != EAGAIN) { | 427 | if (wl_display_flush(bar->display) == -1 && errno != EAGAIN) { |
@@ -420,6 +439,9 @@ static void free_outputs(struct wl_list *list) { | |||
420 | } | 439 | } |
421 | 440 | ||
422 | void bar_teardown(struct swaybar *bar) { | 441 | void bar_teardown(struct swaybar *bar) { |
442 | #if HAVE_TRAY | ||
443 | destroy_tray(bar->tray); | ||
444 | #endif | ||
423 | free_outputs(&bar->outputs); | 445 | free_outputs(&bar->outputs); |
424 | if (bar->config) { | 446 | if (bar->config) { |
425 | free_config(bar->config); | 447 | free_config(bar->config); |