macOS: double click title to enlarge window

Previously with `macos-titlebar-style	= tabs`, double clicking title will do nothing
This commit is contained in:
Lukas
2026-04-10 13:41:53 +02:00
parent 1348e04626
commit e7f58ad72e
2 changed files with 14 additions and 2 deletions

View File

@@ -241,11 +241,11 @@ class TitlebarTabsTahoeTerminalWindow: TransparentTitlebarTerminalWindow, NSTool
switch itemIdentifier {
case .title:
let item = NSToolbarItem(itemIdentifier: .title)
item.view = NSHostingView(rootView: TitleItem(viewModel: viewModel))
item.view = ClickThroughHostingView(rootView: TitleItem(viewModel: viewModel))
// Fix: https://github.com/ghostty-org/ghostty/discussions/9027
item.view?.setContentCompressionResistancePriority(.required, for: .horizontal)
item.visibilityPriority = .user
item.isEnabled = true
item.isEnabled = false
// This is the documented way to avoid the glass view on an item.
// We don't want glass on our title.
@@ -308,3 +308,10 @@ extension TitlebarTabsTahoeTerminalWindow {
}
}
}
/// A "Ghosting" Hosting View, that acts like it's not there
private class ClickThroughHostingView<Content: View>: NSHostingView<Content> {
override func hitTest(_ point: NSPoint) -> NSView? {
nil
}
}

View File

@@ -689,6 +689,11 @@ private class CenteredDynamicLabel: NSTextField {
setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
}
/// Click through, so we can double click here to enlarge current window
override func hitTest(_ point: NSPoint) -> NSView? {
nil
}
// Vertically center the text
override func draw(_ dirtyRect: NSRect) {
guard let attributedString = self.attributedStringValue.mutableCopy() as? NSMutableAttributedString else {