From 494e4a07f2c4b072147cd0051346318a7580bc60 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 5 Dec 2023 09:22:18 +0200 Subject: [PATCH] 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. --- src/plugins/shakecursor/shakedetector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/shakecursor/shakedetector.cpp b/src/plugins/shakecursor/shakedetector.cpp index 246e5d0c85..0f4e69264f 100644 --- a/src/plugins/shakecursor/shakedetector.cpp +++ b/src/plugins/shakecursor/shakedetector.cpp @@ -72,7 +72,7 @@ std::optional 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; }