From b635e1608041d3aacf4135e8aaf54dee40142fea Mon Sep 17 00:00:00 2001 From: seven-mile Date: Tue, 5 Sep 2023 17:30:38 +0800 Subject: [PATCH] fix: should not call "rounding cancel" dwm api for versions before 22000 --- dcomp.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/dcomp.cpp b/dcomp.cpp index 136f5f1..430478f 100644 --- a/dcomp.cpp +++ b/dcomp.cpp @@ -401,8 +401,23 @@ CreateCompositorForWindow(HWND hWnd) { wData.cbData = sizeof(BOOL); winrt::check_bool(lSetWindowCompositionAttribute(hWnd, &wData)); - BOOL disable = FALSE; - winrt::check_hresult(DwmSetWindowAttribute(hWnd, DWMWA_WINDOW_CORNER_PREFERENCE, &disable, sizeof(disable))); + // if > 22000, then disable corner rounding + OSVERSIONINFOEX info{ + .dwMajorVersion = 10, + .dwMinorVersion = 0, + .dwBuildNumber = 22000, + }; + DWORDLONG dwlConditionMask = 0; + VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(dwlConditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL); + if (VerifyVersionInfo(&info, + VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER, + dwlConditionMask)) { + BOOL disable = FALSE; + winrt::check_hresult(DwmSetWindowAttribute( + hWnd, DWMWA_WINDOW_CORNER_PREFERENCE, &disable, sizeof(disable))); + } return {compositor, rootVisual}; }