diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 1c73588b7c..1a2ac4a4dd 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -977,7 +977,10 @@ void QWidgetWindow::handleExposeEvent(QExposeEvent *event) } if (exposed) { + // QTBUG-39220, QTBUG-58575: set all (potentially fully obscured parent widgets) mapped. m_widget->setAttribute(Qt::WA_Mapped); + for (QWidget *p = m_widget->parentWidget(); p && !p->testAttribute(Qt::WA_Mapped); p = p->parentWidget()) + p->setAttribute(Qt::WA_Mapped); if (!event->region().isNull()) wPriv->syncBackingStore(event->region()); } else { diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 2da04397d0..f4da4c3e5f 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -44,6 +44,8 @@ #include #include #include +#include +#include #include @@ -79,6 +81,7 @@ private slots: void tst_showWithoutActivating(); void tst_paintEventOnSecondShow(); + void tst_exposeObscuredMapped_QTBUG39220(); void tst_paintEventOnResize_QTBUG50796(); #if QT_CONFIG(draganddrop) @@ -377,6 +380,33 @@ void tst_QWidget_window::tst_paintEventOnSecondShow() QTRY_VERIFY(w.paintEventCount > 0); } +void tst_QWidget_window::tst_exposeObscuredMapped_QTBUG39220() +{ + const auto integration = QGuiApplicationPrivate::platformIntegration(); + if (!integration->hasCapability(QPlatformIntegration::MultipleWindows) + || !integration->hasCapability(QPlatformIntegration::NonFullScreenWindows) + || QGuiApplication::platformName() == QLatin1String("winrt")) { + QSKIP("The platform does not have the required capabilities"); + } + // QTBUG-39220: Fully obscured parent widgets may not receive expose + // events (as is the case for frameless, obscured parents on Windows). + // Ensure Qt::WA_Mapped is set so updating works. + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + const QSize size = availableGeometry.size() / 6; + QWidget topLevel; + setFrameless(&topLevel); + topLevel.resize(size); + const QPoint sizeP(size.width(), size.height()); + topLevel.move(availableGeometry.center() - sizeP / 2); + QWidget *child = new QWidget(&topLevel); + child->resize(size); + child->move(0, 0); + QVERIFY(child->winId()); + topLevel.show(); + QTRY_VERIFY(child->testAttribute(Qt::WA_Mapped)); + QVERIFY(topLevel.testAttribute(Qt::WA_Mapped)); +} + void tst_QWidget_window::tst_paintEventOnResize_QTBUG50796() { const QRect availableGeo = QGuiApplication::primaryScreen()->availableGeometry();