1 /* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
2 * © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
3 * See LICENSE file for license details. */
12 static unsigned int nlayouts = 0;
13 static unsigned int masterw = MASTERWIDTH;
14 static unsigned int nmaster = NMASTER;
18 unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
21 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
24 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
25 mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
26 th = (n > nmaster) ? wah / (n - nmaster) : 0;
29 for(i = 0, c = clients; c; c = c->next)
32 XMoveWindow(dpy, c->win, c->x, c->y);
41 nw = mw - 2 * c->border;
42 nh = mh - 2 * c->border;
44 else { /* tile window */
46 nw = tw - 2 * c->border;
47 if(th > 2 * c->border) {
48 ny += (i - nmaster) * th;
50 nh = wah - ny - 2 * c->border;
52 nh = th - 2 * c->border;
54 else /* fallback if th <= 2 * c->border */
55 nh = wah - 2 * c->border;
57 resize(c, nx, ny, nw, nh, False);
62 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
64 if(!sel || !isvisible(sel)) {
65 for(c = stack; c && !isvisible(c); c = c->snext);
79 for(c = clients; c; c = c->next) {
82 XMoveWindow(dpy, c->win, c->x, c->y);
84 resize(c, c->x, c->y, c->w, c->h, True);
88 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
91 if(!sel || !isvisible(sel)) {
92 for(c = stack; c && !isvisible(c); c = c->snext);
99 focusclient(const char *arg) {
105 for(c = sel->prev; c && !isvisible(c); c = c->prev);
107 for(c = clients; c && c->next; c = c->next);
108 for(; c && !isvisible(c); c = c->prev);
112 for(c = sel->next; c && !isvisible(c); c = c->next);
114 for(c = clients; c && !isvisible(c); c = c->next);
123 incmasterw(const char *arg) {
125 if(lt->arrange != tile)
128 masterw = MASTERWIDTH;
131 if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
132 || waw * (masterw + i) / 1000 <= 2 * BORDERPX)
140 incnmaster(const char *arg) {
147 if((lt->arrange != tile) || (nmaster + i < 1)
148 || (wah / (nmaster + i) <= 2 * BORDERPX))
163 nlayouts = sizeof layout / sizeof layout[0];
164 for(blw = i = 0; i < nlayouts; i++) {
165 w = textw(layout[i].symbol);
172 nexttiled(Client *c) {
173 for(; c && (c->isfloating || !isvisible(c)); c = c->next);
185 if(sel->isfloating || lt->arrange == floating)
186 XRaiseWindow(dpy, sel->win);
187 if(lt->arrange != floating) {
189 XLowerWindow(dpy, sel->win);
190 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
193 XLowerWindow(dpy, c->win);
197 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
201 setlayout(const char *arg) {
205 for(i = 0; i < nlayouts && lt != &layout[i]; i++);
206 if(i == nlayouts - 1)
213 if(i < 0 || i >= nlayouts)
224 togglemax(const char *arg) {
227 if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed)
229 if((sel->ismax = !sel->ismax)) {
234 resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
237 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
239 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
243 zoom(const char *arg) {
247 if(!sel || lt->arrange != tile || sel->isfloating)
249 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
251 if((c = sel) == nexttiled(clients))
252 if(!(c = nexttiled(c->next)))