aewl
changeset 382:76b62c0c8c11
improved selection policy
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Tue, 29 Aug 2006 15:28:29 +0200 |
parents | b00cc483d13b |
children | 2ec9cead84a7 |
files | view.c |
diffstat | 1 files changed, 24 insertions(+), 20 deletions(-) [+] |
line diff
1.1 --- a/view.c Tue Aug 29 13:40:09 2006 +0200 1.2 +++ b/view.c Tue Aug 29 15:28:29 2006 +0200 1.3 @@ -3,31 +3,39 @@ 1.4 * See LICENSE file for license details. 1.5 */ 1.6 #include "dwm.h" 1.7 +#include <stdio.h> 1.8 1.9 /* static */ 1.10 1.11 +static Client * 1.12 +minclient() 1.13 +{ 1.14 + Client *c, *min; 1.15 + 1.16 + for(min = c = clients; c; c = c->next) 1.17 + if(c->weight < min->weight) 1.18 + min = c; 1.19 + return min; 1.20 +} 1.21 + 1.22 + 1.23 static void 1.24 reorder() 1.25 { 1.26 - Client *c, *orig, *p; 1.27 + Client *c, *newclients, *tail; 1.28 1.29 - orig = clients; 1.30 - clients = NULL; 1.31 - 1.32 - while((c = orig)) { 1.33 - orig = orig->next; 1.34 + newclients = tail = NULL; 1.35 + while((c = minclient())) { 1.36 detach(c); 1.37 - 1.38 - for(p = clients; p && p->next && p->weight <= c->weight; p = p->next); 1.39 - c->prev = p; 1.40 - if(p) { 1.41 - if((c->next = p->next)) 1.42 - c->next->prev = c; 1.43 - p->next = c; 1.44 + if(tail) { 1.45 + c->prev = tail; 1.46 + tail->next = c; 1.47 + tail = c; 1.48 } 1.49 else 1.50 - clients = c; 1.51 + tail = newclients = c; 1.52 } 1.53 + clients = newclients; 1.54 } 1.55 1.56 /* extern */ 1.57 @@ -59,9 +67,7 @@ 1.58 else 1.59 ban(c); 1.60 } 1.61 - if(!sel || !isvisible(sel)) 1.62 - sel = getnext(clients); 1.63 - if(sel) 1.64 + if((sel = getnext(clients))) 1.65 focus(sel); 1.66 else 1.67 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 1.68 @@ -124,9 +130,7 @@ 1.69 else 1.70 ban(c); 1.71 } 1.72 - if(!sel || !isvisible(sel)) 1.73 - sel = getnext(clients); 1.74 - if(sel) 1.75 + if((sel = getnext(clients))) 1.76 focus(sel); 1.77 else 1.78 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);