1
0

improved selection policy

This commit is contained in:
Anselm R. Garbe 2006-08-29 15:28:29 +02:00
parent 9d73909075
commit c3c94c0e0a

44
view.c
View File

@ -3,31 +3,39 @@
* See LICENSE file for license details. * See LICENSE file for license details.
*/ */
#include "dwm.h" #include "dwm.h"
#include <stdio.h>
/* static */ /* static */
static Client *
minclient()
{
Client *c, *min;
for(min = c = clients; c; c = c->next)
if(c->weight < min->weight)
min = c;
return min;
}
static void static void
reorder() reorder()
{ {
Client *c, *orig, *p; Client *c, *newclients, *tail;
orig = clients; newclients = tail = NULL;
clients = NULL; while((c = minclient())) {
while((c = orig)) {
orig = orig->next;
detach(c); detach(c);
if(tail) {
for(p = clients; p && p->next && p->weight <= c->weight; p = p->next); c->prev = tail;
c->prev = p; tail->next = c;
if(p) { tail = c;
if((c->next = p->next))
c->next->prev = c;
p->next = c;
} }
else else
clients = c; tail = newclients = c;
} }
clients = newclients;
} }
/* extern */ /* extern */
@ -59,9 +67,7 @@ dofloat(Arg *arg)
else else
ban(c); ban(c);
} }
if(!sel || !isvisible(sel)) if((sel = getnext(clients)))
sel = getnext(clients);
if(sel)
focus(sel); focus(sel);
else else
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@ -124,9 +130,7 @@ dotile(Arg *arg)
else else
ban(c); ban(c);
} }
if(!sel || !isvisible(sel)) if((sel = getnext(clients)))
sel = getnext(clients);
if(sel)
focus(sel); focus(sel);
else else
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);