fix(startup): defer Windows window activation (#37)

- Keep the Windows WebView host hidden and unfocused during native construction.\n- Queue deep-link, torrent, single-instance, and extension restore requests until Tauri is ready.\n- Reveal and focus the main window through one startup-safe path.\n\nFixes #37.
This commit is contained in:
NimBold
2026-08-27 17:00:57 +03:30
parent 8163e2241a
commit 9c0ba106d6
2 changed files with 49 additions and 29 deletions
+10 -12
View File
@@ -308,18 +308,16 @@ async fn download_handler(
None => return Err(StatusCode::BAD_REQUEST),
};
if let Some(window) = state.app_handle.get_webview_window("main") {
let is_visible = window.is_visible().unwrap_or(true);
if !is_visible {
let _ = window.show();
let _ = window.set_focus();
// Sleep briefly to let the webview wake up from macOS App Nap
// otherwise the IPC event emitted immediately after is dropped.
tokio::time::sleep(std::time::Duration::from_millis(300)).await;
} else {
let _ = window.show();
let _ = window.set_focus();
}
let is_hidden = state
.app_handle
.get_webview_window("main")
.and_then(|window| window.is_visible().ok())
.is_some_and(|is_visible| !is_visible);
crate::restore_main_window(&state.app_handle);
if is_hidden {
// Sleep briefly to let the webview wake up from macOS App Nap
// otherwise the IPC event emitted immediately after is dropped.
tokio::time::sleep(std::time::Duration::from_millis(300)).await;
}
if !wait_for_frontend(&state.frontend_ready).await {