Skip to content

Commit 56456f4

Browse files
committed
fix #804: frame focus delay issues
1 parent 327d572 commit 56456f4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

doom-modeline-core.el

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,13 @@ used as an advice to window creation functions."
12551255

12561256
(defun doom-modeline-focus-change (&rest _)
12571257
"Focus change."
1258-
(if (frame-focus-state)
1259-
(doom-modeline-set-selected-window)
1258+
(if (frame-focus-state (frame-parent))
1259+
(progn
1260+
(doom-modeline-set-selected-window)
1261+
;; HACK: pulse after focusing in the frame to refresh the buffer name.
1262+
;; @see https://github.com/seagle0128/doom-modeline/issues/591
1263+
(when (fboundp 'pulse-momentary-highlight-region)
1264+
(pulse-momentary-highlight-region 0 0)))
12601265
(doom-modeline-unset-selected-window)))
12611266

12621267

doom-modeline.el

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
253253
(add-hook 'focus-in-hook #'doom-modeline-set-selected-window)
254254
(add-hook 'focus-out-hook #'doom-modeline-unset-selected-window)))
255255
(add-hook 'window-selection-change-functions #'doom-modeline-set-selected-window)
256+
(advice-add #'handle-switch-frame :after #'doom-modeline-focus-change)
256257

257258
;; Automatically set mode-lines
258259
(add-hook 'after-change-major-mode-hook #'doom-modeline-auto-set-modeline)
@@ -291,6 +292,7 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
291292
(remove-hook 'focus-in-hook #'doom-modeline-set-selected-window)
292293
(remove-hook 'focus-out-hook #'doom-modeline-unset-selected-window)))
293294
(remove-hook 'window-selection-change-functions #'doom-modeline-set-selected-window)
295+
(advice-remove #'handle-switch-frame #'doom-modeline-focus-change)
294296

295297
;; For major modes
296298
(remove-hook 'after-change-major-mode-hook #'doom-modeline-auto-set-modeline)

0 commit comments

Comments
 (0)