i3bar: implement the tray_output option

This commit is contained in:
Michael Stapelberg 2011-10-21 19:47:56 +01:00
parent d71db710dd
commit 8a24be9555
3 changed files with 15 additions and 5 deletions

View File

@ -18,6 +18,7 @@ typedef struct config_t {
char *bar_id; char *bar_id;
char *command; char *command;
char *fontname; char *fontname;
char *tray_output;
} config_t; } config_t;
config_t config; config_t config;

View File

@ -90,8 +90,9 @@ static int config_string_cb(void *params_, const unsigned char *val, unsigned in
} }
if (!strcmp(cur_key, "tray_output")) { if (!strcmp(cur_key, "tray_output")) {
printf("tray_output %.*s\n", len, val); DLOG("tray_output %.*s\n", len, val);
/* XXX: these are not implemented yet */ FREE(config.tray_output);
asprintf(&config.tray_output, "%.*s", len, val);
return 1; return 1;
} }

View File

@ -489,6 +489,9 @@ static void handle_client_message(xcb_client_message_event_t* event) {
SLIST_FOREACH(walk, outputs, slist) { SLIST_FOREACH(walk, outputs, slist) {
if (!walk->active) if (!walk->active)
continue; continue;
if (config.tray_output &&
strcasecmp(walk->name, config.tray_output) != 0)
continue;
DLOG("using output %s\n", walk->name); DLOG("using output %s\n", walk->name);
output = walk; output = walk;
} }
@ -988,6 +991,7 @@ void init_xcb_late(char *fontname) {
* *
*/ */
void init_tray() { void init_tray() {
DLOG("Initializing system tray functionality\n");
/* request the tray manager atom for the X11 display we are running on */ /* request the tray manager atom for the X11 display we are running on */
char atomname[strlen("_NET_SYSTEM_TRAY_S") + 11]; char atomname[strlen("_NET_SYSTEM_TRAY_S") + 11];
snprintf(atomname, strlen("_NET_SYSTEM_TRAY_S") + 11, "_NET_SYSTEM_TRAY_S%d", screen); 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() { void reconfig_windows() {
uint32_t mask; uint32_t mask;
uint32_t values[5]; uint32_t values[5];
static bool tray_configured = false;
i3_output *walk; i3_output *walk;
SLIST_FOREACH(walk, outputs, slist) { SLIST_FOREACH(walk, outputs, slist) {
@ -1207,9 +1212,6 @@ void reconfig_windows() {
if (walk->bar == XCB_NONE) { if (walk->bar == XCB_NONE) {
DLOG("Creating Window for output %s\n", walk->name); 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->bar = xcb_generate_id(xcb_connection);
walk->buffer = 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; 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"))) { (!config.hide_on_modifier && xcb_request_failed(map_cookie, "Could not map window"))) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!tray_configured &&
strcasecmp("none", config.tray_output) != 0) {
init_tray();
tray_configured = true;
}
} else { } else {
/* We already have a bar, so we just reconfigure it */ /* We already have a bar, so we just reconfigure it */
mask = XCB_CONFIG_WINDOW_X | mask = XCB_CONFIG_WINDOW_X |