@@ -80,29 +80,24 @@ pub fn build() -> tauri::Builder<tauri::Wry> {
8080 )
8181 . on_window_event ( |window, event| {
8282 match event {
83- WindowEvent :: CloseRequested { api, .. } => {
84- if window. label ( ) == "main" {
85- api. prevent_close ( ) ;
86- let _ = window
87- . app_handle ( )
88- . save_window_state ( StateFlags :: SIZE | StateFlags :: POSITION ) ;
89- let _ = window. hide ( ) ;
90- // On Windows, force the WebView to stay active after hiding the window
91- // so that background JS (global hotkey detection via keys_held events)
92- // continues running while the app is minimized to the system tray.
93- #[ cfg( target_os = "windows" ) ]
94- {
95- crate :: platform:: window:: keep_webview_active (
96- window. app_handle ( ) ,
97- "main" ,
98- ) ;
99- crate :: platform:: window:: set_webview_keepalive ( true ) ;
100- }
101- #[ cfg( target_os = "macos" ) ]
102- {
103- if let Err ( err) = crate :: platform:: macos:: dock:: hide_dock_icon ( ) {
104- log:: error!( "Failed to hide dock icon: {err}" ) ;
105- }
83+ WindowEvent :: CloseRequested { api, .. } if window. label ( ) == "main" => {
84+ api. prevent_close ( ) ;
85+ let _ = window
86+ . app_handle ( )
87+ . save_window_state ( StateFlags :: SIZE | StateFlags :: POSITION ) ;
88+ let _ = window. hide ( ) ;
89+ // On Windows, force the WebView to stay active after hiding the window
90+ // so that background JS (global hotkey detection via keys_held events)
91+ // continues running while the app is minimized to the system tray.
92+ #[ cfg( target_os = "windows" ) ]
93+ {
94+ crate :: platform:: window:: keep_webview_active ( window. app_handle ( ) , "main" ) ;
95+ crate :: platform:: window:: set_webview_keepalive ( true ) ;
96+ }
97+ #[ cfg( target_os = "macos" ) ]
98+ {
99+ if let Err ( err) = crate :: platform:: macos:: dock:: hide_dock_icon ( ) {
100+ log:: error!( "Failed to hide dock icon: {err}" ) ;
106101 }
107102 }
108103 }
0 commit comments