Skip to content

Commit 7040ff3

Browse files
aboseclaude
andcommitted
fix: use inner_size on Windows to prevent window growing on each restart
On Windows, set_size() sets the client area but outer_size() includes decorations, causing the window to grow by the decoration size on each save/restore cycle. Use inner_size() on Windows for consistent round-trip. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent aab53fa commit 7040ff3

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src-tauri/src/main.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,24 @@ fn process_window_event(event: &GlobalWindowEvent, trust_state: &State<WindowAes
359359
Ok(pos) => (pos.x, pos.y),
360360
Err(_) => (0, 0),
361361
};
362-
let (width, height) = match window.outer_size() {
363-
Ok(size) => (size.width, size.height),
364-
Err(_) => (0, 0),
362+
// On Windows, set_size() sets the inner (client) area, so we must save
363+
// inner_size() to avoid the window growing by the decoration size on each restart.
364+
// On macOS, outer_size()/set_size() are consistent, so we keep outer_size().
365+
let (width, height) = {
366+
#[cfg(target_os = "windows")]
367+
{
368+
match window.inner_size() {
369+
Ok(size) => (size.width, size.height),
370+
Err(_) => (0, 0),
371+
}
372+
}
373+
#[cfg(not(target_os = "windows"))]
374+
{
375+
match window.outer_size() {
376+
Ok(size) => (size.width, size.height),
377+
Err(_) => (0, 0),
378+
}
379+
}
365380
};
366381
boot_config::write_boot_config(1, x, y, width, height, maximized);
367382
}

0 commit comments

Comments
 (0)