From 6bfedf8bf71ef11a26f2e8c3cddbac55ce873e5c Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Sat, 30 Jul 2016 10:00:11 +0800 Subject: Fix input focus transfer between workspaces * exwm-input.el (exwm-input--set-focus): Make input focus revert to parent by default (to prevent input focus from following pointer). * exwm-input.el (exwm-input--update-focus): Switch to another workspace if input focus is transfered to it. * exwm-workspace.el (exwm-workspace--on-focus-in, exwm-workspace--init) (exwm-workspace--exit): Remove `exwm-workspace--on-focus-in' and related uses. --- exwm-input.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'exwm-input.el') diff --git a/exwm-input.el b/exwm-input.el index 0b5ce98e6a..0da0558e84 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -73,7 +73,7 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.") (exwm--log "Focus on #x%x with SetInputFocus" id) (xcb:+request exwm--connection (make-instance 'xcb:SetInputFocus - :revert-to xcb:InputFocus:PointerRoot + :revert-to xcb:InputFocus:Parent :focus id :time xcb:Time:CurrentTime))) (exwm-input--set-active-window id) @@ -169,9 +169,15 @@ This value should always be overwritten.") (xcb:flush exwm--connection))) (when (eq (selected-window) window) (exwm--log "Focus on %s" window) - (select-frame-set-input-focus (window-frame window) t) - (exwm-input--set-active-window) - (xcb:flush exwm--connection))))) + (if (and (exwm-workspace--workspace-p (selected-frame)) + (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)) + ;; The focus is still on the current workspace. + (select-frame-set-input-focus (window-frame window) t) + (exwm-input--set-active-window) + (xcb:flush exwm--connection)))))) (setq exwm-input--update-focus-lock nil)) (defun exwm-input--on-minibuffer-setup () -- cgit 1.4.1