plugins/shakecursor: reset detector on mouse press

A sequence of mouse moves shouldn't trigger the effect if the user
presses any mouse button during the mouse moves.
wilder/Plasma/6.2
Yifan Zhu 2 years ago
parent ac9b9a6772
commit e68ac506af
  1. 5
      src/plugins/shakecursor/shakecursor.cpp
  2. 5
      src/plugins/shakecursor/shakedetector.cpp
  3. 1
      src/plugins/shakecursor/shakedetector.h

@ -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;
}

@ -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.

@ -22,6 +22,7 @@ class ShakeDetector
public:
ShakeDetector();
void reset();
bool update(QMouseEvent *event);
quint64 interval() const;

Loading…
Cancel
Save