macOS: set the initial window position after window is loaded

This commit is contained in:
Lukas
2026-03-11 17:35:23 +01:00
parent e8c82ca1af
commit 45d360dc68
2 changed files with 15 additions and 6 deletions

View File

@@ -1061,6 +1061,16 @@ class TerminalController: BaseTerminalController, TabGroupCloseCoordinator.Contr
}
}
// Set the initial window position. This must happen after the window
// is fully set up (content view, toolbar, default size) so that
// decorations added by subclass awakeFromNib (e.g. toolbar for tabs
// style) don't change the frame after the position is restored.
if let terminalWindow = window as? TerminalWindow {
terminalWindow.setInitialWindowPosition(
x: derivedConfig.windowPositionX,
y: derivedConfig.windowPositionY,
)
}
// Store our initial frame so we can know our default later. This MUST
// be after the defaultSize call above so that we don't re-apply our frame.
// Note: we probably want to set this on the first frame change or something

View File

@@ -120,11 +120,10 @@ class TerminalWindow: NSWindow {
// If window decorations are disabled, remove our title
if !config.windowDecorations { styleMask.remove(.titled) }
// Set our window positioning to coordinates if config value exists, otherwise
// fallback to original centering behavior
setInitialWindowPosition(
x: config.windowPositionX,
y: config.windowPositionY)
// NOTE: setInitialWindowPosition is NOT called here because subclass
// awakeFromNib may add decorations (e.g. toolbar for tabs style) that
// change the frame. It is called from TerminalController.windowDidLoad
// after the window is fully set up.
// If our traffic buttons should be hidden, then hide them
if config.macosWindowButtons == .hidden {
@@ -537,7 +536,7 @@ class TerminalWindow: NSWindow {
terminalController?.updateColorSchemeForSurfaceTree()
}
private func setInitialWindowPosition(x: Int16?, y: Int16?) {
func setInitialWindowPosition(x: Int16?, y: Int16?) {
// If we don't have an X/Y then we try to use the previously saved window pos.
guard let x = x, let y = y else {
if !LastWindowPosition.shared.restore(self) {