aewl
diff view.c @ 651:b9f4efd21473
added MODKEY-{plus,minus} shortcuts (increasing/decreasing master clients)
author | Anselm R. Garbe <arg@suckless.org> |
---|---|
date | Fri, 05 Jan 2007 14:48:16 +0100 |
parents | f3b8c71a69d4 |
children | 04734db9a219 |
line diff
1.1 --- a/view.c Fri Jan 05 12:50:39 2007 +0100 1.2 +++ b/view.c Fri Jan 05 14:48:16 2007 +0100 1.3 @@ -11,6 +11,40 @@ 1.4 return c; 1.5 } 1.6 1.7 +static Bool 1.8 +ismaster(Client *c) { 1.9 + Client *cl; 1.10 + unsigned int i; 1.11 + 1.12 + for(cl = nexttiled(clients), i = 0; cl && cl != c; cl = nexttiled(cl->next), i++); 1.13 + return i < nmaster; 1.14 +} 1.15 + 1.16 +static void 1.17 +pop(Client *c) { 1.18 + detach(c); 1.19 + if(clients) 1.20 + clients->prev = c; 1.21 + c->next = clients; 1.22 + clients = c; 1.23 +} 1.24 + 1.25 +static void 1.26 +swap(Client *c1, Client *c2) { 1.27 + Client tmp = *c1; 1.28 + Client *cp = c1->prev; 1.29 + Client *cn = c1->next; 1.30 + 1.31 + *c1 = *c2; 1.32 + c1->prev = cp; 1.33 + c1->next = cn; 1.34 + cp = c2->prev; 1.35 + cn = c2->next; 1.36 + *c2 = tmp; 1.37 + c2->prev = cp; 1.38 + c2->next = cn; 1.39 +} 1.40 + 1.41 static void 1.42 togglemax(Client *c) { 1.43 XEvent ev; 1.44 @@ -34,6 +68,15 @@ 1.45 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 1.46 } 1.47 1.48 +static Client * 1.49 +topofstack() { 1.50 + Client *c; 1.51 + unsigned int i; 1.52 + 1.53 + for(c = nexttiled(clients), i = 0; c && i < nmaster; c = nexttiled(c->next), i++); 1.54 + return (i < nmaster) ? NULL : c; 1.55 +} 1.56 + 1.57 /* extern */ 1.58 1.59 void (*arrange)(void) = DEFMODE; 1.60 @@ -248,7 +291,7 @@ 1.61 1.62 void 1.63 zoom(Arg *arg) { 1.64 - unsigned int i, n; 1.65 + unsigned int n; 1.66 Client *c; 1.67 1.68 if(!sel) 1.69 @@ -262,19 +305,15 @@ 1.70 if(n <= nmaster || (arrange == dofloat)) 1.71 return; 1.72 1.73 - for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next)) 1.74 - i++; 1.75 - if(c == sel && i < nmaster) 1.76 - for(; c && i < nmaster; c = nexttiled(c->next)) 1.77 - i++; 1.78 - if(!c) 1.79 - return; 1.80 + if(ismaster((c = sel))) { 1.81 + if(!(c = topofstack())) 1.82 + return; 1.83 + swap(c, sel); 1.84 + c = sel; 1.85 + } 1.86 + else 1.87 + pop(c); 1.88 1.89 - detach(c); 1.90 - if(clients) 1.91 - clients->prev = c; 1.92 - c->next = clients; 1.93 - clients = c; 1.94 focus(c); 1.95 arrange(); 1.96 }