From de599089a3ad6a4ec479aac499ec14d268a81cd3 Mon Sep 17 00:00:00 2001 From: moetunes Date: Sat, 24 Dec 2011 05:07:43 +1000 Subject: [PATCH] Added keyboard shortcut to toggle the panel --- ChangeLog | 3 +++ config.h.def | 1 + dminiwm.c | 26 +++++++++++++++++++++----- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e9f6c0..4f5a416 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +24/12/11 + Added keyboard shortcut to toggle the panel + 23/12/11 Added keyboard shortcut options to follow window to new desktop or not diff --git a/config.h.def b/config.h.def index d198fcb..4105661 100644 --- a/config.h.def +++ b/config.h.def @@ -88,6 +88,7 @@ static key keys[] = { { MOD1, XK_p, resize_stack, {.i = 10}}, { MOD1, XK_o, resize_stack, {.i = -10}}, { MOD1, XK_Tab, last_desktop, {NULL}}, + { MOD1, XK_b, toggle_panel, {NULL}}, { MOD1, XK_Return, spawn, {.com = urxvtcmd}}, { MOD1, XK_Up, spawn, {.com = volupcmd}}, { MOD1, XK_Down, spawn, {.com = voldowncmd}}, diff --git a/dminiwm.c b/dminiwm.c index e268cb7..dd4b2c6 100644 --- a/dminiwm.c +++ b/dminiwm.c @@ -105,6 +105,7 @@ static void configurerequest(XEvent *e); static void destroynotify(XEvent *e); static void enternotify(XEvent *e); static void follow_client_to_desktop(const Arg arg); +static void last_desktop(); static void logger(const char* e); static unsigned long getcolor(const char* color); static void grabkeys(); @@ -128,9 +129,9 @@ static void sigchld(int unused); static void spawn(const Arg arg); static void start(); static void swap_master(); -static void tile(); -static void last_desktop(); static void switch_mode(const Arg arg); +static void tile(); +static void toggle_panel(); static void update_current(); // Include configuration file (need struct key) @@ -144,6 +145,7 @@ static int previous_desktop; static int growth; static int master_size; static int mode; +static int panel_size; static int sh; static int sw; static int screen; @@ -459,7 +461,7 @@ void tile() { int y = 0; // For a top panel - if(TOP_PANEL == 0) y = PANEL_HEIGHT; + if(TOP_PANEL == 0) y = panel_size; // If only one window if(head != NULL && head->next == NULL) @@ -625,6 +627,19 @@ void resize_stack(const Arg arg) { tile(); } +void toggle_panel() { + if(PANEL_HEIGHT > 0) { + if(panel_size >0) { + sh += panel_size; + panel_size = 0; + } else { + panel_size = PANEL_HEIGHT; + sh -= panel_size; + } + tile(); + } +} + /* ********************** Keyboard Management ********************** */ void grabkeys() { int i; @@ -668,7 +683,7 @@ void configurerequest(XEvent *e) { int y = 0; wc.x = ev->x; - if(TOP_PANEL == 0) y = PANEL_HEIGHT; + if(TOP_PANEL == 0) y = panel_size; wc.y = ev->y + y; if(ev->width < sw-BORDER_WIDTH) wc.width = ev->width; @@ -898,8 +913,9 @@ void setup() { root = RootWindow(dis,screen); // Screen width and height + panel_size = PANEL_HEIGHT; sw = XDisplayWidth(dis,screen) - BORDER_WIDTH; - sh = (XDisplayHeight(dis,screen) - PANEL_HEIGHT) - BORDER_WIDTH; + sh = (XDisplayHeight(dis,screen) - panel_size) - BORDER_WIDTH; // Colors win_focus = getcolor(FOCUS);