From 9e96ea43436d5ed200c57d6b229cddf9bdf9e55a Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <zhaoyuhang@rankyee.com> Date: 周一, 10 2月 2025 18:06:41 +0800 Subject: [PATCH] make demo a GUI application in CMake --- src/core/contexts/win32windowcontext.cpp | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp index ce1037a..775f2ca 100644 --- a/src/core/contexts/win32windowcontext.cpp +++ b/src/core/contexts/win32windowcontext.cpp @@ -33,6 +33,10 @@ #include "qwkglobal_p.h" #include "qwkwindowsextra_p.h" +#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) && (QT_VERSION <= QT_VERSION_CHECK(6, 6, 1)) +# error Current Qt version has a critical bug which will break QWK functionality. Please upgrade to > 6.6.1 or downgrade to < 6.6.0 +#endif + namespace QWK { enum IconButtonClickLevelFlag { @@ -922,7 +926,8 @@ // from the top side. In the end I found that we only need to extend from the left // side if we extend long enough. In this way we can see the special material even // when the host object is a QWidget and the title bar still remain hidden. But even - // though this solution seems perfect, I really don't know why it works. + // though this solution seems perfect, I really don't know why it works. The following + // hack is totally based on experiments. static constexpr const MARGINS margins = {65536, 0, 0, 0}; apis.pDwmExtendFrameIntoClientArea(hwnd, &margins); }; @@ -2016,6 +2021,21 @@ // and align it with the upper-left corner of our new client area". const auto clientRect = wParam ? &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0] : reinterpret_cast<LPRECT>(lParam); + [[maybe_unused]] const auto& flickerReducer = qScopeGuard([this]() { + // When we receive this message, it means the window size has changed + // already, and it seems this message always come before any client + // area size notifications (eg. WM_WINDOWPOSCHANGED and WM_SIZE). Let + // D3D/VK paint immediately to let user see the latest result as soon + // as possible. + const auto& isTargetSurface = [](const QSurface::SurfaceType st){ + return st != QSurface::RasterSurface && st != QSurface::OpenGLSurface + && st != QSurface::RasterGLSurface && st != QSurface::OpenVGSurface; + }; + if (m_windowHandle && isTargetSurface(m_windowHandle->surfaceType()) + && isDwmCompositionEnabled() && DynamicApis::instance().pDwmFlush) { + DynamicApis::instance().pDwmFlush(); + } + }); if (isSystemBorderEnabled()) { // Store the original top margin before the default window procedure applies the // default frame. -- Gitblit v1.9.1