Re: [dwm] Cycle urgent windows patch for dwm-4.9

From: Martin Oppegaard <martin_AT_deathaven.com>
Date: Sun, 30 Mar 2008 15:01:15 +0200

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.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. */

Received on Sun Mar 30 2008 - 15:02:00 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:29:18 UTC