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 <jens.bache-wiig@digia.com>
This commit is contained in:
Samuel Rødal 2012-11-09 18:16:04 +01:00 committed by The Qt Project
parent e5eeffbf8b
commit d729ca5ece

View File

@ -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<PeekFunc>::iterator it = m_peekFuncs.begin();
while (it != m_peekFuncs.end()) {
// These callbacks return true if the event is what they were