about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--client.c20
-rw-r--r--event.c2
2 files changed, 13 insertions, 9 deletions
diff --git a/client.c b/client.c
index 177eb94..510ec59 100644
--- a/client.c
+++ b/client.c
@@ -81,7 +81,7 @@ void
 focus(Client *c) {
 	Client *old = sel;
 
-	if(!issel || (c && !isvisible(c)))
+	if(c && !isvisible(c))
 		return;
 
 	if(old && old != c) {
@@ -89,14 +89,18 @@ focus(Client *c) {
 		XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]);
 	}
 	if(c) {
-		detachstack(c);
-		c->snext = stack;
-		stack = c;
-		grabbuttons(c, True);
-		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
-		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+		if(issel) {
+			detachstack(c);
+			c->snext = stack;
+			stack = c;
+			grabbuttons(c, True);
+			XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
+			XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+		}
+		else
+			XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
 	}
-	else
+	else if(issel)
 		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
 	sel = c;
 	drawstatus();
diff --git a/event.c b/event.c
index e0718d3..2e021d5 100644
--- a/event.c
+++ b/event.c
@@ -269,8 +269,8 @@ leavenotify(XEvent *e) {
 	XCrossingEvent *ev = &e->xcrossing;
 
 	if((ev->window == root) && !ev->same_screen) {
-		focus(NULL);
 		issel = False;
+		focus(sel);
 	}
 }