From bc50714ce9388a2756f0d835c8509f2b1918650c Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Wed, 29 Apr 2026 19:48:24 +0200 Subject: [PATCH 1/7] macOS: provide means to restore menu shortcuts --- macos/Sources/App/macOS/AppDelegate.swift | 12 ++++++++++ macos/Sources/App/macOS/MainMenu.xib | 15 ++++-------- .../Ghostty/Ghostty.MenuShortcutManager.swift | 23 +++++++++++++++++++ 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index a971df9ba..038eda1c5 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -1128,6 +1128,18 @@ extension AppDelegate { self.menuFindParent?.setImageIfDesired(systemSymbolName: "text.page.badge.magnifyingglass") } + /// Save restorable menu items for later + /// + /// If you plan to add more items here, make sure you add the default shortcut in MainMenu.xib + @MainActor private func saveRestorableMenuItems() { + [ + menuUndo, menuRedo, + menuCopy, menuPaste, menuSelectAll, + ] + .compactMap { $0 } + .forEach(menuShortcutManager.saveRestorableMenuItem(_:)) + } + /// Sync all of our menu item keyboard shortcuts with the Ghostty configuration. @MainActor private func syncMenuShortcuts(_ config: Ghostty.Config) { guard ghostty.readiness == .ready else { return } diff --git a/macos/Sources/App/macOS/MainMenu.xib b/macos/Sources/App/macOS/MainMenu.xib index 30cd985db..60413559b 100644 --- a/macos/Sources/App/macOS/MainMenu.xib +++ b/macos/Sources/App/macOS/MainMenu.xib @@ -223,27 +223,23 @@ - - + - - + - - + - - + @@ -254,8 +250,7 @@ - - + diff --git a/macos/Sources/Ghostty/Ghostty.MenuShortcutManager.swift b/macos/Sources/Ghostty/Ghostty.MenuShortcutManager.swift index d7145745f..b0d1b255a 100644 --- a/macos/Sources/Ghostty/Ghostty.MenuShortcutManager.swift +++ b/macos/Sources/Ghostty/Ghostty.MenuShortcutManager.swift @@ -13,6 +13,29 @@ extension Ghostty { /// If multiple items map to the same shortcut, the most recent one wins. private var menuItemsByShortcut: [MenuShortcutKey: Weak] = [:] + /// Original shortcut configured in xib indexed by their action + private var restorableMenuItemsByOriginalShortcut: [MenuShortcutKey: Weak] = [:] + + func saveRestorableMenuItem(_ item: NSMenuItem) { + guard + let key = MenuShortcutKey(item) + else { + return + } + // Later registrations intentionally override earlier ones for the same key. + restorableMenuItemsByOriginalShortcut[key] = .init(item) + } + + /// Restore shortcuts for the items that are registered + /// + /// - Important: the item is only restored when the current shortcut is empty + func restoreMenuShortcuts() { + for (key, item) in restorableMenuItemsByOriginalShortcut where item.value?.keyEquivalent.isEmpty == true { + item.value?.keyEquivalent = key.keyEquivalent + item.value?.keyEquivalentModifierMask = key.modifierFlags + } + } + /// Reset our shortcut index since we're about to rebuild all menu bindings. func reset() { menuItemsByShortcut.removeAll(keepingCapacity: true) From 72f4983b8abc9a6f576f1cfda68f028e94996b5e Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Wed, 29 Apr 2026 21:11:21 +0200 Subject: [PATCH 2/7] macOS: restore menu shortcuts for non terminal first responders --- macos/Sources/App/macOS/AppDelegate.swift | 51 ++++++++++++++++++- .../Surface View/SurfaceView_AppKit.swift | 8 ++- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 038eda1c5..4bdbd247f 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -1,4 +1,5 @@ import AppKit +import Combine import SwiftUI import UserNotifications import OSLog @@ -154,6 +155,10 @@ class AppDelegate: NSObject, private let appIconUpdater = AppIconUpdater() @MainActor private lazy var menuShortcutManager = Ghostty.MenuShortcutManager() + /// A signal to trigger restoration for shortcuts of registered menus, like copy and paste + let restoreShortcutsRequest = PassthroughSubject() + /// A throttle observer for the signal above + private var resetMenuObserver: Any? override init() { #if DEBUG @@ -209,6 +214,8 @@ class AppDelegate: NSObject, toggleSecureInput(self) } + saveRestorableMenuItems() + // Initial config loading ghosttyConfigDidChange(config: ghostty.config) @@ -614,8 +621,11 @@ class AppDelegate: NSObject, return event } + @MainActor @objc private func windowDidBecomeKey(_ notification: Notification) { - syncFloatOnTopMenu(notification.object as? NSWindow) + let window = notification.object as? NSWindow + syncFloatOnTopMenu(window) + restoreRegisteredMenusIfNeeded(for: window) } @objc private func quickTerminalDidChangeVisibility(_ notification: Notification) { @@ -1138,6 +1148,17 @@ extension AppDelegate { ] .compactMap { $0 } .forEach(menuShortcutManager.saveRestorableMenuItem(_:)) + + resetMenuObserver = restoreShortcutsRequest + .throttle(for: .seconds(0.5), scheduler: DispatchQueue.main, latest: false) + .sink { [weak self] in + guard let self else { return } + // We need to check the first responder again, + // because a request could be fired multiple time in a short time. + // It's hard for us to filter them out, + // but firstResponder will be updated correctly + restoreRegisteredMenusIfNeeded(for: nil) + } } /// Sync all of our menu item keyboard shortcuts with the Ghostty configuration. @@ -1216,6 +1237,34 @@ extension AppDelegate { menuShortcutManager.syncMenuShortcut(config, action: action, menuItem: menuItem) } + @MainActor private func restoreRegisteredMenusIfNeeded(for window: NSWindow?) { + guard let window = window ?? NSApp.keyWindow else { + return + } + guard + window is TerminalWindow || window is QuickTerminalWindow, + window.firstResponder is Ghostty.SurfaceView + else { + // Restore for: + // 1. About Window + // 2. Alert modal + // 3. ConfigurationErrors + // 4. InlineTitleEditor + // 5. SearchOverlay + // 6. CommandPalette + // 7. Help search + menuShortcutManager.restoreMenuShortcuts() + return + } + // If it's a terminal window with surface focused, + // then we re-sync the menu shortcuts + syncMenuShortcuts(ghostty.config) + + // For cases like after closing About which is the last window, + // the restore shortcuts will stays there and most of them should be disabled or no-op. + // The next time a terminal window is open, the shortcuts will be updated + } + @MainActor func performGhosttyBindingMenuKeyEquivalent(with event: NSEvent) -> Bool { menuShortcutManager.performGhosttyBindingMenuKeyEquivalent(with: event) } diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift index f631c2c05..adb7334cc 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift @@ -786,16 +786,20 @@ extension Ghostty { override func becomeFirstResponder() -> Bool { let result = super.becomeFirstResponder() if result { focusDidChange(true) } + (NSApp.delegate as? AppDelegate)? + .restoreShortcutsRequest + .send() return result } override func resignFirstResponder() -> Bool { let result = super.resignFirstResponder() - // We sometimes call this manually (see SplitView) as a way to force us to // yield our focus state. if result { focusDidChange(false) } - + (NSApp.delegate as? AppDelegate)? + .restoreShortcutsRequest + .send() return result } From 91f9152d34ac8c95793f7d19f0ca666d69493a3c Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Sun, 29 Mar 2026 13:57:23 +0200 Subject: [PATCH 3/7] macOS: add cut menu --- macos/Sources/App/macOS/AppDelegate.swift | 8 ++++++-- macos/Sources/App/macOS/MainMenu.xib | 6 ++++++ macos/Sources/Ghostty/Ghostty.Config.swift | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 4bdbd247f..320eb0781 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -40,6 +40,7 @@ class AppDelegate: NSObject, @IBOutlet private var menuUndo: NSMenuItem? @IBOutlet private var menuRedo: NSMenuItem? + @IBOutlet private var menuCut: NSMenuItem? @IBOutlet private var menuCopy: NSMenuItem? @IBOutlet private var menuPaste: NSMenuItem? @IBOutlet private var menuPasteSelection: NSMenuItem? @@ -1144,6 +1145,7 @@ extension AppDelegate { @MainActor private func saveRestorableMenuItems() { [ menuUndo, menuRedo, + menuCut, menuCopy, menuPaste, menuSelectAll, ] .compactMap { $0 } @@ -1185,6 +1187,7 @@ extension AppDelegate { syncMenuShortcut(config, action: "undo", menuItem: self.menuUndo) syncMenuShortcut(config, action: "redo", menuItem: self.menuRedo) + syncMenuShortcut(config, action: nil, menuItem: self.menuCut) syncMenuShortcut(config, action: "copy_to_clipboard", menuItem: self.menuCopy) syncMenuShortcut(config, action: "paste_from_clipboard", menuItem: self.menuPaste) syncMenuShortcut(config, action: "paste_from_selection", menuItem: self.menuPasteSelection) @@ -1233,7 +1236,7 @@ extension AppDelegate { reloadDockMenu() } - @MainActor private func syncMenuShortcut(_ config: Ghostty.Config, action: String, menuItem: NSMenuItem?) { + @MainActor private func syncMenuShortcut(_ config: Ghostty.Config, action: String?, menuItem: NSMenuItem?) { menuShortcutManager.syncMenuShortcut(config, action: action, menuItem: menuItem) } @@ -1346,7 +1349,8 @@ extension AppDelegate: NSMenuItemValidation { item.title = "Redo" } return undoManager.canRedo - + case menuCut?.action: + return false default: return true } diff --git a/macos/Sources/App/macOS/MainMenu.xib b/macos/Sources/App/macOS/MainMenu.xib index 60413559b..2ec221ba7 100644 --- a/macos/Sources/App/macOS/MainMenu.xib +++ b/macos/Sources/App/macOS/MainMenu.xib @@ -25,6 +25,7 @@ + @@ -234,6 +235,11 @@ + + + + + diff --git a/macos/Sources/Ghostty/Ghostty.Config.swift b/macos/Sources/Ghostty/Ghostty.Config.swift index 9b094f21c..18d767207 100644 --- a/macos/Sources/Ghostty/Ghostty.Config.swift +++ b/macos/Sources/Ghostty/Ghostty.Config.swift @@ -116,8 +116,8 @@ extension Ghostty { /// configuration would be "quit" action. /// /// Returns nil if there is no key equivalent for the given action. - func keyboardShortcut(for action: String) -> KeyboardShortcut? { - guard let cfg = self.config else { return nil } + func keyboardShortcut(for action: String?) -> KeyboardShortcut? { + guard let action, let cfg = self.config else { return nil } let trigger = ghostty_config_trigger(cfg, action, UInt(action.lengthOfBytes(using: .utf8))) return Ghostty.keyboardShortcut(for: trigger) From 7e8c77d1ac9a85db08c1866781e5c20dd9a5d36a Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Fri, 1 May 2026 18:08:13 +0200 Subject: [PATCH 4/7] macOS: restore and re-sync only restorable menu items --- macos/Sources/App/macOS/AppDelegate.swift | 15 +++++----- .../Ghostty/Ghostty.MenuShortcutManager.swift | 29 +++++++++++++++---- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 320eb0781..9f4a7a68b 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -1144,12 +1144,13 @@ extension AppDelegate { /// If you plan to add more items here, make sure you add the default shortcut in MainMenu.xib @MainActor private func saveRestorableMenuItems() { [ - menuUndo, menuRedo, - menuCut, - menuCopy, menuPaste, menuSelectAll, - ] - .compactMap { $0 } - .forEach(menuShortcutManager.saveRestorableMenuItem(_:)) + (menuUndo, "undo"), + (menuRedo, "redo"), + (menuCut, nil), + (menuCopy, "copy_to_clipboard"), + (menuPaste, "paste_from_clipboard"), + (menuSelectAll, "select_all"), + ].forEach(menuShortcutManager.saveRestorableMenuItem(_:action:)) resetMenuObserver = restoreShortcutsRequest .throttle(for: .seconds(0.5), scheduler: DispatchQueue.main, latest: false) @@ -1261,7 +1262,7 @@ extension AppDelegate { } // If it's a terminal window with surface focused, // then we re-sync the menu shortcuts - syncMenuShortcuts(ghostty.config) + menuShortcutManager.reSyncRestoredMenuShortcuts(config: ghostty.config) // For cases like after closing About which is the last window, // the restore shortcuts will stays there and most of them should be disabled or no-op. diff --git a/macos/Sources/Ghostty/Ghostty.MenuShortcutManager.swift b/macos/Sources/Ghostty/Ghostty.MenuShortcutManager.swift index b0d1b255a..6bbfa0f51 100644 --- a/macos/Sources/Ghostty/Ghostty.MenuShortcutManager.swift +++ b/macos/Sources/Ghostty/Ghostty.MenuShortcutManager.swift @@ -14,28 +14,45 @@ extension Ghostty { private var menuItemsByShortcut: [MenuShortcutKey: Weak] = [:] /// Original shortcut configured in xib indexed by their action - private var restorableMenuItemsByOriginalShortcut: [MenuShortcutKey: Weak] = [:] + private var restorableMenuItemsByOriginalShortcut: [MenuShortcutKey: (Weak, String?)] = [:] - func saveRestorableMenuItem(_ item: NSMenuItem) { + private var menuItemsRestored = [(Weak, String?)]() + + func saveRestorableMenuItem(_ item: NSMenuItem?, action ghosttyAction: String?) { guard + let item, let key = MenuShortcutKey(item) else { return } // Later registrations intentionally override earlier ones for the same key. - restorableMenuItemsByOriginalShortcut[key] = .init(item) + restorableMenuItemsByOriginalShortcut[key] = (.init(item), ghosttyAction) } /// Restore shortcuts for the items that are registered /// /// - Important: the item is only restored when the current shortcut is empty func restoreMenuShortcuts() { - for (key, item) in restorableMenuItemsByOriginalShortcut where item.value?.keyEquivalent.isEmpty == true { - item.value?.keyEquivalent = key.keyEquivalent - item.value?.keyEquivalentModifierMask = key.modifierFlags + menuItemsRestored.removeAll() + for (key, item) in restorableMenuItemsByOriginalShortcut { + if let menuItem = item.0.value, menuItem.keyEquivalent.isEmpty { + menuItem.keyEquivalent = key.keyEquivalent + menuItem.keyEquivalentModifierMask = key.modifierFlags + menuItemsRestored.append(item) + } } } + /// Re-sync shortcuts for the items that are restored + func reSyncRestoredMenuShortcuts(config: Ghostty.Config) { + for item in menuItemsRestored { + if let menuItem = item.0.value { + syncMenuShortcut(config, action: item.1, menuItem: menuItem) + } + } + menuItemsRestored.removeAll() + } + /// Reset our shortcut index since we're about to rebuild all menu bindings. func reset() { menuItemsByShortcut.removeAll(keepingCapacity: true) From b4de3da554c5d791d0b3c18ef85f28123321d06c Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Fri, 1 May 2026 18:09:30 +0200 Subject: [PATCH 5/7] macOS: fix menu restoration after reload --- macos/Sources/App/macOS/AppDelegate.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 9f4a7a68b..fc516c72f 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -1233,6 +1233,9 @@ extension AppDelegate { // // syncMenuShortcut(config, action: "toggle_fullscreen", menuItem: self.menuToggleFullScreen) + // Restore the restorable menu shortcuts if needed + restoreShortcutsRequest.send() + // Dock menu reloadDockMenu() } From 968ca02a081e80d72606944c7a6dfefd260d233d Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Sun, 3 May 2026 09:49:56 +0200 Subject: [PATCH 6/7] macOS: restore menu shortcuts based on first responder --- macos/Sources/App/macOS/AppDelegate.swift | 77 ++++++++----------- .../Surface View/SurfaceView_AppKit.swift | 6 -- 2 files changed, 31 insertions(+), 52 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index fc516c72f..56946eeaf 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -156,9 +156,7 @@ class AppDelegate: NSObject, private let appIconUpdater = AppIconUpdater() @MainActor private lazy var menuShortcutManager = Ghostty.MenuShortcutManager() - /// A signal to trigger restoration for shortcuts of registered menus, like copy and paste - let restoreShortcutsRequest = PassthroughSubject() - /// A throttle observer for the signal above + /// A observer for resetting menu shortcuts based on firstResponder private var resetMenuObserver: Any? override init() { @@ -215,7 +213,7 @@ class AppDelegate: NSObject, toggleSecureInput(self) } - saveRestorableMenuItems() + setupRestorableMenuItems() // Initial config loading ghosttyConfigDidChange(config: ghostty.config) @@ -626,7 +624,6 @@ class AppDelegate: NSObject, @objc private func windowDidBecomeKey(_ notification: Notification) { let window = notification.object as? NSWindow syncFloatOnTopMenu(window) - restoreRegisteredMenusIfNeeded(for: window) } @objc private func quickTerminalDidChangeVisibility(_ notification: Notification) { @@ -1139,10 +1136,10 @@ extension AppDelegate { self.menuFindParent?.setImageIfDesired(systemSymbolName: "text.page.badge.magnifyingglass") } - /// Save restorable menu items for later + /// Save restorable menu items and restore them whenever the first responder is not a terminal surface /// /// If you plan to add more items here, make sure you add the default shortcut in MainMenu.xib - @MainActor private func saveRestorableMenuItems() { + @MainActor private func setupRestorableMenuItems() { [ (menuUndo, "undo"), (menuRedo, "redo"), @@ -1152,15 +1149,34 @@ extension AppDelegate { (menuSelectAll, "select_all"), ].forEach(menuShortcutManager.saveRestorableMenuItem(_:action:)) - resetMenuObserver = restoreShortcutsRequest - .throttle(for: .seconds(0.5), scheduler: DispatchQueue.main, latest: false) - .sink { [weak self] in + // The reason we're using publisher here instead of `windowDidBecomeKey` + // is that we want reset the observer whenever the key window is changed. + // + // I had a case where help menu's window becomes key with terminal window opened then moving away from help menu doesn't trigger another notification. + resetMenuObserver = NSApp.publisher(for: \.keyWindow) + .flatMap { + $0?.publisher(for: \.firstResponder, options: [.new]) + .map { $0 is Ghostty.SurfaceView } + .eraseToAnyPublisher() ?? + Just(true).eraseToAnyPublisher() + // When the keyWindow is nil, we want to re-sync them + } + .removeDuplicates() + .sink { [weak self] isSurfaceFocused in guard let self else { return } - // We need to check the first responder again, - // because a request could be fired multiple time in a short time. - // It's hard for us to filter them out, - // but firstResponder will be updated correctly - restoreRegisteredMenusIfNeeded(for: nil) + if isSurfaceFocused { + menuShortcutManager.reSyncRestoredMenuShortcuts(config: ghostty.config) + } else { + // Restore for non terminal responders, like: + // 1. About Window + // 2. Alert modal + // 3. ConfigurationErrors + // 4. InlineTitleEditor + // 5. SearchOverlay + // 6. CommandPalette + // 7. Help search + menuShortcutManager.restoreMenuShortcuts() + } } } @@ -1233,9 +1249,6 @@ extension AppDelegate { // // syncMenuShortcut(config, action: "toggle_fullscreen", menuItem: self.menuToggleFullScreen) - // Restore the restorable menu shortcuts if needed - restoreShortcutsRequest.send() - // Dock menu reloadDockMenu() } @@ -1244,34 +1257,6 @@ extension AppDelegate { menuShortcutManager.syncMenuShortcut(config, action: action, menuItem: menuItem) } - @MainActor private func restoreRegisteredMenusIfNeeded(for window: NSWindow?) { - guard let window = window ?? NSApp.keyWindow else { - return - } - guard - window is TerminalWindow || window is QuickTerminalWindow, - window.firstResponder is Ghostty.SurfaceView - else { - // Restore for: - // 1. About Window - // 2. Alert modal - // 3. ConfigurationErrors - // 4. InlineTitleEditor - // 5. SearchOverlay - // 6. CommandPalette - // 7. Help search - menuShortcutManager.restoreMenuShortcuts() - return - } - // If it's a terminal window with surface focused, - // then we re-sync the menu shortcuts - menuShortcutManager.reSyncRestoredMenuShortcuts(config: ghostty.config) - - // For cases like after closing About which is the last window, - // the restore shortcuts will stays there and most of them should be disabled or no-op. - // The next time a terminal window is open, the shortcuts will be updated - } - @MainActor func performGhosttyBindingMenuKeyEquivalent(with event: NSEvent) -> Bool { menuShortcutManager.performGhosttyBindingMenuKeyEquivalent(with: event) } diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift index adb7334cc..540f31ac3 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift @@ -786,9 +786,6 @@ extension Ghostty { override func becomeFirstResponder() -> Bool { let result = super.becomeFirstResponder() if result { focusDidChange(true) } - (NSApp.delegate as? AppDelegate)? - .restoreShortcutsRequest - .send() return result } @@ -797,9 +794,6 @@ extension Ghostty { // We sometimes call this manually (see SplitView) as a way to force us to // yield our focus state. if result { focusDidChange(false) } - (NSApp.delegate as? AppDelegate)? - .restoreShortcutsRequest - .send() return result } From b2835f2f7d6a3e9d6d867cfba22e3cdc19421003 Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Sun, 3 May 2026 09:58:56 +0200 Subject: [PATCH 7/7] macOS: revert some changes --- macos/Sources/App/macOS/AppDelegate.swift | 4 +--- macos/Sources/Ghostty/Ghostty.Config.swift | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 56946eeaf..e84f19e32 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -620,10 +620,8 @@ class AppDelegate: NSObject, return event } - @MainActor @objc private func windowDidBecomeKey(_ notification: Notification) { - let window = notification.object as? NSWindow - syncFloatOnTopMenu(window) + syncFloatOnTopMenu(notification.object as? NSWindow) } @objc private func quickTerminalDidChangeVisibility(_ notification: Notification) { diff --git a/macos/Sources/Ghostty/Ghostty.Config.swift b/macos/Sources/Ghostty/Ghostty.Config.swift index 18d767207..9b094f21c 100644 --- a/macos/Sources/Ghostty/Ghostty.Config.swift +++ b/macos/Sources/Ghostty/Ghostty.Config.swift @@ -116,8 +116,8 @@ extension Ghostty { /// configuration would be "quit" action. /// /// Returns nil if there is no key equivalent for the given action. - func keyboardShortcut(for action: String?) -> KeyboardShortcut? { - guard let action, let cfg = self.config else { return nil } + func keyboardShortcut(for action: String) -> KeyboardShortcut? { + guard let cfg = self.config else { return nil } let trigger = ghostty_config_trigger(cfg, action, UInt(action.lengthOfBytes(using: .utf8))) return Ghostty.keyboardShortcut(for: trigger)