@@ -28,7 +28,7 @@ use defguard_client::{
2828 events:: handle_deep_link,
2929 periodic:: run_periodic_tasks,
3030 service,
31- tray:: { configure_tray_icon, setup_tray, show_main_window } ,
31+ tray:: { configure_tray_icon, setup_tray} ,
3232 utils:: load_log_targets,
3333 window_manager:: * ,
3434 LOG_FILENAME , VERSION ,
@@ -211,9 +211,25 @@ fn main() {
211211 } )
212212 // Initialize plugins here, except for `tauri_plugin_log` which is handled in `setup()`.
213213 // Single instance plugin should always be the first to register.
214- . plugin ( tauri_plugin_single_instance:: init ( |app, _argv, _cwd| {
215- // Running instance might be hidden, so show it.
216- show_main_window ( app) ;
214+ . plugin ( tauri_plugin_single_instance:: init ( |app, argv, _cwd| {
215+ let is_deep_link = argv. iter ( ) . any ( |a| a. starts_with ( "defguard://" ) ) ;
216+ // User tried to spawn second instance, mirror tray left click path.
217+ if !is_deep_link {
218+ #[ cfg( target_os = "linux" ) ]
219+ let _ = WindowManager :: open_full_view ( app) ;
220+
221+ #[ cfg( not( target_os = "linux" ) ) ]
222+ {
223+ let has_locations = tauri:: async_runtime:: block_on (
224+ defguard_client:: window_manager:: has_non_service_locations ( ) ,
225+ ) ;
226+ if has_locations {
227+ let _ = WindowManager :: open_tray ( app) ;
228+ } else {
229+ let _ = WindowManager :: open_full_view ( app) ;
230+ }
231+ }
232+ }
217233 } ) )
218234 . plugin ( tauri_plugin_deep_link:: init ( ) )
219235 . plugin ( tauri_plugin_dialog:: init ( ) )
0 commit comments