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 * © 2006-2007 Jukka Salmi <jukka at salmi dot ch>
4 * © 2007 Premysl Hruby <dfenze at gmail dot com>
5 * © 2007 Szabolcs Nagy <nszabolcs at gmail dot com>
6 * See LICENSE file for license details. */
15 static unsigned int nlayouts = 0;
16 static unsigned int masterw = MASTERWIDTH;
17 static unsigned int nmaster = NMASTER;
23 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
31 XMoveWindow(dpy, c->win, c->x, c->y);
37 unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
40 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
43 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
44 mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
45 th = (n > nmaster) ? wah / (n - nmaster) : 0;
48 for(i = 0, c = clients; c; c = c->next)
58 nw = mw - 2 * c->border;
60 if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */
64 else { /* tile window */
66 nw = tw - 2 * c->border;
67 if(th > 2 * c->border) {
68 ny += (i - nmaster) * th;
70 if(i + 1 == n) /* remainder */
71 nh = wah - th * (i - nmaster);
74 else /* fallback if th <= 2 * c->border */
75 nh = wah - 2 * c->border;
77 resize(c, nx, ny, nw, nh, False);
94 for(c = clients; c; c = c->next)
97 XMoveWindow(dpy, c->win, c->x, c->y);
99 resize(c, c->x, c->y, c->w, c->h, True);
108 focusclient(const char *arg) {
114 for(c = sel->prev; c && !isvisible(c); c = c->prev);
116 for(c = clients; c && c->next; c = c->next);
117 for(; c && !isvisible(c); c = c->prev);
121 for(c = sel->next; c && !isvisible(c); c = c->next);
123 for(c = clients; c && !isvisible(c); c = c->next);
132 incmasterw(const char *arg) {
134 if(lt->arrange != tile)
137 masterw = MASTERWIDTH;
140 if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
141 || waw * (masterw + i) / 1000 <= 2 * BORDERPX)
149 incnmaster(const char *arg) {
156 if((lt->arrange != tile) || (nmaster + i < 1)
157 || (wah / (nmaster + i) <= 2 * BORDERPX))
172 nlayouts = sizeof layout / sizeof layout[0];
173 for(blw = i = 0; i < nlayouts; i++) {
174 w = textw(layout[i].symbol);
181 nexttiled(Client *c) {
182 for(; c && (c->isfloating || !isvisible(c)); c = c->next);
194 if(sel->isfloating || lt->arrange == floating)
195 XRaiseWindow(dpy, sel->win);
196 if(lt->arrange != floating) {
198 XLowerWindow(dpy, sel->win);
199 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
202 XLowerWindow(dpy, c->win);
206 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
210 setlayout(const char *arg) {
215 if(lt == layout + nlayouts)
220 if(i < 0 || i >= nlayouts)
231 togglebar(const char *arg) {
233 bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
241 togglemax(const char *arg) {
244 if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed)
246 if((sel->ismax = !sel->ismax)) {
251 resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
254 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
256 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
260 zoom(const char *arg) {
263 if(!sel || lt->arrange == floating || sel->isfloating)
265 if((c = sel) == nexttiled(clients))
266 if(!(c = nexttiled(c->next)))