Skip to content

Commit

Permalink
Make equalize_splits action only affect current window
Browse files Browse the repository at this point in the history
  • Loading branch information
liby committed Mar 4, 2025
1 parent ee8ae19 commit 423bc19
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
17 changes: 17 additions & 0 deletions macos/Sources/Features/Terminal/TerminalController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,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) {
Expand Down Expand Up @@ -859,6 +865,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
Expand Down
7 changes: 0 additions & 7 deletions macos/Sources/Ghostty/Ghostty.TerminalSplit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -76,7 +75,6 @@ extension Ghostty {
container: container
)
.onReceive(pubZoom) { onZoom(notification: $0) }
.onReceive(pubEqualize) { onEqualize(notification: $0) }
}
}
.navigationTitle(surfaceTitle ?? "Ghostty")
Expand Down Expand Up @@ -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.
Expand Down

1 comment on commit 423bc19

@edrozenberg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix!

Afaict one side-effect of this, is that equalize no longer works in the Quick Terminal (Mac).

It works great in any "normal" Ghostty windows or tabs which are not the Quick Terminal.

Please sign in to comment.