fix(core): fix window.center panic when window size > screen, closes #2978 (#3002)

This commit is contained in:
Amr Bashir 2021-12-09 05:21:29 +02:00 committed by GitHub
parent 1e336b6872
commit 76ce9f61dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-runtime-wry": patch
---
Fix `window.center` panic when window size is bigger than screen size.

View File

@ -2476,8 +2476,8 @@ fn on_window_close<'a>(
fn center_window(window: &Window, window_size: WryPhysicalSize<u32>) -> Result<()> {
if let Some(monitor) = window.current_monitor() {
let screen_size = monitor.size();
let x = (screen_size.width - window_size.width) / 2;
let y = (screen_size.height - window_size.height) / 2;
let x = (screen_size.width as i32 - window_size.width as i32) / 2;
let y = (screen_size.height as i32 - window_size.height as i32) / 2;
window.set_outer_position(WryPhysicalPosition::new(x, y));
Ok(())
} else {