aewl

changeset 127:1480e19f6377

using double-linked list in order to get correct prev focus handling
author arg@10ksloc.org
date Thu, 20 Jul 2006 16:54:20 +0200
parents 1489f6b97714
children 0a407fbb8092
files client.c config.mk dwm.h tag.c
diffstat 4 files changed, 45 insertions(+), 21 deletions(-) [+]
line diff
     1.1 --- a/client.c	Thu Jul 20 15:40:41 2006 +0200
     1.2 +++ b/client.c	Thu Jul 20 16:54:20 2006 +0200
     1.3 @@ -77,7 +77,6 @@
     1.4  		c = getnext(clients, tsel);
     1.5  	if(c) {
     1.6  		higher(c);
     1.7 -		c->revert = sel;
     1.8  		focus(c);
     1.9  	}
    1.10  }
    1.11 @@ -93,7 +92,11 @@
    1.12  	if(sel->ismax)
    1.13  		togglemax(NULL);
    1.14  
    1.15 -	if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
    1.16 +	if(!(c = getprev(sel->prev))) {
    1.17 +		for(c = clients; c && c->next; c = c->next);
    1.18 +		c = getprev(c);
    1.19 +	}
    1.20 +	if(c) {
    1.21  		higher(c);
    1.22  		focus(c);
    1.23  	}
    1.24 @@ -127,6 +130,8 @@
    1.25  	int dx = 0, dy = 0;
    1.26  
    1.27  	switch(c->grav) {
    1.28 +	default:
    1.29 +		break;
    1.30  	case StaticGravity:
    1.31  	case NorthWestGravity:
    1.32  	case NorthGravity:
    1.33 @@ -143,11 +148,11 @@
    1.34  	case SouthWestGravity:
    1.35  		dy = -(c->h);
    1.36  		break;
    1.37 -	default:
    1.38 -		break;
    1.39  	}
    1.40  
    1.41  	switch (c->grav) {
    1.42 +	default:
    1.43 +		break;
    1.44  	case StaticGravity:
    1.45  	case NorthWestGravity:
    1.46  	case WestGravity:
    1.47 @@ -164,8 +169,6 @@
    1.48  	case SouthEastGravity:
    1.49  		dx = -(c->w + c->border);
    1.50  		break;
    1.51 -	default:
    1.52 -		break;
    1.53  	}
    1.54  
    1.55  	if(invert) {
    1.56 @@ -204,7 +207,6 @@
    1.57  void
    1.58  manage(Window w, XWindowAttributes *wa)
    1.59  {
    1.60 -	int diff;
    1.61  	Client *c;
    1.62  	Window trans;
    1.63  	XSetWindowAttributes twa;
    1.64 @@ -224,7 +226,7 @@
    1.65  	c->proto = getproto(c->win);
    1.66  	setsize(c);
    1.67  	XSelectInput(dpy, c->win,
    1.68 -			StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
    1.69 +		StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
    1.70  	XGetTransientForHint(dpy, c->win, &trans);
    1.71  	twa.override_redirect = 1;
    1.72  	twa.background_pixmap = ParentRelative;
    1.73 @@ -237,6 +239,8 @@
    1.74  
    1.75  	settags(c);
    1.76  
    1.77 +	if(clients)
    1.78 +		clients->prev = c;
    1.79  	c->next = clients;
    1.80  	clients = c;
    1.81  
    1.82 @@ -264,6 +268,7 @@
    1.83  	else {
    1.84  		XMapRaised(dpy, c->win);
    1.85  		XMapRaised(dpy, c->title);
    1.86 +
    1.87  	}
    1.88  }
    1.89  
    1.90 @@ -273,9 +278,15 @@
    1.91  	Client **l;
    1.92  
    1.93  	for(l = &clients; *l && *l != c; l = &(*l)->next);
    1.94 +	if(c->prev)
    1.95 +		c->prev->next = c->next;
    1.96 +	if(c->next)
    1.97 +		c->next->prev = c->prev;
    1.98  	*l = c->next;
    1.99  
   1.100 -	c->next = clients; /* pop */
   1.101 +	if(clients)
   1.102 +		clients->prev = c;
   1.103 +	c->next = clients;
   1.104  	clients = c;
   1.105  	arrange(NULL);
   1.106  }
   1.107 @@ -439,13 +450,18 @@
   1.108  	XDestroyWindow(dpy, c->title);
   1.109  
   1.110  	for(l = &clients; *l && *l != c; l = &(*l)->next);
   1.111 +	if(c->prev)
   1.112 +		c->prev->next = c->next;
   1.113 +	if(c->next)
   1.114 +		c->next->prev = c->prev;
   1.115  	*l = c->next;
   1.116 -	for(l = &clients; *l; l = &(*l)->next)
   1.117 -		if((*l)->revert == c)
   1.118 -			(*l)->revert = NULL;
   1.119 -	if(sel == c)
   1.120 -		sel = sel->revert ? sel->revert : clients;
   1.121 -
   1.122 +	if(sel == c) {
   1.123 +		sel = getnext(c->next, tsel);
   1.124 +		if(!sel)
   1.125 +			sel = getprev(c->prev);
   1.126 +		if(!sel)
   1.127 +			sel = clients;
   1.128 +	}
   1.129  	free(c);
   1.130  
   1.131  	XSync(dpy, False);
     2.1 --- a/config.mk	Thu Jul 20 15:40:41 2006 +0200
     2.2 +++ b/config.mk	Thu Jul 20 16:54:20 2006 +0200
     2.3 @@ -13,12 +13,12 @@
     2.4  LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
     2.5  
     2.6  # Linux/BSD
     2.7 -CFLAGS = -O3 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
     2.8 +#CFLAGS = -O3 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
     2.9 +#	-DVERSION=\"${VERSION}\"
    2.10 +#LDFLAGS = ${LIBS}
    2.11 +CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
    2.12  	-DVERSION=\"${VERSION}\"
    2.13 -LDFLAGS = ${LIBS}
    2.14 -#CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
    2.15 -#	-DVERSION=\"${VERSION}\"
    2.16 -#LDFLAGS = -g ${LIBS}
    2.17 +LDFLAGS = -g ${LIBS}
    2.18  
    2.19  
    2.20  # Solaris
     3.1 --- a/dwm.h	Thu Jul 20 15:40:41 2006 +0200
     3.2 +++ b/dwm.h	Thu Jul 20 16:54:20 2006 +0200
     3.3 @@ -76,7 +76,7 @@
     3.4  	Bool isfloat;
     3.5  	Bool ismax;
     3.6  	Client *next;
     3.7 -	Client *revert;
     3.8 +	Client *prev;
     3.9  	Window win;
    3.10  	Window title;
    3.11  };
    3.12 @@ -135,6 +135,7 @@
    3.13  extern void dofloat(Arg *arg);
    3.14  extern void dotile(Arg *arg);
    3.15  extern Client *getnext(Client *c, unsigned int t);
    3.16 +extern Client *getprev(Client *c);
    3.17  extern void heretag(Arg *arg);
    3.18  extern void replacetag(Arg *arg);
    3.19  extern void settags(Client *c);
     4.1 --- a/tag.c	Thu Jul 20 15:40:41 2006 +0200
     4.2 +++ b/tag.c	Thu Jul 20 16:54:20 2006 +0200
     4.3 @@ -140,6 +140,13 @@
     4.4  	return c;
     4.5  }
     4.6  
     4.7 +Client *
     4.8 +getprev(Client *c)
     4.9 +{
    4.10 +	for(; c && !c->tags[tsel]; c = c->prev);
    4.11 +	return c;
    4.12 +}
    4.13 +
    4.14  void
    4.15  heretag(Arg *arg)
    4.16  {