Skip to content

Commit

Permalink
Fix mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master committed Jan 6, 2025
1 parent 65f4a6b commit 0103bf3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 3 additions & 1 deletion crates/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 16 additions & 4 deletions crates/tauri-runtime-wry/src/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,23 @@ pub fn calculate_window_center_position(
window_size: tao::dpi::PhysicalSize<u32>,
target_monitor: tao::monitor::MonitorHandle,
) -> tao::dpi::PhysicalPosition<i32> {
use crate::monitor::MonitorExt;
let size: tao::dpi::PhysicalSize<u32>;
let position: tao::dpi::PhysicalPosition<i32>;
#[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,
)
}

0 comments on commit 0103bf3

Please sign in to comment.