[dwm] fibonacci layout patch [update for dwm-5.0.1]
Attached is a slightly different implementation of the fibonacci() function that respects `mfact' for the master window [and lets you resize your master window with M-j M-k] This worked under hg tip (1314). Comments, insights welcome. --Madhu void fibonacci(int shape) { /* shape = 2 == dwindle * shape = 1 == counter clockwise spiral * shape = 0 == clockwise spiral */ unsigned int i, n, nx, ny, nw, nh; unsigned int mw, NX0; Client *c; 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; nx = NX0 = (wx + mw c-x + c-w) ? c-x + c-w + 2 * c-bw : wx + mw; ny = wy; nw = (wx + mw c-x + c-w) ? wx + ww - nx : ww - mw; nh = wh; 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 /= 2; else nh /= 2; } if ((i % 4) == 0) { if (shape == 2) nx += nw; else if (shape == 1) { nx += nw; if ((i+1) n) ny += nh; } else nx += nw; } else if ((i % 4) == 1) { if (shape == 2) ny += nh; else if (shape == 1) { ny -= nh; if ((i+1) n) nx += nw; } else { ny += nh; if ((i+1) n) nx += nw; } } else if ((i % 4) == 2) { if (shape == 2) nx += nw; else if (shape == 1) nx -= nw; else { nx -= nw; if (i+1 n) ny += nh; } } else if ((i % 4) == 3) { if (shape == 2) ny += nh; else if (shape == 1) ny += nh; else ny -= nh; } if (i == 0) nx = NX0; i++; } resize(c, nx, ny, nw - 2 * c-bw, nh - 2 * c-bw, resizehints); } }
Re: [dwm] way towards 5.0
* [EMAIL PROTECTED] Wrote on Thu, 22 May 2008 20:17:47 +0200: | - removed reapply() | I'm not sure removing reapply() and forcing people to restart dwm is a | neat idea for those using logon managers. Quitting dwm ends my Xsession, | kills the X clients and takes me back to xdm. | | Perhaps I'm missing something, if so, please clarify. The first thing I did on getting dwm was to add a (badly named) function: void startwm(const char *arg) { static char *shell = NULL; if(!shell !(shell = getenv(SHELL))) shell = /bin/sh; if(!arg) return; execlp(shell, shell, -c, arg, (char *)NULL); fprintf(stderr, dwm: execlp '%s -c %s', shell, arg); } and then add a keybinding, Mod-q, in config.h keys[] to re-exec the process: { MODKEY, XK_q, startwm, exec dwm /dev/null }, I called it `startwm' because I wanted to exec other window managers too. but it is really just an exec(2) and spawn doesn't cut it here. -- Madhu PS Perhaps this could be folded into, or perhaps spawn() could be layered on top of a different function which could also be used for this purpose?
[dwm] fibonacci layout patch [update for dwm-4.9]
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); } }