From d729ca5ece6a9cfa0a3e90af96142da59b8cd796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 9 Nov 2012 18:16:04 +0100 Subject: Added motion event compression in xcb plugin. We did this in 4.8 too, to avoid swamping the event queue with stale motion events. If you're interested in fine grained motion events you just need to have a responsive main loop. Most applications are only interested in the latest mouse position in any case. Fixes performance issues in QML where an onMouseXChanged or onMouseYChanged in a mouse area does directly or indirectly runs some heavy computations, slowing rendering to a halt since the main loop is constantly busy. Change-Id: I169c96458db4d57b689d6c2c915765b11c35e123 Reviewed-by: Jens Bache-Wiig --- src/plugins/platforms/xcb/qxcbconnection.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 266491d5d9..78f1efb745 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -961,6 +961,14 @@ void QXcbConnection::processXcbEvents() if (!response_type) { handleXcbError((xcb_generic_error_t *)event); } else { + if (response_type == XCB_MOTION_NOTIFY) { + // compress multiple motion notify events in a row + // to avoid swamping the event queue + xcb_generic_event_t *next = eventqueue->value(i+1, 0); + if (next && (next->response_type & ~0x80) == XCB_MOTION_NOTIFY) + continue; + } + QVector::iterator it = m_peekFuncs.begin(); while (it != m_peekFuncs.end()) { // These callbacks return true if the event is what they were -- cgit v1.2.3