Skip to content

Commit

Permalink
fix: 修复 Win11 中窗口化状态下标题栏上部被边框遮挡的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed Dec 8, 2023
1 parent b72f95c commit 4902706
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Magpie/XamlWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 4902706

Please sign in to comment.