Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

fix(windows): center the main window on startup (#1664)

ppxbb1171ecd2365
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 303627713..1d8eefb9a 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -252,7 +252,16 @@ pub fn run() {
#[cfg(not(target_os = "linux"))]
fn window_state_flags() -> tauri_plugin_window_state::StateFlags {
use tauri_plugin_window_state::StateFlags;
- StateFlags::SIZE | StateFlags::POSITION | StateFlags::MAXIMIZED | StateFlags::FULLSCREEN
+ #[cfg(target_os = "windows")]
+ {
+ // Start at the configured size, centered, instead of restoring geometry after the
+ // window is visible (Windows briefly showed the default position before that move).
+ StateFlags::MAXIMIZED | StateFlags::FULLSCREEN
+ }
+ #[cfg(not(target_os = "windows"))]
+ {
+ StateFlags::SIZE | StateFlags::POSITION | StateFlags::MAXIMIZED | StateFlags::FULLSCREEN
+ }
}
/// Routes IDE menu items to the focused window's frontend (`executeAction`).
diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json
index 03e50cdfe..c51f9225f 100644
--- a/src-tauri/tauri.windows.conf.json
+++ b/src-tauri/tauri.windows.conf.json
@@ -7,6 +7,7 @@
"title": "OpenIDEA",
"width": 1440,
"height": 900,
+ "center": true,
"minWidth": 800,
"minHeight": 500,
"decorations": false,