diff options
| author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2012-03-01 19:33:17 +0200 |
|---|---|---|
| committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2012-12-16 02:11:13 +0200 |
| commit | 5f4c250dfccca65f7547b7d5546aa67a2d2ad46a (patch) | |
| tree | 2f39411c19bd1c582eea71ac223ec95388bfe133 | |
| parent | 62c0675d7d62ec1bc8bc3d751311cf4986d2ffcd (diff) | |
make panel toggleable with a shortcut
| -rw-r--r-- | config.def.h | 2 | ||||
| -rw-r--r-- | monsterwm.c | 19 |
2 files changed, 18 insertions, 3 deletions
diff --git a/config.def.h b/config.def.h index 7dfe268..0e301d3 100644 --- a/config.def.h +++ b/config.def.h @@ -11,6 +11,7 @@ /** generic settings **/ #define MASTER_SIZE 0.52 +#define SHOW_PANEL True /* show panel by default on exec */ #define TOP_PANEL True /* False means panel is on bottom */ #define PANEL_HEIGHT 18 /* 0 for no space for panel, thus no panel */ #define DEFAULT_MODE TILE /* initial layout/mode: TILE MONOCLE BSTACK GRID FLOAT */ @@ -50,6 +51,7 @@ static const char *termcmd[] = { "xterm", NULL }; */ static Key keys[] = { /* modifier key function argument */ + { MOD1, XK_b, togglepanel, {NULL}}, { MOD1|SHIFT, XK_c, killclient, {NULL}}, { MOD1, XK_j, next_win, {NULL}}, { MOD1, XK_k, prev_win, {NULL}}, diff --git a/monsterwm.c b/monsterwm.c index b1109f3..008e421 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -91,6 +91,7 @@ static void quit(); static void spawn(const Arg *arg); static void swap_master(); static void switch_mode(const Arg *arg); +static void togglepanel(); #include "config.h" @@ -121,10 +122,12 @@ typedef struct Client { * head - the start of the client list * curr - the currently highlighted window * prev - the client that previously had focus + * sbar - the visibility status of the panel/statusbar */ typedef struct { int mode; Client *head, *curr, *prev; + Bool sbar; } Desktop; /* hidden function prototypes sorted alphabetically */ @@ -957,8 +960,9 @@ void setup(void) { ww = XDisplayWidth(dis, screen); wh = XDisplayHeight(dis, screen) - PANEL_HEIGHT; - /* initialize mode for each desktop */ - for (unsigned int d = 0; d < DESKTOPS; d++) desktops[d] = (Desktop){ .mode = DEFAULT_MODE }; + /* initialize mode and panel visibility for each desktop */ + for (unsigned int d = 0; d < DESKTOPS; d++) + desktops[d] = (Desktop){ .mode = DEFAULT_MODE, .sbar = SHOW_PANEL }; /* get color for focused and unfocused client borders */ win_focus = getcolor(FOCUS, screen); @@ -1084,7 +1088,16 @@ void switch_mode(const Arg *arg) { */ void tile(Desktop *d) { if (!d->head || d->mode == FLOAT) return; /* nothing to arange */ - layout[d->head->next ? d->mode:MONOCLE](0, TOP_PANEL ? PANEL_HEIGHT:0, ww, wh, d); + layout[d->head->next ? d->mode:MONOCLE](0, TOP_PANEL && d->sbar ? PANEL_HEIGHT:0, + ww, wh + (d->sbar ? 0:PANEL_HEIGHT), d); +} + +/** + * toggle visibility state of the panel/bar + */ +void togglepanel(void) { + desktops[currdeskidx].sbar = !desktops[currdeskidx].sbar; + tile(&desktops[currdeskidx]); } /** |
