diff -r 2a3f59cc8d2f dwm.c --- a/dwm.c Wed Oct 24 20:34:08 2007 +0200 +++ b/dwm.c Fri Oct 26 16:49:06 2007 +0200 @@ -198,6 +198,7 @@ int (*xerrorxlib)(Display *, XErrorEvent int (*xerrorxlib)(Display *, XErrorEvent *); unsigned int bh, bpos; unsigned int blw = 0; +unsigned int csel = 0; unsigned int ltidx = 0; /* default */ unsigned int nlayouts = 0; unsigned int nrules = 0; @@ -235,6 +236,7 @@ Regs *regs = NULL; #define NTAGS (sizeof tags / sizeof tags[0]) Bool seltags[NTAGS] = {[0] = True}; Bool prevtags[NTAGS] = {[0] = True}; +unsigned int ltidxs[NTAGS]; /* function implementations */ void @@ -277,7 +279,7 @@ arrange(void) { unban(c); else ban(c); - layouts[ltidx].arrange(); + layouts[ltidxs[csel]].arrange(); focus(NULL); restack(); } @@ -549,7 +551,7 @@ drawbar(void) { dc.x += dc.w; } dc.w = blw; - drawtext(layouts[ltidx].symbol, dc.norm); + drawtext(layouts[ltidxs[csel]].symbol, dc.norm); x = dc.x + dc.w; dc.w = textw(stext); dc.x = sw - dc.w; @@ -895,7 +897,7 @@ Bool Bool isarrange(void (*func)()) { - return func == layouts[ltidx].arrange; + return func == layouts[ltidxs[csel]].arrange; } Bool @@ -1378,8 +1380,8 @@ setlayout(const char *arg) { unsigned int i; if(!arg) { - if(++ltidx == nlayouts) - ltidx = 0;; + if(++ltidxs[csel] == nlayouts) + ltidxs[csel] = 0; } else { for(i = 0; i < nlayouts; i++) @@ -1387,7 +1389,7 @@ setlayout(const char *arg) { break; if(i == nlayouts) return; - ltidx = i; + ltidxs[csel] = i; } if(sel) arrange(); @@ -1479,6 +1481,8 @@ setup(void) { dc.h = bh = dc.font.height + 2; /* init layouts */ + for(i = 0; i < NTAGS; i++) + ltidxs[i] = 0; mwfact = MWFACT; nlayouts = sizeof layouts / sizeof layouts[0]; for(blw = i = 0; i < nlayouts; i++) { @@ -1673,8 +1677,12 @@ toggleview(const char *arg) { i = idxoftag(arg); seltags[i] = !seltags[i]; for(j = 0; j < NTAGS && !seltags[j]; j++); - if(j == NTAGS) + if(j == NTAGS) { seltags[i] = True; /* at least one tag must be viewed */ + j = i; + } + if (csel == i) + csel = j; arrange(); } @@ -1842,12 +1850,17 @@ view(const char *arg) { for(i = 0; i < NTAGS; i++) seltags[i] = arg == NULL; seltags[idxoftag(arg)] = True; + csel = idxoftag(arg); arrange(); } void viewprevtag(const char *arg) { static Bool tmptags[sizeof tags / sizeof tags[0]]; + int i = 0; + + while(i