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.
This commit is contained in:
parent
ac9b9a6772
commit
e68ac506af
3 changed files with 9 additions and 2 deletions
|
@ -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…
Reference in a new issue