From 16f7d78035136b8f52e5a06a4078f6cfe694ab5d Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Wed, 31 Mar 2021 20:35:21 +0800 Subject: [PATCH] Win32: Fix the flickering issue when resizing Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- framelesshelper_win32.cpp | 7 +++++++ qtacryliceffecthelper.cpp | 12 +++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/framelesshelper_win32.cpp b/framelesshelper_win32.cpp index fb7d184..5bf5c0b 100644 --- a/framelesshelper_win32.cpp +++ b/framelesshelper_win32.cpp @@ -412,6 +412,13 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me } } } + // Fix the flickering issue while resizing. + // "clientRect->right += 1;" also works. + // The only draw back of this small trick is it will affect + // Qt's coordinate system. It makes the "canvas" of the window + // larger than it should be. Be careful if you need to paint + // something manually either through QPainter or Qt Quick. + clientRect->bottom += 1; // If the window bounds change, we're going to relayout and repaint // anyway. Returning WVR_REDRAW avoids an extra paint before that of // the old client pixels in the (now wrong) location, and thus makes diff --git a/qtacryliceffecthelper.cpp b/qtacryliceffecthelper.cpp index 1c16d32..40b52c2 100644 --- a/qtacryliceffecthelper.cpp +++ b/qtacryliceffecthelper.cpp @@ -250,13 +250,19 @@ void QtAcrylicEffectHelper::paintWindowFrame(QPainter *painter, const QRect &rec const int width = rect.isValid() ? rect.width() : m_window->width(); const int height = rect.isValid() ? rect.height() : m_window->height(); #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - const QList lines = { + using BorderLines = QList; #else - const QVector lines = { + using BorderLines = QVector; #endif +#ifdef Q_OS_WINDOWS + const int internalFix = 1; +#else + const int internalFix = 0; +#endif + const BorderLines lines = { {0, 0, static_cast(width), 0}, {width - m_frameThickness, 0, width - m_frameThickness, static_cast(height)}, - {static_cast(width), height - m_frameThickness, 0, height - m_frameThickness}, + {static_cast(width), height - m_frameThickness - internalFix, 0, height - m_frameThickness - internalFix}, {0, static_cast(height), 0, 0} }; const bool active = m_window->isActive();