Commit bd58d779 authored by Martin Flöser's avatar Martin Flöser

Don't trigger modifier only shortcuts if pointer interaction

Summary:
If the user clicked a pointer button or scrolled a pointer axis the
held modifier was most likely intended to modify the pointer event.
Thus the modifier only shortcut should not be triggered.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2435
parent 3a730fa5
......@@ -197,7 +197,6 @@ void ModifierOnlyShortcutTest::testTrigger()
kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++);
kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++);
QCOMPARE(input()->qtButtonStates(), Qt::NoButton);
QEXPECT_FAIL("", "Button not yet handled", Continue);
QCOMPARE(triggeredSpy.count(), 2);
// mouse button press before mod press, release before mod release
......@@ -207,7 +206,6 @@ void ModifierOnlyShortcutTest::testTrigger()
kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++);
QCOMPARE(input()->qtButtonStates(), Qt::NoButton);
QEXPECT_FAIL("", "Button not yet handled", Continue);
QCOMPARE(triggeredSpy.count(), 2);
// mouse button click while mod is pressed
......@@ -217,21 +215,18 @@ void ModifierOnlyShortcutTest::testTrigger()
kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++);
QCOMPARE(input()->qtButtonStates(), Qt::NoButton);
QEXPECT_FAIL("", "Button not yet handled", Continue);
QCOMPARE(triggeredSpy.count(), 2);
// scroll while mod is pressed
kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++);
kwinApp()->platform()->pointerAxisVertical(5.0, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++);
QEXPECT_FAIL("", "Axis not yet handled", Continue);
QCOMPARE(triggeredSpy.count(), 2);
// same for horizontal
kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++);
kwinApp()->platform()->pointerAxisHorizontal(5.0, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++);
QEXPECT_FAIL("", "Axis not yet handled", Continue);
QCOMPARE(triggeredSpy.count(), 2);
}
......
......@@ -95,6 +95,12 @@ Xkb::Xkb(InputRedirection *input)
xkb_context_set_log_level(m_context, XKB_LOG_LEVEL_DEBUG);
xkb_context_set_log_fn(m_context, &xkbLogHandler);
}
auto resetModOnlyShortcut = [this] {
m_modOnlyShortcut.modifier = Qt::NoModifier;
};
QObject::connect(m_input, &InputRedirection::pointerButtonStateChanged, resetModOnlyShortcut);
QObject::connect(m_input, &InputRedirection::pointerAxisChanged, resetModOnlyShortcut);
}
Xkb::~Xkb()
......@@ -243,7 +249,8 @@ void Xkb::updateKey(uint32_t key, InputRedirection::KeyboardKeyState state)
updateModifiers();
if (state == InputRedirection::KeyboardKeyPressed) {
m_modOnlyShortcut.pressCount++;
if (m_modOnlyShortcut.pressCount == 1) {
if (m_modOnlyShortcut.pressCount == 1 &&
m_input->qtButtonStates() == Qt::NoButton) {
m_modOnlyShortcut.modifier = Qt::KeyboardModifier(int(m_modifiers));
} else {
m_modOnlyShortcut.modifier = Qt::NoModifier;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment