autotests/pointer_input: add test for moving fullscreen windows

This commit is contained in:
Xaver Hugl 2022-08-12 15:22:06 +02:00
parent 8a154d3af1
commit 02f9978489

View file

@ -99,6 +99,7 @@ private Q_SLOTS:
void testUpdateFocusOnDecorationDestroy(); void testUpdateFocusOnDecorationDestroy();
void testModifierClickUnrestrictedMove_data(); void testModifierClickUnrestrictedMove_data();
void testModifierClickUnrestrictedMove(); void testModifierClickUnrestrictedMove();
void testModifierClickUnrestrictedFullscreenMove();
void testModifierClickUnrestrictedMoveGlobalShortcutsDisabled(); void testModifierClickUnrestrictedMoveGlobalShortcutsDisabled();
void testModifierScrollOpacity_data(); void testModifierScrollOpacity_data();
void testModifierScrollOpacity(); void testModifierScrollOpacity();
@ -607,6 +608,57 @@ void PointerInputTest::testModifierClickUnrestrictedMove()
QVERIFY(!buttonSpy.wait(100)); 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<quint32>());
Window *window = Test::renderAndWaitForShown(surface, toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), 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() void PointerInputTest::testModifierClickUnrestrictedMoveGlobalShortcutsDisabled()
{ {
// this test ensures that Alt+mouse button press triggers unrestricted move // this test ensures that Alt+mouse button press triggers unrestricted move