diff -r f330c3a2dc76 config.def.h --- a/config.def.h Tue Mar 25 09:41:14 2008 +++ b/config.def.h Sat Mar 29 10:27:32 2008 @@ -54,6 +54,7 @@ { MODKEY, XK_r, reapply, NULL }, { MODKEY, XK_h, setmfact, "-0.05" }, { MODKEY, XK_l, setmfact, "+0.05" }, + { MODKEY, XK_u, cycleurgent, NULL }, { MODKEY, XK_Return, zoom, NULL }, { MODKEY, XK_Tab, viewprevtag, NULL }, { MODKEY|ShiftMask, XK_c, killclient, NULL }, diff -r f330c3a2dc76 dwm.c --- a/dwm.c Tue Mar 25 09:41:14 2008 +++ b/dwm.c Sat Mar 29 10:27:32 2008 @@ -202,6 +202,7 @@ void updatewmhints(Client *c); void view(const char *arg); void viewprevtag(const char *arg); /* views previous selected tags */ +void cycleurgent(const char *arg); int xerror(Display *dpy, XErrorEvent *ee); int xerrordummy(Display *dpy, XErrorEvent *ee); int xerrorstart(Display *dpy, XErrorEvent *ee); @@ -235,6 +236,9 @@ Client *clients = NULL; Client *sel = NULL; Client *stack = NULL; +Client *initucycle = NULL; /* initiated urgent-cycle */ +Bool *iucprevtags; /* the urgent-cycle initiator's previous tags */ +Bool inucycle = False; /* in urgent-cycle */ Cursor cursor[CurLast]; Display *dpy; DC dc = {0}; @@ -692,6 +696,7 @@ grabbuttons(c, True); } sel = c; + inucycle = False; if(c) { XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); @@ -1533,6 +1538,7 @@ /* init tags */ seltags = emallocz(TAGSZ); prevtags = emallocz(TAGSZ); + iucprevtags = emallocz(TAGSZ); seltags[0] = prevtags[0] = True; /* init layouts */ @@ -1883,6 +1889,32 @@ arrange(); } +void cycleurgent(const char *arg) { + Client *c; + + if(!sel) + return; + if(!inucycle) { + initucycle = sel; + memcpy(iucprevtags, prevtags, TAGSZ); + } + + for(c = clients; c && !c->isurgent; c = c->next); + if(c) { + memcpy(prevtags, seltags, TAGSZ); + memcpy(seltags, c->tags, TAGSZ); + focus(c); + arrange(); + inucycle = True; + return; + } + + memcpy(prevtags, iucprevtags, TAGSZ); + memcpy(seltags, initucycle->tags, TAGSZ); + focus(initucycle); + arrange(); +} + /* 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. */