--- dwm.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/dwm.c b/dwm.c index 96b43f7..5af74a2 100644 --- a/dwm.c +++ b/dwm.c _AT_@ -170,6 +170,7 @@ static void focus(Client *c); static void focusin(XEvent *e); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); +static unsigned long getcolor_in_window(const char *colstr, Window w, unsigned long fallback); static Bool getrootptr(int *x, int *y); static long getstate(Window w); static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); _AT_@ -791,7 +792,7 @@ focus(Client *c) { detachstack(c); attachstack(c); grabbuttons(c, True); - XSetWindowBorder(dpy, c->win, scheme[SchemeSel].border->pix); + XSetWindowBorder(dpy, c->win, getcolor_in_window(selbordercolor, c->win, scheme[SchemeSel].border->pix)); setfocus(c); } else { _AT_@ -865,6 +866,22 @@ getatomprop(Client *c, Atom prop) { return atom; } +unsigned long +getcolor_in_window(const char *colstr, Window w, unsigned long fallback) { + if (!w) + return fallback; + XWindowAttributes attr; + if (!XGetWindowAttributes(dpy, w, &attr)) + return fallback; + + Colormap cmap = attr.colormap; + XColor color; + + if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) + return fallback; + return color.pixel; +} + Bool getrootptr(int *x, int *y) { int di; _AT_@ -1038,7 +1055,7 @@ manage(Window w, XWindowAttributes *wa) { wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); - XSetWindowBorder(dpy, w, scheme[SchemeNorm].border->pix); + XSetWindowBorder(dpy, w, getcolor_in_window(normbordercolor, w, scheme[SchemeNorm].border->pix)); configure(c); /* propagates border_width, if size doesn't change */ updatewindowtype(c); updatesizehints(c); _AT_@ -1684,7 +1701,7 @@ unfocus(Client *c, Bool setfocus) { if(!c) return; grabbuttons(c, False); - XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix); + XSetWindowBorder(dpy, c->win, getcolor_in_window(normbordercolor, c->win, scheme[SchemeNorm].border->pix)); if(setfocus) { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XDeleteProperty(dpy, root, netatom[NetActiveWindow]); -- 2.6.2Received on Tue Oct 27 2015 - 20:27:32 CET
This archive was generated by hypermail 2.3.0 : Tue Oct 27 2015 - 20:36:10 CET