aewl
diff tag.c @ 270:dacd3f3c5823
implemented restack behavior (floats are on top in tiled mode)
author | Anselm R.Garbe <arg@10ksloc.org> |
---|---|
date | Mon, 14 Aug 2006 10:18:24 +0200 |
parents | 8a8ea74e1b87 |
children | be40a56df248 |
line diff
1.1 --- a/tag.c Mon Aug 14 08:52:15 2006 +0200 1.2 +++ b/tag.c Mon Aug 14 10:18:24 2006 +0200 1.3 @@ -58,18 +58,17 @@ 1.4 ban(c); 1.5 } 1.6 if((sel = getnext(clients))) { 1.7 - higher(sel); 1.8 focus(sel); 1.9 + restack(); 1.10 } 1.11 else 1.12 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 1.13 - drawall(); 1.14 } 1.15 1.16 void 1.17 dotile(Arg *arg) 1.18 { 1.19 - int n, i, w, h; 1.20 + int h, i, n, w; 1.21 Client *c; 1.22 1.23 w = sw - mw; 1.24 @@ -86,7 +85,6 @@ 1.25 c->ismax = False; 1.26 if(isvisible(c)) { 1.27 if(c->isfloat) { 1.28 - higher(c); 1.29 resize(c, True, TopLeft); 1.30 continue; 1.31 } 1.32 @@ -123,13 +121,11 @@ 1.33 else 1.34 ban(c); 1.35 } 1.36 - if((sel = getnext(clients))) { 1.37 - higher(sel); 1.38 + if((sel = getnext(clients))) 1.39 focus(sel); 1.40 - } 1.41 else 1.42 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 1.43 - drawall(); 1.44 + restack(); 1.45 } 1.46 1.47 Client * 1.48 @@ -200,6 +196,56 @@ 1.49 } 1.50 1.51 void 1.52 +restack() 1.53 +{ 1.54 + static unsigned int nwins = 0; 1.55 + static Window *wins = NULL; 1.56 + unsigned int f, fi, m, mi, n; 1.57 + Client *c; 1.58 + XEvent ev; 1.59 + 1.60 + for(f = 0, m = 0, c = clients; c; c = c->next) 1.61 + if(isvisible(c)) { 1.62 + if(c->isfloat || arrange == dofloat) 1.63 + f++; 1.64 + else 1.65 + m++; 1.66 + } 1.67 + 1.68 + n = 2 * (f + m); 1.69 + if(nwins < n) { 1.70 + nwins = n; 1.71 + wins = erealloc(wins, nwins * sizeof(Window)); 1.72 + } 1.73 + 1.74 + fi = 0; 1.75 + mi = 2 * f; 1.76 + if(sel->isfloat || arrange == dofloat) { 1.77 + wins[fi++] = sel->title; 1.78 + wins[fi++] = sel->win; 1.79 + } 1.80 + else { 1.81 + wins[mi++] = sel->title; 1.82 + wins[mi++] = sel->win; 1.83 + } 1.84 + for(c = clients; c; c = c->next) 1.85 + if(isvisible(c) && c != sel) { 1.86 + if(c->isfloat || arrange == dofloat) { 1.87 + wins[fi++] = c->title; 1.88 + wins[fi++] = c->win; 1.89 + } 1.90 + else { 1.91 + wins[mi++] = c->title; 1.92 + wins[mi++] = c->win; 1.93 + } 1.94 + } 1.95 + XRestackWindows(dpy, wins, n); 1.96 + drawall(); 1.97 + XSync(dpy, False); 1.98 + while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 1.99 +} 1.100 + 1.101 +void 1.102 settags(Client *c) 1.103 { 1.104 char classinst[256]; 1.105 @@ -248,7 +294,6 @@ 1.106 seltag[i] = False; 1.107 seltag[arg->i] = True; 1.108 arrange(NULL); 1.109 - drawall(); 1.110 } 1.111 1.112 void 1.113 @@ -261,5 +306,4 @@ 1.114 if(i == ntags) 1.115 seltag[arg->i] = True; /* cannot toggle last view */ 1.116 arrange(NULL); 1.117 - drawall(); 1.118 }