introduce split-preserve-zoom config to maintain zoomed splits during navigation

This commit is contained in:
lorenries
2025-10-08 12:04:42 -04:00
committed by Mitchell Hashimoto
parent 67eb480577
commit d364e421a8
5 changed files with 81 additions and 2 deletions

View File

@@ -621,9 +621,14 @@ class BaseTerminalController: NSWindowController,
return
}
// Remove the zoomed state for this surface tree.
if surfaceTree.zoomed != nil {
surfaceTree = .init(root: surfaceTree.root, zoomed: nil)
if derivedConfig.splitPreserveZoom.contains(.navigation) {
surfaceTree = SplitTree(
root: surfaceTree.root,
zoomed: surfaceTree.root?.node(view: nextSurface))
} else {
surfaceTree = SplitTree(root: surfaceTree.root, zoomed: nil)
}
}
// Move focus to the next surface
@@ -1188,17 +1193,20 @@ class BaseTerminalController: NSWindowController,
let macosTitlebarProxyIcon: Ghostty.MacOSTitlebarProxyIcon
let windowStepResize: Bool
let focusFollowsMouse: Bool
let splitPreserveZoom: Ghostty.Config.SplitPreserveZoom
init() {
self.macosTitlebarProxyIcon = .visible
self.windowStepResize = false
self.focusFollowsMouse = false
self.splitPreserveZoom = .init()
}
init(_ config: Ghostty.Config) {
self.macosTitlebarProxyIcon = config.macosTitlebarProxyIcon
self.windowStepResize = config.windowStepResize
self.focusFollowsMouse = config.focusFollowsMouse
self.splitPreserveZoom = config.splitPreserveZoom
}
}
}

View File

@@ -124,6 +124,14 @@ extension Ghostty {
return .init(rawValue: v)
}
var splitPreserveZoom: SplitPreserveZoom {
guard let config = self.config else { return .init() }
var v: CUnsignedInt = 0
let key = "split-preserve-zoom"
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return .init() }
return .init(rawValue: v)
}
var initialWindow: Bool {
guard let config = self.config else { return true }
var v = true;
@@ -690,6 +698,12 @@ extension Ghostty.Config {
static let border = BellFeatures(rawValue: 1 << 4)
}
struct SplitPreserveZoom: OptionSet {
let rawValue: CUnsignedInt
static let navigation = SplitPreserveZoom(rawValue: 1 << 0)
}
enum MacDockDropBehavior: String {
case new_tab = "new-tab"
case new_window = "new-window"