1 /* © 2004-2007 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);
75 for(c = clients; c; c = c->next) {
78 XMoveWindow(dpy, c->win, c->x, c->y);
80 resize(c, c->x, c->y, c->w, c->h, True);
84 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
87 if(!sel || !isvisible(sel)) {
88 for(c = stack; c && !isvisible(c); c = c->snext);
95 focusclient(const char *arg) {
101 for(c = sel->prev; c && !isvisible(c); c = c->prev);
103 for(c = clients; c && c->next; c = c->next);
104 for(; c && !isvisible(c); c = c->prev);
108 for(c = sel->next; c && !isvisible(c); c = c->next);
110 for(c = clients; c && !isvisible(c); c = c->next);
119 incmasterw(const char *arg) {
121 if(lt->arrange != tile)
124 masterw = MASTERWIDTH;
127 if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
128 || waw * (masterw + i) / 1000 <= 2 * BORDERPX)
136 incnmaster(const char *arg) {
143 if((lt->arrange != tile) || (nmaster + i < 1)
144 || (wah / (nmaster + i) <= 2 * BORDERPX))
159 nlayouts = sizeof layout / sizeof layout[0];
160 for(blw = i = 0; i < nlayouts; i++) {
161 w = textw(layout[i].symbol);
168 nexttiled(Client *c) {
169 for(; c && (c->isfloating || !isvisible(c)); c = c->next);
181 if(sel->isfloating || lt->arrange == floating)
182 XRaiseWindow(dpy, sel->win);
183 if(lt->arrange != floating) {
185 XLowerWindow(dpy, sel->win);
186 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
189 XLowerWindow(dpy, c->win);
193 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
197 setlayout(const char *arg) {
201 for(i = 0; i < nlayouts && lt != &layout[i]; i++);
202 if(i == nlayouts - 1)
209 if(i < 0 || i >= nlayouts)
220 togglemax(const char *arg) {
223 if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed)
225 if((sel->ismax = !sel->ismax)) {
230 resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
233 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
235 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
239 zoom(const char *arg) {
243 if(!sel || lt->arrange != tile || sel->isfloating)
245 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
247 if((c = sel) == nexttiled(clients))
248 if(!(c = nexttiled(c->next)))