diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-01-23 10:28:58 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-23 13:10:00 +0100 |
commit | 7ed6a247bfcf314b4a7bc8332b813b3e92997e41 (patch) | |
tree | 827621c7626ab7a4ddad67f2155267f100c5ebd8 /src/gui/kernel/qguiapplication.cpp | |
parent | 141e5c3878cb13d1cfb5b2834193f64e620f5d99 (diff) |
Fix synthesizing mouse events when touches change ordering
There is no guarantee the touches will be listed in the same order in
an update: the platform/generic plug-in, the drivers, etc. are all
free to shuffle the list of touch points in each report (even though
the order is fairly stable with most systems).
Therefore, to be safe, move and release events should be generated not
from the first point in the list but from the one with the matching
id.
Change-Id: I6615224cbf2cfdc440143eb3191482a23d85c6a4
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 6e0d96a788..6a8f8582be 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -114,6 +114,7 @@ static bool force_reverse = false; QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0; QTouchDevice *QGuiApplicationPrivate::m_fakeTouchDevice = 0; +int QGuiApplicationPrivate::m_fakeMouseSourcePointId = 0; #ifndef QT_NO_CLIPBOARD QClipboard *QGuiApplicationPrivate::qt_clipboard = 0; @@ -1036,11 +1037,22 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To if (touchEvent.device()->type() != QTouchDevice::TouchPad) { Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton; - const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().first(); - - QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp, touchPoint.pos(), touchPoint.screenPos(), b, e->modifiers); - fake.synthetic = true; - processMouseEvent(&fake); + QList<QTouchEvent::TouchPoint> touchPoints = touchEvent.touchPoints(); + if (eventType == QEvent::TouchBegin) + m_fakeMouseSourcePointId = touchPoints.first().id(); + + for (int i = 0; i < touchPoints.count(); ++i) { + const QTouchEvent::TouchPoint &touchPoint = touchPoints.at(i); + if (touchPoint.id() == m_fakeMouseSourcePointId) { + QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp, + touchPoint.pos(), + touchPoint.screenPos(), + b, e->modifiers); + fake.synthetic = true; + processMouseEvent(&fake); + break; + } + } } } } |