From c76810a8c67e01972916830562310ef79ee4bbc1 Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Sun, 11 Dec 2011 16:42:09 +0200 Subject: implement togglepanel() function; to "hide" the panel on runtime togglepanel() doesn't really hide the panel togglepanel() actually resizes the windows to ignore the panel height thus overriding it when no windows are visible the panel is there, which is kind of a feature --- config.def.h | 1 + config.h | 1 + dminiwm.c | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 0529128..4280b24 100644 --- a/config.def.h +++ b/config.def.h @@ -54,6 +54,7 @@ const char *dmenucmd[] = { "dmenu", NULL }; /** Shortcuts **/ static key keys[] = { /* modifier key function argument */ + { MOD1, XK_b, togglepanel, {NULL}}, { MOD1|ShiftMask, XK_c, killclient, {NULL}}, { MOD1, XK_j, next_win, {NULL}}, { MOD1, XK_k, prev_win, {NULL}}, diff --git a/config.h b/config.h index 109de3b..c0cc622 100644 --- a/config.h +++ b/config.h @@ -65,6 +65,7 @@ const char *mtogglecmd[] = { "mpc", "toggle", NULL }; /** Shortcuts **/ static key keys[] = { /* modifier key function argument */ + { MOD1, XK_b, togglepanel, {NULL}}, { MOD1|ShiftMask, XK_c, killclient, {NULL}}, { MOD1, XK_j, next_win, {NULL}}, { MOD1, XK_k, prev_win, {NULL}}, diff --git a/dminiwm.c b/dminiwm.c index 6bdd872..f82da04 100644 --- a/dminiwm.c +++ b/dminiwm.c @@ -75,6 +75,7 @@ typedef struct { int growth; client *head; client *current; + Bool showpanel; } desktop; typedef struct { @@ -109,6 +110,7 @@ static void resize_master(const Arg arg); static void resize_stack(const Arg arg); static void save_desktop(int i); static void select_desktop(int i); +static void togglepanel(); static void deletewindow(Window w); static void setup(void); static void sigchld(); @@ -145,6 +147,7 @@ static client *head = NULL; static client *current = NULL; static Atom atoms[ATOM_COUNT]; static desktop desktops[DESKTOPS]; +static Bool showpanel = True; /* events array */ static void (*events[LASTEvent])(XEvent *e) = { @@ -323,6 +326,7 @@ void save_desktop(int i) { desktops[i].growth = growth; desktops[i].head = head; desktops[i].current = current; + desktops[i].showpanel = showpanel; } void select_desktop(int i) { @@ -332,16 +336,25 @@ void select_desktop(int i) { growth = desktops[i].growth; head = desktops[i].head; current = desktops[i].current; + showpanel = desktops[i].showpanel; current_desktop = i; } +void togglepanel() { + showpanel = !showpanel; + save_desktop(current_desktop); + tile(); +} + void tile(void) { if(head == NULL) return; /* no need to arange anything */ client *c; int n = 0; int x = 0; - int y = (TOP_PANEL) ? PANEL_HEIGHT : 0; + int panel_height = (showpanel) ? PANEL_HEIGHT : 0; + int y = (TOP_PANEL) ? panel_height : 0; + sh = XDisplayHeight(dis, screen) - panel_height - BORDER_WIDTH; if(head->next == NULL) { XMoveResizeWindow(dis, head->win, 0, y, sw + 2*BORDER_WIDTH, sh + 2*BORDER_WIDTH); -- cgit v1.3.1