Skip to content

Commit 0f5107e

Browse files
authored
Merge pull request #9 from wecode-ai/human/hippo-20260420-025224
fix: windows 窗口阴影导致位置偏移
2 parents b25a876 + 253093a commit 0f5107e

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

src-tauri/src/screenshot.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -831,16 +831,35 @@ pub async fn show_screenshot_window(
831831
let y = monitor
832832
.y()
833833
.map_err(|e| format!("获取显示器Y坐标失败: {}", e))?;
834-
let width = monitor
835-
.width()
836-
.map_err(|e| format!("获取显示器宽度失败: {}", e))?;
837-
let height = monitor
838-
.height()
839-
.map_err(|e| format!("获取显示器高度失败: {}", e))?;
840834
let scale_factor = monitor
841835
.scale_factor()
842836
.map_err(|e| format!("获取显示器缩放比例失败: {}", e))?;
843837

838+
// Windows 上 xcap 返回的是物理像素,需要转换为逻辑像素
839+
// macOS 上返回的已经是逻辑像素
840+
#[cfg(target_os = "windows")]
841+
let (width, height) = {
842+
let w = monitor
843+
.width()
844+
.map_err(|e| format!("获取显示器宽度失败: {}", e))? as f32
845+
/ scale_factor;
846+
let h = monitor
847+
.height()
848+
.map_err(|e| format!("获取显示器高度失败: {}", e))? as f32
849+
/ scale_factor;
850+
(w as u32, h as u32)
851+
};
852+
853+
#[cfg(not(target_os = "windows"))]
854+
let (width, height) = (
855+
monitor
856+
.width()
857+
.map_err(|e| format!("获取显示器宽度失败: {}", e))?,
858+
monitor
859+
.height()
860+
.map_err(|e| format!("获取显示器高度失败: {}", e))?,
861+
);
862+
844863
// 调试日志:打印显示器信息
845864
log::info!(
846865
"[screenshot][rust] monitor_info: id={}, x={}, y={}, width={}, height={}, scale_factor={}",

src-tauri/tauri.conf.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"maximizable": false,
2424
"minHeight": 280,
2525
"minWidth": 360,
26+
"shadow": false,
2627
"skipTaskbar": true,
2728
"title": "WeCut",
2829
"transparent": true,
@@ -58,6 +59,7 @@
5859
"height": 200,
5960
"label": "toast",
6061
"resizable": false,
62+
"shadow": false,
6163
"skipTaskbar": true,
6264
"transparent": true,
6365
"url": "index.html/#/toast",
@@ -77,6 +79,7 @@
7779
"minHeight": 280,
7880
"minWidth": 480,
7981
"resizable": true,
82+
"shadow": false,
8083
"skipTaskbar": true,
8184
"title": "发送消息",
8285
"transparent": true,
@@ -92,6 +95,7 @@
9295
"label": "screenshot",
9396
"maximizable": false,
9497
"resizable": true,
98+
"shadow": false,
9599
"skipTaskbar": true,
96100
"title": "截图",
97101
"transparent": true,

0 commit comments

Comments
 (0)