mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-06 07:38:21 +00:00
macOS: set the initial window position after window is loaded
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user