diff --git a/autotests/integration/shell_client_test.cpp b/autotests/integration/shell_client_test.cpp --- a/autotests/integration/shell_client_test.cpp +++ b/autotests/integration/shell_client_test.cpp @@ -92,6 +92,8 @@ void testAppMenu(); void testNoDecorationModeRequested_data(); void testNoDecorationModeRequested(); + void testSendClientWithTransientToDesktop_data(); + void testSendClientWithTransientToDesktop(); }; void TestShellClient::initTestCase() @@ -1087,5 +1089,61 @@ QCOMPARE(c->isDecorated(), true); } +void TestShellClient::testSendClientWithTransientToDesktop_data() +{ + QTest::addColumn("type"); + + QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; + QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; + QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; +} + +void TestShellClient::testSendClientWithTransientToDesktop() +{ + // this test verifies that when sending a client to a desktop all transients are also send to that desktop + + VirtualDesktopManager::self()->setCount(2); + QScopedPointer surface{Test::createSurface()}; + QFETCH(Test::ShellSurfaceType, type); + QScopedPointer shellSurface{qobject_cast(Test::createShellSurface(type, surface.data()))}; + + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); + QVERIFY(c); + + // let's create a transient window + QScopedPointer transientSurface{Test::createSurface()}; + QScopedPointer transientShellSurface{qobject_cast(Test::createShellSurface(type, transientSurface.data()))}; + transientShellSurface->setTransientFor(shellSurface.data()); + + auto transient = Test::renderAndWaitForShown(transientSurface.data(), QSize(100, 50), Qt::blue); + QVERIFY(transient); + QCOMPARE(workspace()->activeClient(), transient); + QCOMPARE(transient->transientFor(), c); + QVERIFY(c->transients().contains(transient)); + + QCOMPARE(c->desktop(), 1); + QVERIFY(!c->isOnAllDesktops()); + QCOMPARE(transient->desktop(), 1); + QVERIFY(!transient->isOnAllDesktops()); + workspace()->slotWindowToDesktop(2); + + QCOMPARE(c->desktop(), 1); + QCOMPARE(transient->desktop(), 2); + + // activate c + workspace()->activateClient(c); + QCOMPARE(workspace()->activeClient(), c); + QVERIFY(c->isActive()); + + // and send it to the desktop it's already on + QCOMPARE(c->desktop(), 1); + QCOMPARE(transient->desktop(), 2); + workspace()->slotWindowToDesktop(1); + + // which should move the transient back to the desktop + QCOMPARE(c->desktop(), 1); + QCOMPARE(transient->desktop(), 1); +} + WAYLANDTEST_MAIN(TestShellClient) #include "shell_client_test.moc" diff --git a/workspace.cpp b/workspace.cpp --- a/workspace.cpp +++ b/workspace.cpp @@ -1169,14 +1169,11 @@ c->checkWorkspacePosition( QRect(), old_desktop ); - if (Client *client = dynamic_cast(c)) { - // TODO: adjust transients for non-X11 - auto transients_stacking_order = ensureStackingOrder(client->transients()); - for (auto it = transients_stacking_order.constBegin(); - it != transients_stacking_order.constEnd(); - ++it) - sendClientToDesktop(*it, desk, dont_activate); - } + auto transients_stacking_order = ensureStackingOrder(c->transients()); + for (auto it = transients_stacking_order.constBegin(); + it != transients_stacking_order.constEnd(); + ++it) + sendClientToDesktop(*it, desk, dont_activate); updateClientArea(); }