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;
34 resize(c, True, TopLeft);
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) {
59 resize(c, True, TopLeft);
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)
87 resize(c, True, TopLeft);
95 c->w = mw - 2 * BORDERPX;
96 c->h = mh - 2 * BORDERPX;
98 else { /* tile window */
100 c->w = tw - 2 * BORDERPX;
102 c->y += (i - nmaster) * th;
103 c->h = th - 2 * BORDERPX;
105 else /* fallback if th < bh */
106 c->h = wah - 2 * BORDERPX;
108 resize(c, False, TopLeft);
114 if(!sel || !isvisible(sel)) {
115 for(c = stack; c && !isvisible(c); c = c->snext);
122 focusnext(Arg *arg) {
127 if(!(c = getnext(sel->next)))
128 c = getnext(clients);
136 focusprev(Arg *arg) {
141 if(!(c = getprev(sel->prev))) {
142 for(c = clients; c && c->next; c = c->next);
152 incnmaster(Arg *arg) {
153 if((arrange == dofloat) || (nmaster + arg->i < 1) || (wah / (nmaster + arg->i) < bh))
164 isvisible(Client *c) {
167 for(i = 0; i < ntags; i++)
168 if(c->tags[i] && seltag[i])
174 resizemaster(Arg *arg) {
178 if(master + arg->i > 950 || master + arg->i < 50)
194 if(sel->isfloat || arrange == dofloat) {
195 XRaiseWindow(dpy, sel->win);
196 XRaiseWindow(dpy, sel->twin);
198 if(arrange != dofloat) {
200 XLowerWindow(dpy, sel->twin);
201 XLowerWindow(dpy, sel->win);
203 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
206 XLowerWindow(dpy, c->twin);
207 XLowerWindow(dpy, c->win);
212 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
216 togglefloat(Arg *arg) {
217 if (!sel || arrange == dofloat)
219 sel->isfloat = !sel->isfloat;
224 togglemode(Arg *arg) {
225 arrange = (arrange == dofloat) ? dotile : dofloat;
234 toggleview(Arg *arg) {
237 seltag[arg->i] = !seltag[arg->i];
238 for(i = 0; i < ntags && !seltag[i]; i++);
240 seltag[arg->i] = True; /* cannot toggle last view */
246 snprintf(mtext, sizeof mtext, arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, nmaster);
254 for(i = 0; i < ntags; i++)
255 seltag[i] = (arg->i == -1) ? True : False;
256 if(arg->i >= 0 && arg->i < ntags)
257 seltag[arg->i] = True;
268 if(sel->isfloat || (arrange == dofloat)) {
272 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
275 if((c = sel) == nexttiled(clients))
276 if(!(c = nexttiled(c->next)))