From 51bade182798f685e716b321d2100748cf3cd2a3 Mon Sep 17 00:00:00 2001 From: zrr1999 <2742392377@qq.com> Date: Mon, 29 Jan 2024 19:51:55 +0800 Subject: [PATCH 1/3] fix --- src-tauri/src/window.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/window.rs b/src-tauri/src/window.rs index f79fbd7b1a..0dde14363e 100644 --- a/src-tauri/src/window.rs +++ b/src-tauri/src/window.rs @@ -39,11 +39,11 @@ fn get_current_monitor(x: i32, y: i32) -> Monitor { for m in monitors { let size = m.size(); let position = m.position(); - - if x >= position.x - && x <= (position.x + size.width as i32) - && y >= position.y - && y <= (position.y + size.height as i32) + let scale_factor = m.scale_factor() as i32; + if x >= position.x/scale_factor + && x <= ((position.x + size.width as i32)/scale_factor) + && y >= position.y/scale_factor + && y <= ((position.y + size.height as i32)/scale_factor) { info!("Current Monitor: {:?}", m); return m; From 788013c976805a7c5b12792cc7dac6cd4bc5136b Mon Sep 17 00:00:00 2001 From: zrr1999 <2742392377@qq.com> Date: Mon, 29 Jan 2024 19:59:00 +0800 Subject: [PATCH 2/3] fix --- src-tauri/src/window.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/window.rs b/src-tauri/src/window.rs index 0dde14363e..ee3372484f 100644 --- a/src-tauri/src/window.rs +++ b/src-tauri/src/window.rs @@ -40,10 +40,13 @@ fn get_current_monitor(x: i32, y: i32) -> Monitor { let size = m.size(); let position = m.position(); let scale_factor = m.scale_factor() as i32; - if x >= position.x/scale_factor - && x <= ((position.x + size.width as i32)/scale_factor) - && y >= position.y/scale_factor - && y <= ((position.y + size.height as i32)/scale_factor) + let scaled_x = x * scale_factor; + let scaled_y = y * scale_factor; + + 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; From 91c4a9ff0fb6f7bc60271bc56b94da0915343dd2 Mon Sep 17 00:00:00 2001 From: zrr1999 <2742392377@qq.com> Date: Mon, 29 Jan 2024 20:49:29 +0800 Subject: [PATCH 3/3] fix screenshot --- src-tauri/src/screenshot.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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);