[dwm] fibonacci layout patch [update for dwm-4.9]

From: Madhu <enometh_AT_meer.net>
Date: Thu, 15 May 2008 11:57:02 +0530 (IST)

Helu kids, the last fibonacci layout patch was for dwm-4.6:
herbst.homeunix.org/~jceb/dwm/4.6/current/dwm-4.6-fibonacci.diff
Preserving the logic of that patch, here is an updated fibonacci()
function which works with dwm-4.9 with the default `single' geometry.
It uses tilemaster() to draw the master window (so it can be resized
as usual), and leaves focus and stacking tasks to arrange(),
elsewhere. Hopefully this can be tested and used to update the
patch for dwm-5.0 when it happens -- Guby, Madhu.

void
fibonacci(int shape) {
        const float fract = 0.5;
        unsigned int i, n = counttiled(), nx, ny, nw, nh;
        Client *c;

        if (n == 0)
                return;

        c = tilemaster(n);
        if (--n == 0)
                return;

        nx = tx;
        ny = ty;
        nw = tw;
        nh = th;

        for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next)) {
                if((i % 2 && nw / 2 > 2 * c->bw) || (!(i % 2) && nh / 2 > 2 * c->bw))
                {
                        if((i+1) < n) {
                                if(i % 2)
                                        nw *= fract;
                                else
                                        nh *= fract;
                                if((i % 4) == 2 && !shape)
                                        ny += nh;
                                else if((i % 4) == 3 && !shape)
                                        nx += nw;
                        }
                        if((i % 4) == 0) {
                                if(shape)
                                        nx += nw;
                                else
                                        nx -= nw;
                        }
                        else if((i % 4) == 1)
                                ny += nh;
                        else if((i % 4) == 2)
                                nx += nw;
                        else if((i % 4) == 3) {
                                if(shape)
                                        ny += nh;
                                else
                                        ny -= nh;
                        }
                        if (i == 0)
                                nx = tx;
                        i++;
                }
                tileresize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw);
        }
}
Received on Thu May 15 2008 - 08:27:11 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:39:36 UTC