1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
2 * See LICENSE file for license details.
11 static unsigned int nlayouts = 0;
12 static unsigned int masterw = MASTERWIDTH;
13 static unsigned int nmaster = NMASTER;
17 unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
20 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
23 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
24 mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
25 th = (n > nmaster) ? wah / (n - nmaster) : 0;
28 for(i = 0, c = clients; c; c = c->next)
31 XMoveWindow(dpy, c->win, c->x, c->y);
40 nw = mw - 2 * BORDERPX;
41 nh = mh - 2 * BORDERPX;
43 else { /* tile window */
45 nw = tw - 2 * BORDERPX;
46 if(th > 2 * BORDERPX) {
47 ny += (i - nmaster) * th;
48 nh = th - 2 * BORDERPX;
50 else /* fallback if th <= 2 * BORDERPX */
51 nh = wah - 2 * BORDERPX;
53 resize(c, nx, ny, nw, nh, False);
58 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
60 if(!sel || !isvisible(sel)) {
61 for(c = stack; c && !isvisible(c); c = c->snext);
77 for(c = sel->next; c && !isvisible(c); c = c->next);
79 for(c = clients; c && !isvisible(c); c = c->next);
92 for(c = sel->prev; c && !isvisible(c); c = c->prev);
94 for(c = clients; c && c->next; c = c->next);
95 for(; c && !isvisible(c); c = c->prev);
104 incmasterw(Arg arg) {
105 if(lt->arrange != tile)
108 masterw = MASTERWIDTH;
110 if(waw * (masterw + arg.i) / 1000 >= waw - 2 * BORDERPX
111 || waw * (masterw + arg.i) / 1000 <= 2 * BORDERPX)
119 incnmaster(Arg arg) {
120 if((lt->arrange != tile) || (nmaster + arg.i < 1)
121 || (wah / (nmaster + arg.i) <= 2 * BORDERPX))
135 nlayouts = sizeof layout / sizeof layout[0];
136 for(blw = i = 0; i < nlayouts; i++) {
137 w = textw(layout[i].symbol);
144 nexttiled(Client *c) {
145 for(; c && (c->isversatile || !isvisible(c)); c = c->next);
157 if(sel->isversatile || lt->arrange == versatile)
158 XRaiseWindow(dpy, sel->win);
159 if(lt->arrange != versatile) {
160 if(!sel->isversatile)
161 XLowerWindow(dpy, sel->win);
162 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
165 XLowerWindow(dpy, c->win);
169 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
177 for(i = 0; i < nlayouts && lt != &layout[i]; i++);
178 if(i == nlayouts - 1)
184 if(arg.i < 0 || arg.i >= nlayouts)
198 if(!sel || (lt->arrange != versatile && !sel->isversatile) || sel->isfixed)
200 if((sel->ismax = !sel->ismax)) {
205 resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
208 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
210 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
217 for(c = clients; c; c = c->next) {
220 XMoveWindow(dpy, c->win, c->x, c->y);
222 resize(c, c->x, c->y, c->w, c->h, True);
226 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
229 if(!sel || !isvisible(sel)) {
230 for(c = stack; c && !isvisible(c); c = c->snext);
241 if(!sel || lt->arrange != tile || sel->isversatile)
243 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
245 if((c = sel) == nexttiled(clients))
246 if(!(c = nexttiled(c->next)))