]> git.sur5r.net Git - i3/i3/commitdiff
Added option to select primary display on tray_output
authorJose Pereira <onaips@gmail.com>
Sun, 1 Apr 2012 14:07:15 +0000 (15:07 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 5 Apr 2012 12:42:07 +0000 (14:42 +0200)
docs/userguide
i3bar/include/outputs.h
i3bar/src/outputs.c
i3bar/src/xcb.c
src/ipc.c

index 957d0c7fceba520f07b500c17ad06c890a186ebd..ad7c6195b68c253410318af2bf9254eed6e870b0 100644 (file)
@@ -964,7 +964,7 @@ you can turn off the functionality entirely.
 
 *Syntax*:
 -------------------------
-tray_output <none|output>
+tray_output <none|primary|output>
 -------------------------
 
 *Example*:
@@ -974,12 +974,20 @@ bar {
     tray_output none
 }
 
+# show tray icons on the primary monitor
+tray_output primary
+
 # show tray icons on the big monitor
 bar {
     tray_output HDMI2
 }
 -------------------------
 
+Note that you might not have a primary output configured yet. To do so, run:
+-------------------------
+xrandr --output <output> --primary
+-------------------------
+
 === Font
 
 Specifies the font (again, X core font, not Xft, just like in i3) to be used in
index 6501c318a534b8c407fb90ef4aa742530a314d77..f9ddd54bd8dff82d15f1705598bd436af6d4210a 100644 (file)
@@ -40,6 +40,7 @@ i3_output* get_output_by_name(char* name);
 struct i3_output {
     char*          name;          /* Name of the output */
     bool           active;        /* If the output is active */
+    bool           primary;       /* If it is the primary output */
     int            ws;            /* The number of the currently visible ws */
     rect           rect;          /* The rect (relative to the root-win) */
 
index 9dc5cab8563ffd200816296b7c4851d155749168..83a4c2487a14f109e4d2111be899bd8427f10211 100644 (file)
@@ -45,15 +45,19 @@ static int outputs_null_cb(void *params_) {
 static int outputs_boolean_cb(void *params_, int val) {
     struct outputs_json_params *params = (struct outputs_json_params*) params_;
 
-    if (strcmp(params->cur_key, "active")) {
-        return 0;
+    if (!strcmp(params->cur_key, "active")) {
+        params->outputs_walk->active = val;
+        FREE(params->cur_key);
+        return 1;
     }
 
-    params->outputs_walk->active = val;
-
-    FREE(params->cur_key);
+    if (!strcmp(params->cur_key, "primary")) {
+        params->outputs_walk->primary = val;
+        FREE(params->cur_key);
+        return 1;
+    }
 
-    return 1;
+    return 0;
 }
 
 /*
index 4d4dd3848c114807e0e78d0b7dd96f737bb782c0..a3f0dda8020e09f49b4a4442e2619dad77457e3e 100644 (file)
@@ -450,9 +450,12 @@ 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;
+                if (config.tray_output) {
+                    if ((strcasecmp(walk->name, config.tray_output) != 0) &&
+                        (!walk->primary || strcasecmp("primary", config.tray_output) != 0))
+                        continue;
+                }
+
                 DLOG("using output %s\n", walk->name);
                 output = walk;
             }
index 40ad868414e9afdd44912bf4ce27bf7dd7a53a82..5e91e21de27e325595602002b32a2c9ce1d76aba 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -443,6 +443,9 @@ IPC_HANDLER(get_outputs) {
         ystr("active");
         y(bool, output->active);
 
+        ystr("primary");
+        y(bool, output->primary);
+
         ystr("rect");
         y(map_open);
         ystr("x");