From 97160c9b90327776e22e0b534ce8ecd4e27a601b Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 7 Dec 2021 09:47:39 +0200 Subject: [PATCH] autotests: Add a test that checks one possible corner case during xdg-toplevel initialization If the preferred decoration mode changes after the initial commit but before the surface is mapped, there's a chance that kwin can send a bad configure event, it's been the case in the past. Add a test to prevent such cases go unnoticed. --- autotests/integration/xdgshellclient_test.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/autotests/integration/xdgshellclient_test.cpp b/autotests/integration/xdgshellclient_test.cpp index c8ff0d0748..bc5375713e 100644 --- a/autotests/integration/xdgshellclient_test.cpp +++ b/autotests/integration/xdgshellclient_test.cpp @@ -106,6 +106,7 @@ private Q_SLOTS: void testDoubleMaximize(); void testMaximizeAndChangeDecorationModeAfterInitialCommit(); void testFullScreenAndChangeDecorationModeAfterInitialCommit(); + void testChangeDecorationModeAfterInitialCommit(); }; void TestXdgShellClient::testXdgWindowReactive() @@ -1885,5 +1886,32 @@ void TestXdgShellClient::testFullScreenAndChangeDecorationModeAfterInitialCommit QCOMPARE(toplevelConfigureRequestedSpy.last().at(1).value(), Test::XdgToplevel::State::Fullscreen); } +void TestXdgShellClient::testChangeDecorationModeAfterInitialCommit() +{ + // This test verifies that the compositor will respond with a good configure event when + // the decoration mode changes after the first surface commit but before the surface is mapped. + + QScopedPointer surface(Test::createSurface()); + QScopedPointer shellSurface(Test::createXdgToplevelSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); + QScopedPointer decoration(Test::createXdgToplevelDecorationV1(shellSurface.data())); + QSignalSpy decorationConfigureRequestedSpy(decoration.data(), &Test::XdgToplevelDecorationV1::configureRequested); + QSignalSpy toplevelConfigureRequestedSpy(shellSurface.data(), &Test::XdgToplevel::configureRequested); + QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested); + + // Perform the initial commit. + surface->commit(KWayland::Client::Surface::CommitFlag::None); + QVERIFY(surfaceConfigureRequestedSpy.wait()); + QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value(), QSize(0, 0)); + QCOMPARE(decorationConfigureRequestedSpy.last().at(0).value(), Test::XdgToplevelDecorationV1::mode_server_side); + + // Change decoration mode. + decoration->set_mode(Test::XdgToplevelDecorationV1::mode_client_side); + + // The configure event should still have 0x0 size. + QVERIFY(surfaceConfigureRequestedSpy.wait()); + QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value(), QSize(0, 0)); + QCOMPARE(decorationConfigureRequestedSpy.last().at(0).value(), Test::XdgToplevelDecorationV1::mode_client_side); +} + WAYLANDTEST_MAIN(TestXdgShellClient) #include "xdgshellclient_test.moc"