Hi,
just looked at Anselm's commit 'finished libsl/drw integration'
( 5364697914fd4272fc1a6494b4fc522d2935427a ) and during merging a patch of mine
I saw the no longer needed color enum, and the new definitions of thmnorm and
thmsel.
As I use extra border colors for floating and urgent windows, I made a patch to
use an array to hold themes, so that themes can be added as desired.
I removed the color enum, and replaced it with a Theme enum.
Comments welcome, please see attached patch.
Kind regards
Julian
diff --git a/dwm.c b/dwm.c
--- a/dwm.c
+++ b/dwm.c
@@ -58,7 +58,7 @@
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
-enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
+enum { ThmNorm, ThmSel, ThmLast }; /* themes */
enum { NetSupported, NetWMName, NetWMState,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@@ -260,8 +260,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
static Atom wmatom[WMLast], netatom[NetLast];
static Bool running = True;
static Cur *cursor[CurLast];
-static Theme thmnorm[ColLast];
-static Theme thmsel[ColLast];
+static Theme thm[ThmLast];
static Display *dpy;
static Drw *drw;
static Fnt *fnt;
@@ -476,12 +475,12 @@ cleanup(void) {
drw_cur_free(drw, cursor[CurResize]);
drw_cur_free(drw, cursor[CurMove]);
drw_font_free(dpy, fnt);
- drw_clr_free(thmnorm->border);
- drw_clr_free(thmnorm->bg);
- drw_clr_free(thmnorm->fg);
- drw_clr_free(thmsel->border);
- drw_clr_free(thmsel->bg);
- drw_clr_free(thmsel->fg);
+ drw_clr_free(thm[ThmNorm].border);
+ drw_clr_free(thm[ThmNorm].bg);
+ drw_clr_free(thm[ThmNorm].fg);
+ drw_clr_free(thm[ThmSel].border);
+ drw_clr_free(thm[ThmSel].bg);
+ drw_clr_free(thm[ThmSel].fg);
drw_free(drw);
XSync(dpy, False);
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
@@ -705,14 +704,14 @@ drawbar(Monitor *m) {
x = 0;
for(i = 0; i < LENGTH(tags); i++) {
w = TEXTW(tags[i]);
- drw_settheme(drw, m->tagset[m->seltags] & 1 << i ? thmsel :
thmnorm);
+ drw_settheme(drw, m->tagset[m->seltags] & 1 << i ? &thm[ThmSel]
: &thm[ThmNorm]);
drw_text(drw, x, 0, w, bh, tags[i], urg & 1 << i);
drw_rect(drw, x, 0, w, bh, m == selmon && selmon->sel &&
selmon->sel->tags & 1 << i,
occ & 1 << i, urg & 1 << i);
x += w;
}
w = blw = TEXTW(m->ltsymbol);
- drw_settheme(drw, thmnorm);
+ drw_settheme(drw, &thm[ThmNorm]);
drw_text(drw, x, 0, w, bh, m->ltsymbol, 0);
x += w;
xx = x;
@@ -730,12 +729,12 @@ drawbar(Monitor *m) {
if((w = x - xx) > bh) {
x = xx;
if(m->sel) {
- drw_settheme(drw, m == selmon ? thmsel : thmnorm);
+ drw_settheme(drw, m == selmon ? &thm[ThmSel] :
&thm[ThmNorm]);
drw_text(drw, x, 0, w, bh, m->sel->name, 0);
drw_rect(drw, x, 0, w, bh, m->sel->isfixed,
m->sel->isfloating, 0);
}
else {
- drw_settheme(drw, thmnorm);
+ drw_settheme(drw, &thm[ThmNorm]);
drw_text(drw, x, 0, w, bh, NULL, 0);
}
}
@@ -793,7 +792,7 @@ focus(Client *c) {
detachstack(c);
attachstack(c);
grabbuttons(c, True);
- XSetWindowBorder(dpy, c->win, thmsel->border->rgb);
+ XSetWindowBorder(dpy, c->win, thm[ThmSel].border->rgb);
setfocus(c);
}
else {
@@ -1041,7 +1040,7 @@ manage(Window w, XWindowAttributes *wa) {
wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
- XSetWindowBorder(dpy, w, thmnorm->border->rgb);
+ XSetWindowBorder(dpy, w, thm[ThmNorm].border->rgb);
configure(c); /* propagates border_width, if size doesn't change */
updatewindowtype(c);
updatesizehints(c);
@@ -1523,12 +1522,12 @@ setup(void) {
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */
- thmnorm->border = drw_clr_create(drw, normbordercolor);
- thmnorm->bg = drw_clr_create(drw, normbgcolor);
- thmnorm->fg = drw_clr_create(drw, normfgcolor);
- thmsel->border = drw_clr_create(drw, selbordercolor);
- thmsel->bg = drw_clr_create(drw, selbgcolor);
- thmsel->fg = drw_clr_create(drw, selfgcolor);
+ thm[ThmNorm].border = drw_clr_create(drw, normbordercolor);
+ thm[ThmNorm].bg = drw_clr_create(drw, normbgcolor);
+ thm[ThmNorm].fg = drw_clr_create(drw, normfgcolor);
+ thm[ThmSel].border = drw_clr_create(drw, selbordercolor);
+ thm[ThmSel].bg = drw_clr_create(drw, selbgcolor);
+ thm[ThmSel].fg = drw_clr_create(drw, selfgcolor);
/* init bars */
updatebars();
updatestatus();
@@ -1674,7 +1673,7 @@ unfocus(Client *c, Bool setfocus) {
if(!c)
return;
grabbuttons(c, False);
- XSetWindowBorder(dpy, c->win, thmnorm->border->rgb);
+ XSetWindowBorder(dpy, c->win, thm[ThmNorm].border->rgb);
if(setfocus) {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);