mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
fix(macos): hide all child frames when toggling non-native fullscreen
For a couple of years now, there's been a bug on macOS with the non-native fullscreen implementation. When enabling fullscreen, any child-frames created by packages like lsp-ui, company-box, posframe, etc. all re-appear on top of the fullscreened frame, and stay there until you re-trigger whatever package/command that created the childframe originally. This works around this issue by simply closing all child frames when toggling non-native fullscreen.
This commit is contained in:
@@ -39,7 +39,28 @@
|
||||
|
||||
;; Fix the default default-directory value.
|
||||
(if (string= default-directory "/")
|
||||
(setq default-directory "~/")))
|
||||
(setq default-directory "~/"))
|
||||
|
||||
(defun delete-child-frames (&optional frame)
|
||||
"Close all child frames of FRAME.
|
||||
If FRAME is nil, it defaults to the currently selected frame."
|
||||
(interactive)
|
||||
(let ((frame (or frame (selected-frame))))
|
||||
(dolist (f (frame-list))
|
||||
(when (eq (frame-parent f) frame)
|
||||
(delete-frame f)))))
|
||||
|
||||
(defun siren-toggle-frame-fullscreen-advice (&optional frame)
|
||||
"If `ns-use-native-fullscreen' is not t, close all child frames of FRAME.
|
||||
If FRAME is nil, it defaults to the currently selected frame."
|
||||
(unless ns-use-native-fullscreen
|
||||
(delete-child-frames frame)))
|
||||
|
||||
;; On macOS when using non-native fullscreen, child-frames re-appear and are
|
||||
;; stuck on top of the main frame when fullscreen is enabled. This advice
|
||||
;; closes all child-frames when toggling fullscreen state to avoid this.
|
||||
(advice-add 'toggle-frame-fullscreen :after
|
||||
#'siren-toggle-frame-fullscreen-advice))
|
||||
|
||||
;; macOS Fullscreen (requires Emacs 24.4 or later)
|
||||
(global-set-key (kbd "s-<return>") 'toggle-frame-fullscreen)
|
||||
|
||||
Reference in New Issue
Block a user