swaybar: add tray interface

This commit is contained in:
Ian Fan 2018-10-28 10:25:47 +00:00
parent 598e950296
commit 5f65f33989
8 changed files with 110 additions and 13 deletions

View file

@ -18,6 +18,9 @@
#include "swaybar/ipc.h"
#include "swaybar/status_line.h"
#include "swaybar/render.h"
#if HAVE_TRAY
#include "swaybar/tray/tray.h"
#endif
#include "ipc-client.h"
#include "list.h"
#include "log.h"
@ -362,6 +365,10 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
pointer->cursor_surface = wl_compositor_create_surface(bar->compositor);
assert(pointer->cursor_surface);
#if HAVE_TRAY
bar->tray = create_tray(bar);
#endif
if (bar->config->workspace_buttons) {
ipc_get_workspaces(bar);
}
@ -403,6 +410,11 @@ void bar_run(struct swaybar *bar) {
loop_add_fd(bar->eventloop, bar->status->read_fd, POLLIN,
status_in, bar);
}
#if HAVE_TRAY
if (bar->tray) {
loop_add_fd(bar->eventloop, bar->tray->fd, POLLIN, tray_in, bar->tray->bus);
}
#endif
while (1) {
errno = 0;
if (wl_display_flush(bar->display) == -1 && errno != EAGAIN) {
@ -420,6 +432,9 @@ static void free_outputs(struct wl_list *list) {
}
void bar_teardown(struct swaybar *bar) {
#if HAVE_TRAY
destroy_tray(bar->tray);
#endif
free_outputs(&bar->outputs);
if (bar->config) {
free_config(bar->config);