i3 - improved tiling WM


i3bar: Simplify hide mode logic

Patch status: merged

Patch by Tony Crisci

Long description:

When determining whether to hide or unhide the bar on redraw in hide
mode, use simpler rules. When the config specifies the 'show' state or a
workspace is urgent, or if the caller requests it, or the modifier is
pressed, show the bar. Otherwise, hide the bar.

To apply this patch, use:
curl http://cr.i3wm.org/patch/287/raw.patch | git am

b/i3bar/src/xcb.c

17
@@ -1626,9 +1626,6 @@ void draw_bars(bool unhide) {
18
 
19
     refresh_statusline();
20
 
21
-    static char *last_urgent_ws = NULL;
22
-    bool walks_away = true;
23
-
24
     i3_output *outputs_walk;
25
     SLIST_FOREACH(outputs_walk, outputs, slist) {
26
         if (!outputs_walk->active) {
27
@@ -1697,9 +1694,6 @@ void draw_bars(bool unhide) {
28
                         fg_color = colors.focus_ws_fg;
29
                         bg_color = colors.focus_ws_bg;
30
                         border_color = colors.focus_ws_border;
31
-                        if (last_urgent_ws && strcmp(i3string_as_utf8(ws_walk->name),
32
-                                                     last_urgent_ws) == 0)
33
-                            walks_away = false;
34
                     }
35
                 }
36
                 if (ws_walk->urgent) {
37
@@ -1708,10 +1702,6 @@ void draw_bars(bool unhide) {
38
                     bg_color = colors.urgent_ws_bg;
39
                     border_color = colors.urgent_ws_border;
40
                     unhide = true;
41
-                    if (!ws_walk->focused) {
42
-                        FREE(last_urgent_ws);
43
-                        last_urgent_ws = sstrdup(i3string_as_utf8(ws_walk->name));
44
-                    }
45
                 }
46
                 uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND;
47
                 uint32_t vals_border[] = { border_color, border_color };
48
@@ -1783,13 +1773,11 @@ void draw_bars(bool unhide) {
49
     }
50
 
51
     /* Assure the bar is hidden/unhidden according to the specified hidden_state and mode */
52
-    bool should_unhide = (config.hidden_state == S_SHOW || (unhide && config.hidden_state == S_HIDE));
53
-    bool should_hide = (config.hide_on_modifier == M_INVISIBLE);
54
-
55
-    if (mod_pressed || (should_unhide && !should_hide)) {
56
+    if (mod_pressed ||
57
+            config.hidden_state == S_SHOW ||
58
+            unhide) {
59
         unhide_bars();
60
-    } else if (!mod_pressed && (walks_away || should_hide)) {
61
-        FREE(last_urgent_ws);
62
+    } else if (config.hide_on_modifier == M_HIDE) {
63
         hide_bars();
64
     }
65