diff options
| author | arg@10ksloc.org <unknown> | 2006-07-20 16:54:20 +0200 | 
|---|---|---|
| committer | arg@10ksloc.org <unknown> | 2006-07-20 16:54:20 +0200 | 
| commit | 72707c2fae68f5eba6ea97cbf356bfb968c8a15d (patch) | |
| tree | 86285130145cd1672f32c9ebe207b9d41bd10032 | |
| parent | 06dc514bc7327f1a2a35cb533bcf18715305da44 (diff) | |
| download | dwm-72707c2fae68f5eba6ea97cbf356bfb968c8a15d.tar.gz | |
using double-linked list in order to get correct prev focus handling
| -rw-r--r-- | client.c | 46 | ||||
| -rw-r--r-- | config.mk | 10 | ||||
| -rw-r--r-- | dwm.h | 3 | ||||
| -rw-r--r-- | tag.c | 7 | 
4 files changed, 45 insertions, 21 deletions
| @@ -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; @@ -224,7 +226,7 @@ manage(Window w, XWindowAttributes *wa)  	c->proto = getproto(c->win);  	setsize(c);  	XSelectInput(dpy, c->win, -			StructureNotifyMask | PropertyChangeMask | EnterWindowMask); +		StructureNotifyMask | PropertyChangeMask | EnterWindowMask);  	XGetTransientForHint(dpy, c->win, &trans);  	twa.override_redirect = 1;  	twa.background_pixmap = ParentRelative; @@ -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)  { | 
