summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-08-24 18:59:54 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-08-26 16:44:53 +0200
commitb5f972361aa01f55511712016fb2f4f540cdbc66 (patch)
tree45651e80c6e7423c7b6409b471a1f819f5464fac /tests
parentc3555fc33d6b7897a36b0176aef68a2e7139d51a (diff)
Introduce QWindow::paintEvent with QPA plumbing
The explicit paint event on QtGui and QPA level allows us to untangle the expose event, which today has at least 3 different meanings. It also allows us to follow the platform more closely in its semantics of when painting can happen. On some platforms a paint can come in before a window is exposed, e.g. to prepare the first frame. On others a paint can come in after a window has been de-exposed, to save a snapshot of the window for use in an application switcher or similar. The expose keeps its semantics of being a barrier signaling that the application can now render at will, for example in a threaded render loop. There are two compatibility code paths in this patch: 1. For platform plugins that do not yet report the PaintEvents capability, QtGui will synthesize paint events on the platform's behalf, based on the existing expose events coming from the platform. 2. For applications that do not yet implement paintEvent, QtGui will send expose events instead, ensuring the same behavior as before. For now none of the platform plugins deliver paint events natively, so the first compatibility code path is always active. Task-numnber: QTBUG-82676 Change-Id: I0fbe0d4cf451d6a1f07f5eab8d376a6c8a53ce8c Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp2
-rw-r--r--tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp3
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp42
3 files changed, 46 insertions, 1 deletions
diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp
index 6f2ed47b72..ed89e6fbb4 100644
--- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp
+++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp
@@ -72,7 +72,7 @@ public:
bool event(QEvent *event) override
{
m_received[event->type()]++;
- return QWindow::event(event);
+ return QRasterWindow::event(event);
}
int received(QEvent::Type type)
diff --git a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
index fb4f80f085..79c669753b 100644
--- a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
+++ b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
@@ -70,7 +70,10 @@ public:
backingStore.endPaint();
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
backingStore.flush(event->region().boundingRect());
+QT_WARNING_POP
}
private:
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 29e863776a..dd0fb46eca 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -55,6 +55,7 @@ private slots:
void setVisible();
void setVisibleFalseDoesNotCreateWindow();
void eventOrderOnShow();
+ void paintEvent();
void resizeEventAfterResize();
void exposeEventOnShrink_QTBUG54040();
void mapGlobal();
@@ -307,7 +308,10 @@ public:
m_order << event->type();
switch (event->type()) {
case QEvent::Expose:
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
m_exposeRegion = static_cast<QExposeEvent *>(event)->region();
+QT_WARNING_POP
break;
case QEvent::PlatformSurface:
@@ -392,6 +396,44 @@ void tst_QWindow::eventOrderOnShow()
QVERIFY(window.eventIndex(QEvent::Resize) < window.eventIndex(QEvent::Expose));
}
+class PaintWindow : public Window
+{
+public:
+ using Window::Window;
+
+protected:
+ void paintEvent(QPaintEvent *) {
+ // Handled, not calling base class
+ }
+};
+
+void tst_QWindow::paintEvent()
+{
+ PaintWindow window;
+ window.setTitle(QLatin1String(QTest::currentTestFunction()));
+ window.setGeometry(QRect(m_availableTopLeft, m_testWindowSize));
+ window.show();
+
+ QTRY_VERIFY(window.received(QEvent::Expose));
+ QTRY_VERIFY(window.received(QEvent::Paint));
+ QVERIFY(window.isExposed());
+
+ // There is no defined order between paint and expose, so we don't test that
+
+ window.reset();
+ window.resize(m_testWindowSize * 2);
+
+ QTRY_VERIFY(window.received(QEvent::Paint));
+ QVERIFY(!window.received(QEvent::Expose));
+
+ window.reset();
+ window.hide();
+
+ QTRY_VERIFY(window.received(QEvent::Expose));
+ QVERIFY(!window.received(QEvent::Paint));
+ QVERIFY(!window.isExposed());
+}
+
void tst_QWindow::resizeEventAfterResize()
{
// Some platforms enforce minimum widths for windows, which can cause extra resize