about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--client.c46
-rw-r--r--config.mk10
-rw-r--r--dwm.h3
-rw-r--r--tag.c7
4 files changed, 45 insertions, 21 deletions
diff --git a/client.c b/client.c
index 1bdebd2..34c69aa 100644
--- a/client.c
+++ b/client.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;
@@ -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);
diff --git a/config.mk b/config.mk
index 605f462..f119fbe 100644
--- a/config.mk
+++ b/config.mk
@@ -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
diff --git a/dwm.h b/dwm.h
index e72bca2..8a7237c 100644
--- a/dwm.h
+++ b/dwm.h
@@ -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);
diff --git a/tag.c b/tag.c
index 5da3c31..21eb9fa 100644
--- a/tag.c
+++ b/tag.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)
 {
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522