]> git.sur5r.net Git - i3/i3/commitdiff
Automatically hide i3bar when it's unneeded.
authordarkraven <drdarkraven@gmail.com>
Thu, 26 Jul 2012 18:53:32 +0000 (02:53 +0800)
committerMichael Stapelberg <michael@stapelberg.de>
Wed, 1 Aug 2012 23:44:25 +0000 (01:44 +0200)
When a workspace marked 'urgent', i3bar unhide
itself. if I want to hide it again, I must press the
modifier.This sometimes annoys me.

In this patch I change the above behavior to this:
If a urgent workspace occurs, i3bar will unhide itself;
and when you navigates away from the last urgent
workspace and there is no more urgent workspace, i3bar
will hide itself.

i3bar/src/xcb.c

index 289d7d9ed96a5e759bafe8784c24edc7c14df154..419a47238fda317f784f57e7af5aff048128c924 100644 (file)
@@ -1464,6 +1464,9 @@ void draw_bars() {
         }
 
         i3_ws *ws_walk;
+        static char *last_urgent_ws = NULL;
+        bool has_urgent = false, walks_away = true;
+
         TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) {
             DLOG("Drawing Button for WS %s at x = %d, len = %d\n", ws_walk->name, i, ws_walk->name_width);
             uint32_t fg_color = colors.inactive_ws_fg;
@@ -1478,6 +1481,8 @@ void draw_bars() {
                     fg_color = colors.focus_ws_fg;
                     bg_color = colors.focus_ws_bg;
                     border_color = colors.focus_ws_border;
+                    if (last_urgent_ws && strcmp(ws_walk->name, last_urgent_ws) == 0)
+                        walks_away = false;
                 }
             }
             if (ws_walk->urgent) {
@@ -1485,6 +1490,11 @@ void draw_bars() {
                 fg_color = colors.urgent_ws_fg;
                 bg_color = colors.urgent_ws_bg;
                 border_color = colors.urgent_ws_border;
+                has_urgent = true;
+                if (!ws_walk->focused) {
+                    FREE(last_urgent_ws);
+                    last_urgent_ws = sstrdup(ws_walk->name);
+                }
                 /* The urgent-hint should get noticed, so we unhide the bars shortly */
                 unhide_bars();
             }
@@ -1517,6 +1527,11 @@ void draw_bars() {
             i += 10 + ws_walk->name_width + 1;
         }
 
+        if (!has_urgent && !mod_pressed && walks_away) {
+            FREE(last_urgent_ws);
+            hide_bars();
+        }
+
         i = 0;
     }