all repos — dwm @ 012710a3cee6a15e4b8284edb57d39332ddd60b4

my dwm build

implemented urgent hint handling (with multihead support)
anselm@aab unknown
Mon, 11 Feb 2008 20:34:17 +0000
commit

012710a3cee6a15e4b8284edb57d39332ddd60b4

parent

c2c54cc0faad89483edf3ffddee3e3ff20cf8263

1 files changed, 37 insertions(+), 11 deletions(-)

jump to
M dwm.cdwm.c

@@ -68,7 +68,7 @@ int basew, baseh, incw, inch, maxw, maxh, minw, minh;

int minax, maxax, minay, maxay; long flags; unsigned int border, oldborder; - Bool isbanned, isfixed, isfloating; + Bool isbanned, isfixed, isfloating, isurgent; Bool *tags; Client *next; Client *prev;

@@ -146,7 +146,7 @@ void detach(Client *c);

void detachstack(Client *c); void drawbar(void); void drawsquare(Monitor *, Bool filled, Bool empty, unsigned long col[ColLast]); -void drawtext(Monitor *, const char *text, unsigned long col[ColLast]); +void drawtext(Monitor *, const char *text, unsigned long col[ColLast], Bool invert); void *emallocz(unsigned int size); void enternotify(XEvent *e); void eprint(const char *errstr, ...);

@@ -166,6 +166,7 @@ unsigned int idxoftag(const char *tag);

void initfont(Monitor*, const char *fontstr); Bool isoccupied(Monitor *m, unsigned int t); Bool isprotodel(Client *c); +Bool isurgent(int monitor, unsigned int t); Bool isvisible(Client *c, int monitor); void keypress(XEvent *e); void killclient(const char *arg);

@@ -201,6 +202,7 @@ void unmapnotify(XEvent *e);

void updatebarpos(Monitor *m); void updatesizehints(Client *c); void updatetitle(Client *c); +void updatewmhints(Client *c); void view(const char *arg); void viewprevtag(const char *arg); /* views previous selected tags */ int xerror(Display *dpy, XErrorEvent *ee);

@@ -573,17 +575,17 @@ m->dc.x = 0;

for(j = 0; j < LENGTH(tags); j++) { m->dc.w = textw(m, tags[j]); if(m->seltags[j]) { - drawtext(m, tags[j], m->dc.sel); + drawtext(m, tags[j], m->dc.sel, isurgent(i, j)); drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.sel); } else { - drawtext(m, tags[j], m->dc.norm); + drawtext(m, tags[j], m->dc.norm, isurgent(i, j)); drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.norm); } m->dc.x += m->dc.w; } m->dc.w = blw; - drawtext(m, m->layout->symbol, m->dc.norm); + drawtext(m, m->layout->symbol, m->dc.norm, False); x = m->dc.x + m->dc.w; m->dc.w = textw(m, stext); m->dc.x = m->sw - m->dc.w;

@@ -591,15 +593,15 @@ if(m->dc.x < x) {

m->dc.x = x; m->dc.w = m->sw - x; } - drawtext(m, stext, m->dc.norm); + drawtext(m, stext, m->dc.norm, False); if((m->dc.w = m->dc.x - x) > bh) { m->dc.x = x; if(sel && sel->monitor == selmonitor) { - drawtext(m, sel->name, m->dc.sel); + drawtext(m, sel->name, m->dc.sel, False); drawsquare(m, False, sel->isfloating, m->dc.sel); } else - drawtext(m, NULL, m->dc.norm); + drawtext(m, NULL, m->dc.norm, False); } XCopyArea(dpy, m->dc.drawable, m->barwin, m->dc.gc, 0, 0, m->sw, bh, 0, 0); XSync(dpy, False);

@@ -628,13 +630,13 @@ }

} void -drawtext(Monitor *m, const char *text, unsigned long col[ColLast]) { +drawtext(Monitor *m, const char *text, unsigned long col[ColLast], Bool invert) { int x, y, w, h; static char buf[256]; unsigned int len, olen; XRectangle r = { m->dc.x, m->dc.y, m->dc.w, m->dc.h }; - XSetForeground(dpy, m->dc.gc, col[ColBG]); + XSetForeground(dpy, m->dc.gc, col[invert ? ColFG : ColBG]); XFillRectangles(dpy, m->dc.drawable, m->dc.gc, &r, 1); if(!text) return;

@@ -660,7 +662,7 @@ buf[len - 3] = '.';

} if(w > m->dc.w) return; /* too long */ - XSetForeground(dpy, m->dc.gc, col[ColFG]); + XSetForeground(dpy, m->dc.gc, col[invert ? ColBG : ColFG]); if(m->dc.font.set) XmbDrawString(dpy, m->dc.drawable, m->dc.font.set, m->dc.gc, x, y, buf, len); else

@@ -999,6 +1001,16 @@ return ret;

} Bool +isurgent(int monitor, unsigned int t) { + Client *c; + + for(c = clients; c; c = c->next) + if(c->monitor == monitor && c->isurgent && c->tags[t]) + return True; + return False; +} + +Bool isvisible(Client *c, int monitor) { unsigned int i;

@@ -1214,6 +1226,10 @@ arrange();

break; case XA_WM_NORMAL_HINTS: updatesizehints(c); + break; + case XA_WM_HINTS: + updatewmhints(c); + drawbar(); break; } if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {

@@ -1914,6 +1930,16 @@ void

updatetitle(Client *c) { if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name); +} + +void +updatewmhints(Client *c) { + XWMHints *wmh; + + if((wmh = XGetWMHints(dpy, c->win))) { + c->isurgent = (wmh->flags & XUrgencyHint) ? True : False; + XFree(wmh); + } } /* There's no way to check accesses to destroyed windows, thus those cases are