From 84b8d866e60ed7c83f83e27e93217ed3d35d0f6c Mon Sep 17 00:00:00 2001 From: Benjamin Port Date: Tue, 30 Jun 2020 16:02:30 +0200 Subject: [PATCH] Prevent move/resize event when handling a maximize event --- .../integration/move_resize_window_test.cpp | 33 +++++++++++++++---- xdgshellclient.cpp | 1 + 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/autotests/integration/move_resize_window_test.cpp b/autotests/integration/move_resize_window_test.cpp index 2393ca3317..01c4a8b9bb 100644 --- a/autotests/integration/move_resize_window_test.cpp +++ b/autotests/integration/move_resize_window_test.cpp @@ -81,6 +81,7 @@ private Q_SLOTS: void testDestroyMoveClient(); void testDestroyResizeClient(); void testSetFullScreenWhenMoving(); + void testSetMaximizeWhenMoving(); private: KWayland::Client::ConnectionThread *m_connection = nullptr; @@ -1125,15 +1126,35 @@ void MoveResizeWindowTest::testSetFullScreenWhenMoving() auto client = Test::renderAndWaitForShown(surface.data(), QSize(500, 800), Qt::blue); QVERIFY(client); - // The client should receive a configure event upon becoming active. - QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); - QVERIFY(configureRequestedSpy.isValid()); - QVERIFY(configureRequestedSpy.wait()); - workspace()->slotWindowMove(); QCOMPARE(client->isMove(), true); client->setFullScreen(true); - QCOMPARE(client->isFullScreen(), true); + QCOMPARE(client->isMove(), false); + QCOMPARE(workspace()->moveResizeClient(), nullptr); + // Let's pretend that the client crashed. + shellSurface.reset(); + surface.reset(); + QVERIFY(Test::waitForWindowDestroyed(client)); +} + +void MoveResizeWindowTest::testSetMaximizeWhenMoving() +{ + // Ensure we disable moving event when changeMaximize is triggered + using namespace KWayland::Client; + + QScopedPointer surface(Test::createSurface()); + QVERIFY(!surface.isNull()); + + QScopedPointer shellSurface(Test::createXdgShellStableSurface(surface.data())); + QVERIFY(!shellSurface.isNull()); + + // let's render + auto client = Test::renderAndWaitForShown(surface.data(), QSize(500, 800), Qt::blue); + QVERIFY(client); + + workspace()->slotWindowMove(); + QCOMPARE(client->isMove(), true); + client->setMaximize(true, true); QCOMPARE(client->isMove(), false); QCOMPARE(workspace()->moveResizeClient(), nullptr); // Let's pretend that the client crashed. diff --git a/xdgshellclient.cpp b/xdgshellclient.cpp index 957d1c559d..744e9a1a8a 100644 --- a/xdgshellclient.cpp +++ b/xdgshellclient.cpp @@ -1757,6 +1757,7 @@ void XdgToplevelClient::changeMaximize(bool horizontal, bool vertical, bool adju } StackingUpdatesBlocker blocker(workspace()); + dontMoveResize(); // call into decoration update borders if (isDecorated() && decoration()->client() && !(options->borderlessMaximizedWindows() && m_requestedMaximizeMode == KWin::MaximizeFull)) {