From 163e6cccca6c5c7d752041554811ade86666fddd Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 7 Oct 2024 14:58:34 -1000 Subject: [PATCH] macos: quick terminal window blur settings take effect properly Fixes #2410 --- .../QuickTerminal/QuickTerminalController.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift index 29bf9d539..89bb4ddc5 100644 --- a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift +++ b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift @@ -253,6 +253,16 @@ class QuickTerminalController: BaseTerminalController { private func syncAppearance() { guard let window else { return } + // If our window is not visible, then delay this. This is possible specifically + // during state restoration but probably in other scenarios as well. To delay, + // we just loop directly on the dispatch queue. We have to delay because some + // APIs such as window blur have no effect unless the window is visible. + guard window.isVisible else { + // Weak window so that if the window changes or is destroyed we aren't holding a ref + DispatchQueue.main.async { [weak self] in self?.syncAppearance() } + return + } + // If we have window transparency then set it transparent. Otherwise set it opaque. if (ghostty.config.backgroundOpacity < 1) { window.isOpaque = false