mirror of git://git.suckless.org/dwm
using double-linked list in order to get correct prev focus handling
This commit is contained in:
parent
06dc514bc7
commit
72707c2fae
44
client.c
44
client.c
|
@ -77,7 +77,6 @@ focusnext(Arg *arg)
|
||||||
c = getnext(clients, tsel);
|
c = getnext(clients, tsel);
|
||||||
if(c) {
|
if(c) {
|
||||||
higher(c);
|
higher(c);
|
||||||
c->revert = sel;
|
|
||||||
focus(c);
|
focus(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +92,11 @@ focusprev(Arg *arg)
|
||||||
if(sel->ismax)
|
if(sel->ismax)
|
||||||
togglemax(NULL);
|
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);
|
higher(c);
|
||||||
focus(c);
|
focus(c);
|
||||||
}
|
}
|
||||||
|
@ -127,6 +130,8 @@ gravitate(Client *c, Bool invert)
|
||||||
int dx = 0, dy = 0;
|
int dx = 0, dy = 0;
|
||||||
|
|
||||||
switch(c->grav) {
|
switch(c->grav) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
case StaticGravity:
|
case StaticGravity:
|
||||||
case NorthWestGravity:
|
case NorthWestGravity:
|
||||||
case NorthGravity:
|
case NorthGravity:
|
||||||
|
@ -143,11 +148,11 @@ gravitate(Client *c, Bool invert)
|
||||||
case SouthWestGravity:
|
case SouthWestGravity:
|
||||||
dy = -(c->h);
|
dy = -(c->h);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (c->grav) {
|
switch (c->grav) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
case StaticGravity:
|
case StaticGravity:
|
||||||
case NorthWestGravity:
|
case NorthWestGravity:
|
||||||
case WestGravity:
|
case WestGravity:
|
||||||
|
@ -164,8 +169,6 @@ gravitate(Client *c, Bool invert)
|
||||||
case SouthEastGravity:
|
case SouthEastGravity:
|
||||||
dx = -(c->w + c->border);
|
dx = -(c->w + c->border);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(invert) {
|
if(invert) {
|
||||||
|
@ -204,7 +207,6 @@ lower(Client *c)
|
||||||
void
|
void
|
||||||
manage(Window w, XWindowAttributes *wa)
|
manage(Window w, XWindowAttributes *wa)
|
||||||
{
|
{
|
||||||
int diff;
|
|
||||||
Client *c;
|
Client *c;
|
||||||
Window trans;
|
Window trans;
|
||||||
XSetWindowAttributes twa;
|
XSetWindowAttributes twa;
|
||||||
|
@ -237,6 +239,8 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
|
|
||||||
settags(c);
|
settags(c);
|
||||||
|
|
||||||
|
if(clients)
|
||||||
|
clients->prev = c;
|
||||||
c->next = clients;
|
c->next = clients;
|
||||||
clients = c;
|
clients = c;
|
||||||
|
|
||||||
|
@ -264,6 +268,7 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
else {
|
else {
|
||||||
XMapRaised(dpy, c->win);
|
XMapRaised(dpy, c->win);
|
||||||
XMapRaised(dpy, c->title);
|
XMapRaised(dpy, c->title);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,9 +278,15 @@ pop(Client *c)
|
||||||
Client **l;
|
Client **l;
|
||||||
|
|
||||||
for(l = &clients; *l && *l != c; l = &(*l)->next);
|
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;
|
*l = c->next;
|
||||||
|
|
||||||
c->next = clients; /* pop */
|
if(clients)
|
||||||
|
clients->prev = c;
|
||||||
|
c->next = clients;
|
||||||
clients = c;
|
clients = c;
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
@ -439,13 +450,18 @@ unmanage(Client *c)
|
||||||
XDestroyWindow(dpy, c->title);
|
XDestroyWindow(dpy, c->title);
|
||||||
|
|
||||||
for(l = &clients; *l && *l != c; l = &(*l)->next);
|
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;
|
*l = c->next;
|
||||||
for(l = &clients; *l; l = &(*l)->next)
|
if(sel == c) {
|
||||||
if((*l)->revert == c)
|
sel = getnext(c->next, tsel);
|
||||||
(*l)->revert = NULL;
|
if(!sel)
|
||||||
if(sel == c)
|
sel = getprev(c->prev);
|
||||||
sel = sel->revert ? sel->revert : clients;
|
if(!sel)
|
||||||
|
sel = clients;
|
||||||
|
}
|
||||||
free(c);
|
free(c);
|
||||||
|
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
|
10
config.mk
10
config.mk
|
@ -13,12 +13,12 @@ VERSION = 0.5
|
||||||
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
|
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
|
||||||
|
|
||||||
# Linux/BSD
|
# Linux/BSD
|
||||||
CFLAGS = -O3 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
|
#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} \
|
|
||||||
# -DVERSION=\"${VERSION}\"
|
# -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
|
# Solaris
|
||||||
|
|
3
dwm.h
3
dwm.h
|
@ -76,7 +76,7 @@ struct Client {
|
||||||
Bool isfloat;
|
Bool isfloat;
|
||||||
Bool ismax;
|
Bool ismax;
|
||||||
Client *next;
|
Client *next;
|
||||||
Client *revert;
|
Client *prev;
|
||||||
Window win;
|
Window win;
|
||||||
Window title;
|
Window title;
|
||||||
};
|
};
|
||||||
|
@ -135,6 +135,7 @@ extern void appendtag(Arg *arg);
|
||||||
extern void dofloat(Arg *arg);
|
extern void dofloat(Arg *arg);
|
||||||
extern void dotile(Arg *arg);
|
extern void dotile(Arg *arg);
|
||||||
extern Client *getnext(Client *c, unsigned int t);
|
extern Client *getnext(Client *c, unsigned int t);
|
||||||
|
extern Client *getprev(Client *c);
|
||||||
extern void heretag(Arg *arg);
|
extern void heretag(Arg *arg);
|
||||||
extern void replacetag(Arg *arg);
|
extern void replacetag(Arg *arg);
|
||||||
extern void settags(Client *c);
|
extern void settags(Client *c);
|
||||||
|
|
Loading…
Reference in New Issue