about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--exwm-input.el7
-rw-r--r--exwm-workspace.el4
2 files changed, 8 insertions, 3 deletions
diff --git a/exwm-input.el b/exwm-input.el
index 62779c9e2be6..4a6d56e2fbfe 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -174,6 +174,11 @@ This value should always be overwritten.")
           (xcb:flush exwm--connection)))))
   (setq exwm-input--update-focus-lock nil))
 
+(defun exwm-input--on-minibuffer-setup ()
+  "Run in `minibuffer-setup-hook' to set input focus."
+  ;; Set input focus on the Emacs frame
+  (x-focus-frame (window-frame (minibuffer-selected-window))))
+
 (defun exwm-input--set-active-window (&optional id)
   "Set _NET_ACTIVE_WINDOW."
   (xcb:+request exwm--connection
@@ -604,6 +609,8 @@ Its usage is the same with `exwm-input-set-simulation-keys'."
               #'exwm-floating--stop-moveresize)
   (xcb:+event exwm--connection 'xcb:MotionNotify
               #'exwm-floating--do-moveresize)
+  ;; The input focus should be set on the frame when minibuffer is active.
+  (add-hook 'minibuffer-setup-hook #'exwm-input--on-minibuffer-setup)
   ;; `pre-command-hook' marks the end of a key sequence (existing or not)
   (add-hook 'pre-command-hook #'exwm-input--finish-key-sequence)
   ;; Control `exwm-input--during-command'
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 08c90751dbbf..3a4a5a8ef66c 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -996,9 +996,7 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first."
              ;; Exclude non-graphical frames.
              (frame-parameter nil 'exwm-outer-id))
     (add-hook 'post-command-hook #'exwm-workspace--update-minibuffer-height)
-    (exwm-workspace--show-minibuffer)
-    ;; Set input focus on the Emacs frame
-    (x-focus-frame (window-frame (minibuffer-selected-window)))))
+    (exwm-workspace--show-minibuffer)))
 
 (defun exwm-workspace--on-minibuffer-exit ()
   "Run in minibuffer-exit-hook to hide the minibuffer container."