Hi,
    I noticed that I was working on dwm-4.9 which was very old. I have
updated my local repository to the hg tip and have prepared a patch against
that. The functionality is the same as shown before. Screenshots at
http://picasaweb.google.com/cchinopio/Dwm
    I have started using this as my default layout and it feels good in
regular use. I have also found it useful to map shortcuts to directly
activate the tileo, tile and floating layouts. The following is an excerpt
from my configuration

Layout layouts[] = {
    /* symbol     arrange function */
    { "[]/",      tileo }, /* first entry is default */
    { "[]=",      tile },
    { "><>",      NULL }, /* no layout function means floating behavior */
};

...
    { MODKEY|ShiftMask,             XK_t,      togglelayout,   (char*)"[]="
},
    { MODKEY|ShiftMask,             XK_n,      togglelayout,   (char*)"[]/"
},
    { MODKEY|ShiftMask,             XK_f,      togglelayout,   (char*)"><>"
},
...

    Comments and suggestions are most welcome.

diff -r 95fb2c66d92a dwm.c
--- a/dwm.c    Tue Jun 10 14:56:35 2008 -0400
+++ b/dwm.c    Tue Jun 10 15:34:29 2008 -0400
@@ -168,6 +168,7 @@ void tag(const void *arg);
 void tag(const void *arg);
 int textnw(const char *text, uint len);
 void tile(void);
+void tileo(void);
 void togglebar(const void *arg);
 void togglefloating(const void *arg);
 void togglelayout(const void *arg);
@@ -1186,12 +1187,14 @@ restack(void) {
     if(ismax || sel->isfloating || !lt->arrange)
         XRaiseWindow(dpy, sel->win);
     if(!ismax && lt->arrange) {
-        wc.stack_mode = Below;
+        wc.stack_mode = Above;
         wc.sibling = barwin;
         for(c = stack; c; c = c->snext)
             if(!c->isfloating && !c->isbanned) {
                 XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
                 wc.sibling = c->win;
+                if(c == sel)
+                    wc.stack_mode = Below;
             }
     }
     XSync(dpy, False);
@@ -1457,6 +1460,47 @@ tile(void) {
                ? (wy + wh) - y : h) - 2 * c->bw, resizehints);
         if(h != wh)
             y = c->y + c->h + 2 * c->bw;
+    }
+}
+
+void
+tileo(void) {
+    int x, y, h, w, mw;
+    uint 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;
     }
 }


-- 
Pinocchio

Reply via email to