Re: [dwm] An "overlapped tiled" layout

From: Monsieur Pinocchio <cchinopio_AT_gmail.com>
Date: Mon, 8 Sep 2008 21:47:53 -0400

Just want to make a small correction to the patch I sent in my previous
mail.

This is the complete patch for tileo over dwm-5.1

diff -ur ../../src/dwm/config.def.h ./config.def.h
--- ../../src/dwm/config.def.h 2008-07-30 03:15:06.244596000 -0400
+++ ./config.def.h 2008-07-30 03:17:02.254598000 -0400
@@ -29,6 +29,7 @@
 static Layout layouts[] = {
        /* symbol arrange function */
        { "[]=", tile }, /* first entry is default */
+ { "[]/", tileo },
        { "><>", NULL }, /* no layout function means floating
behavior */
        { "[M]", monocle },
 };
@@ -61,8 +62,9 @@
        { MODKEY, XK_Tab, view, {0} },
        { MODKEY|ShiftMask, XK_c, killclient, {0} },
        { MODKEY, XK_t, setlayout, {.v =
&layouts[0]} },
- { MODKEY, XK_f, setlayout, {.v =
&layouts[1]} },
- { MODKEY, XK_m, setlayout, {.v =
&layouts[2]} },
+ { MODKEY, XK_o, setlayout, {.v =
&layouts[1]} },
+ { MODKEY, XK_f, setlayout, {.v =
&layouts[2]} },
+ { MODKEY, XK_m, setlayout, {.v =
&layouts[3]} },
        { MODKEY, XK_space, setlayout, {0} },
        { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
        { MODKEY, XK_0, view, {.ui = ~0
} },
@@ -85,7 +87,7 @@
 static Button buttons[] = {
        /* click event mask button
function argument */
        { ClkLtSymbol, 0, Button1,
setlayout, {0} },
- { ClkLtSymbol, 0, Button3,
setlayout, {.v = &layouts[2]} },
+ { ClkLtSymbol, 0, Button3,
setlayout, {.v = &layouts[3]} },
        { ClkWinTitle, 0, Button2,
zoom, {0} },
        { ClkStatusText, 0, Button2,
spawn, {.v = termcmd } },
        { ClkClientWin, MODKEY, Button1,
movemouse, {0} },
diff -ur ../../src/dwm/dwm.c ./dwm.c
--- ../../src/dwm/dwm.c 2008-07-30 03:15:06.252595000 -0400
+++ ./dwm.c 2008-09-08 21:37:00.132304219 -0400
@@ -185,6 +185,7 @@
 static void tag(const Arg *arg);
 static int textnw(const char *text, unsigned int len);
 static void tile(void);
+static void tileo(void);
 static void togglebar(const Arg *arg);
 static void togglefloating(const Arg *arg);
 static void toggletag(const Arg *arg);
@@ -1195,13 +1196,16 @@
        if(sel->isfloating || !lt[sellt]->arrange)
                XRaiseWindow(dpy, sel->win);
        if(lt[sellt]->arrange) {
- wc.stack_mode = Below;
+ wc.stack_mode = Above;
                wc.sibling = barwin;
- for(c = stack; c; c = c->snext)
+ for(c = clients; c ; c = c->next) {
                        if(!c->isfloating && ISVISIBLE(c)) {
                                XConfigureWindow(dpy, c->win,
CWSibling|CWStackMode, &wc);
                                wc.sibling = c->win;
                        }
+ if(c == sel && ISVISIBLE(c))
+ wc.stack_mode = Below;
+ }
        }
        XSync(dpy, False);
        while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
@@ -1478,6 +1482,47 @@
 }

 void
+tileo(void) {
+ int x, y, h, w, mw;
+ unsigned int i, n;
+ Client *c;
+ const double ratio = 0.8;
+
+ for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++);
+ if(n == 0)
+ return;
+
+ /* master */
+ c = nexttiled(clients);
+ mw = mfact * ww;
+ resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw,
resizehints);
+
+ 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 is the vertical distance between windows in the stack.
+ * The height of all windows in the stack is ratio * wh */
+ if(n > 1)
+ h = (1-ratio) * wh / (n - 1);
+ else
+ h = wh;
+
+ if(h < bh)
+ h = wh;
+
+ for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
+ resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
+ ? (wy + wh) - y : ratio * wh) - 2 * c->bw,
resizehints);
+ if(h != wh)
+ y = c->y + h;
+ }
+}
+
+void
 togglebar(const Arg *arg) {
        showbar = !showbar;
        updategeom();

-- 
Pinocchio
Received on Tue Sep 09 2008 - 01:47:53 UTC

This archive was generated by hypermail 2.2.0 : Tue Sep 09 2008 - 02:00:02 UTC