diff options
author | Alexander Volkov <a.volkov@rusbitech.ru> | 2015-06-02 11:40:38 +0300 |
---|---|---|
committer | Alexander Volkov <a.volkov@rusbitech.ru> | 2015-06-03 14:05:11 +0000 |
commit | 015bc9d7ce91ab2dfe361286317da8e062536846 (patch) | |
tree | 1de8d996749b9ee472128a8c1d488827b3c4ecbb /src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | |
parent | f04ed82ca2ca7b1e4e2bbb79bec02ce932e11e48 (diff) |
xcb: Track touch points on a per device basis
Until now there was no connection between the tracked touch points and
the touch device. So the touch point for one device could be updated
by the touch event from another device.
Change-Id: I09fcf03a171cc361c6b5b4995758aa53d29ff414
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection_xi2.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index c7784ddb48..b9f9a6843e 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -52,6 +52,7 @@ struct XInput2TouchDeviceData { } XIDeviceInfo *xiDeviceInfo; QTouchDevice *qtTouchDevice; + QHash<int, QWindowSystemInterface::TouchPoint> touchPoints; // Stuff that is relevant only for touchpads QHash<int, QPointF> pointPressedPosition; // in screen coordinates where each point was pressed @@ -552,15 +553,15 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo xXIDeviceEvent *xiDeviceEvent = static_cast<xXIDeviceEvent *>(xiDevEvent); XInput2TouchDeviceData *dev = touchDeviceForId(xiDeviceEvent->sourceid); Q_ASSERT(dev); - const bool firstTouch = m_touchPoints.isEmpty(); + const bool firstTouch = dev->touchPoints.isEmpty(); if (xiDeviceEvent->evtype == XI_TouchBegin) { QWindowSystemInterface::TouchPoint tp; tp.id = xiDeviceEvent->detail % INT_MAX; tp.state = Qt::TouchPointPressed; tp.pressure = -1.0; - m_touchPoints[tp.id] = tp; + dev->touchPoints[tp.id] = tp; } - QWindowSystemInterface::TouchPoint &touchPoint = m_touchPoints[xiDeviceEvent->detail]; + QWindowSystemInterface::TouchPoint &touchPoint = dev->touchPoints[xiDeviceEvent->detail]; qreal x = fixed1616ToReal(xiDeviceEvent->root_x); qreal y = fixed1616ToReal(xiDeviceEvent->root_y); qreal nx = -1.0, ny = -1.0, d = 0.0; @@ -677,10 +678,10 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled())) qCDebug(lcQpaXInput) << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition << " area " << touchPoint.area << " pressure " << touchPoint.pressure; - QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiDeviceEvent->time, dev->qtTouchDevice, m_touchPoints.values()); + QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiDeviceEvent->time, dev->qtTouchDevice, dev->touchPoints.values()); if (touchPoint.state == Qt::TouchPointReleased) // If a touchpoint was released, we can forget it, because the ID won't be reused. - m_touchPoints.remove(touchPoint.id); + dev->touchPoints.remove(touchPoint.id); else // Make sure that we don't send TouchPointPressed/Moved in more than one QTouchEvent // with this touch point if the next XI2 event is about a different touch point. |