1 /* See LICENSE file for copyright and license details. */
10 static unsigned int nlayouts = 0;
11 static unsigned int masterw = MASTERWIDTH;
12 static unsigned int nmaster = NMASTER;
16 unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
19 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
22 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
23 mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
24 th = (n > nmaster) ? wah / (n - nmaster) : 0;
27 for(i = 0, c = clients; c; c = c->next)
37 nw = mw - 2 * c->border;
39 if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */
43 else { /* tile window */
45 nw = tw - 2 * c->border;
46 if(th > 2 * c->border) {
47 ny += (i - nmaster) * th;
49 if(i + 1 == n) /* remainder */
50 nh = wah - th * (i - nmaster);
53 else /* fallback if th <= 2 * c->border */
54 nh = wah - 2 * c->border;
56 resize(c, nx, ny, nw, nh, False);
73 for(c = clients; c; c = c->next)
76 resize(c, c->x, c->y, c->w, c->h, True);
85 focusclient(const char *arg) {
91 for(c = sel->prev; c && !isvisible(c); c = c->prev);
93 for(c = clients; c && c->next; c = c->next);
94 for(; c && !isvisible(c); c = c->prev);
98 for(c = sel->next; c && !isvisible(c); c = c->next);
100 for(c = clients; c && !isvisible(c); c = c->next);
109 incmasterw(const char *arg) {
111 if(lt->arrange != tile)
114 masterw = MASTERWIDTH;
117 if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
118 || waw * (masterw + i) / 1000 <= 2 * BORDERPX)
126 incnmaster(const char *arg) {
133 if((lt->arrange != tile) || (nmaster + i < 1)
134 || (wah / (nmaster + i) <= 2 * BORDERPX))
149 nlayouts = sizeof layout / sizeof layout[0];
150 for(blw = i = 0; i < nlayouts; i++) {
151 w = textw(layout[i].symbol);
158 nexttiled(Client *c) {
159 for(; c && (c->isfloating || !isvisible(c)); c = c->next);
172 if(sel->isfloating || lt->arrange == floating)
173 XRaiseWindow(dpy, sel->win);
174 if(lt->arrange != floating) {
175 wc.stack_mode = Below;
177 if(!sel->isfloating) {
178 XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
179 wc.sibling = sel->win;
181 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
184 XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
189 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
193 setlayout(const char *arg) {
198 if(lt == layout + nlayouts)
203 if(i < 0 || i >= nlayouts)
214 togglebar(const char *arg) {
216 bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
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 * sel->border, wah - 2 * sel->border, True);
237 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
239 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
243 zoom(const char *arg) {
246 if(!sel || lt->arrange == floating || sel->isfloating)
248 if((c = sel) == nexttiled(clients))
249 if(!(c = nexttiled(c->next)))