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.
This commit is contained in:
Chris Feng 2016-10-06 19:26:53 +08:00
parent 09b4f09158
commit d0c2ca75f8

View file

@ -212,7 +212,10 @@ This value should always be overwritten.")
(with-current-buffer (window-buffer window) (with-current-buffer (window-buffer window)
(if (eq major-mode 'exwm-mode) (if (eq major-mode 'exwm-mode)
(if (not (eq exwm--frame exwm-workspace--current)) (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--log "Set focus on #x%x" exwm--id)
(exwm-input--set-focus exwm--id) (exwm-input--set-focus exwm--id)
(when exwm--floating-frame (when exwm--floating-frame
@ -233,7 +236,11 @@ This value should always be overwritten.")
(not (eq (selected-frame) exwm-workspace--current))) (not (eq (selected-frame) exwm-workspace--current)))
;; The focus is on another workspace (e.g. it got clicked) ;; The focus is on another workspace (e.g. it got clicked)
;; so switch to it. ;; 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. ;; The focus is still on the current workspace.
(if (not (and (exwm-workspace--minibuffer-own-frame-p) (if (not (and (exwm-workspace--minibuffer-own-frame-p)
(minibufferp))) (minibufferp)))