remove global bh/blw and add a Statusbar type
This commit is contained in:
parent
2eaadb39e7
commit
a6a705dd85
8
config.c
8
config.c
|
@ -17,8 +17,6 @@
|
||||||
#include "layouts/spiral.h"
|
#include "layouts/spiral.h"
|
||||||
#include "layouts/floating.h"
|
#include "layouts/floating.h"
|
||||||
|
|
||||||
int blw = 0;
|
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
static void initfont(const char *, Display *, DC *);
|
static void initfont(const char *, Display *, DC *);
|
||||||
static unsigned long initcolor(const char *colstr, Display *, int);
|
static unsigned long initcolor(const char *colstr, Display *, int);
|
||||||
|
@ -165,6 +163,8 @@ static void
|
||||||
set_default_config(jdwm_config *jdwmconf)
|
set_default_config(jdwm_config *jdwmconf)
|
||||||
{
|
{
|
||||||
strcpy(jdwmconf->statustext, "jdwm-" VERSION);
|
strcpy(jdwmconf->statustext, "jdwm-" VERSION);
|
||||||
|
jdwmconf->statusbar.width = 0;
|
||||||
|
jdwmconf->statusbar.height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parse configuration file and initialize some stuff
|
/** 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");
|
eprint("unknown layout in configuration file\n");
|
||||||
|
|
||||||
j = textw(jdwmconf->layouts[i].symbol);
|
j = textw(jdwmconf->layouts[i].symbol);
|
||||||
if(j > blw)
|
if(j > jdwmconf->statusbar.width)
|
||||||
blw = j;
|
jdwmconf->statusbar.width = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
jdwmconf->layouts[i].symbol = NULL;
|
jdwmconf->layouts[i].symbol = NULL;
|
||||||
|
|
9
config.h
9
config.h
|
@ -54,6 +54,13 @@ typedef struct
|
||||||
const char *arg;
|
const char *arg;
|
||||||
} Key;
|
} Key;
|
||||||
|
|
||||||
|
/** Status bar */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
} Statusbar;
|
||||||
|
|
||||||
/** Main configuration structure */
|
/** Main configuration structure */
|
||||||
struct jdwm_config
|
struct jdwm_config
|
||||||
{
|
{
|
||||||
|
@ -101,6 +108,8 @@ struct jdwm_config
|
||||||
char statustext[256];
|
char statustext[256];
|
||||||
/** Current layout */
|
/** Current layout */
|
||||||
Layout * current_layout;
|
Layout * current_layout;
|
||||||
|
/** Status bar */
|
||||||
|
Statusbar statusbar;
|
||||||
};
|
};
|
||||||
|
|
||||||
void parse_config(Display *, int, DC *, jdwm_config *); /* parse configuration file */
|
void parse_config(Display *, int, DC *, jdwm_config *); /* parse configuration file */
|
||||||
|
|
7
draw.c
7
draw.c
|
@ -3,7 +3,6 @@
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
|
||||||
extern int sw; /* screen geometry */
|
extern int sw; /* screen geometry */
|
||||||
extern int bh, blw; /* bar height, bar layout label width */
|
|
||||||
extern Window barwin;
|
extern Window barwin;
|
||||||
extern DC dc; /* global draw context */
|
extern DC dc; /* global draw context */
|
||||||
extern Client *clients, *sel, *stack; /* global client list and stack */
|
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.x += dc.w;
|
||||||
}
|
}
|
||||||
dc.w = blw;
|
dc.w = jdwmconf->statusbar.width;
|
||||||
drawtext(disp, jdwmconf->current_layout->symbol, dc.norm);
|
drawtext(disp, jdwmconf->current_layout->symbol, dc.norm);
|
||||||
x = dc.x + dc.w;
|
x = dc.x + dc.w;
|
||||||
dc.w = textw(jdwmconf->statustext);
|
dc.w = textw(jdwmconf->statustext);
|
||||||
|
@ -138,7 +137,7 @@ drawstatus(Display *disp, jdwm_config * jdwmconf)
|
||||||
dc.w = sw - x;
|
dc.w = sw - x;
|
||||||
}
|
}
|
||||||
drawtext(disp, jdwmconf->statustext, dc.norm);
|
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;
|
dc.x = x;
|
||||||
if(sel)
|
if(sel)
|
||||||
|
@ -149,6 +148,6 @@ drawstatus(Display *disp, jdwm_config * jdwmconf)
|
||||||
else
|
else
|
||||||
drawtext(disp, NULL, dc.norm);
|
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);
|
XSync(disp, False);
|
||||||
}
|
}
|
||||||
|
|
9
event.c
9
event.c
|
@ -15,7 +15,6 @@
|
||||||
/* extern */
|
/* extern */
|
||||||
extern int screen, sw, sh; /* screen geometry */
|
extern int screen, sw, sh; /* screen geometry */
|
||||||
extern int wax, way, wah, waw; /* windowarea geometry */
|
extern int wax, way, wah, waw; /* windowarea geometry */
|
||||||
extern int bh, blw; /* bar height, bar layout label width */
|
|
||||||
extern Window barwin;
|
extern Window barwin;
|
||||||
extern DC dc; /* global draw context */
|
extern DC dc; /* global draw context */
|
||||||
extern Cursor cursor[CurLast];
|
extern Cursor cursor[CurLast];
|
||||||
|
@ -152,7 +151,7 @@ handle_event_buttonpress(XEvent * e, jdwm_config *jdwmconf)
|
||||||
return;
|
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);
|
uicb_setlayout(e->xany.display, jdwmconf, NULL);
|
||||||
}
|
}
|
||||||
else if((c = getclient(ev->window)))
|
else if((c = getclient(ev->window)))
|
||||||
|
@ -240,9 +239,9 @@ handle_event_configurenotify(XEvent * e, jdwm_config *jdwmconf)
|
||||||
sw = ev->width;
|
sw = ev->width;
|
||||||
sh = ev->height;
|
sh = ev->height;
|
||||||
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, jdwmconf->statusbar.height, DefaultDepth(e->xany.display, screen));
|
||||||
XResizeWindow(e->xany.display, barwin, sw, bh);
|
XResizeWindow(e->xany.display, barwin, sw, jdwmconf->statusbar.height);
|
||||||
updatebarpos(e->xany.display, jdwmconf->current_bpos);
|
updatebarpos(e->xany.display, jdwmconf->statusbar, jdwmconf->current_bpos);
|
||||||
arrange(e->xany.display, jdwmconf);
|
arrange(e->xany.display, jdwmconf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
19
jdwm.c
19
jdwm.c
|
@ -19,7 +19,6 @@
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
|
|
||||||
int screen, sx, sy, sw, sh, wax, way, waw, wah;
|
int screen, sx, sy, sw, sh, wax, way, waw, wah;
|
||||||
int bh;
|
|
||||||
Atom jdwmprops, wmatom[WMLast], netatom[NetLast];
|
Atom jdwmprops, wmatom[WMLast], netatom[NetLast];
|
||||||
Client *clients = NULL;
|
Client *clients = NULL;
|
||||||
Client *sel = NULL;
|
Client *sel = NULL;
|
||||||
|
@ -175,19 +174,19 @@ setup(Display *disp, jdwm_config *jdwmconf)
|
||||||
sw = DisplayWidth(disp, screen);
|
sw = DisplayWidth(disp, screen);
|
||||||
sh = DisplayHeight(disp, screen);
|
sh = DisplayHeight(disp, screen);
|
||||||
/* bar */
|
/* bar */
|
||||||
dc.h = bh = dc.font.height + 2;
|
dc.h = jdwmconf->statusbar.height = dc.font.height + 2;
|
||||||
wa.override_redirect = 1;
|
wa.override_redirect = 1;
|
||||||
wa.background_pixmap = ParentRelative;
|
wa.background_pixmap = ParentRelative;
|
||||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
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,
|
DefaultDepth(disp, screen), CopyFromParent,
|
||||||
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, jdwmconf->current_bpos);
|
updatebarpos(disp, jdwmconf->statusbar, 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, jdwmconf->statusbar.height, DefaultDepth(disp, screen));
|
||||||
dc.gc = XCreateGC(disp, DefaultRootWindow(disp), 0, 0);
|
dc.gc = XCreateGC(disp, DefaultRootWindow(disp), 0, 0);
|
||||||
XSetLineAttributes(disp, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
XSetLineAttributes(disp, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
if(!dc.font.set)
|
if(!dc.font.set)
|
||||||
|
@ -217,7 +216,7 @@ uicb_quit(Display *disp __attribute__ ((unused)),
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updatebarpos(Display *disp, int bpos)
|
updatebarpos(Display *disp, Statusbar statusbar, int bpos)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
|
@ -228,16 +227,16 @@ updatebarpos(Display *disp, int bpos)
|
||||||
switch (bpos)
|
switch (bpos)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
wah -= bh;
|
wah -= statusbar.height;
|
||||||
way += bh;
|
way += statusbar.height;
|
||||||
XMoveWindow(disp, barwin, sx, sy);
|
XMoveWindow(disp, barwin, sx, sy);
|
||||||
break;
|
break;
|
||||||
case BarBot:
|
case BarBot:
|
||||||
wah -= bh;
|
wah -= statusbar.height;
|
||||||
XMoveWindow(disp, barwin, sx, sy + wah);
|
XMoveWindow(disp, barwin, sx, sy + wah);
|
||||||
break;
|
break;
|
||||||
case BarOff:
|
case BarOff:
|
||||||
XMoveWindow(disp, barwin, sx, sy - bh);
|
XMoveWindow(disp, barwin, sx, sy - statusbar.height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XSync(disp, False);
|
XSync(disp, False);
|
||||||
|
|
2
jdwm.h
2
jdwm.h
|
@ -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 *, 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 */
|
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 */
|
||||||
|
|
||||||
|
|
2
layout.c
2
layout.c
|
@ -178,7 +178,7 @@ uicb_togglebar(Display *disp,
|
||||||
jdwmconf->current_bpos = (jdwmconf->bpos == BarOff) ? BarTop : jdwmconf->bpos;
|
jdwmconf->current_bpos = (jdwmconf->bpos == BarOff) ? BarTop : jdwmconf->bpos;
|
||||||
else
|
else
|
||||||
jdwmconf->current_bpos = BarOff;
|
jdwmconf->current_bpos = BarOff;
|
||||||
updatebarpos(disp, jdwmconf->current_bpos);
|
updatebarpos(disp, jdwmconf->statusbar, jdwmconf->current_bpos);
|
||||||
arrange(disp, jdwmconf);
|
arrange(disp, jdwmconf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
|
|
||||||
extern int wah, waw; /* windowarea geometry */
|
extern int wah, waw; /* windowarea geometry */
|
||||||
extern int bh, bpos; /* bar height, bar position */
|
|
||||||
extern Client *clients; /* global client list and stack */
|
extern Client *clients; /* global client list and stack */
|
||||||
extern DC dc;
|
extern DC dc;
|
||||||
|
|
||||||
|
@ -37,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 + (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 */
|
/* 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;
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
extern int wax, way, wah, waw; /* windowarea geometry */
|
extern int wax, way, wah, waw; /* windowarea geometry */
|
||||||
extern int bh; /* bar height */
|
|
||||||
extern Client *sel, *clients;
|
extern Client *sel, *clients;
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
@ -85,7 +84,7 @@ _tile(jdwm_config *jdwmconf, const Bool right)
|
||||||
mh = (n <= nmaster) ? wah / (n > 0 ? n : 1) : wah / nmaster;
|
mh = (n <= nmaster) ? wah / (n > 0 ? n : 1) : wah / nmaster;
|
||||||
mw = (n <= nmaster) ? waw : mwfact * waw;
|
mw = (n <= nmaster) ? waw : mwfact * waw;
|
||||||
th = (n > nmaster) ? wah / (n - nmaster) : 0;
|
th = (n > nmaster) ? wah / (n - nmaster) : 0;
|
||||||
if(n > nmaster && th < bh)
|
if(n > nmaster && th < jdwmconf->statusbar.height)
|
||||||
th = wah;
|
th = wah;
|
||||||
|
|
||||||
nx = wax;
|
nx = wax;
|
||||||
|
|
Loading…
Reference in New Issue