remove bpos from global var, added in jdwmconf

This commit is contained in:
Julien Danjou 2007-09-05 20:39:11 +02:00
parent f7173bd79d
commit 24e15433b7
7 changed files with 12 additions and 15 deletions

View File

@ -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");

View File

@ -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 */

View File

@ -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);
}
}

5
jdwm.c
View File

@ -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;

2
jdwm.h
View File

@ -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 */

View File

@ -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);
}

View File

@ -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;