diff --git a/crates/tauri-runtime-wry/src/monitor/macos.rs b/crates/tauri-runtime-wry/src/monitor/macos.rs index 29f70e6cf629..82d810844fe4 100644 --- a/crates/tauri-runtime-wry/src/monitor/macos.rs +++ b/crates/tauri-runtime-wry/src/monitor/macos.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use tauri_runtime::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalRect}; +use tauri_runtime::dpi::{LogicalSize, PhysicalRect}; impl super::MonitorExt for tao::monitor::MonitorHandle { fn work_area(&self) -> PhysicalRect { @@ -10,11 +10,20 @@ impl super::MonitorExt for tao::monitor::MonitorHandle { use tao::platform::macos::MonitorHandleExtMacOS; if let Some(ns_screen) = self.ns_screen() { let ns_screen: &NSScreen = unsafe { &*ns_screen.cast() }; - let rect = ns_screen.visibleFrame(); + let screen_frame = ns_screen.frame(); + let visible_frame = ns_screen.visibleFrame(); + let scale_factor = self.scale_factor(); + + let mut position = self.position().to_logical::(scale_factor); + + position.x += visible_frame.origin.x - screen_frame.origin.x; + position.y -= visible_frame.origin.y - screen_frame.origin.y; + PhysicalRect { - size: LogicalSize::new(rect.size.width, rect.size.height).to_physical(scale_factor), - position: LogicalPosition::new(rect.origin.x, rect.origin.y).to_physical(scale_factor), + size: LogicalSize::new(visible_frame.size.width, visible_frame.size.height) + .to_physical(scale_factor), + position: position.to_physical(scale_factor), } } else { PhysicalRect {