diff -u dwm-0.9/config.default.h dwm-0.9.modified/config.default.h --- dwm-0.9/config.default.h 2006-08-15 09:09:18.000000000 +0100 +++ dwm-0.9.modified/config.default.h 2006-08-16 19:29:27.000000000 +0100 @@ -15,6 +15,9 @@ #define MODKEY Mod1Mask #define MASTERW 60 /* percent */ +const int WID_SLIDE=1; +#define NO_COLS 4 + #define KEYS \ static Key key[] = { \ /* modifier key function arguments */ \ @@ -46,6 +49,8 @@ { MODKEY|ControlMask, XK_3, toggleview, { .i = 3 } }, \ { MODKEY|ControlMask, XK_4, toggleview, { .i = 4 } }, \ { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ + { MODKEY, XK_p, adjustcoltypes, { .i = 1 } }, \ + { MODKEY, XK_o, adjustcoltypes, { .i = -1 } }, \ }; #define RULES \ Only in dwm-0.9.modified: config.h diff -u dwm-0.9/dwm.h dwm-0.9.modified/dwm.h --- dwm-0.9/dwm.h 2006-08-15 09:09:18.000000000 +0100 +++ dwm-0.9.modified/dwm.h 2006-08-16 19:22:42.000000000 +0100 @@ -130,6 +130,7 @@ extern void toggletag(Arg *arg); extern void toggleview(Arg *arg); extern void view(Arg *arg); +extern void adjustcoltypes(Arg *arg); /* util.c */ extern void *emallocz(unsigned int size); diff -u dwm-0.9/tag.c dwm-0.9.modified/tag.c --- dwm-0.9/tag.c 2006-08-15 09:09:18.000000000 +0100 +++ dwm-0.9.modified/tag.c 2006-08-16 19:36:53.000000000 +0100 @@ -57,22 +57,54 @@ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); } +static int noFullCols=1; +static int noStackCols=NO_COLS-1; + +/* change the balance between number of full and stacked columns */ +void +adjustcoltypes(Arg *arg) +{ + if(!arg || (arg->i==1 && noFullCols==NO_COLS) + || (arg->i==-1 && noFullCols==0)){ + return; + } + noFullCols+=arg->i; + noStackCols-=arg->i; + arrange(NULL); +} + void dotile(Arg *arg) { - int h, i, n, w; + int n, i, colNo, cumHgt; Client *c; + int noPerCol[NO_COLS],heights[NO_COLS]; + Bool useTrivialCols; - w = sw - mw; + useTrivialCols=1; for(n = 0, c = clients; c; c = c->next) if(isvisible(c) && !c->isfloat) n++; - - if(n > 1) - h = (sh - bh) / (n - 1); - else - h = sh - bh; - + for(i = 0; i < NO_COLS; ++i){ /* default to every column full height */ + noPerCol[i] = i; + heights[i] = sh-bh; + } + if(noStackCols>0 && n >= NO_COLS + && (n-noFullCols)*bh <= (sh-bh)*noStackCols){ + /* need to set up non-trivial slave columns */ + int noLongCols = (n-noFullCols)%noStackCols; + int noInShortCol = (n-noFullCols)/noStackCols; + for(i = noFullCols; i < NO_COLS; ++i){ + int no = noInShortCol + (i>=NO_COLS-noLongCols?1:0); + heights[i] = (sh - bh) / no; + /* convert into cumulative total of when new column begins */ + noPerCol[i] = no + (i==0 ? -1 : noPerCol[i - 1]); + } + useTrivialCols = 0; + } + mw = sw / NO_COLS; + colNo = 0; + cumHgt = sy + bh; for(i = 0, c = clients; c; c = c->next) { c->ismax = False; if(isvisible(c)) { @@ -80,32 +112,26 @@ resize(c, True, TopLeft); continue; } - if(n == 1) { - c->x = sx; + /* fewer clients than total columns OR slave cols are too full */ + if(useTrivialCols) { + int nP = (n>NO_COLS?NO_COLS:n); + int iP = ((i>=NO_COLS?NO_COLS-1:i)+WID_SLIDE)%nP; + c->x = sx + (iP*sw) / nP; c->y = sy + bh; - c->w = sw - 2; + c->w = sw / nP - 2; c->h = sh - 2 - bh; } - else if(i == 0) { - c->x = sx; - c->y = sy + bh; + else{ /* standard table driven approach to layout */ + c->x = sx + ((colNo+WID_SLIDE)%NO_COLS)*mw; + c->y = cumHgt; c->w = mw - 2; - c->h = sh - 2 - bh; - } - else if(h > bh) { - c->x = sx + mw; - c->y = sy + (i - 1) * h + bh; - c->w = w - 2; - if(i + 1 == n) - c->h = sh - c->y - 2; - else - c->h = h - 2; - } - else { /* fallback if h < bh */ - c->x = sx + mw; - c->y = sy + bh; - c->w = w - 2; - c->h = sh - 2 - bh; + c->h = heights[colNo] - 2; + cumHgt += heights[colNo]; + if(i == noPerCol[colNo]){ /* next client starts a new column */ + c->h = sh - 2 - c->y; + ++colNo; + cumHgt = sy + bh; + } } resize(c, False, TopLeft); i++;