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*/ /** Main configuration object for parsing*/
config_t jdwmlibconf; config_t jdwmlibconf;
/** Current bar position */
int bpos;
/** Link a name to a function */ /** Link a name to a function */
typedef struct typedef struct
{ {
@ -281,7 +278,7 @@ parse_config(Display * disp, int scr, DC * drawcontext, jdwm_config *jdwmconf)
else if(!strncmp(tmp, "BarOff", 6)) else if(!strncmp(tmp, "BarOff", 6))
jdwmconf->bpos = BarOff; jdwmconf->bpos = BarOff;
bpos = jdwmconf->bpos; jdwmconf->current_bpos = jdwmconf->bpos;
/* borderpx */ /* borderpx */
jdwmconf->borderpx = config_lookup_int(&jdwmlibconf, "jdwm.borderpx"); jdwmconf->borderpx = config_lookup_int(&jdwmlibconf, "jdwm.borderpx");

View File

@ -79,6 +79,8 @@ struct jdwm_config
unsigned int numlockmask; unsigned int numlockmask;
/** Bar position */ /** Bar position */
int bpos; int bpos;
/** Current bar position */
int current_bpos;
/** Border size */ /** Border size */
int borderpx; int borderpx;
/** Master width factor */ /** Master width factor */

View File

@ -244,7 +244,7 @@ configurenotify(XEvent * e, jdwm_config *jdwmconf)
XFreePixmap(e->xany.display, dc.drawable); XFreePixmap(e->xany.display, dc.drawable);
dc.drawable = XCreatePixmap(e->xany.display, DefaultRootWindow(e->xany.display), sw, bh, DefaultDepth(e->xany.display, screen)); dc.drawable = XCreatePixmap(e->xany.display, DefaultRootWindow(e->xany.display), sw, bh, DefaultDepth(e->xany.display, screen));
XResizeWindow(e->xany.display, barwin, sw, bh); XResizeWindow(e->xany.display, barwin, sw, bh);
updatebarpos(e->xany.display); updatebarpos(e->xany.display, jdwmconf->current_bpos);
arrange(e->xany.display, jdwmconf); arrange(e->xany.display, jdwmconf);
} }
} }

5
jdwm.c
View File

@ -20,7 +20,6 @@
#include "tag.h" #include "tag.h"
/* extern */ /* extern */
extern int bpos; /* bar position */
extern void (*handler[LASTEvent]) (XEvent *, jdwm_config *); /* event handler */ extern void (*handler[LASTEvent]) (XEvent *, jdwm_config *); /* event handler */
int screen, sx, sy, sw, sh, wax, way, waw, wah; int screen, sx, sy, sw, sh, wax, way, waw, wah;
@ -201,7 +200,7 @@ setup(Display *disp, jdwm_config *jdwmconf)
DefaultVisual(disp, screen), DefaultVisual(disp, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
XDefineCursor(disp, barwin, cursor[CurNormal]); XDefineCursor(disp, barwin, cursor[CurNormal]);
updatebarpos(disp); updatebarpos(disp, jdwmconf->current_bpos);
XMapRaised(disp, barwin); XMapRaised(disp, barwin);
/* pixmap for everything */ /* pixmap for everything */
dc.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), sw, bh, DefaultDepth(disp, screen)); dc.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), sw, bh, DefaultDepth(disp, screen));
@ -236,7 +235,7 @@ uicb_quit(Display *disp __attribute__ ((unused)),
} }
void void
updatebarpos(Display *disp) updatebarpos(Display *disp, int bpos)
{ {
XEvent ev; XEvent ev;

2
jdwm.h
View File

@ -42,7 +42,7 @@ enum
{ WMProtocols, WMDelete, WMName, WMState, WMLast }; /* default atoms */ { WMProtocols, WMDelete, WMName, WMState, WMLast }; /* default atoms */
Bool gettextprop(Display *, Window, Atom, char *, unsigned int); /* return text property, UTF-8 compliant */ 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 */ void uicb_quit(Display *, jdwm_config *, const char *); /* quit jdwm nicely */
int xerror(Display *, XErrorEvent *); /* jdwm's X error handler */ int xerror(Display *, XErrorEvent *); /* jdwm's X error handler */

View File

@ -20,7 +20,6 @@ static char prop[128];
/* extern */ /* extern */
extern Layout ** taglayouts; extern Layout ** taglayouts;
extern int wax, way, wah, waw; /* windowarea geometry */ extern int wax, way, wah, waw; /* windowarea geometry */
extern int bpos; /* bar position */
extern Window barwin; extern Window barwin;
extern Client *clients, *sel; /* global client list */ extern Client *clients, *sel; /* global client list */
extern Bool *seltags; extern Bool *seltags;
@ -201,11 +200,11 @@ uicb_togglebar(Display *disp,
jdwm_config *jdwmconf, jdwm_config *jdwmconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
if(bpos == BarOff) if(jdwmconf->current_bpos == BarOff)
bpos = (jdwmconf->bpos == BarOff) ? BarTop : jdwmconf->bpos; jdwmconf->current_bpos = (jdwmconf->bpos == BarOff) ? BarTop : jdwmconf->bpos;
else else
bpos = BarOff; jdwmconf->current_bpos = BarOff;
updatebarpos(disp); updatebarpos(disp, jdwmconf->current_bpos);
arrange(disp, jdwmconf); arrange(disp, jdwmconf);
} }

View File

@ -36,7 +36,7 @@ grid(Display *disp, jdwm_config *jdwmconf)
continue; continue;
c->ismax = False; c->ismax = False;
cx = (i / rows) * cw; 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 */ /* adjust height/width of last row/column's windows */
ah = ((i + 1) % rows == 0) ? wah - ch * rows : 0; ah = ((i + 1) % rows == 0) ? wah - ch * rows : 0;
aw = (i >= rows * (cols - 1)) ? waw - cw * cols : 0; aw = (i >= rows * (cols - 1)) ? waw - cw * cols : 0;