https://bugs.kde.org/show_bug.cgi?id=357692

--- Comment #10 from Thomas Lübking <thomas.luebk...@gmail.com> ---
(In reply to Qbert from comment #9)

> Because the goal is to prevent unnecessary polling when the
> cursor is not moving at all?
Yes. Some dead-zone would be good to protect against judder. One might als want
to introduce a timer (QElapsedTimer) to keep the poll rate alive for eg. 250ms
in case you perform non-continuous movements (what's nearly inavoidable on very
slow actions)

Eg. this:

diff --git a/cursor.cpp b/cursor.cpp
index 271eec9..86f58cc 100644
--- a/cursor.cpp
+++ b/cursor.cpp
@@ -31,6 +31,7 @@ along with this program.  If not, see
<http://www.gnu.org/licenses/>.
 #include <KSharedConfig>
 // Qt
 #include <QDBusConnection>
+#include <QElapsedTimer>
 #include <QScreen>
 #include <QTimer>
 // xcb
@@ -322,12 +323,13 @@ void X11Cursor::mousePolled()
 {
     static QPoint lastPos = currentPos();
     static uint16_t lastMask = m_buttonMask;
+    static QElapsedTimer timeout;

     doGetPos(); // Update if needed

     static int distance = 0;
     distance = (2*distance + QPoint(currentPos() -
lastPos).manhattanLength())/3;
-    m_mousePollingTimer->setInterval(distance > 16 ? 25 : 100);
+    m_mousePollingTimer->setInterval((distance > 3 || timeout.restart() < 250)
? 25 : 100);

     if (lastPos != currentPos() || lastMask != m_buttonMask) {
         emit mouseChanged(currentPos(), lastPos,

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to