From 574a6a769115034f37bdecf3284545d74843816a Mon Sep 17 00:00:00 2001
From: chunhualin1 <chunhualin1@lenovo.com>
Date: 星期三, 12 八月 2026 15:21:41 +0800
Subject: [PATCH] 添加显示器切换兼容处理
---
src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs b/src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs
index 45e0692..f7f5b18 100644
--- a/src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs
+++ b/src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs
@@ -1,3 +1,4 @@
+using Moli.Desktop.Configuration;
using Moli.Desktop.Diagnostics;
using Moli.Desktop.Layout;
@@ -17,16 +18,22 @@
public bool IsSupported() => true;
- public bool TryAttachDesktopWindow(IntPtr hwnd, RectD bounds, out string? error)
+ public bool TryAttachDesktopWindow(IntPtr hwnd, MonitorInfo monitor, RectD bounds, out string? error)
{
error = null;
+ var scale = monitor.Scale;
+ var x = (int)(bounds.X * scale);
+ var y = (int)(bounds.Y * scale);
+ var w = (int)(bounds.Width * scale);
+ var h = (int)(bounds.Height * scale);
+
if (!NativeMethods.SetWindowPos(
hwnd,
NativeMethods.HwndBottom,
- (int)bounds.X,
- (int)bounds.Y,
- (int)bounds.Width,
- (int)bounds.Height,
+ x,
+ y,
+ w,
+ h,
NativeMethods.SwpNoActivate | NativeMethods.SwpShowWindow))
{
error = $"SetWindowPos failed with {NativeMethods.GetLastError()}";
--
Gitblit v1.9.1