Sine Striker
2023-12-18 59814f0ef77528995e2655247aecf2dfdf2f67d9
src/core/contexts/win32windowcontext.cpp
@@ -117,7 +117,7 @@
    private:
        DynamicApis() {
#define DYNAMIC_API_RESOLVE(DLL, NAME)                                                             \
    p##NAME = reinterpret_cast<decltype(p##NAME)>(DLL.resolve(#NAME))
  p##NAME = reinterpret_cast<decltype(p##NAME)>(DLL.resolve(#NAME))
            QSystemLibrary user32(QStringLiteral("user32"));
            DYNAMIC_API_RESOLVE(user32, GetDpiForWindow);
@@ -332,7 +332,7 @@
    static inline quint32 getDpiForWindow(HWND hwnd) {
        const DynamicApis &apis = DynamicApis::instance();
        if (apis.pGetDpiForWindow) {         // Win10
        if (apis.pGetDpiForWindow) { // Win10
            return apis.pGetDpiForWindow(hwnd);
        } else if (apis.pGetDpiForMonitor) { // Win8.1
            HMONITOR monitor = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
@@ -780,7 +780,7 @@
        g_wndProcHash->insert(hWnd, ctx);
    }
    static inline void removeManagedWindow(HWND hWnd, bool restore) {
    static inline void removeManagedWindow(HWND hWnd) {
        // Remove window handle mapping
        if (!g_wndProcHash->remove(hWnd))
            return;
@@ -789,11 +789,6 @@
        if (g_wndProcHash->empty()) {
            WindowsNativeEventFilter::uninstall();
        }
        // Restore window proc
        if (restore) {
            ::SetWindowLongPtrW(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(g_qtWindowProc));
        }
    }
    Win32WindowContext::Win32WindowContext() : AbstractWindowContext() {
@@ -801,7 +796,7 @@
    Win32WindowContext::~Win32WindowContext() {
        if (windowId) {
            removeManagedWindow(reinterpret_cast<HWND>(windowId), false);
            removeManagedWindow(reinterpret_cast<HWND>(windowId));
        }
    }
@@ -897,11 +892,8 @@
        return getWindowFrameBorderThickness(reinterpret_cast<HWND>(windowId));
    }
    void Win32WindowContext::winIdChanged(QWindow *oldWindow, bool destroyed) {
        if (oldWindow) {
            removeManagedWindow(reinterpret_cast<HWND>(windowId), !destroyed);
        }
    void Win32WindowContext::winIdChanged(QWindow *oldWindow) {
        removeManagedWindow(reinterpret_cast<HWND>(windowId));
        if (!m_windowHandle) {
            return;
        }