diff options
-rw-r--r-- | src/input/backend/inputchord.cpp | 24 | ||||
-rw-r--r-- | tests/auto/input/inputchord/tst_inputchord.cpp | 4 |
2 files changed, 17 insertions, 11 deletions
diff --git a/src/input/backend/inputchord.cpp b/src/input/backend/inputchord.cpp index cbac127b4..260048f99 100644 --- a/src/input/backend/inputchord.cpp +++ b/src/input/backend/inputchord.cpp @@ -136,23 +136,29 @@ void InputChord::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) bool InputChord::process(InputHandler *inputHandler, qint64 currentTime) { - if (m_startTime != 0) { - // Check if we are still inside the time limit for the chord - if ((currentTime - m_startTime) > m_timeout) { - reset(); - return false; - } - } - + const qint64 startTime = m_startTime; bool triggered = false; + int activeInputs = 0; for (const Qt3DCore::QNodeId &actionInputId : qAsConst(m_chords)) { AbstractActionInput *actionInput = inputHandler->lookupActionInput(actionInputId); if (actionInput && actionInput->process(inputHandler, currentTime)) { triggered |= actionTriggered(actionInputId); - if (m_startTime == 0) + activeInputs++; + if (startTime == 0) m_startTime = currentTime; } } + + if (startTime != 0) { + // Check if we are still inside the time limit for the chord + if ((currentTime - startTime) > m_timeout) { + reset(); + if (activeInputs > 0) + m_startTime = startTime; + return false; + } + } + return triggered; } diff --git a/tests/auto/input/inputchord/tst_inputchord.cpp b/tests/auto/input/inputchord/tst_inputchord.cpp index 1e2dc417a..cd9216646 100644 --- a/tests/auto/input/inputchord/tst_inputchord.cpp +++ b/tests/auto/input/inputchord/tst_inputchord.cpp @@ -269,10 +269,10 @@ private Q_SLOTS: QCOMPARE(backendInputChord.process(&handler, 1000000400), false); // Too late // THEN - QCOMPARE(backendInputChord.process(&handler, 1000000600), true); // Yes, that's yet another bug + QCOMPARE(backendInputChord.process(&handler, 1000000600), false); // THEN - QCOMPARE(backendInputChord.process(&handler, 1000000800), true); // Yes, that's yet another bug + QCOMPARE(backendInputChord.process(&handler, 1000000800), false); } }; |