Ignore modifier mouse actions when the pointer is constrained

Summary:
If the pointer is constrained all mouse events should go to the window.
Also our Alt+click. To use Alt+click nevertheless one can just unconfine
the window.

CCBUG: 399375

Test Plan: Run the adjusted autotest before and after change

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15982
This commit is contained in:
Martin Flöser 2018-10-06 18:03:19 +02:00
parent e16334b3f2
commit cefc15e573
2 changed files with 37 additions and 14 deletions

View file

@ -186,6 +186,27 @@ void TestPointerConstraints::testConfinedPointer()
QCOMPARE(pointerPositionChangedSpy.count(), 1);
QCOMPARE(KWin::Cursor::pos(), position);
// modifier + click should be ignored
// first ensure the settings are ok
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
group.writeEntry("CommandAllKey", QStringLiteral("Alt"));
group.writeEntry("CommandAll1", "Move");
group.writeEntry("CommandAll2", "Move");
group.writeEntry("CommandAll3", "Move");
group.sync();
workspace()->slotReconfigure();
QCOMPARE(options->commandAllModifier(), Qt::AltModifier);
QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove);
QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove);
QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove);
quint32 timestamp = 1;
kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++);
kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++);
QVERIFY(!c->isMove());
kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++);
// deactivate the client, this should unconfine
workspace()->activateClient(nullptr);
QVERIFY(unconfinedSpy.wait());

View file

@ -707,20 +707,22 @@ std::pair<bool, bool> performClientMouseAction(QMouseEvent *event, AbstractClien
Options::MouseCommand command = Options::MouseNothing;
bool wasAction = false;
if (static_cast<MouseEvent*>(event)->modifiersRelevantForGlobalShortcuts() == options->commandAllModifier()) {
wasAction = true;
switch (event->button()) {
case Qt::LeftButton:
command = options->commandAll1();
break;
case Qt::MiddleButton:
command = options->commandAll2();
break;
case Qt::RightButton:
command = options->commandAll3();
break;
default:
// nothing
break;
if (!input()->pointer()->isConstrained()) {
wasAction = true;
switch (event->button()) {
case Qt::LeftButton:
command = options->commandAll1();
break;
case Qt::MiddleButton:
command = options->commandAll2();
break;
case Qt::RightButton:
command = options->commandAll3();
break;
default:
// nothing
break;
}
}
} else {
if (action == MouseAction::ModifierAndWindow) {