Yuhang Zhao
2023-12-27 e5370435a9d4297d0ba227f2237d7ed16bba7e82
fix some win32 issues
3个文件已修改
36 ■■■■■ 已修改文件
src/core/contexts/win32windowcontext.cpp 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/qwindowkit_windows.h 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/shared/qwkwindowsextra_p.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/win32windowcontext.cpp
@@ -684,10 +684,20 @@
            if (!m_windowHandle)
                return {};
            auto hwnd = reinterpret_cast<HWND>(windowId);
            RECT frame{};
            ::AdjustWindowRectExForDpi(&frame, ::GetWindowLongPtrW(hwnd, GWL_STYLE), FALSE, 0,
                                       getDpiForWindow(hwnd));
            auto frame = [this]() -> RECT {
                auto hwnd = reinterpret_cast<HWND>(windowId);
                // According to MSDN, WS_OVERLAPPED is not allowed for AdjustWindowRect.
                auto style = static_cast<DWORD>(::GetWindowLongPtrW(hwnd, GWL_STYLE) & ~WS_OVERLAPPED);
                auto exStyle = static_cast<DWORD>(::GetWindowLongPtrW(hwnd, GWL_EXSTYLE));
                RECT result{};
                const DynamicApis &apis = DynamicApis::instance();
                if (apis.pAdjustWindowRectExForDpi) {
                    apis.pAdjustWindowRectExForDpi(&result, style, FALSE, exStyle, getDpiForWindow(hwnd));
                } else {
                    ::AdjustWindowRectEx(&result, style, FALSE, exStyle);
                }
                return result;
            }();
            return QVariant::fromValue(rect2qrect(frame));
        }
@@ -809,7 +819,7 @@
        if (key == QStringLiteral("extra-margins")) {
            auto margins = qmargins2margins(attribute.value<QMargins>());
            DynamicApis::instance().pDwmExtendFrameIntoClientArea(hwnd, &margins);
            apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
            return true;
        }
@@ -940,12 +950,9 @@
        }
        if (key == QStringLiteral("dwm-blur")) {
            // TODO: Optimize
            // Currently not available!!!
            if (attribute.toBool()) {
                // We need to extend the window frame into the whole client area to be able
                // to see the blurred window background.
                apis.pDwmExtendFrameIntoClientArea(hwnd, &extendedMargins);
                // We can't extend the window frame for this effect.
                restoreMargins();
                if (isWin8OrGreater()) {
                    ACCENT_POLICY policy{};
                    policy.dwAccentState = ACCENT_ENABLE_BLURBEHIND;
@@ -977,7 +984,6 @@
                    bb.dwFlags = DWM_BB_ENABLE;
                    apis.pDwmEnableBlurBehindWindow(hwnd, &bb);
                }
                restoreMargins();
            }
            return true;
        }
src/core/qwindowkit_windows.h
@@ -99,7 +99,7 @@
                   (rovi.dwMajorVersion == 6 && rovi.dwMinorVersion >= 2);
        }
        inline bool IsWindows10_Real() {
        inline bool IsWindows10Only_Real() {
            return IsWindows10OrGreater_Real() && !IsWindows11OrGreater_Real();
        }
@@ -144,8 +144,8 @@
        return result;
    }
    static inline bool isWin10() {
        static const bool result = Private::IsWindows10_Real();
    static inline bool isWin10Only() {
        static const bool result = Private::IsWindows10Only_Real();
        return result;
    };
src/core/shared/qwkwindowsextra_p.h
@@ -170,6 +170,7 @@
            DYNAMIC_API_DECLARE(DwmEnableBlurBehindWindow);
            DYNAMIC_API_DECLARE(GetDpiForWindow);
            DYNAMIC_API_DECLARE(GetSystemMetricsForDpi);
            DYNAMIC_API_DECLARE(AdjustWindowRectExForDpi);
            DYNAMIC_API_DECLARE(GetDpiForMonitor);
            DYNAMIC_API_DECLARE(timeGetDevCaps);
            DYNAMIC_API_DECLARE(timeBeginPeriod);
@@ -193,6 +194,7 @@
                DYNAMIC_API_RESOLVE(user32, GetDpiForWindow);
                DYNAMIC_API_RESOLVE(user32, GetSystemMetricsForDpi);
                DYNAMIC_API_RESOLVE(user32, SetWindowCompositionAttribute);
                DYNAMIC_API_RESOLVE(user32, AdjustWindowRectExForDpi);
                QSystemLibrary shcore(QStringLiteral("shcore"));
                DYNAMIC_API_RESOLVE(shcore, GetDpiForMonitor);