From 2832aaacd4cbdb86271130dbfca284687d641a85 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Thu, 12 Jul 2012 11:39:06 +0200 Subject: Make sure the emulated mouse event comes last With the recent refactoring in qtdeclarative for the handling of touch and mouse events, QQuickCanvas automatically transforms touch events in mouse events too. It means that since we do something similar in the platform plugin, in the case of QQuickCanvas the mouse event is duplicated. It it fine except that having mouse event, touch event, mouse event in that order is likely to mess the states of some elements. It happens to be the case for MouseArea which will discard the second mouse event in the case of a press, and because of that not receive the other events. By changing the order in the plugin, we ensure getting events in the following order: touch event, mouse event, mouse event. In the case of MouseArea, since the press event will be accepted with nothing in between, we'll keep receiving the other events. Note that we can't simply remove the mouse event simulation on our side, otherwise we'd break QWidget support. Change-Id: If08fe0d97c6d60d0f858b228a014d94bc86dcf6f Reviewed-by: Thomas McGuire Reviewed-by: Kevin Krammer Reviewed-by: Sean Harmer --- .../platforms/qnx/qqnxscreeneventhandler.cpp | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index 4a1e904838..802362ca86 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -384,23 +384,6 @@ void QQnxScreenEventHandler::handleTouchEvent(screen_event_t event, int qnxType) m_lastMouseWindow = qnxWindow; if (w) { - // convert primary touch to mouse event - if (touchId == 0) { - - // convert point to local coordinates - QPoint globalPoint(pos[0], pos[1]); - QPoint localPoint(windowPos[0], windowPos[1]); - - // map touch state to button state - Qt::MouseButtons buttons = (qnxType == SCREEN_EVENT_MTOUCH_RELEASE) ? Qt::NoButton : Qt::LeftButton; - - // inject event into Qt - QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons); - qScreenEventDebug() << Q_FUNC_INFO << "Qt mouse, w =" << w - << ", (" << localPoint.x() << "," << localPoint.y() - << "), b =" << buttons; - } - // get size of screen which contains window QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(w); QSizeF screenSize = platformScreen->physicalSize(); @@ -444,6 +427,23 @@ void QQnxScreenEventHandler::handleTouchEvent(screen_event_t event, int qnxType) qScreenEventDebug() << Q_FUNC_INFO << "Qt touch, w =" << w << ", p=(" << pos[0] << "," << pos[1] << "), t=" << type; + + // convert primary touch to mouse event + if (touchId == 0) { + + // convert point to local coordinates + QPoint globalPoint(pos[0], pos[1]); + QPoint localPoint(windowPos[0], windowPos[1]); + + // map touch state to button state + Qt::MouseButtons buttons = (qnxType == SCREEN_EVENT_MTOUCH_RELEASE) ? Qt::NoButton : Qt::LeftButton; + + // inject event into Qt + QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons); + qScreenEventDebug() << Q_FUNC_INFO << "Qt mouse, w =" << w + << ", (" << localPoint.x() << "," << localPoint.y() + << "), b =" << buttons; + } } } } -- cgit v1.2.3