mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
Hide main title when covered by tabs
This commit is contained in:

committed by
Mitchell Hashimoto

parent
85beda9c49
commit
12a01c0460
@@ -25,6 +25,16 @@ class TerminalToolbar: NSToolbar, NSToolbarDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
var titleIsHidden: Bool {
|
||||
get {
|
||||
titleTextField.isHidden
|
||||
}
|
||||
|
||||
set {
|
||||
titleTextField.isHidden = newValue
|
||||
}
|
||||
}
|
||||
|
||||
override init(identifier: NSToolbar.Identifier) {
|
||||
super.init(identifier: identifier)
|
||||
|
||||
|
@@ -153,7 +153,7 @@ class TerminalWindow: NSWindow {
|
||||
// This is required because the removeTitlebarAccessoryViewController hook does not
|
||||
// catch the creation of a new window by "tearing off" a tab from a tabbed window.
|
||||
if let tabGroup = self.tabGroup, tabGroup.windows.count < 2 {
|
||||
hideCustomTabBarViews()
|
||||
resetCustomTabBarViews()
|
||||
}
|
||||
|
||||
super.becomeKey()
|
||||
@@ -538,17 +538,22 @@ class TerminalWindow: NSWindow {
|
||||
let isTabBar = titlebarAccessoryViewControllers[index].identifier == Self.TabBarController
|
||||
super.removeTitlebarAccessoryViewController(at: index)
|
||||
if (isTabBar) {
|
||||
hideCustomTabBarViews()
|
||||
resetCustomTabBarViews()
|
||||
}
|
||||
}
|
||||
|
||||
// To be called immediately after the tab bar is disabled.
|
||||
private func hideCustomTabBarViews() {
|
||||
private func resetCustomTabBarViews() {
|
||||
// Hide the window buttons backdrop.
|
||||
windowButtonsBackdrop?.isHidden = true
|
||||
|
||||
// Hide the window drag handle.
|
||||
windowDragHandle?.isHidden = true
|
||||
|
||||
// Reenable the main toolbar title
|
||||
if let toolbar = toolbar as? TerminalToolbar {
|
||||
toolbar.titleIsHidden = false
|
||||
}
|
||||
}
|
||||
|
||||
private func pushTabsToTitlebar(_ tabBarController: NSTitlebarAccessoryViewController) {
|
||||
@@ -557,6 +562,11 @@ class TerminalWindow: NSWindow {
|
||||
generateToolbar()
|
||||
}
|
||||
|
||||
// The main title conflicts with titlebar tabs, so hide it
|
||||
if let toolbar = toolbar as? TerminalToolbar {
|
||||
toolbar.titleIsHidden = true
|
||||
}
|
||||
|
||||
// HACK: wait a tick before doing anything, to avoid edge cases during startup... :/
|
||||
// If we don't do this then on launch windows with restored state with tabs will end
|
||||
// up with messed up tab bars that don't show all tabs.
|
||||
|
Reference in New Issue
Block a user