diff --git a/crates/tauri-runtime-wry/src/lib.rs b/crates/tauri-runtime-wry/src/lib.rs index 54305bc2f515..c114ff6163ce 100644 --- a/crates/tauri-runtime-wry/src/lib.rs +++ b/crates/tauri-runtime-wry/src/lib.rs @@ -65,10 +65,12 @@ use tao::{ UserAttentionType as TaoUserAttentionType, }, }; +#[cfg(desktop)] +use tauri_utils::config::PreventOverflowConfig; #[cfg(target_os = "macos")] use tauri_utils::TitleBarStyle; use tauri_utils::{ - config::{Color, PreventOverflowConfig, WindowConfig}, + config::{Color, WindowConfig}, Theme, }; use url::Url; diff --git a/crates/tauri-runtime-wry/src/window/mod.rs b/crates/tauri-runtime-wry/src/window/mod.rs index 612bd69a1787..3be499e65c02 100644 --- a/crates/tauri-runtime-wry/src/window/mod.rs +++ b/crates/tauri-runtime-wry/src/window/mod.rs @@ -61,11 +61,23 @@ pub fn calculate_window_center_position( window_size: tao::dpi::PhysicalSize, target_monitor: tao::monitor::MonitorHandle, ) -> tao::dpi::PhysicalPosition { - use crate::monitor::MonitorExt; + let size: tao::dpi::PhysicalSize; + let position: tao::dpi::PhysicalPosition; + #[cfg(desktop)] + { + use crate::monitor::MonitorExt; + let work_area = target_monitor.work_area(); + size = work_area.size; + position = work_area.position; + } + #[cfg(mobile)] + { + size = target_monitor.size(); + position = target_monitor.position(); + } - let work_area = target_monitor.work_area(); tao::dpi::PhysicalPosition::new( - (work_area.size.width - window_size.width) as i32 / 2 + work_area.position.x, - (work_area.size.height - window_size.height) as i32 / 2 + work_area.position.y, + (size.width - window_size.width) as i32 / 2 + position.x, + (size.height - window_size.height) as i32 / 2 + position.y, ) }