From 5a5478abe1dfdc45dc2163b63a87301c572115e6 Mon Sep 17 00:00:00 2001 From: Aaron Ruan Date: Tue, 25 Feb 2025 15:05:53 +0800 Subject: [PATCH] feat: respect maximize config on macOS Signed-off-by: Aaron Ruan --- macos/Sources/Features/Terminal/TerminalController.swift | 6 +++++- macos/Sources/Ghostty/Ghostty.Config.swift | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 252e40eb5..d7ddb793e 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -375,7 +375,11 @@ class TerminalController: BaseTerminalController { // If we have only a single surface (no splits) and that surface requested // an initial size then we set it here now. if case let .leaf(leaf) = surfaceTree { - if let initialSize = leaf.surface.initialSize, + if config.maximize { + if let screen = window.screen ?? NSScreen.main { + window.setFrame(screen.visibleFrame, display: true) + } + } else if let initialSize = leaf.surface.initialSize, let screen = window.screen ?? NSScreen.main { // Get the current frame of the window var frame = window.frame diff --git a/macos/Sources/Ghostty/Ghostty.Config.swift b/macos/Sources/Ghostty/Ghostty.Config.swift index ec23632f7..f30174b8e 100644 --- a/macos/Sources/Ghostty/Ghostty.Config.swift +++ b/macos/Sources/Ghostty/Ghostty.Config.swift @@ -514,6 +514,14 @@ extension Ghostty { _ = ghostty_config_get(config, &v, key, UInt(key.count)) return v } + + var maximize: Bool { + guard let config = self.config else { return true } + var v = false; + let key = "maximize" + _ = ghostty_config_get(config, &v, key, UInt(key.count)) + return v + } } }