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 * © 2007 Premysl Hruby <dfenze at gmail dot com>
4 * © 2007 Szabolcs Nagy <nszabolcs at gmail dot com>
5 * See LICENSE file for license details. */
14 static unsigned int nlayouts = 0;
15 static unsigned int masterw = MASTERWIDTH;
16 static unsigned int nmaster = NMASTER;
22 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
30 XMoveWindow(dpy, c->win, c->x, c->y);
36 unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
39 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
42 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
43 mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
44 th = (n > nmaster) ? wah / (n - nmaster) : 0;
47 for(i = 0, c = clients; c; c = c->next)
57 nw = mw - 2 * c->border;
59 if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */
63 else { /* tile window */
65 nw = tw - 2 * c->border;
66 if(th > 2 * c->border) {
67 ny += (i - nmaster) * th;
69 if(i + 1 == n) /* remainder */
70 nh = wah - th * (i - nmaster);
73 else /* fallback if th <= 2 * c->border */
74 nh = wah - 2 * c->border;
76 resize(c, nx, ny, nw, nh, False);
93 for(c = clients; c; c = c->next)
96 XMoveWindow(dpy, c->win, c->x, c->y);
98 resize(c, c->x, c->y, c->w, c->h, True);
107 focusclient(const char *arg) {
113 for(c = sel->prev; c && !isvisible(c); c = c->prev);
115 for(c = clients; c && c->next; c = c->next);
116 for(; c && !isvisible(c); c = c->prev);
120 for(c = sel->next; c && !isvisible(c); c = c->next);
122 for(c = clients; c && !isvisible(c); c = c->next);
131 incmasterw(const char *arg) {
133 if(lt->arrange != tile)
136 masterw = MASTERWIDTH;
139 if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
140 || waw * (masterw + i) / 1000 <= 2 * BORDERPX)
148 incnmaster(const char *arg) {
155 if((lt->arrange != tile) || (nmaster + i < 1)
156 || (wah / (nmaster + i) <= 2 * BORDERPX))
171 nlayouts = sizeof layout / sizeof layout[0];
172 for(blw = i = 0; i < nlayouts; i++) {
173 w = textw(layout[i].symbol);
180 nexttiled(Client *c) {
181 for(; c && (c->isfloating || !isvisible(c)); c = c->next);
193 if(sel->isfloating || lt->arrange == floating)
194 XRaiseWindow(dpy, sel->win);
195 if(lt->arrange != floating) {
197 XLowerWindow(dpy, sel->win);
198 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
201 XLowerWindow(dpy, c->win);
205 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
209 setlayout(const char *arg) {
214 if(lt == layout + nlayouts)
219 if(i < 0 || i >= nlayouts)
230 togglebar(const char *arg) {
232 bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
240 togglemax(const char *arg) {
243 if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed)
245 if((sel->ismax = !sel->ismax)) {
250 resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
253 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
255 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
259 zoom(const char *arg) {
262 if(!sel || lt->arrange == floating || sel->isfloating)
264 if((c = sel) == nexttiled(clients))
265 if(!(c = nexttiled(c->next)))