diff --git a/examples/widgets/mainwindows/mdi/mdi.pro b/examples/widgets/mainwindows/mdi/mdi.pro index 9f8ed11..c3419b0 100644 --- a/examples/widgets/mainwindows/mdi/mdi.pro +++ b/examples/widgets/mainwindows/mdi/mdi.pro @@ -6,7 +6,7 @@ SOURCES = main.cpp \ mainwindow.cpp \ mdichild.cpp RESOURCES = mdi.qrc - +CONFIG+=console # install target.path = $$[QT_INSTALL_EXAMPLES]/widgets/mainwindows/mdi INSTALLS += target diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index b05ba28..2085a2d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2228,6 +2228,7 @@ void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::E // as a convenience for plugins, send a resize event before the first expose event if they haven't done so QSize size = p->geometry.size(); QResizeEvent e(size, size); + qDebug() << __FUNCTION__ << size << window; QGuiApplication::sendSpontaneousEvent(window, &e); p->resizeEventPending = false; diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 03e4925..acde88d 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -244,6 +244,7 @@ bool QWindowsNativeInterface::asyncExpose() const void QWindowsNativeInterface::setAsyncExpose(bool value) { + qDebug() << __FUNCTION__ << value; QWindowsContext::instance()->setAsyncExpose(value); } diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 9b2b676..597f4a1 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -942,13 +942,21 @@ void QWindowsWindow::setVisible(bool visible) if (m_data.hwnd) { if (visible) { show_sys(); - QWindowSystemInterface::handleExposeEvent(window(), - QRect(QPoint(), geometry().size())); + + // When the window is layered, we won't get WM_PAINT, and "we" are in control + // over the rendering of the window + // There is nobody waiting for this, so we don't need to flush afterwards. + QWindow *w = window(); + if (w->format().alphaBufferSize() > 0) + QWindowSystemInterface::handleExposeEvent(w, QRect(0, 0, w->width(), w->height())); + } else { if (hasMouseCapture()) setMouseGrabEnabled(false); hide_sys(); QWindowSystemInterface::handleExposeEvent(window(), QRegion()); + QWindowSystemInterface::flushWindowSystemEvents(); + qDebug() << __FUNCTION__ << "hide" << window(); } } } @@ -1096,12 +1104,11 @@ void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) const void QWindowsWindow::handleShown() { - QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), geometry().size())); } void QWindowsWindow::handleHidden() { - QWindowSystemInterface::handleExposeEvent(window(), QRegion()); + qDebug() << __FUNCTION__ << window(); } void QWindowsWindow::setGeometry(const QRect &rectIn) @@ -1273,8 +1280,7 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, InvalidateRect(hwnd, 0, false); BeginPaint(hwnd, &ps); QWindowSystemInterface::handleExposeEvent(window(), QRegion(qrectFromRECT(ps.rcPaint))); - if (!QWindowsContext::instance()->asyncExpose()) - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(); EndPaint(hwnd, &ps); } else { @@ -1285,8 +1291,7 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, qDebug() << __FUNCTION__ << this << window() << updateRect; QWindowSystemInterface::handleExposeEvent(window(), QRegion(updateRect)); - if (!QWindowsContext::instance()->asyncExpose()) - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(); EndPaint(hwnd, &ps); } return true; @@ -1353,8 +1358,9 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowState state) m_windowState = state; QWindowSystemInterface::handleWindowStateChanged(window(), state); if (state == Qt::WindowMinimized) { - handleHidden(); - QWindowSystemInterface::flushWindowSystemEvents(); // Tell QQuickWindow to stop rendering now. + QWindowSystemInterface::handleExposeEvent(window(), QRegion()); + qDebug() << __FUNCTION__ << "minimized/hide" << window(); + QWindowSystemInterface::flushWindowSystemEvents(); // Make sure QWindow::isExposed() is in sync } } diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 90cfb34..0acab03 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -6993,6 +6993,8 @@ void QWidgetPrivate::sendPendingMoveAndResizeEvents(bool recursive, bool disable } if (q->testAttribute(Qt::WA_PendingResizeEvent)) { + if (q->isWindow()) + qDebug() << __FUNCTION__ << q; QResizeEvent e(data.crect.size(), QSize()); QApplication::sendEvent(q, &e); q->setAttribute(Qt::WA_PendingResizeEvent, false); @@ -8033,6 +8035,7 @@ bool QWidget::event(QEvent *event) break; case QEvent::Resize: + qDebug() << __FUNCTION__ << this << "RESIZE"; resizeEvent((QResizeEvent*)event); d->updateWidgetTransform(); break; diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index bedcfe7..20b1abf 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -521,6 +521,7 @@ void QWidgetWindow::handleMoveEvent(QMoveEvent *event) void QWidgetWindow::handleResizeEvent(QResizeEvent *event) { + qDebug() << __FUNCTION__ << m_widget << event->size(); QSize oldSize = m_widget->data->crect.size(); updateGeometry(); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 69d890f..63980f3 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4428,11 +4428,8 @@ void tst_QWidget::setWindowGeometry() widget.setGeometry(rect); widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(&widget)); - if (m_platform == QStringLiteral("windows")) { - QEXPECT_FAIL("130,100 0x200, flags 0", "QTBUG-26424", Continue); - QEXPECT_FAIL("130,50 0x0, flags 0", "QTBUG-26424", Continue); - } + if (rect.isValid()) + QVERIFY(QTest::qWaitForWindowExposed(&widget)); QTRY_COMPARE(widget.geometry(), rect); // setGeometry() while shown @@ -4462,7 +4459,8 @@ void tst_QWidget::setWindowGeometry() // show() again, geometry() should still be the same widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(&widget)); + if (rect.isValid()) + QVERIFY(QTest::qWaitForWindowExposed(&widget)); QTRY_COMPARE(widget.geometry(), rect); // final hide(), again geometry() should be unchanged @@ -4510,7 +4508,8 @@ void tst_QWidget::setWindowGeometry() // show() again, geometry() should still be the same widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(&widget)); + if (rect.isValid()) + QVERIFY(QTest::qWaitForWindowExposed(&widget)); QTest::qWait(10); QTRY_COMPARE(widget.geometry(), rect); @@ -4655,7 +4654,8 @@ void tst_QWidget::windowMoveResize() // show() again, pos() should be the same widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(&widget)); + if (rect.isValid()) + QVERIFY(QTest::qWaitForWindowExposed(&widget)); QApplication::processEvents(); QTRY_COMPARE(widget.pos(), rect.topLeft()); QTRY_COMPARE(widget.size(), rect.size()); @@ -4724,7 +4724,8 @@ void tst_QWidget::windowMoveResize() // show() again, pos() should be the same widget.show(); - QVERIFY(QTest::qWaitForWindowExposed(&widget)); + if (rect.isValid()) + QVERIFY(QTest::qWaitForWindowExposed(&widget)); QTest::qWait(10); QTRY_COMPARE(widget.pos(), rect.topLeft()); QTRY_COMPARE(widget.size(), rect.size());