Skip to content

Commit e849783

Browse files
committed
Fix settings window style and Cmd+W close handling
Add NSToolbar to settings window so .unified toolbar style takes effect, making the sidebar extend into the titlebar (matching standard macOS Settings appearance). Add SettingsWindow subclass that responds to the close: action from Ghostty's Close menu item, which otherwise goes unhandled in non-terminal windows.
1 parent 4b51461 commit e849783

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

macos/Ghostty.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
Features/Settings/ConfigurationErrorsController.swift,
116116
Features/Settings/ConfigurationErrorsView.swift,
117117
Features/Settings/SettingsView.swift,
118+
Features/Settings/SettingsWindow.swift,
118119
Features/Splits/SplitTree.swift,
119120
Features/Splits/SplitView.Divider.swift,
120121
Features/Splits/SplitView.swift,

macos/Sources/App/macOS/AppDelegate.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ class AppDelegate: NSObject,
11541154

11551155
@IBAction func showSettings(_ sender: Any?) {
11561156
if settingsWindowController == nil {
1157-
let window = NSWindow(
1157+
let window = SettingsWindow(
11581158
contentRect: NSRect(x: 0, y: 0, width: 720, height: 500),
11591159
styleMask: [.titled, .closable, .miniaturizable, .resizable],
11601160
backing: .buffered,
@@ -1164,7 +1164,12 @@ class AppDelegate: NSObject,
11641164
window.center()
11651165
window.isReleasedWhenClosed = false
11661166
window.collectionBehavior = [.moveToActiveSpace]
1167+
1168+
let toolbar = NSToolbar(identifier: "SettingsToolbar")
1169+
toolbar.showsBaselineSeparator = false
1170+
window.toolbar = toolbar
11671171
window.toolbarStyle = .unified
1172+
11681173
window.minSize = NSSize(width: 680, height: 450)
11691174
window.contentViewController = NSHostingController(rootView: SettingsView())
11701175
settingsWindowController = NSWindowController(window: window)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import AppKit
2+
3+
/// Custom NSWindow subclass for the Settings window.
4+
///
5+
/// Adds two things over a plain NSWindow:
6+
/// 1. Responds to the `close:` action sent by Ghostty's "Close" menu item
7+
/// (which maps to `close_surface`). Terminal views handle this natively,
8+
/// but non-terminal windows like Settings need to handle it explicitly.
9+
/// NSWindow.close() is ObjC selector `close` (no colon), so `close:`
10+
/// (with colon) is a distinct selector and doesn't conflict.
11+
class SettingsWindow: NSWindow {
12+
@objc(close:) func closeFromMenu(_ sender: Any?) {
13+
performClose(sender)
14+
}
15+
}

0 commit comments

Comments
 (0)