using double-linked list in order to get correct prev focus handling

pull/1/head
arg@10ksloc.org 19 years ago
parent 06dc514bc7
commit 72707c2fae
  1. 44
      client.c
  2. 10
      config.mk
  3. 3
      dwm.h
  4. 7
      tag.c

@ -77,7 +77,6 @@ focusnext(Arg *arg)
c = getnext(clients, tsel);
if(c) {
higher(c);
c->revert = sel;
focus(c);
}
}
@ -93,7 +92,11 @@ focusprev(Arg *arg)
if(sel->ismax)
togglemax(NULL);
if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
if(!(c = getprev(sel->prev))) {
for(c = clients; c && c->next; c = c->next);
c = getprev(c);
}
if(c) {
higher(c);
focus(c);
}
@ -127,6 +130,8 @@ gravitate(Client *c, Bool invert)
int dx = 0, dy = 0;
switch(c->grav) {
default:
break;
case StaticGravity:
case NorthWestGravity:
case NorthGravity:
@ -143,11 +148,11 @@ gravitate(Client *c, Bool invert)
case SouthWestGravity:
dy = -(c->h);
break;
default:
break;
}
switch (c->grav) {
default:
break;
case StaticGravity:
case NorthWestGravity:
case WestGravity:
@ -164,8 +169,6 @@ gravitate(Client *c, Bool invert)
case SouthEastGravity:
dx = -(c->w + c->border);
break;
default:
break;
}
if(invert) {
@ -204,7 +207,6 @@ lower(Client *c)
void
manage(Window w, XWindowAttributes *wa)
{
int diff;
Client *c;
Window trans;
XSetWindowAttributes twa;
@ -237,6 +239,8 @@ manage(Window w, XWindowAttributes *wa)
settags(c);
if(clients)
clients->prev = c;
c->next = clients;
clients = c;
@ -264,6 +268,7 @@ manage(Window w, XWindowAttributes *wa)
else {
XMapRaised(dpy, c->win);
XMapRaised(dpy, c->title);
}
}
@ -273,9 +278,15 @@ pop(Client *c)
Client **l;
for(l = &clients; *l && *l != c; l = &(*l)->next);
if(c->prev)
c->prev->next = c->next;
if(c->next)
c->next->prev = c->prev;
*l = c->next;
c->next = clients; /* pop */
if(clients)
clients->prev = c;
c->next = clients;
clients = c;
arrange(NULL);
}
@ -439,13 +450,18 @@ unmanage(Client *c)
XDestroyWindow(dpy, c->title);
for(l = &clients; *l && *l != c; l = &(*l)->next);
if(c->prev)
c->prev->next = c->next;
if(c->next)
c->next->prev = c->prev;
*l = c->next;
for(l = &clients; *l; l = &(*l)->next)
if((*l)->revert == c)
(*l)->revert = NULL;
if(sel == c)
sel = sel->revert ? sel->revert : clients;
if(sel == c) {
sel = getnext(c->next, tsel);
if(!sel)
sel = getprev(c->prev);
if(!sel)
sel = clients;
}
free(c);
XSync(dpy, False);

@ -13,12 +13,12 @@ VERSION = 0.5
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
# Linux/BSD
CFLAGS = -O3 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
-DVERSION=\"${VERSION}\"
LDFLAGS = ${LIBS}
#CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
#CFLAGS = -O3 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
# -DVERSION=\"${VERSION}\"
#LDFLAGS = -g ${LIBS}
#LDFLAGS = ${LIBS}
CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
-DVERSION=\"${VERSION}\"
LDFLAGS = -g ${LIBS}
# Solaris

@ -76,7 +76,7 @@ struct Client {
Bool isfloat;
Bool ismax;
Client *next;
Client *revert;
Client *prev;
Window win;
Window title;
};
@ -135,6 +135,7 @@ extern void appendtag(Arg *arg);
extern void dofloat(Arg *arg);
extern void dotile(Arg *arg);
extern Client *getnext(Client *c, unsigned int t);
extern Client *getprev(Client *c);
extern void heretag(Arg *arg);
extern void replacetag(Arg *arg);
extern void settags(Client *c);

@ -140,6 +140,13 @@ getnext(Client *c, unsigned int t)
return c;
}
Client *
getprev(Client *c)
{
for(; c && !c->tags[tsel]; c = c->prev);
return c;
}
void
heretag(Arg *arg)
{

Loading…
Cancel
Save