Skip to content

Commit 76ce9f6

Browse files
authored
fix(core): fix window.center panic when window size > screen, closes #2978 (#3002)
1 parent 1e336b6 commit 76ce9f6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.changes/core-center-window.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-runtime-wry": patch
3+
---
4+
5+
Fix `window.center` panic when window size is bigger than screen size.

core/tauri-runtime-wry/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2476,8 +2476,8 @@ fn on_window_close<'a>(
24762476
fn center_window(window: &Window, window_size: WryPhysicalSize<u32>) -> Result<()> {
24772477
if let Some(monitor) = window.current_monitor() {
24782478
let screen_size = monitor.size();
2479-
let x = (screen_size.width - window_size.width) / 2;
2480-
let y = (screen_size.height - window_size.height) / 2;
2479+
let x = (screen_size.width as i32 - window_size.width as i32) / 2;
2480+
let y = (screen_size.height as i32 - window_size.height as i32) / 2;
24812481
window.set_outer_position(WryPhysicalPosition::new(x, y));
24822482
Ok(())
24832483
} else {

0 commit comments

Comments
 (0)