From 2944128e051e3b322e7a27dc29a14b830c0af31d Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Wed, 31 Jan 2024 20:07:35 -0500 Subject: [PATCH] fix(macOS): restoring tabbed windows with titlebar tabs enabled --- .../Features/Terminal/TerminalController.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 37d6a516b..3d23a22bf 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -208,8 +208,19 @@ class TerminalController: NSWindowController, NSWindowDelegate, // Set the background color of the window window.backgroundColor = NSColor(ghostty.config.backgroundColor) - // Handle titlebar tabs config option - window.titlebarTabs = ghostty.config.macosTitlebarTabs + // Handle titlebar tabs config option. Something about what we do while setting up the + // titlebar tabs interferes with the window restore process unless window.tabbingMode + // is set to .preferred, so we set it, and switch back to automatic as soon as we can. + if (ghostty.config.macosTitlebarTabs) { + window.tabbingMode = .preferred + window.titlebarTabs = true + DispatchQueue.main.async { + window.tabbingMode = .automatic + } + } + + // Set a custom background on the titlebar - this is required for when + // titlebar tabs is used in conjunction with a transparent background. window.setTitlebarBackground( window .backgroundColor