From a9aad872ee3933e24e9c6343e1e451f725e94652 Mon Sep 17 00:00:00 2001 From: "haptix@web.de" Date: Fri, 12 Apr 2013 00:09:40 +0200 Subject: [PATCH] unhide hidden i3bar when mode is active This patch also handles unhiding of i3bar in case the i3bar modifier key is pressed for activating a new binding mode. --- i3bar/src/xcb.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index bfe393b4..7cc955b9 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -80,6 +80,9 @@ ev_io *xkb_io; /* The name of current binding mode */ static mode binding; +/* Indicates whether a new binding mode was recently activated */ +bool activated_mode = false; + /* The parsed colors */ struct xcb_colors_t { uint32_t bar_fg; @@ -843,7 +846,7 @@ void xkb_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) { modstate = mods & config.modifier; } -#define DLOGMOD(modmask, status, barfunc) \ +#define DLOGMOD(modmask, status) \ do { \ switch (modmask) { \ case ShiftMask: \ @@ -868,14 +871,17 @@ void xkb_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) { DLOG("Mod5Mask got " #status "!\n"); \ break; \ } \ - barfunc(); \ } while (0) if (modstate != mod_pressed) { if (modstate == 0) { - DLOGMOD(config.modifier, released, hide_bars); + DLOGMOD(config.modifier, released); + if (!activated_mode) + hide_bars(); } else { - DLOGMOD(config.modifier, pressed, unhide_bars); + DLOGMOD(config.modifier, pressed); + activated_mode = false; + unhide_bars(); } mod_pressed = modstate; } @@ -1752,5 +1758,6 @@ void redraw_bars(void) { void set_current_mode(struct mode *current) { I3STRING_FREE(binding.name); binding = *current; + activated_mode = binding.name != NULL; return; } -- 2.39.2