mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 19:56:08 +03:00
Merge pull request #411 from mitchellh/macos-dock-click
macos: handle reopen event and open a window if none are visible
This commit is contained in:
@ -47,6 +47,8 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, GhosttyApp
|
|||||||
windowManager = PrimaryWindowManager(ghostty: self.ghostty)
|
windowManager = PrimaryWindowManager(ghostty: self.ghostty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//MARK: - NSApplicationDelegate
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||||
// System settings overrides
|
// System settings overrides
|
||||||
UserDefaults.standard.register(defaults: [
|
UserDefaults.standard.register(defaults: [
|
||||||
@ -100,6 +102,18 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, GhosttyApp
|
|||||||
return .terminateLater
|
return .terminateLater
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This is called when the application is already open and someone double-clicks the icon
|
||||||
|
/// or clicks the dock icon.
|
||||||
|
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
||||||
|
// If we have visible windows then we allow macOS to do its default behavior
|
||||||
|
// of focusing one of them.
|
||||||
|
guard !flag else { return true }
|
||||||
|
|
||||||
|
// No visible windows, open a new one.
|
||||||
|
windowManager.newWindow()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
/// Sync all of our menu item keyboard shortcuts with the Ghostty configuration.
|
/// Sync all of our menu item keyboard shortcuts with the Ghostty configuration.
|
||||||
private func syncMenuShortcuts() {
|
private func syncMenuShortcuts() {
|
||||||
guard ghostty.config != nil else { return }
|
guard ghostty.config != nil else { return }
|
||||||
|
Reference in New Issue
Block a user