diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-06-22 13:15:12 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-07-22 09:08:32 +0200 |
commit | 76d9d869072d22995fa2cc6cb5fec17c42230dc4 (patch) | |
tree | 638fabbe24bd8e1e0e0e3204af68635ece15c774 /tests | |
parent | ac4087a41ecbf5266192858d561535e3bc8e3ad1 (diff) |
qnsview: don't active QWindows inside NSWindows that are not key
A QWindow should only become Active when it's inside an
NSWindow that is Key. If the NSWindow is not key, we need
to wait for it to be so, and handle window activation
from QCocoaWindow::windowDidBecomeKey() instead. Otherwise
Qt will report a QWindow as Active when, in reality, it
is not.
Change-Id: Ib7e63b374f26af527a668c7f7d863c4168a4446d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 21 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp | 10 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 1ec296211f..6e304f2152 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -5685,6 +5685,16 @@ void tst_QWidget::moveChild() parent.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&parent)); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) { + // On some platforms (macOS), the palette will be different depending on if a + // window is active or not. And because of that, the whole window will be + // repainted when going from Inactive to Active. So wait for the window to be + // active before we continue, so the activation doesn't happen at a random + // time below. And call processEvents to have the paint events delivered right away. + QVERIFY(QTest::qWaitForWindowActive(&parent)); + qApp->processEvents(); + } + QTRY_COMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); QTRY_COMPARE(child.r, QRegion(child.rect())); @@ -8029,6 +8039,17 @@ void tst_QWidget::hideOpaqueChildWhileHidden() w.show(); QVERIFY(QTest::qWaitForWindowExposed(&w)); + + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) { + // On some platforms (macOS), the palette will be different depending on if a + // window is active or not. And because of that, the whole window will be + // repainted when going from Inactive to Active. So wait for the window to be + // active before we continue, so the activation doesn't happen at a random + // time below. And call processEvents to have the paint events delivered right away. + QVERIFY(QTest::qWaitForWindowActive(&w)); + qApp->processEvents(); + } + QTRY_COMPARE(child2.r, QRegion(child2.rect())); child.r = QRegion(); child2.r = QRegion(); diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index ccd8d0ec05..099a099c13 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -364,6 +364,16 @@ void tst_QOpenGLWidget::asViewport() widget.show(); QVERIFY(QTest::qWaitForWindowExposed(&widget)); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) { + // On some platforms (macOS), the palette will be different depending on if a + // window is active or not. And because of that, the whole window will be + // repainted when going from Inactive to Active. So wait for the window to be + // active before we continue, so the activation doesn't happen at a random + // time below. And call processEvents to have the paint events delivered right away. + QVERIFY(QTest::qWaitForWindowActive(&widget)); + qApp->processEvents(); + } + QVERIFY(view->paintCount() > 0); view->resetPaintCount(); |