mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: detect when surface tree becomes empty
This commit is contained in:
@ -16,7 +16,13 @@ class TerminalController: NSWindowController, NSWindowDelegate, TerminalViewDele
|
|||||||
var focusedSurface: Ghostty.SurfaceView? = nil
|
var focusedSurface: Ghostty.SurfaceView? = nil
|
||||||
|
|
||||||
/// The surface tree for this window.
|
/// The surface tree for this window.
|
||||||
@Published var surfaceTree: Ghostty.SplitNode? = nil
|
@Published var surfaceTree: Ghostty.SplitNode? = nil {
|
||||||
|
didSet {
|
||||||
|
// If our surface tree becomes nil then it means all our surfaces
|
||||||
|
// have closed, so we also cloud the window.
|
||||||
|
if (surfaceTree == nil) { lastSurfaceDidClose() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Fullscreen state management.
|
/// Fullscreen state management.
|
||||||
private let fullscreenHandler = FullScreenHandler()
|
private let fullscreenHandler = FullScreenHandler()
|
||||||
|
@ -10,9 +10,6 @@ protocol TerminalViewDelegate: AnyObject, ObservableObject {
|
|||||||
|
|
||||||
/// The cell size changed.
|
/// The cell size changed.
|
||||||
func cellSizeDidChange(to: NSSize)
|
func cellSizeDidChange(to: NSSize)
|
||||||
|
|
||||||
/// The last surface closed so there are no active surfaces.
|
|
||||||
func lastSurfaceDidClose()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol TerminalViewModel: ObservableObject {
|
protocol TerminalViewModel: ObservableObject {
|
||||||
@ -23,7 +20,6 @@ extension TerminalViewDelegate {
|
|||||||
func focusedSurfaceDidChange(to: Ghostty.SurfaceView?) {}
|
func focusedSurfaceDidChange(to: Ghostty.SurfaceView?) {}
|
||||||
func titleDidChange(to: String) {}
|
func titleDidChange(to: String) {}
|
||||||
func cellSizeDidChange(to: NSSize) {}
|
func cellSizeDidChange(to: NSSize) {}
|
||||||
func lastSurfaceDidClose() {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TerminalView<ViewModel: TerminalViewModel>: View {
|
struct TerminalView<ViewModel: TerminalViewModel>: View {
|
||||||
@ -95,10 +91,6 @@ struct TerminalView<ViewModel: TerminalViewModel>: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func onClose() {
|
|
||||||
self.delegate?.lastSurfaceDidClose()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DebugBuildWarningView: View {
|
struct DebugBuildWarningView: View {
|
||||||
|
Reference in New Issue
Block a user