From 59690b8ab4f3e4c2cea0467f40e858080943dd62 Mon Sep 17 00:00:00 2001
From: Zhao Yuhang <2546789017@qq.com>
Date: 摹曛, 14 12月 2023 20:45:33 +0800
Subject: [PATCH] tweak

---
 src/core/contexts/win32windowcontext.cpp |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp
index 86ec6bd..0f7b6f7 100644
--- a/src/core/contexts/win32windowcontext.cpp
+++ b/src/core/contexts/win32windowcontext.cpp
@@ -428,8 +428,8 @@
         const auto monitorInfo = getMonitorForWindow(hwnd);
         RECT windowRect{};
         ::GetWindowRect(hwnd, &windowRect);
-        const auto newX = (RECT_WIDTH(monitorInfo.rcMonitor) - RECT_WIDTH(windowRect)) / 2;
-        const auto newY = (RECT_HEIGHT(monitorInfo.rcMonitor) - RECT_HEIGHT(windowRect)) / 2;
+        const auto newX = monitorInfo.rcMonitor.left + (RECT_WIDTH(monitorInfo.rcMonitor) - RECT_WIDTH(windowRect)) / 2;
+        const auto newY = monitorInfo.rcMonitor.top + (RECT_HEIGHT(monitorInfo.rcMonitor) - RECT_HEIGHT(windowRect)) / 2;
         ::SetWindowPos(hwnd, nullptr, newX, newY, 0, 0,
                        SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
     }
@@ -448,6 +448,9 @@
         ::GetWindowPlacement(hwnd, &wp);
         return ((wp.showCmd == SW_NORMAL) || (wp.showCmd == SW_RESTORE));
 #else
+        if (isFullScreen(hwnd)) {
+            return false;
+        }
         const auto style = static_cast<DWORD>(::GetWindowLongPtrW(hwnd, GWL_STYLE));
         return (!(style & (WS_MINIMIZE | WS_MAXIMIZE)));
 #endif
@@ -797,7 +800,7 @@
             case ShowSystemMenuHook: {
                 const auto &pos = *static_cast<const QPoint *>(data);
                 auto hWnd = reinterpret_cast<HWND>(m_windowHandle->winId());
-                showSystemMenu2(hWnd, qpoint2point(pos), false,
+                showSystemMenu2(hWnd, qpoint2point(QHighDpi::toNativeGlobalPosition(pos, m_windowHandle)), false,
                                 m_delegate->isHostSizeFixed(m_host));
                 return;
             }
@@ -840,7 +843,7 @@
                 }
                 painter.save();
 
-                // ### TODO: do we need to enable or disable it?
+                // We needs anti-aliasing to give us better result.
                 painter.setRenderHint(QPainter::Antialiasing);
 
                 painter.setPen(pen);
@@ -849,6 +852,7 @@
                     QPoint{m_windowHandle->width(), 0}
                 });
                 painter.restore();
+                return;
             }
 
             default: {
@@ -1235,7 +1239,7 @@
                     // If wParam is TRUE, the window is being shown.
                     // If lParam is zero, the message was sent because of a call to the ShowWindow
                     // function.
-                    if (wParam && lParam == 0) {
+                    if (wParam && !lParam) {
                         centered = true;
                         moveToDesktopCenter(hWnd);
                     }

--
Gitblit v1.9.1