@@ -195,9 +195,9 @@ public static void SetTheme(string theme, string themeOverridesFile)
195195 }
196196 }
197197
198- public static void SetupTrayIcon ( bool enable )
198+ public void SetupTrayIcon ( bool enable )
199199 {
200- if ( enable )
200+ if ( enable && Native . OS . EnsureSingleInstance ( ) )
201201 {
202202 var icons = new TrayIcons {
203203 new TrayIcon {
@@ -212,6 +212,7 @@ public static void SetupTrayIcon(bool enable)
212212 } ;
213213 icons [ 0 ] . Clicked += ( _ , _ ) => ToggleWindow ( ) ;
214214 TrayIcon . SetIcons ( Current , icons ) ;
215+ _createdSystemTrayIcon = true ;
215216 }
216217 }
217218
@@ -588,11 +589,11 @@ private void TryLaunchedAsNormal(IClassicDesktopStyleApplicationLifetime desktop
588589 startupRepo = desktop . Args [ 0 ] ;
589590
590591 var pref = ViewModels . Preference . Instance ;
591- if ( pref . SystemTrayIcon ) {
592+ if ( _createdSystemTrayIcon ) {
592593 desktop . ShutdownMode = ShutdownMode . OnExplicitShutdown ;
593594 }
594595
595- _launcher = new ViewModels . Launcher ( startupRepo ) ;
596+ _launcher = new ViewModels . Launcher ( startupRepo , _createdSystemTrayIcon ) ;
596597 desktop . MainWindow = new Views . Launcher ( ) { DataContext = _launcher } ;
597598
598599#if ! DISABLE_UPDATE_DETECTION
@@ -605,5 +606,6 @@ private void TryLaunchedAsNormal(IClassicDesktopStyleApplicationLifetime desktop
605606 private ResourceDictionary _activeLocale = null ;
606607 private ResourceDictionary _themeOverrides = null ;
607608 private ResourceDictionary _fontsOverrides = null ;
609+ private bool _createdSystemTrayIcon = false ;
608610 }
609611}
0 commit comments