diff options
Diffstat (limited to 'dwm.c')
-rw-r--r-- | dwm.c | 70 |
1 files changed, 70 insertions, 0 deletions
@@ -169,8 +169,10 @@ static void detachstack(Client *c); static Monitor *dirtomon(int dir); static void drawbar(Monitor *m); static void drawbars(void); +static void dwindle(Monitor *mon); static void enternotify(XEvent *e); static void expose(XEvent *e); +static void fibonacci(Monitor *mon, int s); static void focus(Client *c); static void focusin(XEvent *e); static void focusmon(const Arg *arg); @@ -225,6 +227,7 @@ static void sigchld(int unused); static void sighup(int unused); static void sigterm(int unused); static void spawn(const Arg *arg); +static void spiral(Monitor *mon); static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *); @@ -783,6 +786,11 @@ drawbars(void) } void +dwindle(Monitor *mon) { + fibonacci(mon, 1); +} + +void enternotify(XEvent *e) { Client *c; @@ -812,6 +820,63 @@ expose(XEvent *e) } void +fibonacci(Monitor *mon, int s) { + unsigned int i, n, nx, ny, nw, nh; + Client *c; + + for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + nx = mon->wx; + ny = 0; + nw = mon->ww; + nh = mon->wh; + + for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) { + if((i % 2 && nh / 2 > 2 * c->bw) + || (!(i % 2) && nw / 2 > 2 * c->bw)) { + if(i < n - 1) { + if(i % 2) + nh /= 2; + else + nw /= 2; + if((i % 4) == 2 && !s) + nx += nw; + else if((i % 4) == 3 && !s) + ny += nh; + } + if((i % 4) == 0) { + if(s) + ny += nh; + else + ny -= nh; + } + else if((i % 4) == 1) + nx += nw; + else if((i % 4) == 2) + ny += nh; + else if((i % 4) == 3) { + if(s) + nx += nw; + else + nx -= nw; + } + if(i == 0) + { + if(n != 1) + nw = mon->ww * mon->mfact; + ny = mon->wy; + } + else if(i == 1) + nw = mon->ww - nw; + i++; + } + resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False); + } +} + +void focus(Client *c) { if (!c || !ISVISIBLE(c)) @@ -1812,6 +1877,11 @@ spawn(const Arg *arg) } void +spiral(Monitor *mon) { + fibonacci(mon, 0); +} + +void tag(const Arg *arg) { if (selmon->sel && arg->ui & TAGMASK) { |