From 49027063c63c95d54f7fcff26c9078dd69456e4c Mon Sep 17 00:00:00 2001 From: Xu <34770031+Blinue@users.noreply.github.com> Date: Fri, 8 Dec 2023 20:19:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Win11=20=E4=B8=AD?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=8C=96=E7=8A=B6=E6=80=81=E4=B8=8B=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E6=A0=8F=E4=B8=8A=E9=83=A8=E8=A2=AB=E8=BE=B9=E6=A1=86?= =?UTF-8?q?=E9=81=AE=E6=8C=A1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Magpie/XamlWindow.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Magpie/XamlWindow.h b/src/Magpie/XamlWindow.h index 15a0d1e29..8d4fb2dc7 100644 --- a/src/Magpie/XamlWindow.h +++ b/src/Magpie/XamlWindow.h @@ -458,10 +458,17 @@ class XamlWindowT { } uint32_t _GetTopBorderHeight() const noexcept { - static constexpr uint32_t TOP_BORDER_HEIGHT = 1; + // 最大化时没有上边框 + if (_isMaximized) { + return 0; + } - // Win11 或最大化时没有上边框 - return (Win32Utils::GetOSVersion().IsWin11() || _isMaximized) ? 0 : TOP_BORDER_HEIGHT; + // Win10 中窗口边框始终只有一个像素宽,Win11 中的窗口边框宽度和 DPI 缩放有关 + if (Win32Utils::GetOSVersion().IsWin11()) { + return (_currentDpi + USER_DEFAULT_SCREEN_DPI / 2) / USER_DEFAULT_SCREEN_DPI; + } else { + return 1; + } } int _GetResizeHandleHeight() noexcept { @@ -495,7 +502,9 @@ class XamlWindowT { } } - int topBorderHeight = _GetTopBorderHeight(); + // Win10 中上边框被涂黑来显示系统原始边框,Win11 中 DWM 绘制的上边框也位于客户区内, + // 很可能是为了和 Win10 兼容。XAML Islands 不应该和上边框重叠。 + const int topBorderHeight = (int)_GetTopBorderHeight(); // SWP_NOZORDER 确保 XAML Islands 窗口始终在标题栏窗口下方,否则主窗口在调整大小时会闪烁 SetWindowPos(