From 123e361f5505254bcf202d25cf3acd7e0e207d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 2 Sep 2015 11:36:36 +0200 Subject: [PATCH] [libinput] Pointer motion event compression If we have multiple pointer motion events we compress it to just one. --- libinput/connection.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libinput/connection.cpp b/libinput/connection.cpp index 644979e428..3f732aa87f 100644 --- a/libinput/connection.cpp +++ b/libinput/connection.cpp @@ -219,7 +219,20 @@ void Connection::processEvents() } case LIBINPUT_EVENT_POINTER_MOTION: { PointerEvent *pe = static_cast(event.data()); - emit pointerMotion(pe->delta(), pe->time()); + QPointF delta = pe->delta(); + quint32 latestTime = pe->time(); + auto it = m_eventQueue.begin(); + while (it != m_eventQueue.end()) { + if ((*it)->type() == LIBINPUT_EVENT_POINTER_MOTION) { + QScopedPointer p(static_cast(*it)); + delta += p->delta(); + latestTime = p->time(); + it = m_eventQueue.erase(it); + } else { + break; + } + } + emit pointerMotion(delta, latestTime); break; } case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: {