diff --git a/exwm-input.el b/exwm-input.el index f218ea2..cbfd1dc 100644 --- a/exwm-input.el +++ b/exwm-input.el @@ -79,6 +79,9 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.") (exwm-input--set-active-window id) (xcb:flush exwm--connection)))) +(declare-function exwm-workspace--client-p "exwm-workspace.el" + (&optional frame)) + (defvar exwm-input--update-focus-window nil "The (Emacs) window to be focused. This value should always be overwritten.") @@ -87,7 +90,7 @@ This value should always be overwritten.") "Run in `buffer-list-update-hook' to track input focus." (when (and (not (minibufferp)) ;Do not set input focus on minibuffer window. (eq (current-buffer) (window-buffer)) ;e.g. `with-temp-buffer'. - (frame-parameter nil 'exwm-outer-id)) ;e.g. emacsclient frame. + (not (exwm-workspace--client-p))) (setq exwm-input--update-focus-window (selected-window)) (exwm-input--update-focus-defer))) @@ -183,8 +186,9 @@ This value should always be overwritten.") (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)))) + (unless (exwm-workspace--client-p) + ;; 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." diff --git a/exwm-layout.el b/exwm-layout.el index 905a1e3..ee97849 100644 --- a/exwm-layout.el +++ b/exwm-layout.el @@ -375,9 +375,12 @@ selected by `other-buffer'." (exwm-layout--set-client-list-stacking) (xcb:flush exwm--connection)))) +(declare-function exwm-workspace--client-p "exwm-workspace.el" + (&optional frame)) + (defun exwm-layout--on-minibuffer-setup () "Refresh layout when minibuffer grows." - (when (frame-parameter nil 'exwm-outer-id) + (unless (exwm-workspace--client-p) (run-with-idle-timer 0.01 nil ;FIXME (lambda () (when (< 1 (window-height (minibuffer-window))) @@ -386,8 +389,7 @@ selected by `other-buffer'." (defun exwm-layout--on-echo-area-change (&optional dirty) "Run when message arrives or in `echo-area-clear-hook' to refresh layout." (when (and (current-message) - ;; Exclude non-graphical frames. - (frame-parameter nil 'exwm-outer-id) + (not (exwm-workspace--client-p)) (or (cl-position ?\n (current-message)) (> (length (current-message)) (frame-width exwm-workspace--current)))) diff --git a/exwm-workspace.el b/exwm-workspace.el index 097a950..4789aeb 100644 --- a/exwm-workspace.el +++ b/exwm-workspace.el @@ -48,6 +48,10 @@ NIL if FRAME is not a workspace" "Return t if FRAME is a workspace." (memq frame exwm-workspace--list)) +(defsubst exwm-workspace--client-p (&optional frame) + "Return non-nil if FRAME is an emacsclient frame." + (frame-parameter frame 'client)) + (defun exwm-workspace--workspace-from-frame-or-index (frame-or-index) "Retrieve the workspace frame from FRAME-OR-INDEX." (cond @@ -882,24 +886,25 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first." (defun exwm-workspace--update-minibuffer-height (&optional echo-area) "Update the minibuffer frame height." - (let ((height - (with-current-buffer - (window-buffer (minibuffer-window exwm-workspace--minibuffer)) - (max 1 - (if echo-area - (let ((width (frame-width exwm-workspace--minibuffer)) - (result 0)) - (mapc (lambda (i) - (setq result - (+ result - (ceiling (1+ (length i)) width)))) - (split-string (or (current-message) "") "\n")) - result) - (count-screen-lines)))))) - (when (and (integerp max-mini-window-height) - (> height max-mini-window-height)) - (setq height max-mini-window-height)) - (set-frame-height exwm-workspace--minibuffer height))) + (unless (exwm-workspace--client-p) + (let ((height + (with-current-buffer + (window-buffer (minibuffer-window exwm-workspace--minibuffer)) + (max 1 + (if echo-area + (let ((width (frame-width exwm-workspace--minibuffer)) + (result 0)) + (mapc (lambda (i) + (setq result + (+ result + (ceiling (1+ (length i)) width)))) + (split-string (or (current-message) "") "\n")) + result) + (count-screen-lines)))))) + (when (and (integerp max-mini-window-height) + (> height max-mini-window-height)) + (setq height max-mini-window-height)) + (set-frame-height exwm-workspace--minibuffer height)))) (defun exwm-workspace--on-ConfigureNotify (data _synthetic) "Adjust the container to fit the minibuffer frame." @@ -986,8 +991,7 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first." (defun exwm-workspace--on-minibuffer-setup () "Run in minibuffer-setup-hook to show the minibuffer and its container." (when (and (= 1 (minibuffer-depth)) - ;; Exclude non-graphical frames. - (frame-parameter nil 'exwm-outer-id)) + (not (exwm-workspace--client-p))) (add-hook 'post-command-hook #'exwm-workspace--update-minibuffer-height) (exwm-workspace--show-minibuffer)) ;; FIXME: This is a temporary fix for the *Completions* buffer not @@ -1008,8 +1012,7 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first." (defun exwm-workspace--on-minibuffer-exit () "Run in minibuffer-exit-hook to hide the minibuffer container." (when (and (= 1 (minibuffer-depth)) - ;; Exclude non-graphical frames. - (frame-parameter nil 'exwm-outer-id)) + (not (exwm-workspace--client-p))) (remove-hook 'post-command-hook #'exwm-workspace--update-minibuffer-height) (exwm-workspace--hide-minibuffer))) @@ -1018,8 +1021,7 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first." (defun exwm-workspace--on-echo-area-dirty () "Run when new message arrives to show the echo area and its container." (when (and (not (active-minibuffer-window)) - ;; Exclude non-graphical frames. - (frame-parameter nil 'exwm-outer-id) + (not (exwm-workspace--client-p)) (or (current-message) cursor-in-echo-area)) (exwm-workspace--update-minibuffer-height t) @@ -1033,7 +1035,7 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first." (defun exwm-workspace--on-echo-area-clear () "Run in echo-area-clear-hook to hide echo area container." - (when (frame-parameter nil 'exwm-outer-id) ;Exclude non-graphical frames. + (unless (exwm-workspace--client-p) (unless (active-minibuffer-window) (exwm-workspace--hide-minibuffer)) (when exwm-workspace--display-echo-area-timer @@ -1153,6 +1155,8 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first." (set-frame-parameter frame 'exwm-outer-id outer-id) (set-frame-parameter frame 'exwm-container container) (set-frame-parameter frame 'exwm-workspace workspace) + ;; In case it's created by emacsclient. + (set-frame-parameter frame 'client nil) ;; Copy RandR frame parameters from the first workspace to ;; prevent potential problems. The values do not matter here as ;; they'll be updated by the RandR module later. @@ -1324,7 +1328,7 @@ applied to all subsequently created X frames." (unless (frame-parameter i 'window-id) (setq initial-workspaces (delq i initial-workspaces)))) (setq exwm-workspace--client - (frame-parameter (car exwm-workspace--list) 'client)) + (frame-parameter (car initial-workspaces) 'client)) (let ((f (car initial-workspaces))) ;; Remove the possible internal border. (set-frame-parameter f 'internal-border-width 0)