mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 01:06:08 +03:00
Merge pull request #1280 from mitchellh/macos-tree-invalidate
macOS: expand explicit restorable state invalidation to more cases
This commit is contained in:
@ -470,6 +470,12 @@ class TerminalController: NSWindowController, NSWindowDelegate,
|
|||||||
self.window?.close()
|
self.window?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func surfaceTreeDidChange() {
|
||||||
|
// Whenever our surface tree changes in any way (new split, close split, etc.)
|
||||||
|
// we want to invalidate our state.
|
||||||
|
invalidateRestorableState()
|
||||||
|
}
|
||||||
|
|
||||||
//MARK: - Clipboard Confirmation
|
//MARK: - Clipboard Confirmation
|
||||||
|
|
||||||
func clipboardConfirmationComplete(_ action: ClipboardConfirmationView.Action, _ request: Ghostty.ClipboardRequest) {
|
func clipboardConfirmationComplete(_ action: ClipboardConfirmationView.Action, _ request: Ghostty.ClipboardRequest) {
|
||||||
|
@ -190,6 +190,11 @@ class TerminalManager {
|
|||||||
let frame = focusedWindow.frame
|
let frame = focusedWindow.frame
|
||||||
Self.lastCascadePoint = NSPoint(x: frame.minX, y: frame.maxY)
|
Self.lastCascadePoint = NSPoint(x: frame.minX, y: frame.maxY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// I don't think we strictly have to do this but if a window is
|
||||||
|
// closed I want to make sure that the app state is invalided so
|
||||||
|
// we don't reopen closed windows.
|
||||||
|
NSApplication.shared.invalidateRestorableState()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Close all windows, asking for confirmation if necessary.
|
/// Close all windows, asking for confirmation if necessary.
|
||||||
|
@ -13,6 +13,10 @@ protocol TerminalViewDelegate: AnyObject {
|
|||||||
|
|
||||||
/// The cell size changed.
|
/// The cell size changed.
|
||||||
func cellSizeDidChange(to: NSSize)
|
func cellSizeDidChange(to: NSSize)
|
||||||
|
|
||||||
|
/// The surface tree did change in some way, i.e. a split was added, removed, etc. This is
|
||||||
|
/// not called initially.
|
||||||
|
func surfaceTreeDidChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default all the functions so they're optional
|
// Default all the functions so they're optional
|
||||||
@ -97,6 +101,12 @@ struct TerminalView<ViewModel: TerminalViewModel>: View {
|
|||||||
guard let size = newValue else { return }
|
guard let size = newValue else { return }
|
||||||
self.delegate?.cellSizeDidChange(to: size)
|
self.delegate?.cellSizeDidChange(to: size)
|
||||||
}
|
}
|
||||||
|
.onChange(of: viewModel.surfaceTree?.hashValue) { _ in
|
||||||
|
// This is funky, but its the best way I could think of to detect
|
||||||
|
// ANY CHANGE within the deeply nested surface tree -- detecting a change
|
||||||
|
// in the hash value.
|
||||||
|
self.delegate?.surfaceTreeDidChange()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user