@@ -404,9 +404,7 @@ class AppDelegate: NSObject,
404
404
}
405
405
406
406
func applicationDidUpdate( _ notification: Notification ) {
407
- guard derivedConfig. shouldSwitchBetweenActivationPolicies else { return }
408
- // Are we presenting any regular windows ?
409
- NSApp . setActivationPolicy ( NSApp . visibleRegularWindows. isEmpty ? . accessory : . regular)
407
+ syncActivationPolicy ( )
410
408
}
411
409
412
410
/// Syncs a single menu shortcut for the given action. The action string is the same
@@ -540,16 +538,7 @@ class AppDelegate: NSObject,
540
538
DispatchQueue . main. async { self . syncAppearance ( config: config) }
541
539
542
540
// Decide whether to hide/unhide app from dock and app switcher
543
- switch ( config. macosHidden) {
544
- case . never:
545
- NSApp . setActivationPolicy ( . regular)
546
-
547
- case . always:
548
- NSApp . setActivationPolicy ( . accessory)
549
-
550
- case . quick_terminal:
551
- NSApp . setActivationPolicy ( NSApp . visibleRegularWindows. isEmpty ? . accessory : . regular)
552
- }
541
+ syncActivationPolicy ( )
553
542
554
543
// If we have configuration errors, we need to show them.
555
544
let c = ConfigurationErrorsController . sharedInstance
@@ -625,6 +614,20 @@ class AppDelegate: NSObject,
625
614
NSApplication . shared. appearance = . init( ghosttyConfig: config)
626
615
}
627
616
617
+ /// Sync the app activation policy based on the config `MacHidden` value.
618
+ private func syncActivationPolicy( ) {
619
+ switch ( derivedConfig. macosHidden) {
620
+ case . never:
621
+ NSApp . setActivationPolicy ( . regular)
622
+
623
+ case . always:
624
+ NSApp . setActivationPolicy ( . accessory)
625
+
626
+ case . quick_terminal:
627
+ NSApp . setActivationPolicy ( NSApp . visibleRegularWindows. isEmpty ? . accessory : . regular)
628
+ }
629
+ }
630
+
628
631
//MARK: - Restorable State
629
632
630
633
/// We support NSSecureCoding for restorable state. Required as of macOS Sonoma (14) but a good idea anyways.
@@ -795,20 +798,20 @@ class AppDelegate: NSObject,
795
798
let initialWindow : Bool
796
799
let shouldQuitAfterLastWindowClosed : Bool
797
800
let quickTerminalPosition : QuickTerminalPosition
798
- let shouldSwitchBetweenActivationPolicies : Bool
801
+ let macosHidden : Ghostty . Config . MacHidden
799
802
800
803
init ( ) {
801
804
self . initialWindow = true
802
805
self . shouldQuitAfterLastWindowClosed = false
803
806
self . quickTerminalPosition = . top
804
- self . shouldSwitchBetweenActivationPolicies = false
807
+ self . macosHidden = . never
805
808
}
806
809
807
810
init ( _ config: Ghostty . Config ) {
808
811
self . initialWindow = config. initialWindow
809
812
self . shouldQuitAfterLastWindowClosed = config. shouldQuitAfterLastWindowClosed
810
813
self . quickTerminalPosition = config. quickTerminalPosition
811
- self . shouldSwitchBetweenActivationPolicies = config. macosHidden == . quick_terminal
814
+ self . macosHidden = config. macosHidden
812
815
}
813
816
}
814
817
0 commit comments