diff --git a/src/plugins/shakecursor/shakecursor.cpp b/src/plugins/shakecursor/shakecursor.cpp index 926298726c..048dac8a0d 100644 --- a/src/plugins/shakecursor/shakecursor.cpp +++ b/src/plugins/shakecursor/shakecursor.cpp @@ -94,11 +94,12 @@ void ShakeCursorEffect::animateTo(qreal magnification) void ShakeCursorEffect::pointerEvent(MouseEvent *event) { - if (event->type() != QEvent::MouseMove || event->buttons() != Qt::NoButton) { + if (event->buttons() != Qt::NoButton) { + m_shakeDetector.reset(); return; } - if (input()->pointer()->isConstrained()) { + if (input()->pointer()->isConstrained() || event->type() != QEvent::MouseMove) { return; } diff --git a/src/plugins/shakecursor/shakedetector.cpp b/src/plugins/shakecursor/shakedetector.cpp index 10962ba49d..146879e5f7 100644 --- a/src/plugins/shakecursor/shakedetector.cpp +++ b/src/plugins/shakecursor/shakedetector.cpp @@ -39,6 +39,11 @@ static inline bool sameSign(qreal a, qreal b) return (a >= -tolerance && b >= -tolerance) || (a <= tolerance && b <= tolerance); } +void ShakeDetector::reset() +{ + m_history.clear(); +} + bool ShakeDetector::update(QMouseEvent *event) { // Prune the old entries in the history. diff --git a/src/plugins/shakecursor/shakedetector.h b/src/plugins/shakecursor/shakedetector.h index 25f40a7560..4ec7289f29 100644 --- a/src/plugins/shakecursor/shakedetector.h +++ b/src/plugins/shakecursor/shakedetector.h @@ -22,6 +22,7 @@ class ShakeDetector public: ShakeDetector(); + void reset(); bool update(QMouseEvent *event); quint64 interval() const;