From 0641c5b91b285222fab7629d9cf2feb5b961be5d Mon Sep 17 00:00:00 2001 From: yu <191972707@qq.com> Date: Tue, 3 Nov 2026 09:39:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=89=AF=E5=B1=8F=E6=A1=86=E9=80=89?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E5=B1=82=E5=B0=BA=E5=AF=B8=E4=B8=8D=E5=AF=B9?= =?UTF-8?q?\n\n-=20=E6=B7=B7=E5=90=88=20DPI=20=E5=A4=9A=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=99=A8=E4=B8=8B,=20BrowserWindow=20=E6=9E=84=E9=80=A0?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=9B=B4=E6=8E=A5=E4=BC=A0=E5=89=AF=E5=B1=8F?= =?UTF-8?q?=20bounds=20=E4=BC=9A=E6=8C=89=E4=B8=BB=E5=B1=8F=20DPI=20?= =?UTF-8?q?=E8=99=9A=E6=8B=9F=E5=8C=96,=20=E5=AF=BC=E8=87=B4=E5=89=AF?= =?UTF-8?q?=E5=B1=8F=E8=A6=86=E7=9B=96=E5=B1=82=E7=9B=96=E4=B8=8D=E6=BB=A1?= =?UTF-8?q?=E6=88=96=E8=B6=85=E5=87=BA\n-=20=E6=94=B9=E4=B8=BA=E5=85=88?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=9A=90=E8=97=8F=E7=AA=97=E5=8F=A3=E5=86=8D?= =?UTF-8?q?=20setBounds=20=E5=89=AF=E5=B1=8F=20bounds,=20=E6=AD=A4?= =?UTF-8?q?=E6=97=B6=E7=AA=97=E5=8F=A3=E5=B7=B2=E5=85=B3=E8=81=94=E5=89=AF?= =?UTF-8?q?=E5=B1=8F=20DPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/desktop-pick.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/desktop-pick.ts b/src/main/desktop-pick.ts index e3fb8a6..769bfb6 100644 --- a/src/main/desktop-pick.ts +++ b/src/main/desktop-pick.ts @@ -717,16 +717,19 @@ function regionOverlayHtml(): string { export async function pickScreenRegion(): Promise<{ x: number; y: number; width: number; height: number; scale: number; imagePath: string }> { const appWindows = BrowserWindow.getAllWindows().filter(w => !w.isDestroyed()); for (const w of appWindows) w.minimize(); - // 每个显示器各开一个覆盖层, 支持在任意副屏上框选 + // 每个显示器各开一个覆盖层, 支持在任意副屏上框选。 + // 注意: 构造参数里直接传副屏 bounds 在混合 DPI 下会按主屏 DPI 虚拟化导致尺寸不对, + // 必须先创建(隐藏)再 setBounds, 此时窗口已关联副屏 DPI const displays = screen.getAllDisplays(); const url = "data:text/html;charset=utf-8," + encodeURIComponent(regionOverlayHtml()); const overlays = displays.map(display => { const win = new BrowserWindow({ - x: display.bounds.x, y: display.bounds.y, width: display.bounds.width, height: display.bounds.height, + show: false, frame: false, transparent: true, alwaysOnTop: true, skipTaskbar: true, resizable: false, movable: false, webPreferences: { contextIsolation: true, nodeIntegration: false, sandbox: true } }); void win.loadURL(url); + win.setBounds({ x: display.bounds.x, y: display.bounds.y, width: display.bounds.width, height: display.bounds.height }); win.show(); return { win, display }; });