widgets: Sync client rect of paint-on-screen widgets during resize

Paint events are delivered with the client rect of the widget, and
this applies to paint-on-screen widgets as well. The same goes for
how the widget repaint manager tracks dirty rects. Internally we
were also calling paintOnScreen() with client rects, so the use
of geometry() in the resize handler was likely a bug/oversight.

Change-Id: I1312ccf77218d1162e0971e4cbabaa80f49c852c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2020-03-20 17:27:33 +01:00
parent 6434101360
commit d4a4202caa

View File

@ -813,16 +813,16 @@ void QWidgetWindow::handleMoveEvent(QMoveEvent *event)
void QWidgetWindow::handleResizeEvent(QResizeEvent *event)
{
QSize oldSize = m_widget->data->crect.size();
auto oldRect = m_widget->rect();
if (updateSize()) {
QGuiApplication::forwardEvent(m_widget, event);
if (m_widget->d_func()->shouldPaintOnScreen()) {
QRegion updateRegion(geometry());
QRegion dirtyRegion = m_widget->rect();
if (m_widget->testAttribute(Qt::WA_StaticContents))
updateRegion -= QRect(0, 0, oldSize.width(), oldSize.height());
m_widget->d_func()->syncBackingStore(updateRegion);
dirtyRegion -= oldRect;
m_widget->d_func()->syncBackingStore(dirtyRegion);
} else {
m_widget->d_func()->syncBackingStore();
}