diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 00a57997e..fc0ebc7d0 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -16,7 +16,13 @@ class TerminalController: NSWindowController, NSWindowDelegate, TerminalViewDele var focusedSurface: Ghostty.SurfaceView? = nil /// 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. private let fullscreenHandler = FullScreenHandler() diff --git a/macos/Sources/Features/Terminal/TerminalView.swift b/macos/Sources/Features/Terminal/TerminalView.swift index c7505af33..163d4e575 100644 --- a/macos/Sources/Features/Terminal/TerminalView.swift +++ b/macos/Sources/Features/Terminal/TerminalView.swift @@ -10,9 +10,6 @@ protocol TerminalViewDelegate: AnyObject, ObservableObject { /// The cell size changed. func cellSizeDidChange(to: NSSize) - - /// The last surface closed so there are no active surfaces. - func lastSurfaceDidClose() } protocol TerminalViewModel: ObservableObject { @@ -23,7 +20,6 @@ extension TerminalViewDelegate { func focusedSurfaceDidChange(to: Ghostty.SurfaceView?) {} func titleDidChange(to: String) {} func cellSizeDidChange(to: NSSize) {} - func lastSurfaceDidClose() {} } struct TerminalView: View { @@ -95,10 +91,6 @@ struct TerminalView: View { } } } - - func onClose() { - self.delegate?.lastSurfaceDidClose() - } } struct DebugBuildWarningView: View {