i3 - improved tiling WM


i3bar: Simplify hide mode logic

Patch status: rejected

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.

fixes #1101

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

b/i3bar/src/xcb.c

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