diff options
| author | Anselm R. Garbe <arg@10kloc.org> | 2006-08-29 15:28:29 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <arg@10kloc.org> | 2006-08-29 15:28:29 +0200 |
| commit | c3c94c0e0a4da1562b040a17ee670312ad8e65af (patch) | |
| tree | 659b49912cef4ca871d9fcde44cf504676570433 | |
| parent | still something wrong with reorder() (diff) | |
| download | dwm-c3c94c0e0a4da1562b040a17ee670312ad8e65af.tar.gz dwm-c3c94c0e0a4da1562b040a17ee670312ad8e65af.zip | |
improved selection policy
| -rw-r--r-- | view.c | 44 |
1 files changed, 24 insertions, 20 deletions
| @@ -3,31 +3,39 @@ | |||
| 3 | * See LICENSE file for license details. | 3 | * See LICENSE file for license details. |
| 4 | */ | 4 | */ |
| 5 | #include "dwm.h" | 5 | #include "dwm.h" |
| 6 | #include <stdio.h> | ||
| 6 | 7 | ||
| 7 | /* static */ | 8 | /* static */ |
| 8 | 9 | ||
| 10 | static Client * | ||
| 11 | minclient() | ||
| 12 | { | ||
| 13 | Client *c, *min; | ||
| 14 | |||
| 15 | for(min = c = clients; c; c = c->next) | ||
| 16 | if(c->weight < min->weight) | ||
| 17 | min = c; | ||
| 18 | return min; | ||
| 19 | } | ||
| 20 | |||
| 21 | |||
| 9 | static void | 22 | static void |
| 10 | reorder() | 23 | reorder() |
| 11 | { | 24 | { |
| 12 | Client *c, *orig, *p; | 25 | Client *c, *newclients, *tail; |
| 13 | 26 | ||
| 14 | orig = clients; | 27 | newclients = tail = NULL; |
| 15 | clients = NULL; | 28 | while((c = minclient())) { |
| 16 | |||
| 17 | while((c = orig)) { | ||
| 18 | orig = orig->next; | ||
| 19 | detach(c); | 29 | detach(c); |
| 20 | 30 | if(tail) { | |
| 21 | for(p = clients; p && p->next && p->weight <= c->weight; p = p->next); | 31 | c->prev = tail; |
| 22 | c->prev = p; | 32 | tail->next = c; |
| 23 | if(p) { | 33 | tail = c; |
| 24 | if((c->next = p->next)) | ||
| 25 | c->next->prev = c; | ||
| 26 | p->next = c; | ||
| 27 | } | 34 | } |
| 28 | else | 35 | else |
| 29 | clients = c; | 36 | tail = newclients = c; |
| 30 | } | 37 | } |
| 38 | clients = newclients; | ||
| 31 | } | 39 | } |
| 32 | 40 | ||
| 33 | /* extern */ | 41 | /* extern */ |
| @@ -59,9 +67,7 @@ dofloat(Arg *arg) | |||
| 59 | else | 67 | else |
| 60 | ban(c); | 68 | ban(c); |
| 61 | } | 69 | } |
| 62 | if(!sel || !isvisible(sel)) | 70 | if((sel = getnext(clients))) |
| 63 | sel = getnext(clients); | ||
| 64 | if(sel) | ||
| 65 | focus(sel); | 71 | focus(sel); |
| 66 | else | 72 | else |
| 67 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); | 73 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
| @@ -124,9 +130,7 @@ dotile(Arg *arg) | |||
| 124 | else | 130 | else |
| 125 | ban(c); | 131 | ban(c); |
| 126 | } | 132 | } |
| 127 | if(!sel || !isvisible(sel)) | 133 | if((sel = getnext(clients))) |
| 128 | sel = getnext(clients); | ||
| 129 | if(sel) | ||
| 130 | focus(sel); | 134 | focus(sel); |
| 131 | else | 135 | else |
| 132 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); | 136 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
