Hi,
I've made a function for cycling through the windows with the urgent flag
set. The idea is that when first called, you start a cycle which on
completion will give focus back to the window which had it initially. This
window's prevtags are saved. Each call to focus() breaks the cycle, so
you don't have to complete it to continue using dwm as normal.
To be fair, I've only tested the patch with one urgent window. If you
have any ideas as to how to trigger the urgent flag manually,
please let me know.
Best regards,
Martin Oppegaard
--- dwm-4.8/dwm.c 2008-03-13 17:55:43.000000000 +0100
+++ mydwm-4.8/dwm.c 2008-03-27 16:34:22.000000000 +0100
@@ -186,6 +186,7 @@ void updatetitle(Client *c);
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);
@@ -219,6 +220,9 @@ Bool *seltags;
Client *clients = NULL;
Client *sel = NULL;
Client *stack = NULL;
+Client *initucycl; /* initialized urgent cycle */
+Bool *iucprevtags; /* the urgent-cycle initiator's previous tags */
+Bool inucycl = False; /* in urgent cycle */
Cursor cursor[CurLast];
Display *dpy;
DC dc = {0};
@@ -661,6 +665,7 @@ focus(Client *c) {
grabbuttons(c, True);
}
sel = c;
+ inucycl = False;
if(c) {
XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
@@ -1497,6 +1502,7 @@ setup(void) {
/* init tags */
seltags = emallocz(TAGSZ);
prevtags = emallocz(TAGSZ);
+ iucprevtags = emallocz(TAGSZ);
seltags[0] = prevtags[0] = True;
/* init layouts */
@@ -1842,6 +1848,36 @@ viewprevtag(const char *arg) {
arrange();
}
+void
+cycleurgent(const char *arg) {
+ Client *c;
+
+ if(!sel)
+ return;
+
+ if(!inucycl) {
+ initucycl = sel;
+ memcpy(iucprevtags, prevtags, TAGSZ);
+ }
+
+ for(c = clients; c; c = c->next) {
+ if(c->isurgent) {
+ memcpy(prevtags, seltags, TAGSZ);
+ memcpy(seltags, c->tags, TAGSZ);
+ focus(c);
+ arrange();
+ inucycl = True;
+
+ return;
+ }
+ }
+
+ memcpy(prevtags, iucprevtags, TAGSZ);
+ memcpy(seltags, initucycl->tags, TAGSZ);
+ focus(initucycl);
+ 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. */