diff --git a/core/core-ui.el b/core/core-ui.el index 087789710..b66736b1a 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -301,16 +301,27 @@ with `doom//reload-theme').") "Hook run before `switch-to-buffer' and `display-buffer' are called. See `doom-before-switch-buffer-hook'.") -(defun doom*switch-window-hooks (orig-fn &rest args) - (run-hook-with-args 'doom-before-switch-window-hook) - (prog1 (apply orig-fn args) - (run-hook-with-args 'doom-after-switch-window-hook))) +(defun doom*switch-frame-hooks (orig-fn frame &optional norecord) + (if (eq frame (selected-frame)) + (funcall orig-fn frame norecord) + (run-hook-with-args 'doom-before-switch-frame-hook) + (prog1 (funcall orig-fn frame norecord) + (run-hook-with-args 'doom-after-switch-frame-hook)))) +(defun doom*switch-window-hooks (orig-fn window &optional norecord) + (if (or (eq window (selected-window)) + (memq this-command '(mouse-set-point evil-mouse-drag-region)) + (window-minibuffer-p) + (window-minibuffer-p window)) + (funcall orig-fn window norecord) + (run-hook-with-args 'doom-before-switch-window-hook) + (prog1 (funcall orig-fn window norecord) + (run-hook-with-args 'doom-after-switch-window-hook)))) (defun doom*switch-buffer-hooks (orig-fn &rest args) (run-hook-with-args 'doom-before-switch-buffer-hook) (prog1 (apply orig-fn args) (run-hook-with-args 'doom-after-switch-buffer-hook))) -(advice-add #'select-frame :around #'doom*switch-window-hooks) +(advice-add #'select-frame :around #'doom*switch-frame-hooks) (advice-add #'select-window :around #'doom*switch-window-hooks) (advice-add #'switch-to-buffer :around #'doom*switch-buffer-hooks) (advice-add #'display-buffer :around #'doom*switch-buffer-hooks) diff --git a/modules/ui/doom-modeline/config.el b/modules/ui/doom-modeline/config.el index ec029ad36..d1c23c98b 100644 --- a/modules/ui/doom-modeline/config.el +++ b/modules/ui/doom-modeline/config.el @@ -49,9 +49,10 @@ (force-mode-line-update)) (add-hook 'window-configuration-change-hook #'+doom-modeline|set-selected-window) -(add-hook 'focus-in-hook #'+doom-modeline|set-selected-window) +(add-hook 'focus-in-hook #'+doom-modeline|set-selected-window) (add-hook 'focus-out-hook #'+doom-modeline|unset-selected-window) (add-hook 'doom-after-switch-window-hook #'+doom-modeline|set-selected-window) +(add-hook 'doom-after-switch-frame-hook #'+doom-modeline|set-selected-window) ;;