diff --git a/macos/Sources/Ghostty/Ghostty.SplitView.swift b/macos/Sources/Ghostty/Ghostty.SplitView.swift index a7529c7bb..3d675ff35 100644 --- a/macos/Sources/Ghostty/Ghostty.SplitView.swift +++ b/macos/Sources/Ghostty/Ghostty.SplitView.swift @@ -96,6 +96,22 @@ extension Ghostty { container.bottomRight.close() } } + + /// Returns true if any surface in the split stack requires quit confirmation. + func needsConfirmQuit() -> Bool { + switch (self) { + case .noSplit(let leaf): + return leaf.surface.needsConfirmQuit + + case .horizontal(let container): + return container.topLeft.needsConfirmQuit() || + container.bottomRight.needsConfirmQuit() + + case .vertical(let container): + return container.topLeft.needsConfirmQuit() || + container.bottomRight.needsConfirmQuit() + } + } /// Returns true if the split tree contains the given view. func contains(view: SurfaceView) -> Bool { diff --git a/macos/Sources/Ghostty/SurfaceView.swift b/macos/Sources/Ghostty/SurfaceView.swift index 0252b5a42..5ad74a8b5 100644 --- a/macos/Sources/Ghostty/SurfaceView.swift +++ b/macos/Sources/Ghostty/SurfaceView.swift @@ -252,6 +252,13 @@ extension Ghostty { // then the view is moved to a new window. var initialSize: NSSize? = nil + // Returns true if quit confirmation is required for this surface to + // exit safely. + var needsConfirmQuit: Bool { + guard let surface = self.surface else { return false } + return ghostty_surface_needs_confirm_quit(surface) + } + // Returns the inspector instance for this surface, or nil if the // surface has been closed. var inspector: ghostty_inspector_t? {