Implement whell command in input handling

With that all the actions are implemented just like on X11.

There are two not yet implemented differences:
* hide splash window when clicking it
* replay event on special window
This commit is contained in:
Martin Gräßlin 2016-02-18 09:18:39 +01:00
parent 1f1a4ac6e8
commit 2a98c681d0
2 changed files with 54 additions and 1 deletions

View file

@ -62,6 +62,7 @@ private Q_SLOTS:
void testModifierClickUnrestrictedMove();
void testModifierScrollOpacity_data();
void testModifierScrollOpacity();
void testScrollAction();
private:
void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50));
@ -466,6 +467,57 @@ void PointerInputTest::testModifierScrollOpacity()
QVERIFY(!axisSpy.wait(100));
}
void PointerInputTest::testScrollAction()
{
// this test verifies that scroll on inactive window performs a mouse action
using namespace KWayland::Client;
auto pointer = m_seat->createPointer(m_seat);
QVERIFY(pointer);
QVERIFY(pointer->isValid());
QSignalSpy axisSpy(pointer, &Pointer::axisChanged);
QVERIFY(axisSpy.isValid());
// first modify the config for this run
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
group.writeEntry("CommandWindowWheel", "activate and scroll");
group.sync();
workspace()->slotReconfigure();
// create two windows
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(clientAddedSpy.isValid());
Surface *surface1 = m_compositor->createSurface(m_compositor);
QVERIFY(surface1);
ShellSurface *shellSurface1 = m_shell->createSurface(surface1, surface1);
QVERIFY(shellSurface1);
render(surface1);
QVERIFY(clientAddedSpy.wait());
AbstractClient *window1 = workspace()->activeClient();
QVERIFY(window1);
Surface *surface2 = m_compositor->createSurface(m_compositor);
QVERIFY(surface2);
ShellSurface *shellSurface2 = m_shell->createSurface(surface2, surface2);
QVERIFY(shellSurface2);
render(surface2);
QVERIFY(clientAddedSpy.wait());
AbstractClient *window2 = workspace()->activeClient();
QVERIFY(window2);
QVERIFY(window1 != window2);
// move cursor to the inactive window
Cursor::setPos(window1->geometry().center());
quint32 timestamp = 1;
QVERIFY(!window1->isActive());
waylandServer()->backend()->pointerAxisVertical(5, timestamp++);
QVERIFY(window1->isActive());
// but also the wheel event should be passed to the window
QVERIFY(axisSpy.wait());
// we need to wait a little bit, otherwise the test crashes in effectshandler, needs fixing
QTest::qWait(100);
}
}
WAYLANDTEST_MAIN(KWin::PointerInputTest)

View file

@ -568,12 +568,13 @@ public:
// check for modifier
bool passThrough = true;
if (AbstractClient *c = dynamic_cast<AbstractClient*>(input()->pointer()->window().data())) {
// TODO: implement wheel action
bool wasAction = false;
Options::MouseCommand command = Options::MouseNothing;
if (orientation == Qt::Vertical && event->modifiers() == options->commandAllModifier()) {
wasAction = true;
command = options->operationWindowMouseWheel(event->angleDelta().y());
} else {
command = c->getWheelCommand(Qt::Vertical, &wasAction);
}
if (wasAction) {
passThrough = c->performMouseCommand(command, event->globalPos());