mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
Merge pull request #1189 from mitchellh/macos-restore-blur
macos: wait for window to become visible to set blur
This commit is contained in:
@ -532,10 +532,33 @@ extension Ghostty {
|
||||
}
|
||||
|
||||
override func viewDidMoveToWindow() {
|
||||
guard let window = self.window else { return }
|
||||
guard let surface = self.surface else { return }
|
||||
// Set our background blur if requested
|
||||
setWindowBackgroundBlur(window)
|
||||
|
||||
// Try to set the initial window size if we have one
|
||||
setInitialWindowSize()
|
||||
}
|
||||
|
||||
/// This function sets the window background to blur if it is configured on the surface.
|
||||
private func setWindowBackgroundBlur(_ targetWindow: NSWindow?) {
|
||||
// Surface must desire transparency
|
||||
guard let surface = self.surface,
|
||||
ghostty_surface_transparent(surface) else { return }
|
||||
|
||||
// Our target should always be our own view window
|
||||
guard let target = targetWindow,
|
||||
let window = self.window,
|
||||
target == 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.
|
||||
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, weak window] in self?.setWindowBackgroundBlur(window) }
|
||||
return
|
||||
}
|
||||
|
||||
if ghostty_surface_transparent(surface) {
|
||||
// Set the window transparency settings
|
||||
window.isOpaque = false
|
||||
window.hasShadow = false
|
||||
@ -545,10 +568,6 @@ extension Ghostty {
|
||||
ghostty_set_window_background_blur(surface, Unmanaged.passUnretained(window).toOpaque())
|
||||
}
|
||||
|
||||
// Try to set the initial window size if we have one
|
||||
setInitialWindowSize()
|
||||
}
|
||||
|
||||
/// Sets the initial window size requested by the Ghostty config.
|
||||
///
|
||||
/// This only works under certain conditions:
|
||||
|
Reference in New Issue
Block a user