@@ -169,9 +169,9 @@ public static void SetTheme(string theme, string themeOverridesFile)
169169 }
170170 }
171171
172- public static void SetupTrayIcon ( bool enable )
172+ public void SetupTrayIcon ( bool enable )
173173 {
174- if ( enable )
174+ if ( enable && Native . OS . EnsureSingleInstance ( ) )
175175 {
176176 var icons = new TrayIcons {
177177 new TrayIcon {
@@ -186,6 +186,7 @@ public static void SetupTrayIcon(bool enable)
186186 } ;
187187 icons [ 0 ] . Clicked += ( _ , _ ) => ToggleWindow ( ) ;
188188 TrayIcon . SetIcons ( Current , icons ) ;
189+ _createdSystemTrayIcon = true ;
189190 }
190191 }
191192
@@ -519,11 +520,11 @@ private void TryLaunchedAsNormal(IClassicDesktopStyleApplicationLifetime desktop
519520 startupRepo = desktop . Args [ 0 ] ;
520521
521522 var pref = ViewModels . Preference . Instance ;
522- if ( pref . SystemTrayIcon ) {
523+ if ( _createdSystemTrayIcon ) {
523524 desktop . ShutdownMode = ShutdownMode . OnExplicitShutdown ;
524525 }
525526
526- _launcher = new ViewModels . Launcher ( startupRepo ) ;
527+ _launcher = new ViewModels . Launcher ( startupRepo , _createdSystemTrayIcon ) ;
527528 desktop . MainWindow = new Views . Launcher ( ) { DataContext = _launcher } ;
528529
529530#if ! DISABLE_UPDATE_DETECTION
@@ -589,5 +590,6 @@ private void ShowSelfUpdateResult(object data)
589590 private ResourceDictionary _activeLocale = null ;
590591 private ResourceDictionary _themeOverrides = null ;
591592 private ResourceDictionary _fontsOverrides = null ;
593+ private bool _createdSystemTrayIcon = false ;
592594 }
593595}
0 commit comments