summaryrefslogtreecommitdiffstats
path: root/swaybar
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-10-28 10:25:47 +0000
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-12-31 20:40:18 +0000
commit5f65f339896fadf0011b75d78c869594876d35d9 (patch)
treebbb234ad123657f1a8ed1f311cf9183b67e7e961 /swaybar
parentswaybar: remove old tray implementation (diff)
downloadsway-5f65f339896fadf0011b75d78c869594876d35d9.tar.gz
sway-5f65f339896fadf0011b75d78c869594876d35d9.tar.zst
sway-5f65f339896fadf0011b75d78c869594876d35d9.zip
swaybar: add tray interface
Diffstat (limited to 'swaybar')
-rw-r--r--swaybar/bar.c15
-rw-r--r--swaybar/meson.build40
-rw-r--r--swaybar/render.c9
-rw-r--r--swaybar/tray/tray.c21
4 files changed, 72 insertions, 13 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index 53e798bc..c26e76ce 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -18,6 +18,9 @@
18#include "swaybar/ipc.h" 18#include "swaybar/ipc.h"
19#include "swaybar/status_line.h" 19#include "swaybar/status_line.h"
20#include "swaybar/render.h" 20#include "swaybar/render.h"
21#if HAVE_TRAY
22#include "swaybar/tray/tray.h"
23#endif
21#include "ipc-client.h" 24#include "ipc-client.h"
22#include "list.h" 25#include "list.h"
23#include "log.h" 26#include "log.h"
@@ -362,6 +365,10 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
362 pointer->cursor_surface = wl_compositor_create_surface(bar->compositor); 365 pointer->cursor_surface = wl_compositor_create_surface(bar->compositor);
363 assert(pointer->cursor_surface); 366 assert(pointer->cursor_surface);
364 367
368#if HAVE_TRAY
369 bar->tray = create_tray(bar);
370#endif
371
365 if (bar->config->workspace_buttons) { 372 if (bar->config->workspace_buttons) {
366 ipc_get_workspaces(bar); 373 ipc_get_workspaces(bar);
367 } 374 }
@@ -403,6 +410,11 @@ void bar_run(struct swaybar *bar) {
403 loop_add_fd(bar->eventloop, bar->status->read_fd, POLLIN, 410 loop_add_fd(bar->eventloop, bar->status->read_fd, POLLIN,
404 status_in, bar); 411 status_in, bar);
405 } 412 }
413#if HAVE_TRAY
414 if (bar->tray) {
415 loop_add_fd(bar->eventloop, bar->tray->fd, POLLIN, tray_in, bar->tray->bus);
416 }
417#endif
406 while (1) { 418 while (1) {
407 errno = 0; 419 errno = 0;
408 if (wl_display_flush(bar->display) == -1 && errno != EAGAIN) { 420 if (wl_display_flush(bar->display) == -1 && errno != EAGAIN) {
@@ -420,6 +432,9 @@ static void free_outputs(struct wl_list *list) {
420} 432}
421 433
422void bar_teardown(struct swaybar *bar) { 434void bar_teardown(struct swaybar *bar) {
435#if HAVE_TRAY
436 destroy_tray(bar->tray);
437#endif
423 free_outputs(&bar->outputs); 438 free_outputs(&bar->outputs);
424 if (bar->config) { 439 if (bar->config) {
425 free_config(bar->config); 440 free_config(bar->config);
diff --git a/swaybar/meson.build b/swaybar/meson.build
index c27cf2c2..b83f47e5 100644
--- a/swaybar/meson.build
+++ b/swaybar/meson.build
@@ -1,3 +1,28 @@
1tray_files = get_option('enable-tray') ? [
2 'tray/tray.c',
3] : []
4
5swaybar_deps = [
6 cairo,
7 client_protos,
8 gdk_pixbuf,
9 jsonc,
10 math,
11 pango,
12 pangocairo,
13 rt,
14 wayland_client,
15 wayland_cursor,
16 wlroots,
17]
18if get_option('enable-tray')
19 if systemd.found()
20 swaybar_deps += systemd
21 elif elogind.found()
22 swaybar_deps += elogind
23 endif
24endif
25
1executable( 26executable(
2 'swaybar', [ 27 'swaybar', [
3 'bar.c', 28 'bar.c',
@@ -8,21 +33,10 @@ executable(
8 'main.c', 33 'main.c',
9 'render.c', 34 'render.c',
10 'status_line.c', 35 'status_line.c',
36 tray_files
11 ], 37 ],
12 include_directories: [sway_inc], 38 include_directories: [sway_inc],
13 dependencies: [ 39 dependencies: swaybar_deps,
14 cairo,
15 client_protos,
16 gdk_pixbuf,
17 jsonc,
18 math,
19 pango,
20 pangocairo,
21 rt,
22 wayland_client,
23 wayland_cursor,
24 wlroots,
25 ],
26 link_with: [lib_sway_common, lib_sway_client], 40 link_with: [lib_sway_common, lib_sway_client],
27 install_rpath : rpathdir, 41 install_rpath : rpathdir,
28 install: true 42 install: true
diff --git a/swaybar/render.c b/swaybar/render.c
index 96118c42..9fe4ee9c 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -14,6 +14,9 @@
14#include "swaybar/ipc.h" 14#include "swaybar/ipc.h"
15#include "swaybar/render.h" 15#include "swaybar/render.h"
16#include "swaybar/status_line.h" 16#include "swaybar/status_line.h"
17#if HAVE_TRAY
18#include "swaybar/tray/tray.h"
19#endif
17#include "wlr-layer-shell-unstable-v1-client-protocol.h" 20#include "wlr-layer-shell-unstable-v1-client-protocol.h"
18 21
19static const int WS_HORIZONTAL_PADDING = 5; 22static const int WS_HORIZONTAL_PADDING = 5;
@@ -453,6 +456,12 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct swaybar_output *output) {
453 * utilize the available space. 456 * utilize the available space.
454 */ 457 */
455 double x = output->width * output->scale; 458 double x = output->width * output->scale;
459#if HAVE_TRAY
460 if (bar->tray) {
461 uint32_t h = render_tray(cairo, output, &x);
462 max_height = h > max_height ? h : max_height;
463 }
464#endif
456 if (bar->status) { 465 if (bar->status) {
457 uint32_t h = render_status_line(cairo, output, &x); 466 uint32_t h = render_status_line(cairo, output, &x);
458 max_height = h > max_height ? h : max_height; 467 max_height = h > max_height ? h : max_height;
diff --git a/swaybar/tray/tray.c b/swaybar/tray/tray.c
new file mode 100644
index 00000000..d5fb3ea9
--- /dev/null
+++ b/swaybar/tray/tray.c
@@ -0,0 +1,21 @@
1#include <cairo.h>
2#include <stdint.h>
3#include <stdlib.h>
4#include "swaybar/bar.h"
5#include "swaybar/tray/tray.h"
6#include "log.h"
7
8struct swaybar_tray *create_tray(struct swaybar *bar) {
9 wlr_log(WLR_DEBUG, "Initializing tray");
10 return NULL;
11}
12
13void destroy_tray(struct swaybar_tray *tray) {
14}
15
16void tray_in(int fd, short mask, void *data) {
17}
18
19uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x) {
20 return 0; // placeholder
21}