Win32: Fix the flickering issue when resizing

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2021-03-31 20:35:21 +08:00
parent f188c0f88d
commit 16f7d78035
2 changed files with 16 additions and 3 deletions

View File

@ -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

View File

@ -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<QLineF> lines = {
using BorderLines = QList<QLineF>;
#else
const QVector<QLineF> lines = {
using BorderLines = QVector<QLineF>;
#endif
#ifdef Q_OS_WINDOWS
const int internalFix = 1;
#else
const int internalFix = 0;
#endif
const BorderLines lines = {
{0, 0, static_cast<qreal>(width), 0},
{width - m_frameThickness, 0, width - m_frameThickness, static_cast<qreal>(height)},
{static_cast<qreal>(width), height - m_frameThickness, 0, height - m_frameThickness},
{static_cast<qreal>(width), height - m_frameThickness - internalFix, 0, height - m_frameThickness - internalFix},
{0, static_cast<qreal>(height), 0, 0}
};
const bool active = m_window->isActive();