@@ -195,9 +195,9 @@ public static void SetTheme(string theme, string themeOverridesFile)
195
195
}
196
196
}
197
197
198
- public static void SetupTrayIcon ( bool enable )
198
+ public void SetupTrayIcon ( bool enable )
199
199
{
200
- if ( enable )
200
+ if ( enable && Native . OS . EnsureSingleInstance ( ) )
201
201
{
202
202
var icons = new TrayIcons {
203
203
new TrayIcon {
@@ -212,6 +212,7 @@ public static void SetupTrayIcon(bool enable)
212
212
} ;
213
213
icons [ 0 ] . Clicked += ( _ , _ ) => ToggleWindow ( ) ;
214
214
TrayIcon . SetIcons ( Current , icons ) ;
215
+ _createdSystemTrayIcon = true ;
215
216
}
216
217
}
217
218
@@ -588,11 +589,11 @@ private void TryLaunchedAsNormal(IClassicDesktopStyleApplicationLifetime desktop
588
589
startupRepo = desktop . Args [ 0 ] ;
589
590
590
591
var pref = ViewModels . Preference . Instance ;
591
- if ( pref . SystemTrayIcon ) {
592
+ if ( _createdSystemTrayIcon ) {
592
593
desktop . ShutdownMode = ShutdownMode . OnExplicitShutdown ;
593
594
}
594
595
595
- _launcher = new ViewModels . Launcher ( startupRepo ) ;
596
+ _launcher = new ViewModels . Launcher ( startupRepo , _createdSystemTrayIcon ) ;
596
597
desktop . MainWindow = new Views . Launcher ( ) { DataContext = _launcher } ;
597
598
598
599
#if ! DISABLE_UPDATE_DETECTION
@@ -605,5 +606,6 @@ private void TryLaunchedAsNormal(IClassicDesktopStyleApplicationLifetime desktop
605
606
private ResourceDictionary _activeLocale = null ;
606
607
private ResourceDictionary _themeOverrides = null ;
607
608
private ResourceDictionary _fontsOverrides = null ;
609
+ private bool _createdSystemTrayIcon = false ;
608
610
}
609
611
}
0 commit comments