]> git.sur5r.net Git - i3/i3/commitdiff
i3bar: implement the tray_output option
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 21 Oct 2011 18:47:56 +0000 (19:47 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 21 Oct 2011 18:47:56 +0000 (19:47 +0100)
i3bar/include/config.h
i3bar/src/config.c
i3bar/src/xcb.c

index 19b246dcface3ebd96ffa77926ca52b32c22ba02..5997b7f1be899842ce6ddacb3514abfe99f73ccb 100644 (file)
@@ -18,6 +18,7 @@ typedef struct config_t {
     char         *bar_id;
     char         *command;
     char         *fontname;
+    char         *tray_output;
 } config_t;
 
 config_t config;
index ad99fb9ab757dada653b2752dbabbd4afdc9a700..644c623e0214375f35b34be1a296130d3a3ed696 100644 (file)
@@ -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;
     }
 
index a3dba91e4f5e80c17f88cabccd2742eddcd8626b..4e347f576716ad98516e832762dc4220e348a2c4 100644 (file)
@@ -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 |