diff -uprN clean/config.h urgent/config.h --- clean/config.h 2007-09-22 00:59:24.000000000 -0700 +++ urgent/config.h 2007-09-22 04:08:15.000000000 -0700 @@ -7,9 +7,11 @@ #define NORMBORDERCOLOR "#333" #define NORMBGCOLOR "#000" #define NORMFGCOLOR "#ccc" +#define NORMURGENTCOLOR "#0f0" #define SELBORDERCOLOR "#f00" #define SELBGCOLOR "#00f" #define SELFGCOLOR "#fff" +#define SELURGENTCOLOR "#0f0" /* tagging */ const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL }; diff -uprN clean/dwm.c urgent/dwm.c --- clean/dwm.c 2007-09-22 00:59:23.000000000 -0700 +++ urgent/dwm.c 2007-09-25 03:33:27.000000000 -0700 @@ -50,7 +50,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 */ @@ -65,6 +65,7 @@ struct Client { long flags; unsigned int border, oldborder; Bool isbanned, isfixed, ismax, isfloating, wasfloating; + Bool isurgent; Bool *tags; Client *next; Client *prev; @@ -127,7 +128,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); @@ -147,6 +148,7 @@ void initfont(const char *fontstr); Bool isarrange(void (*func)()); 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); @@ -183,6 +185,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); int xerror(Display *dpy, XErrorEvent *ee); int xerrordummy(Display *dsply, XErrorEvent *ee); @@ -537,11 +540,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; } @@ -559,7 +562,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); @@ -569,12 +572,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; @@ -923,6 +926,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; @@ -1033,6 +1046,7 @@ manage(Window w, XWindowAttributes *wa) XSetWindowBorder(dpy, w, dc.norm[ColBorder]); configure(c); /* propagates border_width, if size doesn't change */ updatesizehints(c); + updatewmhints(c); XSelectInput(dpy, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); grabbuttons(c, False); @@ -1144,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); @@ -1474,9 +1492,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; @@ -1802,6 +1822,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. */