Have updated the patch for mercurial tip.
I also add a patch which implements one layout per tag. Haven't looked
at the old one, so I can't say if it's an update or not.
On Thu, Mar 27, 2008 at 05:31:22PM +0100, Martin Oppegaard wrote:
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.0 +0100
+++ mydwm-4.8/dwm.c 2008-03-27 16:34:22.0 +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. */
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