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 * See LICENSE file for license details. */
13 static unsigned int nlayouts = 0;
14 static unsigned int masterw = MASTERWIDTH;
15 static unsigned int nmaster = NMASTER;
21 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
29 XMoveWindow(dpy, c->win, c->x, c->y);
35 unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
38 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
41 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
42 mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
43 th = (n > nmaster) ? wah / (n - nmaster) : 0;
46 for(i = 0, c = clients; c; c = c->next)
56 nw = mw - 2 * c->border;
58 if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */
62 else { /* tile window */
64 nw = tw - 2 * c->border;
65 if(th > 2 * c->border) {
66 ny += (i - nmaster) * th;
68 if(i + 1 == n) /* remainder */
69 nh = wah - th * (i - nmaster);
72 else /* fallback if th <= 2 * c->border */
73 nh = wah - 2 * c->border;
75 resize(c, nx, ny, nw, nh, False);
92 for(c = clients; c; c = c->next)
95 XMoveWindow(dpy, c->win, c->x, c->y);
97 resize(c, c->x, c->y, c->w, c->h, True);
106 focusclient(const char *arg) {
112 for(c = sel->prev; c && !isvisible(c); c = c->prev);
114 for(c = clients; c && c->next; c = c->next);
115 for(; c && !isvisible(c); c = c->prev);
119 for(c = sel->next; c && !isvisible(c); c = c->next);
121 for(c = clients; c && !isvisible(c); c = c->next);
130 incmasterw(const char *arg) {
132 if(lt->arrange != tile)
135 masterw = MASTERWIDTH;
138 if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
139 || waw * (masterw + i) / 1000 <= 2 * BORDERPX)
147 incnmaster(const char *arg) {
154 if((lt->arrange != tile) || (nmaster + i < 1)
155 || (wah / (nmaster + i) <= 2 * BORDERPX))
170 nlayouts = sizeof layout / sizeof layout[0];
171 for(blw = i = 0; i < nlayouts; i++) {
172 w = textw(layout[i].symbol);
179 nexttiled(Client *c) {
180 for(; c && (c->isfloating || !isvisible(c)); c = c->next);
192 if(sel->isfloating || lt->arrange == floating)
193 XRaiseWindow(dpy, sel->win);
194 if(lt->arrange != floating) {
196 XLowerWindow(dpy, sel->win);
197 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
200 XLowerWindow(dpy, c->win);
204 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
208 setlayout(const char *arg) {
213 if(lt == layout + nlayouts)
218 if(i < 0 || i >= nlayouts)
229 togglebar(const char *arg) {
231 bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
239 togglemax(const char *arg) {
242 if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed)
244 if((sel->ismax = !sel->ismax)) {
249 resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
252 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
254 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
258 zoom(const char *arg) {
261 if(!sel || lt->arrange == floating || sel->isfloating)
263 if((c = sel) == nexttiled(clients))
264 if(!(c = nexttiled(c->next)))