From: Gunnar Sletta Date: Wed, 20 Feb 2013 18:39:11 +0000 (+0100) Subject: Make sure exposeEvents trigger a render pass X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=cf53bf9ae6716613c120cc4a0202c69bd59eba1e;p=konrad%2Fqtdeclarative.git Make sure exposeEvents trigger a render pass We needs this on non-compositing window managers to trigger repaints on partial updates. Change-Id: Ied5f3e854173c5e00ad7e1222aeb66eb9c96158c Reviewed-by: Samuel Rødal --- diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 83e8d3f..85ef549 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -305,8 +305,10 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) void QSGGuiThreadRenderLoop::exposureChanged(QQuickWindow *window) { - if (window->isExposed()) + if (window->isExposed()) { + m_windows[window].updatePending = true; renderWindow(window); + } } QImage QSGGuiThreadRenderLoop::grab(QQuickWindow *window) diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index eebcad7..fb26f54 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -372,6 +372,8 @@ bool QSGRenderThread::event(QEvent *e) RLDEBUG1(" Render: WM_Expose"); WMExposeEvent *se = static_cast(e); + pendingUpdate |= RepaintRequest; + if (windowFor(m_windows, se->window)) { RLDEBUG1(" Render: - window already added..."); return true; diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 858653a..b2e07e4 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -320,6 +320,8 @@ private slots: void showHideAnimate(); + void testExpose(); + #ifndef QT_NO_CURSOR void cursor(); #endif @@ -1375,6 +1377,28 @@ void tst_qquickwindow::showHideAnimate() QTRY_VERIFY(created->opacity() < 0.5); } +void tst_qquickwindow::testExpose() +{ + QQuickWindow window; + window.setGeometry(100, 100, 300, 200); + + window.show(); + QTRY_VERIFY(window.isExposed()); + + QSignalSpy swapSpy(&window, SIGNAL(frameSwapped())); + + // exhaust pending exposes, as some platforms send us plenty + // while showing the first time + QTest::qWait(1000); + while (swapSpy.size() != 0) { + swapSpy.clear(); + QTest::qWait(100); + } + + QWindowSystemInterface::handleExposeEvent(&window, QRegion(10, 10, 20, 20)); + QTRY_COMPARE(swapSpy.size(), 1); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc"