## patch to add the doubletile layout to dwm. ## written by SlainVeteran (dwm_doubletile@slainvet.net) in 4 minutes on 17-Feb-2009. diff -rupN dwm-5.3.1/config.def.h dwm-5.3.1.doubletile/config.def.h --- dwm-5.3.1/config.def.h 2008-12-06 09:33:03.000000000 +0000 +++ dwm-5.3.1.doubletile/config.def.h 2009-02-17 22:56:23.000000000 +0000 @@ -29,12 +29,14 @@ static Rule rules[] = { /* layout(s) */ static float mfact = 0.55; /* factor of master area size [0.05..0.95] */ static Bool resizehints = True; /* False means respect size hints in tiled resizals */ +static int dfact = 2; /* number of windows to appear on the left [1..] */ static Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "-|=", doubletile }, }; /* key definitions */ @@ -61,6 +63,8 @@ static Key keys[] = { { MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, XK_u, setdfact, {.i = +1} }, + { MODKEY, XK_i, setdfact, {.i = -1} }, { MODKEY, XK_Return, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, { MODKEY|ShiftMask, XK_c, killclient, {0} }, diff -rupN dwm-5.3.1/dwm.c dwm-5.3.1.doubletile/dwm.c --- dwm-5.3.1/dwm.c 2008-12-06 09:33:03.000000000 +0000 +++ dwm-5.3.1.doubletile/dwm.c 2009-02-17 22:51:06.000000000 +0000 @@ -149,6 +149,7 @@ static void die(const char *errstr, ...) static void drawbar(void); static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]); static void drawtext(const char *text, unsigned long col[ColLast], Bool invert); +static void doubletile(void); static void enternotify(XEvent *e); static void expose(XEvent *e); static void focus(Client *c); @@ -179,6 +180,7 @@ static void run(void); static void scan(void); static void setclientstate(Client *c, long state); static void setlayout(const Arg *arg); +static void setdfact(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void showhide(Client *c); @@ -583,6 +585,50 @@ drawtext(const char *text, unsigned long } void +doubletile(void) { + int x, y, h, w, mw; + unsigned int i, n, min; + Client *c; + + for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + /* main stack */ + min = dfact < n ? dfact : n; + mw = dfact >= n ? ww : mfact * ww; + y = wy; + h = wh / min; + if(h < bh) + h = wh; + + for(i = 0, c = nexttiled(clients); i < min; c = nexttiled(c->next), i++) { + resize(c, wx, y, mw - 2 * c->bw, /* remainder */ ((i + 1 == min) + ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints); + if(h != wh) + y = c->y + HEIGHT(c); + + if(--n == 0) + return; + } + + /* tile stack */ + x = (wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : wx + mw; + y = wy; + w = (wx + mw > c->x + c->w) ? wx + ww - x : ww - mw; + h = wh / n; + if(h < bh) + h = wh; + + for(i = 0; c; c = nexttiled(c->next), i++) { + resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) + ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints); + if(h != wh) + y = c->y + HEIGHT(c); + } +} + +void enternotify(XEvent *e) { Client *c; XCrossingEvent *ev = &e->xcrossing; @@ -1283,6 +1329,19 @@ setlayout(const Arg *arg) { drawbar(); } +void +setdfact(const Arg *arg) { + int i; + + if(!arg || !lt[sellt]->arrange) + return; + i = arg->i + dfact; + if(i < 1) + return; + dfact = i; + arrange(); +} + /* arg > 1.0 will set mfact absolutly */ void setmfact(const Arg *arg) {