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 837c476..f7f5b18 100644
--- a/src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs
+++ b/src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs
@@ -1,5 +1,6 @@
using Moli.Desktop.Configuration;
using Moli.Desktop.Diagnostics;
+using Moli.Desktop.Layout;
namespace Moli.Desktop.Interop;
@@ -17,16 +18,22 @@
public bool IsSupported() => true;
- public bool TryAttachWallpaperWindow(IntPtr hwnd, MonitorInfo monitor, 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)monitor.Bounds.X,
- (int)monitor.Bounds.Y,
- (int)monitor.Bounds.Width,
- (int)monitor.Bounds.Height,
+ x,
+ y,
+ w,
+ h,
NativeMethods.SwpNoActivate | NativeMethods.SwpShowWindow))
{
error = $"SetWindowPos failed with {NativeMethods.GetLastError()}";
--
Gitblit v1.9.1