about summary refs log tree commit diff
path: root/exwm-manage.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-08-12T11·19+0800
committerChris Feng <chris.w.feng@gmail.com>2016-08-12T11·19+0800
commit6bd85db30053b493e079893af0ef9668d134057d (patch)
treeb74cf1df8185b85938fe9efe855492c28ede7c99 /exwm-manage.el
parentdb5128c1b9f77ecefd62a7150ccbdef33dd870af (diff)
* exwm-manage.el (exwm-manage--scan): Check for possibly
destroyed child.
Diffstat (limited to 'exwm-manage.el')
-rw-r--r--exwm-manage.el25
1 files changed, 16 insertions, 9 deletions
diff --git a/exwm-manage.el b/exwm-manage.el
index a8713ff714fa..1dfd3c96cbf1 100644
--- a/exwm-manage.el
+++ b/exwm-manage.el
@@ -389,16 +389,23 @@ manager is shutting down."
 (defun exwm-manage--scan ()
   "Search for existing windows and try to manage them."
   (let* ((tree (xcb:+request-unchecked+reply exwm--connection
-                   (make-instance 'xcb:QueryTree :window exwm--root))))
+                   (make-instance 'xcb:QueryTree
+                                  :window exwm--root)))
+         reply)
     (dolist (i (slot-value tree 'children))
-      (with-slots (override-redirect map-state)
-          (xcb:+request-unchecked+reply exwm--connection
-              (make-instance 'xcb:GetWindowAttributes :window i))
-        (when (and (= 0 override-redirect) (= xcb:MapState:Viewable map-state))
-          (xcb:+request exwm--connection
-              (make-instance 'xcb:UnmapWindow :window i))
-          (xcb:flush exwm--connection)
-          (exwm-manage--manage-window i))))))
+      (setq reply (xcb:+request-unchecked+reply exwm--connection
+                      (make-instance 'xcb:GetWindowAttributes
+                                     :window i)))
+      ;; It's possible the X window has been destroyed.
+      (when reply
+        (with-slots (override-redirect map-state) reply
+          (when (and (= 0 override-redirect)
+                     (= xcb:MapState:Viewable map-state))
+            (xcb:+request exwm--connection
+                (make-instance 'xcb:UnmapWindow
+                               :window i))
+            (xcb:flush exwm--connection)
+            (exwm-manage--manage-window i)))))))
 
 (defvar exwm-manage--ping-lock nil
   "Non-nil indicates EXWM is pinging a window.")