diff -r 2ab6be9cd3ff client.c --- a/client.c Thu Aug 10 16:37:13 2006 +0200 +++ b/client.c Thu Aug 10 18:34:10 2006 +0200 @@ -484,3 +484,32 @@ zoom(Arg *arg) arrange(NULL); focus(sel); } + +void +masterinc(Arg *arg) +{ + int ox, oy, ow, oh; + XEvent ev; + + if(!sel) + return; + + mw += mw * MASTERWINC / 100; + mh += mh * MASTERHINC / 100; + dotile(arg); +} + +void +masterdec(Arg *arg) +{ + int ox, oy, ow, oh; + XEvent ev; + + if(!sel) + return; + + mw -= mw * MASTERWINC / 100; + mh -= mh * MASTERHINC / 100; + dotile(arg); +} + diff -r 2ab6be9cd3ff config.default.h --- a/config.default.h Thu Aug 10 16:37:13 2006 +0200 +++ b/config.default.h Thu Aug 10 18:34:10 2006 +0200 @@ -14,7 +14,12 @@ const char *tags[] = { "0", "1", "2", "3 #define BORDERCOLOR "#9999CC" #define MODKEY Mod1Mask #define NUMLOCKMASK Mod2Mask -#define MASTERW 60 /* percent */ +#define FIRSTPAIR_VER 0 +#define FIRSTPAIR_HOR 1 +#define MASTERW 60 /* percent */ +#define MASTERWINC 10 /* percent */ +#define MASTERH 60 /* percent */ +#define MASTERHINC 10 /* percent */ #define KEYS \ static Key key[] = { \ @@ -44,6 +49,9 @@ static Key key[] = { \ { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ { MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \ + { MODKEY, XK_b, masterinc, { 0 } }, \ + { MODKEY, XK_n, masterdec, { 0 } }, \ + { MODKEY, XK_t, togglehorizvert, { 0 } }, \ }; #define RULES \ diff -r 2ab6be9cd3ff dwm.h --- a/dwm.h Thu Aug 10 16:37:13 2006 +0200 +++ b/dwm.h Thu Aug 10 18:34:10 2006 +0200 @@ -69,7 +69,7 @@ struct Client { extern const char *tags[]; extern char stext[1024]; -extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw; +extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw, mh, fp; extern unsigned int ntags; extern void (*handler[LASTEvent])(XEvent *); extern void (*arrange)(Arg *); @@ -126,9 +126,12 @@ extern void replacetag(Arg *arg); extern void replacetag(Arg *arg); extern void settags(Client *c); extern void togglemode(Arg *arg); +extern void togglehorizvert(Arg *arg); extern void view(Arg *arg); extern void viewnext(Arg *arg); extern void viewprev(Arg *arg); +extern void masterinc(Arg *arg); +extern void masterdec(Arg *arg); /* util.c */ extern void *emallocz(unsigned int size); diff -r 2ab6be9cd3ff main.c --- a/main.c Thu Aug 10 16:37:13 2006 +0200 +++ b/main.c Thu Aug 10 18:34:10 2006 +0200 @@ -84,7 +84,7 @@ xerrorstart(Display *dsply, XErrorEvent char stext[1024]; int tsel = DEFTAG; -int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; +int screen, sx, sy, sw, sh, bx, by, bw, bh, mw, mh, fp; unsigned int ntags; Atom wmatom[WMLast], netatom[NetLast]; Bool running = True; @@ -224,6 +224,8 @@ main(int argc, char *argv[]) sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); mw = (sw * MASTERW) / 100; + mh = (sh * MASTERH) / 100; + fp = FIRSTPAIR_VER; wa.override_redirect = 1; wa.background_pixmap = ParentRelative; diff -r 2ab6be9cd3ff tag.c --- a/tag.c Thu Aug 10 16:37:13 2006 +0200 +++ b/tag.c Thu Aug 10 18:34:10 2006 +0200 @@ -66,21 +66,41 @@ dofloat(Arg *arg) drawall(); } +int countclients(){ + int n; + Client *c; + for(n = 0, c = clients; c; c = c->next) + if(c->tags[tsel] && !c->isfloat){ + n++; + } + return n; +} + void dotile(Arg *arg) { - int n, i, w, h; - Client *c; - - w = sw - mw; - for(n = 0, c = clients; c; c = c->next) - if(c->tags[tsel] && !c->isfloat) - n++; - - if(n > 1) - h = (sh - bh) / (n - 1); - else - h = sh - bh; + int i, extra; + int xoff, yoff, woff, hoff; + Client *c; + int n = countclients(); + int h = n>2 ? (fp==FIRSTPAIR_HOR ? (sh-bh)/(n-2):sh-mh):0; + int w = n>2 ? (fp==FIRSTPAIR_VER ? sw/(n-2):sw-mw):0; + int dims[] = { + /* + x, y, w, h + */ + 0, bh, 0, -bh, /* 0 master n=1 */ + 0, bh, -sw+mw, -bh, /* 4 master n=2 V */ + mw, bh, -mw, -bh, /* - slave n=2 V */ + 0, bh, 0, -sh+mh-bh, /* 12 master n=2 H */ + 0, mh, 0, -mh, /* - slave n=2 H */ + 0, bh, -sw+mw, -sh+mh-bh, /* 20 master n>2 V */ + mw, bh, -mw, -sh+mh-bh, /* - slave n>2 V */ + 0, mh, -sw+w, -sh+h, /* - other n>2 V */ + 0, bh, -sw+mw, -sh+mh-bh, /* 32 master n>2 H */ + 0, mh, -sw+mw, -mh, /* - slave n>2 H */ + mw, bh, -sw+w, -sh+h, /* - other n>2 H */ + }; for(i = 0, c = clients; c; c = c->next) { c->ismax = False; @@ -90,33 +110,30 @@ dotile(Arg *arg) resize(c, True, TopLeft); continue; } - if(n == 1) { - c->x = sx; - c->y = sy + bh; - c->w = sw - 2; - c->h = sh - 2 - bh; - } - else if(i == 0) { - c->x = sx; - c->y = sy + bh; - 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; - } + + extra = 0; + if (n>2) { + extra += 20; + extra += i>1 ? 8 : 4*i; + if (FIRSTPAIR_HOR==fp) + extra += 12; + } + else { + extra += (4+4*i) - ((4+4*i)*(2-n)); + if (FIRSTPAIR_HOR==fp) + extra += 8-8*(2-n); + } + + xoff = dims[0+extra]; + yoff = dims[1+extra]; + woff = dims[2+extra]; + hoff = dims[3+extra]; + + c->x = sx + xoff + (i>1 ? 1:0)*(i-2)*w*(1-fp); + c->y = sy + yoff + (i>1 ? 1:0)*(i-2)*h*fp; + c->w = sw + woff - 2; /* 2 x 1 pix border */ + c->h = sh + hoff - 2; + resize(c, False, TopLeft); i++; } @@ -235,6 +252,13 @@ view(Arg *arg) drawall(); } +void +togglehorizvert(Arg *arg) +{ + fp = 1 - fp; + dotile(arg); +} + void viewnext(Arg *arg) {