On Tue, Nov 18, 2008 at 11:33:53PM +0100, Joerg van den Hoff wrote:
> hi,
> 
> I want to be able to cycle through all tags using some key combination
> (instead of explicitely jumping to tag no. xxx).
> 
> in 4.9 someone on this list helped me getting this right:
> 
> 
> void
> goto_nexttag(const char *arg) {
>     unsigned int i, j;
> 
>     memcpy(prevtags, seltags, sizeof seltags);
>     for (i = 0; i < LENGTH(tags); i++) {
>         if (seltags[i])
>            j = (i + 1) % LENGTH(tags);
>         seltags[i] = False;
>     }
>     seltags[j] = True;
>     arrange();
> }
> 
> 
> was the function needed. this obviously does not work any longer in 5.2.
> looking at the 5.2 source code I was not able to see immediately
> the neccessary modifications to make it work again.
> 
> can somebody help me with this?
> 
> thanks,
> 
> joerg

Attached is a quick patch that will allow you to use meta + right/left
arrow key to cycle through your tags. It works here, but may not be the
best way to do it.

-- 
James Turner
BSD Group Consulting
http://www.bsdgroup.org
--- config.def.h        Tue Sep  9 15:46:17 2008
+++ config.def.h        Tue Nov 18 19:26:53 2008
@@ -61,6 +61,8 @@ static Key keys[] = {
        { MODKEY,                       XK_l,      setmfact,       {.f = +0.05} 
},
        { MODKEY,                       XK_Return, zoom,           {0} },
        { MODKEY,                       XK_Tab,    view,           {0} },
+       { MODKEY,                       XK_Right,  viewnext,       {0} },
+       { MODKEY,                       XK_Left,   viewprevious,   {0} },
        { MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
        { MODKEY,                       XK_t,      setlayout,      {.v = 
&layouts[0]} },
        { MODKEY,                       XK_f,      setlayout,      {.v = 
&layouts[1]} },
--- config.mk   Tue Sep  9 15:46:17 2008
+++ config.mk   Tue Nov 18 19:32:08 2008
@@ -5,7 +5,7 @@ VERSION = 5.2
 
 # paths
 PREFIX = /usr/local
-MANPREFIX = ${PREFIX}/share/man
+MANPREFIX = ${PREFIX}/man
 
 X11INC = /usr/X11R6/include
 X11LIB = /usr/X11R6/lib
diff -u -p dwm-5.2/dwm.c dwm-5.2-patch/dwm.c
--- dwm-5.2/dwm.c       Tue Sep  9 15:46:17 2008
+++ dwm-5.2-patch/dwm.c Tue Nov 18 19:31:55 2008
@@ -198,6 +198,8 @@ static void updatesizehints(Client *c);
 static void updatetitle(Client *c);
 static void updatewmhints(Client *c);
 static void view(const Arg *arg);
+static void viewnext(const Arg *arg);
+static void viewprevious(const Arg *arg);
 static int xerror(Display *dpy, XErrorEvent *ee);
 static int xerrordummy(Display *dpy, XErrorEvent *ee);
 static int xerrorstart(Display *dpy, XErrorEvent *ee);
@@ -1667,6 +1669,40 @@ view(const Arg *arg) {
        if(arg->ui & TAGMASK)
                tagset[seltags] = arg->ui & TAGMASK;
        clearurgent();
+       arrange();
+}
+
+void
+viewnext(const Arg *arg) {
+       unsigned int i;
+
+       for(i = 0; i < LENGTH(tags); i++) {
+               if((1 << i & TAGMASK) == tagset[seltags]) {
+                       seltags ^= 1;
+                       if(i == LENGTH(tags) - 1)
+                               tagset[seltags] = 1 << 0 & TAGMASK;
+                       else
+                               tagset[seltags] = 1 << (i + 1) & TAGMASK;
+                       break;
+               }
+       }
+       arrange();
+}
+
+void
+viewprevious(const Arg *arg) {
+       unsigned int i;
+
+       for(i = 0; i < LENGTH(tags); i++) {
+               if((1 << i & TAGMASK) == tagset[seltags]) {
+                       seltags ^= 1;
+                       if(i == 0)
+                               tagset[seltags] = 1 << (LENGTH(tags) - 1) & 
TAGMASK;
+                       else
+                               tagset[seltags] = 1 << (i - 1) & TAGMASK;
+                       break;
+               }
+       }
        arrange();
 }
 

Reply via email to