move bpos to Statusbar struct and change name of default_statubar_position in jdwmconf

This commit is contained in:
Julien Danjou 2007-09-07 16:35:46 +02:00
parent a6a705dd85
commit d61ca0da62
7 changed files with 20 additions and 18 deletions

View File

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

View File

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

View File

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

6
jdwm.c
View File

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

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

View File

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

View File

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