diff -uprN clean/config.h urgent/config.h --- clean/config.h 2007-12-19 14:42:05.000000000 -0500 +++ urgent/config.h 2007-12-19 14:42:45.000000000 -0500 @@ -7,9 +7,11 @@ #define NORMBORDERCOLOR "#cccccc" #define NORMBGCOLOR "#cccccc" #define NORMFGCOLOR "#000000" +#define NORMURGENTCOLOR "#0f0" #define SELBORDERCOLOR "#0066ff" #define SELBGCOLOR "#0066ff" #define SELFGCOLOR "#ffffff" +#define SELURGENTCOLOR "#0f0" /* tagging */ const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "www" }; diff -uprN clean/dwm.c urgent/dwm.c --- clean/dwm.c 2007-11-21 15:18:41.000000000 -0500 +++ urgent/dwm.c 2007-12-19 14:41:25.000000000 -0500 @@ -52,7 +52,7 @@ /* enums */ enum { BarTop, BarBot, BarOff }; /* bar position */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ +enum { ColBorder, ColFG, ColBG, ColUrgent, ColLast }; /* color */ enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */ @@ -67,6 +67,7 @@ struct Client { long flags; unsigned int border, oldborder; Bool isbanned, isfixed, ismax, isfloating, wasfloating; + Bool isurgent; Bool *tags; Client *next; Client *prev; @@ -129,7 +130,7 @@ void destroynotify(XEvent *e); void detach(Client *c); void detachstack(Client *c); void drawbar(void); -void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]); +void drawsquare(Bool filled, Bool empty, Bool urgent, unsigned long col[ColLast]); void drawtext(const char *text, unsigned long col[ColLast]); void *emallocz(unsigned int size); void enternotify(XEvent *e); @@ -150,6 +151,7 @@ unsigned int idxoftag(const char *tag); void initfont(const char *fontstr); Bool isoccupied(unsigned int t); Bool isprotodel(Client *c); +Bool isurgent(unsigned int t); Bool isvisible(Client *c); void keypress(XEvent *e); void killclient(const char *arg); @@ -186,6 +188,7 @@ void unmapnotify(XEvent *e); void updatebarpos(void); 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); @@ -540,11 +543,11 @@ drawbar(void) { dc.w = textw(tags[i]); if(seltags[i]) { drawtext(tags[i], dc.sel); - drawsquare(sel && sel->tags[i], isoccupied(i), dc.sel); + drawsquare(sel && sel->tags[i], isoccupied(i), isurgent(i), dc.sel); } else { drawtext(tags[i], dc.norm); - drawsquare(sel && sel->tags[i], isoccupied(i), dc.norm); + drawsquare(sel && sel->tags[i], isoccupied(i), isurgent(i), dc.norm); } dc.x += dc.w; } @@ -562,7 +565,7 @@ drawbar(void) { dc.x = x; if(sel) { drawtext(sel->name, dc.sel); - drawsquare(sel->ismax, sel->isfloating, dc.sel); + drawsquare(sel->ismax, sel->isfloating, sel->isurgent, dc.sel); } else drawtext(NULL, dc.norm); @@ -572,12 +575,12 @@ drawbar(void) { } void -drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) { +drawsquare(Bool filled, Bool empty, Bool urgent, unsigned long col[ColLast]) { int x; XGCValues gcv; XRectangle r = { dc.x, dc.y, dc.w, dc.h }; - gcv.foreground = col[ColFG]; + gcv.foreground = urgent ? col[ColUrgent] : col[ColFG]; XChangeGC(dpy, dc.gc, GCForeground, &gcv); x = (dc.font.ascent + dc.font.descent + 2) / 4; r.x = dc.x + 1; @@ -945,6 +948,16 @@ isprotodel(Client *c) { } Bool +isurgent(unsigned int t) { + Client *c; + + for(c = clients; c; c = c->next) + if(c->isurgent && c->tags[t]) + return True; + return False; +} + +Bool isvisible(Client *c) { unsigned int i; @@ -1145,6 +1158,10 @@ propertynotify(XEvent *e) { 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]) { updatetitle(c); @@ -1488,9 +1505,11 @@ setup(void) { dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); dc.norm[ColBG] = getcolor(NORMBGCOLOR); dc.norm[ColFG] = getcolor(NORMFGCOLOR); + dc.norm[ColUrgent] = getcolor(NORMURGENTCOLOR); dc.sel[ColBorder] = getcolor(SELBORDERCOLOR); dc.sel[ColBG] = getcolor(SELBGCOLOR); dc.sel[ColFG] = getcolor(SELFGCOLOR); + dc.norm[ColUrgent] = getcolor(SELURGENTCOLOR); initfont(FONT); dc.h = bh = dc.font.height + 2; @@ -1820,6 +1839,16 @@ updatetitle(Client *c) { 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 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs * default error handler, which may call exit. */