mirror of
https://github.com/nimbold/Firelink.git
synced 2026-09-01 13:38:01 +00:00
fix(startup): avoid reentrant Windows focus (#37)
- Keep the main WebView2 window unfocused during native construction. - Remove the synchronous post-build focus request that caused the Windows stack overflow. - Refs #37.
This commit is contained in:
+5
-12
@@ -18518,22 +18518,15 @@ pub fn run() {
|
||||
// newly-created host window is not focusable yet. Wry
|
||||
// propagates that error from WebviewWindowBuilder::build,
|
||||
// which destroys the native window and makes a release build
|
||||
// look like it started headlessly before exiting. Focus the
|
||||
// window only after WebView2 has been created successfully.
|
||||
// look like it started headlessly before exiting. Leave the
|
||||
// window unfocused until Windows has completed native
|
||||
// activation; a synchronous post-build focus request can
|
||||
// re-enter the WebView2 focus callback on affected systems.
|
||||
main_window_builder = main_window_builder.focused(false);
|
||||
}
|
||||
let main_window = main_window_builder
|
||||
main_window_builder
|
||||
.build()
|
||||
.map_err(|error| format!("failed to create main window: {error}"))?;
|
||||
#[cfg(target_os = "windows")]
|
||||
if let Err(error) = main_window.set_focus() {
|
||||
// The window is already usable if the OS declines this
|
||||
// best-effort activation request. A later user interaction
|
||||
// can focus it without risking startup failure.
|
||||
log::warn!("could not focus the main window after startup: {error}");
|
||||
}
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let _ = main_window;
|
||||
restore_pending_main_window(app.handle());
|
||||
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
|
||||
Reference in New Issue
Block a user