@@ -169,9 +169,9 @@ public static void SetTheme(string theme, string themeOverridesFile)
169
169
}
170
170
}
171
171
172
- public static void SetupTrayIcon ( bool enable )
172
+ public void SetupTrayIcon ( bool enable )
173
173
{
174
- if ( enable )
174
+ if ( enable && Native . OS . EnsureSingleInstance ( ) )
175
175
{
176
176
var icons = new TrayIcons {
177
177
new TrayIcon {
@@ -186,6 +186,7 @@ public static void SetupTrayIcon(bool enable)
186
186
} ;
187
187
icons [ 0 ] . Clicked += ( _ , _ ) => ToggleWindow ( ) ;
188
188
TrayIcon . SetIcons ( Current , icons ) ;
189
+ _createdSystemTrayIcon = true ;
189
190
}
190
191
}
191
192
@@ -519,11 +520,11 @@ private void TryLaunchedAsNormal(IClassicDesktopStyleApplicationLifetime desktop
519
520
startupRepo = desktop . Args [ 0 ] ;
520
521
521
522
var pref = ViewModels . Preference . Instance ;
522
- if ( pref . SystemTrayIcon ) {
523
+ if ( _createdSystemTrayIcon ) {
523
524
desktop . ShutdownMode = ShutdownMode . OnExplicitShutdown ;
524
525
}
525
526
526
- _launcher = new ViewModels . Launcher ( startupRepo ) ;
527
+ _launcher = new ViewModels . Launcher ( startupRepo , _createdSystemTrayIcon ) ;
527
528
desktop . MainWindow = new Views . Launcher ( ) { DataContext = _launcher } ;
528
529
529
530
#if ! DISABLE_UPDATE_DETECTION
@@ -589,5 +590,6 @@ private void ShowSelfUpdateResult(object data)
589
590
private ResourceDictionary _activeLocale = null ;
590
591
private ResourceDictionary _themeOverrides = null ;
591
592
private ResourceDictionary _fontsOverrides = null ;
593
+ private bool _createdSystemTrayIcon = false ;
592
594
}
593
595
}
0 commit comments