From 8a24be955541ff92fd5be2f90c7790009d362ea9 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 21 Oct 2011 19:47:56 +0100 Subject: [PATCH] i3bar: implement the tray_output option --- i3bar/include/config.h | 1 + i3bar/src/config.c | 5 +++-- i3bar/src/xcb.c | 14 +++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/i3bar/include/config.h b/i3bar/include/config.h index 19b246dc..5997b7f1 100644 --- a/i3bar/include/config.h +++ b/i3bar/include/config.h @@ -18,6 +18,7 @@ typedef struct config_t { char *bar_id; char *command; char *fontname; + char *tray_output; } config_t; config_t config; diff --git a/i3bar/src/config.c b/i3bar/src/config.c index ad99fb9a..644c623e 100644 --- a/i3bar/src/config.c +++ b/i3bar/src/config.c @@ -90,8 +90,9 @@ static int config_string_cb(void *params_, const unsigned char *val, unsigned in } if (!strcmp(cur_key, "tray_output")) { - printf("tray_output %.*s\n", len, val); - /* XXX: these are not implemented yet */ + DLOG("tray_output %.*s\n", len, val); + FREE(config.tray_output); + asprintf(&config.tray_output, "%.*s", len, val); return 1; } diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index a3dba91e..4e347f57 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -489,6 +489,9 @@ static void handle_client_message(xcb_client_message_event_t* event) { SLIST_FOREACH(walk, outputs, slist) { if (!walk->active) continue; + if (config.tray_output && + strcasecmp(walk->name, config.tray_output) != 0) + continue; DLOG("using output %s\n", walk->name); output = walk; } @@ -988,6 +991,7 @@ void init_xcb_late(char *fontname) { * */ void init_tray() { + DLOG("Initializing system tray functionality\n"); /* request the tray manager atom for the X11 display we are running on */ char atomname[strlen("_NET_SYSTEM_TRAY_S") + 11]; snprintf(atomname, strlen("_NET_SYSTEM_TRAY_S") + 11, "_NET_SYSTEM_TRAY_S%d", screen); @@ -1194,6 +1198,7 @@ void realloc_sl_buffer() { void reconfig_windows() { uint32_t mask; uint32_t values[5]; + static bool tray_configured = false; i3_output *walk; SLIST_FOREACH(walk, outputs, slist) { @@ -1207,9 +1212,6 @@ void reconfig_windows() { if (walk->bar == XCB_NONE) { DLOG("Creating Window for output %s\n", walk->name); - /* TODO: only call init_tray() if the tray is configured for this output */ - init_tray(); - walk->bar = xcb_generate_id(xcb_connection); walk->buffer = xcb_generate_id(xcb_connection); mask = XCB_CW_BACK_PIXEL | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; @@ -1353,6 +1355,12 @@ void reconfig_windows() { (!config.hide_on_modifier && xcb_request_failed(map_cookie, "Could not map window"))) { exit(EXIT_FAILURE); } + + if (!tray_configured && + strcasecmp("none", config.tray_output) != 0) { + init_tray(); + tray_configured = true; + } } else { /* We already have a bar, so we just reconfigure it */ mask = XCB_CONFIG_WINDOW_X | -- 2.39.5