about summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2013-10-25 19:46:16 +0000
committerokan <okan>2013-10-25 19:46:16 +0000
commit6e17b41f566865629d3dd35a6a60e081e6e2b089 (patch)
tree936ef98f0d1f8a5c6293e010a40fc9059c24ab4e
parent6867821abefd761a840befcfee5a1f1f2fef9831 (diff)
downloadcwm-6e17b41f566865629d3dd35a6a60e081e6e2b089.tar.gz
cwm-6e17b41f566865629d3dd35a6a60e081e6e2b089.tar.xz
cwm-6e17b41f566865629d3dd35a6a60e081e6e2b089.zip
A client_delete should behave differently depending on whether the
triggering event was unmap (with pending destroy) log destroy; we only
need to grab/ungrab the server lock, set WithdrawnState and
XRemoveFromSaveSet clients coming from an unmap event - doing so for
clients coming from destroy are already gone, hence we generate errors.
-rw-r--r--calmwm.h2
-rw-r--r--client.c16
-rw-r--r--xevents.c4
3 files changed, 12 insertions, 10 deletions
diff --git a/calmwm.h b/calmwm.h
index 5a827b4..4f20a81 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -373,7 +373,7 @@ struct client_ctx	*client_current(void);
 void			 client_cycle(struct screen_ctx *, int);
 void			 client_cycle_leave(struct screen_ctx *,
 			     struct client_ctx *);
-void			 client_delete(struct client_ctx *);
+void			 client_delete(struct client_ctx *, int);
 void			 client_draw_border(struct client_ctx *);
 struct client_ctx	*client_find(Window);
 void			 client_freeze(struct client_ctx *);
diff --git a/client.c b/client.c
index 1c41d7e..d9184df 100644
--- a/client.c
+++ b/client.c
@@ -145,17 +145,19 @@ client_init(Window win, struct screen_ctx *sc, int mapped)
 }
 
 void
-client_delete(struct client_ctx *cc)
+client_delete(struct client_ctx *cc, int destroy)
 {
 	struct screen_ctx	*sc = cc->sc;
 	struct winname		*wn;
 
-	XGrabServer(X_Dpy);
-	cc->state = WithdrawnState;
-	xu_set_wm_state(cc->win, cc->state);
-	XRemoveFromSaveSet(X_Dpy, cc->win);
-	XSync(X_Dpy, False);
-	XUngrabServer(X_Dpy);
+	if (destroy) {
+		XGrabServer(X_Dpy);
+		cc->state = WithdrawnState;
+		xu_set_wm_state(cc->win, cc->state);
+		XRemoveFromSaveSet(X_Dpy, cc->win);
+		XSync(X_Dpy, False);
+		XUngrabServer(X_Dpy);
+	}
 
 	TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
 	TAILQ_REMOVE(&Clientq, cc, entry);
diff --git a/xevents.c b/xevents.c
index 4b6ad60..e6247ab 100644
--- a/xevents.c
+++ b/xevents.c
@@ -113,7 +113,7 @@ xev_handle_unmapnotify(XEvent *ee)
 		 */
 		if (XCheckTypedWindowEvent(X_Dpy, cc->win,
 		    DestroyNotify, &ev) || e->send_event != 0) {
-			client_delete(cc);
+			client_delete(cc, 1);
 		} else
 			client_hide(cc);
 	}
@@ -127,7 +127,7 @@ xev_handle_destroynotify(XEvent *ee)
 	struct client_ctx	*cc;
 
 	if ((cc = client_find(e->window)) != NULL)
-		client_delete(cc);
+		client_delete(cc, 0);
 }
 
 static void