From 02f9978489a8c09c316f0ce97f73e324f48d966d Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Fri, 12 Aug 2022 15:22:06 +0200 Subject: [PATCH] autotests/pointer_input: add test for moving fullscreen windows --- autotests/integration/pointer_input.cpp | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/autotests/integration/pointer_input.cpp b/autotests/integration/pointer_input.cpp index 3946f6d3f3..34ae7ed5d2 100644 --- a/autotests/integration/pointer_input.cpp +++ b/autotests/integration/pointer_input.cpp @@ -99,6 +99,7 @@ private Q_SLOTS: void testUpdateFocusOnDecorationDestroy(); void testModifierClickUnrestrictedMove_data(); void testModifierClickUnrestrictedMove(); + void testModifierClickUnrestrictedFullscreenMove(); void testModifierClickUnrestrictedMoveGlobalShortcutsDisabled(); void testModifierScrollOpacity_data(); void testModifierScrollOpacity(); @@ -607,6 +608,57 @@ void PointerInputTest::testModifierClickUnrestrictedMove() QVERIFY(!buttonSpy.wait(100)); } +void PointerInputTest::testModifierClickUnrestrictedFullscreenMove() +{ + // this test ensures that Meta+mouse button press triggers unrestricted move for fullscreen windows + if (workspace()->outputs().size() < 2) { + QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); + } + + // first modify the config for this run + KConfigGroup group = kwinApp()->config()->group("MouseBindings"); + group.writeEntry("CommandAllKey", "Meta"); + group.writeEntry("CommandAll1", "Move"); + group.writeEntry("CommandAll2", "Move"); + group.writeEntry("CommandAll3", "Move"); + group.sync(); + workspace()->slotReconfigure(); + QCOMPARE(options->commandAllModifier(), Qt::MetaModifier); + QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); + QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); + QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); + + // create a window + KWayland::Client::Surface *surface = Test::createSurface(m_compositor); + QVERIFY(surface); + Test::XdgToplevel *shellSurface = Test::createXdgToplevelSurface(surface, surface); + QVERIFY(shellSurface); + shellSurface->set_fullscreen(nullptr); + QSignalSpy toplevelConfigureRequestedSpy(shellSurface, &Test::XdgToplevel::configureRequested); + QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested); + QVERIFY(surfaceConfigureRequestedSpy.wait()); + shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value()); + Window *window = Test::renderAndWaitForShown(surface, toplevelConfigureRequestedSpy.last().at(0).value(), Qt::blue); + QVERIFY(window); + QVERIFY(window->isFullScreen()); + + // move cursor on window + Cursors::self()->mouse()->setPos(window->frameGeometry().center()); + + // simulate modifier+click + quint32 timestamp = 1; + Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++); + QVERIFY(!window->isInteractiveMove()); + Test::pointerButtonPressed(BTN_LEFT, timestamp++); + QVERIFY(window->isInteractiveMove()); + // release modifier should not change it + Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++); + QVERIFY(window->isInteractiveMove()); + // but releasing the key should end move/resize + Test::pointerButtonReleased(BTN_LEFT, timestamp++); + QVERIFY(!window->isInteractiveMove()); +} + void PointerInputTest::testModifierClickUnrestrictedMoveGlobalShortcutsDisabled() { // this test ensures that Alt+mouse button press triggers unrestricted move