about summary refs log tree commit diff
path: root/exwm-input.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-10-06T11·26+0800
committerChris Feng <chris.w.feng@gmail.com>2016-10-06T11·26+0800
commitd0c2ca75f8ac78d87aba3e80902fb0f113b10279 (patch)
tree2e449fb9d212db25a96bd96ab5bf91dc1b0936cf /exwm-input.el
parent09b4f0915828222942d8ac3ae7f970e8d3d8468a (diff)
Fix a possible deadlock
* exwm-input.el (exwm-input--update-focus): Unlock before switching
workspace.  Also make sure the correct Emacs window is chosen for the
target workspace.
Diffstat (limited to 'exwm-input.el')
-rw-r--r--exwm-input.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/exwm-input.el b/exwm-input.el
index 4a8fdbb016..a2f478068e 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -212,7 +212,10 @@ This value should always be overwritten.")
     (with-current-buffer (window-buffer window)
       (if (eq major-mode 'exwm-mode)
           (if (not (eq exwm--frame exwm-workspace--current))
-              (exwm-workspace-switch exwm--frame)
+              (progn
+                (set-frame-parameter exwm--frame 'exwm-selected-window window)
+                (run-with-idle-timer 0 nil #'exwm-workspace-switch
+                                     exwm--frame))
             (exwm--log "Set focus on #x%x" exwm--id)
             (exwm-input--set-focus exwm--id)
             (when exwm--floating-frame
@@ -233,7 +236,11 @@ This value should always be overwritten.")
                    (not (eq (selected-frame) exwm-workspace--current)))
               ;; The focus is on another workspace (e.g. it got clicked)
               ;; so switch to it.
-              (exwm-workspace-switch (selected-frame))
+              (progn
+                (set-frame-parameter (selected-frame) 'exwm-selected-window
+                                     window)
+                (run-with-idle-timer 0 nil #'exwm-workspace-switch
+                                     (selected-frame)))
             ;; The focus is still on the current workspace.
             (if (not (and (exwm-workspace--minibuffer-own-frame-p)
                           (minibufferp)))