From 72a7882cec07a9ad187c9e1772fb08f59a4b9519 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 18 Oct 2013 12:36:47 +0200 Subject: Better QWindowContainer by not relying on native widgets. We change the behavior slightly from the initial implementation in 5.1. Forcing the use of native child widgets is causing massive performance issues so instead, we attach the embedded QWindow directly to the root window. The only exception is QScrollArea and QMdiArea which still enforces native windows for the entire parent chain to make clipping and stacking work. Task-number: QTBUG-34138 Change-Id: If713637bd4dce630552ace2f8ad6b2e86c063721 Reviewed-by: Lars Knoll --- .../qwindowcontainer/tst_qwindowcontainer.cpp | 62 ++++++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) (limited to 'tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp') diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index 2d9cb98e27..c17a03e058 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -68,8 +68,6 @@ public: int numberOfObscures; }; - - class tst_QWindowContainer: public QObject { Q_OBJECT @@ -81,6 +79,7 @@ private slots: void testBehindTheScenesDeletion(); void testUnparenting(); void testActivation(); + void testAncestorChange(); }; @@ -188,6 +187,7 @@ void tst_QWindowContainer::testActivation() root.show(); root.activateWindow(); + QVERIFY(QTest::qWaitForWindowExposed(&root)); QVERIFY(QTest::qWaitForWindowActive(root.windowHandle())); QVERIFY(QGuiApplication::focusWindow() == root.windowHandle()); @@ -204,8 +204,7 @@ void tst_QWindowContainer::testActivation() QTest::qWait(100); window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QVERIFY(QGuiApplication::focusWindow() == window); + QTRY_VERIFY(QGuiApplication::focusWindow() == window); // Verify that all states in the root widget still indicate it is active QVERIFY(root.windowHandle()->isActive()); @@ -231,6 +230,61 @@ void tst_QWindowContainer::testUnparenting() QVERIFY(!window->isVisible()); } +void tst_QWindowContainer::testAncestorChange() +{ + QWidget root; + QWidget *left = new QWidget(&root); + QWidget *right = new QWidget(&root); + + root.setGeometry(0, 0, 200, 100); + left->setGeometry(0, 0, 100, 100); + right->setGeometry(100, 0, 100, 100); + + QWindow *window = new QWindow(); + QWidget *container = QWidget::createWindowContainer(window, left); + container->setGeometry(0, 0, 100, 100); + + // Root + // + left + // | + container + // | + window + // + right + root.show(); + QVERIFY(QTest::qWaitForWindowExposed(&root)); + QCOMPARE(window->geometry(), QRect(0, 0, 100, 100)); + + container->setParent(right); + // Root + // + left + // + right + // + container + // + window + QCOMPARE(window->geometry(), QRect(100, 0, 100, 100)); + + QWidget *newRoot = new QWidget(&root); + newRoot->setGeometry(50, 50, 200, 200); + right->setParent(newRoot); + // Root + // + left + // + newRoot + // + right + // + container + // + window + QCOMPARE(window->geometry(), QRect(150, 50, 100, 100)); + newRoot->move(0, 0); + QCOMPARE(window->geometry(), QRect(100, 0, 100, 100)); + + newRoot->setParent(0); + newRoot->setGeometry(100, 100, 200, 200); + newRoot->show(); + QVERIFY(QTest::qWaitForWindowExposed(newRoot)); + // newRoot + // + right + // + container + // + window + QCOMPARE(window->geometry(), QRect(100, 0, 100, 100)); +} + QTEST_MAIN(tst_QWindowContainer) #include "tst_qwindowcontainer.moc" -- cgit v1.2.3