plugins/shakecursor: Don't trigger for cursor pushback

The shake detector is mistriggered by sporadic pointer movement when the
cursor is pushed back by a screen edge.

As a way to prevent it, this change adds a bounding rectangle
constraint. The cursor will move chaotically within a small bounding
rectangle if it's pushed back. So it should be enough to just check
the length of the diagonal.
This commit is contained in:
Vlad Zahorodnii 2023-12-05 09:22:18 +02:00
parent 999814796b
commit 494e4a07f2

View file

@ -72,7 +72,7 @@ std::optional<qreal> ShakeDetector::update(QMouseEvent *event)
const qreal boundsWidth = right - left;
const qreal boundsHeight = bottom - top;
const qreal diagonal = std::sqrt(boundsWidth * boundsWidth + boundsHeight * boundsHeight);
if (diagonal == 0) {
if (diagonal < 100) {
return std::nullopt;
}