diff --git a/config.c b/config.c index bac1552fb..db4580634 100644 --- a/config.c +++ b/config.c @@ -17,8 +17,6 @@ #include "layouts/spiral.h" #include "layouts/floating.h" -int blw = 0; - /* static */ static void initfont(const char *, Display *, DC *); static unsigned long initcolor(const char *colstr, Display *, int); @@ -165,6 +163,8 @@ static void set_default_config(jdwm_config *jdwmconf) { strcpy(jdwmconf->statustext, "jdwm-" VERSION); + jdwmconf->statusbar.width = 0; + jdwmconf->statusbar.height = 0; } /** Parse configuration file and initialize some stuff @@ -217,8 +217,8 @@ parse_config(Display * disp, int scr, DC * drawcontext, jdwm_config *jdwmconf) eprint("unknown layout in configuration file\n"); j = textw(jdwmconf->layouts[i].symbol); - if(j > blw) - blw = j; + if(j > jdwmconf->statusbar.width) + jdwmconf->statusbar.width = j; } jdwmconf->layouts[i].symbol = NULL; diff --git a/config.h b/config.h index 180c155a8..5f0dadb05 100644 --- a/config.h +++ b/config.h @@ -54,6 +54,13 @@ typedef struct const char *arg; } Key; +/** Status bar */ +typedef struct +{ + int width; + int height; +} Statusbar; + /** Main configuration structure */ struct jdwm_config { @@ -101,6 +108,8 @@ struct jdwm_config char statustext[256]; /** Current layout */ Layout * current_layout; + /** Status bar */ + Statusbar statusbar; }; void parse_config(Display *, int, DC *, jdwm_config *); /* parse configuration file */ diff --git a/draw.c b/draw.c index 7a65cb2e8..2b3d4e83d 100644 --- a/draw.c +++ b/draw.c @@ -3,7 +3,6 @@ #include "layout.h" extern int sw; /* screen geometry */ -extern int bh, blw; /* bar height, bar layout label width */ extern Window barwin; extern DC dc; /* global draw context */ extern Client *clients, *sel, *stack; /* global client list and stack */ @@ -127,7 +126,7 @@ drawstatus(Display *disp, jdwm_config * jdwmconf) } dc.x += dc.w; } - dc.w = blw; + dc.w = jdwmconf->statusbar.width; drawtext(disp, jdwmconf->current_layout->symbol, dc.norm); x = dc.x + dc.w; dc.w = textw(jdwmconf->statustext); @@ -138,7 +137,7 @@ drawstatus(Display *disp, jdwm_config * jdwmconf) dc.w = sw - x; } drawtext(disp, jdwmconf->statustext, dc.norm); - if((dc.w = dc.x - x) > bh) + if((dc.w = dc.x - x) > jdwmconf->statusbar.height) { dc.x = x; if(sel) @@ -149,6 +148,6 @@ drawstatus(Display *disp, jdwm_config * jdwmconf) else drawtext(disp, NULL, dc.norm); } - XCopyArea(disp, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0); + XCopyArea(disp, dc.drawable, barwin, dc.gc, 0, 0, sw, jdwmconf->statusbar.height, 0, 0); XSync(disp, False); } diff --git a/event.c b/event.c index e531091b7..ccbf1c7ad 100644 --- a/event.c +++ b/event.c @@ -15,7 +15,6 @@ /* extern */ extern int screen, sw, sh; /* screen geometry */ extern int wax, way, wah, waw; /* windowarea geometry */ -extern int bh, blw; /* bar height, bar layout label width */ extern Window barwin; extern DC dc; /* global draw context */ extern Cursor cursor[CurLast]; @@ -152,7 +151,7 @@ handle_event_buttonpress(XEvent * e, jdwm_config *jdwmconf) return; } } - if((ev->x < x + blw) && ev->button == Button1) + if((ev->x < x + jdwmconf->statusbar.width) && ev->button == Button1) uicb_setlayout(e->xany.display, jdwmconf, NULL); } else if((c = getclient(ev->window))) @@ -240,9 +239,9 @@ handle_event_configurenotify(XEvent * e, jdwm_config *jdwmconf) sw = ev->width; sh = ev->height; XFreePixmap(e->xany.display, dc.drawable); - dc.drawable = XCreatePixmap(e->xany.display, DefaultRootWindow(e->xany.display), sw, bh, DefaultDepth(e->xany.display, screen)); - XResizeWindow(e->xany.display, barwin, sw, bh); - updatebarpos(e->xany.display, jdwmconf->current_bpos); + 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); arrange(e->xany.display, jdwmconf); } } diff --git a/jdwm.c b/jdwm.c index 1bfbbe28b..8386422ec 100644 --- a/jdwm.c +++ b/jdwm.c @@ -19,7 +19,6 @@ #include "tag.h" int screen, sx, sy, sw, sh, wax, way, waw, wah; -int bh; Atom jdwmprops, wmatom[WMLast], netatom[NetLast]; Client *clients = NULL; Client *sel = NULL; @@ -175,19 +174,19 @@ setup(Display *disp, jdwm_config *jdwmconf) sw = DisplayWidth(disp, screen); sh = DisplayHeight(disp, screen); /* bar */ - dc.h = bh = dc.font.height + 2; + dc.h = jdwmconf->statusbar.height = dc.font.height + 2; wa.override_redirect = 1; wa.background_pixmap = ParentRelative; wa.event_mask = ButtonPressMask | ExposureMask; - barwin = XCreateWindow(disp, DefaultRootWindow(disp), sx, sy, sw, bh, 0, + barwin = XCreateWindow(disp, DefaultRootWindow(disp), sx, sy, sw, jdwmconf->statusbar.height, 0, DefaultDepth(disp, screen), CopyFromParent, DefaultVisual(disp, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); XDefineCursor(disp, barwin, cursor[CurNormal]); - updatebarpos(disp, jdwmconf->current_bpos); + updatebarpos(disp, jdwmconf->statusbar, jdwmconf->current_bpos); XMapRaised(disp, barwin); /* pixmap for everything */ - dc.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), sw, bh, DefaultDepth(disp, screen)); + dc.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), sw, jdwmconf->statusbar.height, DefaultDepth(disp, screen)); dc.gc = XCreateGC(disp, DefaultRootWindow(disp), 0, 0); XSetLineAttributes(disp, dc.gc, 1, LineSolid, CapButt, JoinMiter); if(!dc.font.set) @@ -217,7 +216,7 @@ uicb_quit(Display *disp __attribute__ ((unused)), } void -updatebarpos(Display *disp, int bpos) +updatebarpos(Display *disp, Statusbar statusbar, int bpos) { XEvent ev; @@ -228,16 +227,16 @@ updatebarpos(Display *disp, int bpos) switch (bpos) { default: - wah -= bh; - way += bh; + wah -= statusbar.height; + way += statusbar.height; XMoveWindow(disp, barwin, sx, sy); break; case BarBot: - wah -= bh; + wah -= statusbar.height; XMoveWindow(disp, barwin, sx, sy + wah); break; case BarOff: - XMoveWindow(disp, barwin, sx, sy - bh); + XMoveWindow(disp, barwin, sx, sy - statusbar.height); break; } XSync(disp, False); diff --git a/jdwm.h b/jdwm.h index 15211fbed..386438413 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 *, int); /* updates the bar position */ +void updatebarpos(Display *, Statusbar, int); /* 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 207bc8ab0..58fcb7725 100644 --- a/layout.c +++ b/layout.c @@ -178,7 +178,7 @@ uicb_togglebar(Display *disp, jdwmconf->current_bpos = (jdwmconf->bpos == BarOff) ? BarTop : jdwmconf->bpos; else jdwmconf->current_bpos = BarOff; - updatebarpos(disp, jdwmconf->current_bpos); + updatebarpos(disp, jdwmconf->statusbar, jdwmconf->current_bpos); arrange(disp, jdwmconf); } diff --git a/layouts/grid.c b/layouts/grid.c index ee4d84cb0..4fca1c853 100644 --- a/layouts/grid.c +++ b/layouts/grid.c @@ -5,7 +5,6 @@ #include "tag.h" extern int wah, waw; /* windowarea geometry */ -extern int bh, bpos; /* bar height, bar position */ extern Client *clients; /* global client list and stack */ extern DC dc; @@ -37,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 ? bh : 0); // bh? adjust + cy = (i % rows) * ch + (jdwmconf->current_bpos == 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; diff --git a/layouts/tile.c b/layouts/tile.c index 28750986a..44b5703e9 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -9,7 +9,6 @@ /* extern */ extern int wax, way, wah, waw; /* windowarea geometry */ -extern int bh; /* bar height */ extern Client *sel, *clients; /* static */ @@ -85,7 +84,7 @@ _tile(jdwm_config *jdwmconf, const Bool right) mh = (n <= nmaster) ? wah / (n > 0 ? n : 1) : wah / nmaster; mw = (n <= nmaster) ? waw : mwfact * waw; th = (n > nmaster) ? wah / (n - nmaster) : 0; - if(n > nmaster && th < bh) + if(n > nmaster && th < jdwmconf->statusbar.height) th = wah; nx = wax;