From 10089601c1eefe263276247d6245d3356f68d4a8 Mon Sep 17 00:00:00 2001 From: David Delassus Date: Thu, 3 May 2012 14:25:34 +0200 Subject: [PATCH] Add uicb_infobar_toggle_hide (Closes #18) --- src/client.h | 9 +++++++++ src/config.h | 3 +++ src/infobar.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/infobar.h | 2 ++ src/wmfs.h | 2 +- 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/client.h b/src/client.h index eb10c95..3783f80 100644 --- a/src/client.h +++ b/src/client.h @@ -211,4 +211,13 @@ client_get_larger(struct tag *t, bool ignoring_tag) return lc; } +static inline void +clients_layout_refresh(void) +{ + struct client *c; + + SLIST_FOREACH(c, &W->h.client, next) + layout_fix_hole(c); +} + #endif /* CLIENT_H */ diff --git a/src/config.h b/src/config.h index 9b83688..17e8754 100644 --- a/src/config.h +++ b/src/config.h @@ -88,6 +88,9 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] = { "status" , uicb_status }, { "status_surface", uicb_status_surface }, + /* Infobar */ + { "infobar_toggle_hide", uicb_infobar_toggle_hide }, + /* Mouse */ { "mouse_resize", uicb_mouse_resize }, { "mouse_move", uicb_mouse_move }, diff --git a/src/infobar.c b/src/infobar.c index 453033a..091d47c 100644 --- a/src/infobar.c +++ b/src/infobar.c @@ -515,8 +515,48 @@ infobar_free(struct screen *s) } } +void +uicb_infobar_toggle_hide(Uicb iname) +{ + struct infobar *i; + if (iname) + i = infobar_gb_name(iname); + else + i = SLIST_FIRST(&W->screen->infobars); + if(i->pos == BarHide) + { + i->pos = i->opos; + if(infobar_placement(i, i->pos)) + { + barwin_map(i->bar); + barwin_map_subwin(i->bar); + barwin_refresh_color(i->bar); + infobar_refresh(i); + } + } + else + { + i->opos = i->pos; + i->pos = BarHide; + barwin_unmap_subwin(i->bar); + barwin_unmap(i->bar); + + switch(i->opos) + { + case BarTop: + i->screen->ugeo.y -= i->geo.h; + case BarBottom: + i->screen->ugeo.h += i->geo.h; + case BarHide: + default: + break; + } + } + + clients_layout_refresh(); +} diff --git a/src/infobar.h b/src/infobar.h index 9e9c82f..a61e803 100644 --- a/src/infobar.h +++ b/src/infobar.h @@ -88,4 +88,6 @@ infobar_gb_name(const char *name) return SLIST_FIRST(&s->infobars); } +void uicb_infobar_toggle_hide(Uicb iname); + #endif /* INFOBAR_H */ diff --git a/src/wmfs.h b/src/wmfs.h index 1e6a4b4..d754f78 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -151,7 +151,7 @@ struct infobar struct screen *screen; struct theme *theme; struct status_ctx statusctx; - enum barpos pos; + enum barpos opos, pos; char *elemorder; char *name; TAILQ_HEAD(esub, element) elements;