diff --git a/config.c b/config.c index db4580634..937b4b73a 100644 --- a/config.c +++ b/config.c @@ -299,13 +299,13 @@ parse_config(Display * disp, int scr, DC * drawcontext, jdwm_config *jdwmconf) tmp = config_lookup_string(&jdwmlibconf, "jdwm.barpos"); if(!strncmp(tmp, "BarTop", 6)) - jdwmconf->bpos = BarTop; + jdwmconf->statusbar_default_position = BarTop; else if(!strncmp(tmp, "BarBot", 6)) - jdwmconf->bpos = BarBot; + jdwmconf->statusbar_default_position = BarBot; else if(!strncmp(tmp, "BarOff", 6)) - jdwmconf->bpos = BarOff; + jdwmconf->statusbar_default_position = BarOff; - jdwmconf->current_bpos = jdwmconf->bpos; + jdwmconf->statusbar.position = jdwmconf->statusbar_default_position; /* borderpx */ jdwmconf->borderpx = config_lookup_int(&jdwmlibconf, "jdwm.borderpx"); diff --git a/config.h b/config.h index 5f0dadb05..8112beb11 100644 --- a/config.h +++ b/config.h @@ -57,8 +57,12 @@ typedef struct /** Status bar */ typedef struct { + /** Bar width */ int width; + /** Bar height */ int height; + /** Bar position */ + int position; } Statusbar; /** Main configuration structure */ @@ -90,10 +94,8 @@ struct jdwm_config KeySym modkey; /** Numlock mask */ unsigned int numlockmask; - /** Bar position */ - int bpos; - /** Current bar position */ - int current_bpos; + /** Default status bar position */ + int statusbar_default_position; /** Border size */ int borderpx; /** Master width factor */ diff --git a/event.c b/event.c index ccbf1c7ad..e48fb9d0d 100644 --- a/event.c +++ b/event.c @@ -241,7 +241,7 @@ handle_event_configurenotify(XEvent * e, jdwm_config *jdwmconf) XFreePixmap(e->xany.display, dc.drawable); dc.drawable = XCreatePixmap(e->xany.display, DefaultRootWindow(e->xany.display), sw, jdwmconf->statusbar.height, DefaultDepth(e->xany.display, screen)); XResizeWindow(e->xany.display, barwin, sw, jdwmconf->statusbar.height); - updatebarpos(e->xany.display, jdwmconf->statusbar, jdwmconf->current_bpos); + updatebarpos(e->xany.display, jdwmconf->statusbar); arrange(e->xany.display, jdwmconf); } } diff --git a/jdwm.c b/jdwm.c index 8386422ec..c6e900305 100644 --- a/jdwm.c +++ b/jdwm.c @@ -183,7 +183,7 @@ setup(Display *disp, jdwm_config *jdwmconf) DefaultVisual(disp, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); XDefineCursor(disp, barwin, cursor[CurNormal]); - updatebarpos(disp, jdwmconf->statusbar, jdwmconf->current_bpos); + updatebarpos(disp, jdwmconf->statusbar); XMapRaised(disp, barwin); /* pixmap for everything */ dc.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), sw, jdwmconf->statusbar.height, DefaultDepth(disp, screen)); @@ -216,7 +216,7 @@ uicb_quit(Display *disp __attribute__ ((unused)), } void -updatebarpos(Display *disp, Statusbar statusbar, int bpos) +updatebarpos(Display *disp, Statusbar statusbar) { XEvent ev; @@ -224,7 +224,7 @@ updatebarpos(Display *disp, Statusbar statusbar, int bpos) way = sy; wah = sh; waw = sw; - switch (bpos) + switch (statusbar.position) { default: wah -= statusbar.height; diff --git a/jdwm.h b/jdwm.h index 386438413..9ecfc6b95 100644 --- a/jdwm.h +++ b/jdwm.h @@ -42,7 +42,7 @@ enum { WMProtocols, WMDelete, WMName, WMState, WMLast }; /* default atoms */ Bool gettextprop(Display *, Window, Atom, char *, unsigned int); /* return text property, UTF-8 compliant */ -void updatebarpos(Display *, Statusbar, int); /* updates the bar position */ +void updatebarpos(Display *, Statusbar); /* updates the bar position */ void uicb_quit(Display *, jdwm_config *, const char *); /* quit jdwm nicely */ int xerror(Display *, XErrorEvent *); /* jdwm's X error handler */ diff --git a/layout.c b/layout.c index 58fcb7725..2942b7f33 100644 --- a/layout.c +++ b/layout.c @@ -174,11 +174,11 @@ uicb_togglebar(Display *disp, jdwm_config *jdwmconf, const char *arg __attribute__ ((unused))) { - if(jdwmconf->current_bpos == BarOff) - jdwmconf->current_bpos = (jdwmconf->bpos == BarOff) ? BarTop : jdwmconf->bpos; + if(jdwmconf->statusbar.position == BarOff) + jdwmconf->statusbar.position = (jdwmconf->statusbar.position == BarOff) ? BarTop : jdwmconf->statusbar_default_position; else - jdwmconf->current_bpos = BarOff; - updatebarpos(disp, jdwmconf->statusbar, jdwmconf->current_bpos); + jdwmconf->statusbar.position = BarOff; + updatebarpos(disp, jdwmconf->statusbar); arrange(disp, jdwmconf); } diff --git a/layouts/grid.c b/layouts/grid.c index 4fca1c853..528c7f24c 100644 --- a/layouts/grid.c +++ b/layouts/grid.c @@ -36,7 +36,7 @@ grid(Display *disp, jdwm_config *jdwmconf) continue; c->ismax = False; cx = (i / rows) * cw; - cy = (i % rows) * ch + (jdwmconf->current_bpos == BarTop ? jdwmconf->statusbar.height : 0); // bh? adjust + cy = (i % rows) * ch + (jdwmconf->statusbar.position == BarTop ? jdwmconf->statusbar.height : 0); // bh? adjust /* adjust height/width of last row/column's windows */ ah = ((i + 1) % rows == 0) ? wah - ch * rows : 0; aw = (i >= rows * (cols - 1)) ? waw - cw * cols : 0;