diff --git a/src-tauri/src/screenshot.rs b/src-tauri/src/screenshot.rs index 060dfd92b6..6fe43aa8dd 100644 --- a/src-tauri/src/screenshot.rs +++ b/src-tauri/src/screenshot.rs @@ -10,8 +10,9 @@ pub fn screenshot(x: i32, y: i32) { let screens = Screen::all().unwrap(); for screen in screens { let info = screen.display_info; + let scale_factor = info.scale_factor as i32; info!("Screen: {:?}", info); - if info.x == x && info.y == y { + if info.x * scale_factor == x && info.y * scale_factor == y { let handle = APP.get().unwrap(); let mut app_cache_dir_path = cache_dir().expect("Get Cache Dir Failed"); app_cache_dir_path.push(&handle.config().tauri.bundle.identifier); diff --git a/src-tauri/src/window.rs b/src-tauri/src/window.rs index f79fbd7b1a..ee3372484f 100644 --- a/src-tauri/src/window.rs +++ b/src-tauri/src/window.rs @@ -39,11 +39,14 @@ fn get_current_monitor(x: i32, y: i32) -> Monitor { for m in monitors { let size = m.size(); let position = m.position(); + let scale_factor = m.scale_factor() as i32; + let scaled_x = x * scale_factor; + let scaled_y = y * scale_factor; - if x >= position.x - && x <= (position.x + size.width as i32) - && y >= position.y - && y <= (position.y + size.height as i32) + if scaled_x >= position.x/scale_factor + && scaled_x <= (position.x + size.width as i32) + && scaled_y >= position.y/scale_factor + && scaled_y <= (position.y + size.height as i32) { info!("Current Monitor: {:?}", m); return m;