1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
2 * See LICENSE file for license details.
10 nexttiled(Client *c) {
11 for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
16 togglemax(Client *c) {
22 if((c->ismax = !c->ismax)) {
23 c->rx = c->x; c->x = wax;
24 c->ry = c->y; c->y = way;
25 c->rw = c->w; c->w = waw - 2 * BORDERPX;
26 c->rh = c->h; c->h = wah - 2 * BORDERPX;
35 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
40 void (*arrange)(void) = DEFMODE;
45 c->prev->next = c->next;
47 c->next->prev = c->prev;
50 c->next = c->prev = NULL;
57 for(c = clients; c; c = c->next) {
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);
73 unsigned int i, n, mw, mh, tw, th;
76 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
79 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
80 mw = (n > nmaster) ? (waw * master) / 1000 : waw;
81 th = (n > nmaster) ? wah / (n - nmaster) : 0;
84 for(i = 0, c = clients; c; c = c->next)
95 c->w = mw - 2 * BORDERPX;
96 c->h = mh - 2 * BORDERPX;
98 else { /* tile window */
100 c->w = tw - 2 * BORDERPX;
101 if(th > 2 * BORDERPX) {
102 c->y += (i - nmaster) * th;
103 c->h = th - 2 * BORDERPX;
105 else /* fallback if th <= 2 * BORDERPX */
106 c->h = wah - 2 * BORDERPX;
112 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
113 if(!sel || !isvisible(sel)) {
114 for(c = stack; c && !isvisible(c); c = c->snext);
121 focusnext(Arg *arg) {
126 if(!(c = getnext(sel->next)))
127 c = getnext(clients);
135 focusprev(Arg *arg) {
140 if(!(c = getprev(sel->prev))) {
141 for(c = clients; c && c->next; c = c->next);
151 incnmaster(Arg *arg) {
152 if((arrange == dofloat) || (nmaster + arg->i < 1)
153 || (wah / (nmaster + arg->i) <= 2 * BORDERPX))
163 isvisible(Client *c) {
166 for(i = 0; i < ntags; i++)
167 if(c->tags[i] && seltag[i])
173 resizemaster(Arg *arg) {
177 if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX
178 || waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
193 if(sel->isfloat || arrange == dofloat)
194 XRaiseWindow(dpy, sel->win);
195 if(arrange != dofloat) {
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 togglefloat(Arg *arg) {
210 if (!sel || arrange == dofloat)
212 sel->isfloat = !sel->isfloat;
217 togglemode(Arg *arg) {
218 arrange = (arrange == dofloat) ? dotile : dofloat;
226 toggleview(Arg *arg) {
229 seltag[arg->i] = !seltag[arg->i];
230 for(i = 0; i < ntags && !seltag[i]; i++);
232 seltag[arg->i] = True; /* cannot toggle last view */
240 for(i = 0; i < ntags; i++)
241 seltag[i] = (arg->i == -1) ? True : False;
242 if(arg->i >= 0 && arg->i < ntags)
243 seltag[arg->i] = True;
254 if(sel->isfloat || (arrange == dofloat)) {
258 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
261 if((c = sel) == nexttiled(clients))
262 if(!(c = nexttiled(c->next)))