Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4884,13 +4884,14 @@ fn build_main_window<R: tauri::Runtime>(app: &tauri::AppHandle<R>) -> tauri::Res
#[cfg(target_os = "macos")]
let builder = builder.traffic_light_position(TRAFFIC_LIGHTS);
/*
* Hidden until it is where it belongs. `tauri_plugin_window_state` puts it back at the size and
* place it had as it is built, and `fit_main_window_to_screen` brings it onto a screen that is
* there; only then is it shown. Shown as built, it flashed blank at Windows' default spot for a
* moment and then jumped (52,52 to 360,90 on Windows D).
* Built visible, as the configured window always was. It was built hidden and shown once it
* was in place (to spare a reopened window a moment at the system's default spot), and on
* Windows that froze setup: the WebView2 page under a window first created hidden stopped
* taking native updates a few seconds after a download line appeared, for minutes, until the
* window was activated or clicked. `tauri_plugin_window_state` puts it back at the size and
* place it had as it is built, and `fit_main_window_to_screen` brings it onto a screen.
*/
let window = builder
.visible(false)
.on_new_window(move |destination, _features| {
outside_links::new_window(&destination, |to| {
use tauri_plugin_opener::OpenerExt;
Expand All @@ -4902,7 +4903,6 @@ fn build_main_window<R: tauri::Runtime>(app: &tauri::AppHandle<R>) -> tauri::Res
// At the level kept from the last launch before anything paints (`zoom`).
let _ = window.set_zoom(saved_zoom(app));
fit_main_window_to_screen(app);
let _ = window.show();
Ok(())
}

Expand Down Expand Up @@ -13185,15 +13185,14 @@ mod tests {
);
assert_eq!(window.label(), "main");

// Built hidden, put where it belongs, then shown: never a flash at the system's default
// spot before it moves (Windows D, reopening).
// Never built hidden: on Windows a WebView2 page under a window first created hidden
// stopped taking native updates mid-setup, for minutes, until the window was activated
// (1.0.1 release candidate). Built visible, then put on a screen.
let body = &main[main.find("fn build_main_window").unwrap()..];
let body = &body[..body.find("\n}\n").unwrap()];
let hidden = body.find(".visible(false)").expect("built hidden");
let built = body.find(".build()?").unwrap();
let fitted = body.find("fit_main_window_to_screen(app)").expect("fitted");
let shown = body.find("window.show()").expect("shown");
assert!(hidden < built && built < fitted && fitted < shown, "{body}");
assert!(!body.contains(".visible(false)"), "{body}");
assert!(!body.contains(".show()"), "{body}");
assert!(body.contains("fit_main_window_to_screen(app)"), "{body}");
assert!(window.is_visible().unwrap_or(true));
}

Expand Down
Loading