about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2015-10-11T03·39+0800
committerChris Feng <chris.w.feng@gmail.com>2015-10-11T05·36+0800
commit46461d994b32da1813d3e531b02127c7b9281947 (patch)
tree63577f5c3d28982a4a779d61b04ab98e6374f3e1
parent1aeec4abf4de594841b05310753ae7fab527eb72 (diff)
Improve robustness
* exwm-input.el (exwm-input--update-focus, exwm-input--on-ButtonPress):
  Make sure Emacs windows are alive before manipulating them.
-rw-r--r--exwm-input.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/exwm-input.el b/exwm-input.el
index 9def8ca565bb..6c3485314315 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -111,7 +111,9 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
 
 (defun exwm-input--update-focus ()
   "Update input focus."
-  (when exwm-input--focus-window
+  (when (and exwm-input--focus-window
+             ;; The Emacs window may have been deleted
+             (window-buffer exwm-input--focus-window))
     (with-current-buffer (window-buffer exwm-input--focus-window)
       (if (eq major-mode 'exwm-mode)
           (if (not (eq exwm--frame exwm-workspace--current))
@@ -203,7 +205,12 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
                          ;; The floating X window is on another workspace
                          (exwm-workspace-switch
                           (cl-position exwm--frame exwm-workspace--list))))))
-                 (select-window window)))
+                 ;; It has been reported that the `window' may have be deleted
+                 (if (window-live-p window)
+                     (select-window window)
+                   (setq window
+                         (get-buffer-window (exwm--id->buffer event) t))
+                   (when window (select-window window)))))
              ;; The event should be replayed
              (setq mode xcb:Allow:ReplayPointer))))
     (xcb:+request exwm--connection