From 24e15433b7b51ca69da19021e15160e5bb16af5e Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 5 Sep 2007 20:39:11 +0200 Subject: [PATCH] remove bpos from global var, added in jdwmconf --- config.c | 5 +---- config.h | 2 ++ event.c | 2 +- jdwm.c | 5 ++--- jdwm.h | 2 +- layout.c | 9 ++++----- layouts/grid.c | 2 +- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/config.c b/config.c index e8f675c29..f5c9d288f 100644 --- a/config.c +++ b/config.c @@ -26,9 +26,6 @@ static unsigned int get_numlockmask(Display *); /** Main configuration object for parsing*/ config_t jdwmlibconf; -/** Current bar position */ -int bpos; - /** Link a name to a function */ typedef struct { @@ -281,7 +278,7 @@ parse_config(Display * disp, int scr, DC * drawcontext, jdwm_config *jdwmconf) else if(!strncmp(tmp, "BarOff", 6)) jdwmconf->bpos = BarOff; - bpos = jdwmconf->bpos; + jdwmconf->current_bpos = jdwmconf->bpos; /* borderpx */ jdwmconf->borderpx = config_lookup_int(&jdwmlibconf, "jdwm.borderpx"); diff --git a/config.h b/config.h index 1d4efbb87..abc4a846a 100644 --- a/config.h +++ b/config.h @@ -79,6 +79,8 @@ struct jdwm_config unsigned int numlockmask; /** Bar position */ int bpos; + /** Current bar position */ + int current_bpos; /** Border size */ int borderpx; /** Master width factor */ diff --git a/event.c b/event.c index 7c6cf457c..a39cde90e 100644 --- a/event.c +++ b/event.c @@ -244,7 +244,7 @@ configurenotify(XEvent * e, jdwm_config *jdwmconf) 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); + updatebarpos(e->xany.display, jdwmconf->current_bpos); arrange(e->xany.display, jdwmconf); } } diff --git a/jdwm.c b/jdwm.c index 6bff4ca68..af54e60e5 100644 --- a/jdwm.c +++ b/jdwm.c @@ -20,7 +20,6 @@ #include "tag.h" /* extern */ -extern int bpos; /* bar position */ extern void (*handler[LASTEvent]) (XEvent *, jdwm_config *); /* event handler */ int screen, sx, sy, sw, sh, wax, way, waw, wah; @@ -201,7 +200,7 @@ setup(Display *disp, jdwm_config *jdwmconf) DefaultVisual(disp, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); XDefineCursor(disp, barwin, cursor[CurNormal]); - updatebarpos(disp); + updatebarpos(disp, jdwmconf->current_bpos); XMapRaised(disp, barwin); /* pixmap for everything */ dc.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), sw, bh, DefaultDepth(disp, screen)); @@ -236,7 +235,7 @@ uicb_quit(Display *disp __attribute__ ((unused)), } void -updatebarpos(Display *disp) +updatebarpos(Display *disp, int bpos) { XEvent ev; diff --git a/jdwm.h b/jdwm.h index 401b783d6..15211fbed 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 *disp); /* updates the bar position */ +void updatebarpos(Display *, 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 1a033c62b..94dbcc861 100644 --- a/layout.c +++ b/layout.c @@ -20,7 +20,6 @@ static char prop[128]; /* extern */ extern Layout ** taglayouts; extern int wax, way, wah, waw; /* windowarea geometry */ -extern int bpos; /* bar position */ extern Window barwin; extern Client *clients, *sel; /* global client list */ extern Bool *seltags; @@ -201,11 +200,11 @@ uicb_togglebar(Display *disp, jdwm_config *jdwmconf, const char *arg __attribute__ ((unused))) { - if(bpos == BarOff) - bpos = (jdwmconf->bpos == BarOff) ? BarTop : jdwmconf->bpos; + if(jdwmconf->current_bpos == BarOff) + jdwmconf->current_bpos = (jdwmconf->bpos == BarOff) ? BarTop : jdwmconf->bpos; else - bpos = BarOff; - updatebarpos(disp); + jdwmconf->current_bpos = BarOff; + updatebarpos(disp, jdwmconf->current_bpos); arrange(disp, jdwmconf); } diff --git a/layouts/grid.c b/layouts/grid.c index 967e2cbf9..cfc8b886c 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 + (bpos == BarTop ? bh : 0); // bh? adjust + cy = (i % rows) * ch + (jdwmconf->current_bpos == BarTop ? bh : 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;