diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2016-08-24 08:29:59 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-08-24 19:33:29 +0000 |
commit | c899e0f334f02c1483665cf4cca10cbfaf3b7d18 (patch) | |
tree | 4c18bd304de7ec934c2be433c8316d7a7f1a6069 | |
parent | 54765577f1b89175f8b1fae842c9ffd2c96f4943 (diff) |
Fix timeout handling in input chords
Change-Id: Ic4ab2d781403ada1206e7429ad1cd16ea2330aed
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-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); } }; |