diff options
| author | Bryan Lee <38807139+liby@users.noreply.github.com> | 2025-03-04 22:37:32 +0800 |
|---|---|---|
| committer | Mitchell Hashimoto <m@mitchellh.com> | 2025-03-23 14:29:36 -0700 |
| commit | f1c510f9fed4e339f7f8cc82037c9ca731e7a5c2 (patch) | |
| tree | 139ed4873324129dd496905593e92f79c914c61d | |
| parent | 3264051f8d0a2f3451183d019cbd4286903376c1 (diff) | |
Make `equalize_splits` action only affect current window
| -rw-r--r-- | macos/Sources/Features/Terminal/TerminalController.swift | 17 | ||||
| -rw-r--r-- | macos/Sources/Ghostty/Ghostty.TerminalSplit.swift | 7 |
2 files changed, 17 insertions, 7 deletions
diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 8118103d6..25ec07ba9 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -76,6 +76,12 @@ class TerminalController: BaseTerminalController { selector: #selector(onFrameDidChange), name: NSView.frameDidChangeNotification, object: nil) + center.addObserver( + self, + selector: #selector(onEqualizeSplits), + name: Ghostty.Notification.didEqualizeSplits, + object: nil + ) } required init?(coder: NSCoder) { @@ -801,6 +807,17 @@ class TerminalController: BaseTerminalController { toggleFullscreen(mode: fullscreenMode) } + @objc private func onEqualizeSplits(_ notification: Notification) { + guard let target = notification.object as? Ghostty.SurfaceView else { return } + + // Check if target surface is in current controller's tree + guard surfaceTree?.contains(view: target) ?? false else { return } + + if case .split(let container) = surfaceTree { + _ = container.equalize() + } + } + struct DerivedConfig { let backgroundColor: Color let macosTitlebarStyle: String diff --git a/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift b/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift index cec178245..127c925e1 100644 --- a/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift +++ b/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift @@ -50,7 +50,6 @@ extension Ghostty { var body: some View { let center = NotificationCenter.default let pubZoom = center.publisher(for: Notification.didToggleSplitZoom) - let pubEqualize = center.publisher(for: Notification.didEqualizeSplits) // If we're zoomed, we don't render anything, we are transparent. This // ensures that the View stays around so we don't lose our state, but @@ -76,7 +75,6 @@ extension Ghostty { container: container ) .onReceive(pubZoom) { onZoom(notification: $0) } - .onReceive(pubEqualize) { onEqualize(notification: $0) } } } .navigationTitle(surfaceTitle ?? "Ghostty") @@ -137,11 +135,6 @@ extension Ghostty { } } } - - func onEqualize(notification: SwiftUI.Notification) { - guard case .split(let c) = node else { return } - _ = c.equalize() - } } /// A noSplit leaf node of a split tree. |
