diff options
author | Samuli Piippo <samuli.piippo@qt.io> | 2020-05-25 16:01:39 +0300 |
---|---|---|
committer | Samuli Piippo <samuli.piippo@qt.io> | 2020-08-05 09:34:50 +0300 |
commit | 54182e47c36e3a5ce7c6646153b2f17102309ff9 (patch) | |
tree | 4c991dfdcb30477869d6d260455194de556799e4 /src/plugins/platforms/qnx | |
parent | 4886514fc3345422b74f78171862247fc73e2c0d (diff) |
QNX: adapt to new event APIs
Use the new event APIs and split the single mouse event into
three separate events (move, press, release). QNX events only
give us current state, deduce the pressed and released buttons
by comparing to the previous state.
Change-Id: I9e647922679ddb792b10cb5e6ceee7ede4878444
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
Diffstat (limited to 'src/plugins/platforms/qnx')
-rw-r--r-- | src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index 5653c9ee57..f922f8bb45 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -414,7 +414,7 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event) if (buttonState & 0x01) buttons |= Qt::LeftButton; if (buttonState & 0x02) - buttons |= Qt::MidButton; + buttons |= Qt::MiddleButton; if (buttonState & 0x04) buttons |= Qt::RightButton; if (buttonState & 0x08) @@ -430,20 +430,51 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event) if (w) { // Inject mouse event into Qt only if something has changed. - if (m_lastGlobalMousePoint != globalPoint || - m_lastLocalMousePoint != localPoint || - m_lastButtonState != buttons) { - if (m_lastButtonState != 0 && buttons == 0) + if (m_lastGlobalMousePoint != globalPoint || m_lastLocalMousePoint != localPoint) { + QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons, + Qt::NoButton, QEvent::MouseMove); + qScreenEventDebug() << "Qt mouse move, w=" << w << ", (" << localPoint.x() << "," + << localPoint.y() << "), b=" << static_cast<int>(buttons); + } + + if (m_lastButtonState != buttons) { + static const auto supportedButtons = { Qt::LeftButton, Qt::MiddleButton, + Qt::RightButton, Qt::ExtraButton1, + Qt::ExtraButton2, Qt::ExtraButton3, + Qt::ExtraButton4, Qt::ExtraButton5 }; + + int releasedButtons = (m_lastButtonState ^ buttons) & ~buttons; + for (auto button : supportedButtons) { + if (releasedButtons & button) { + QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons, + button, QEvent::MouseButtonRelease); + qScreenEventDebug() << "Qt mouse release, w=" << w << ", (" << localPoint.x() + << "," << localPoint.y() << "), b=" << button; + } + } + + if (m_lastButtonState != 0 && buttons == 0) { (static_cast<QQnxWindow *>(w->handle()))->handleActivationEvent(); - QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons); - qScreenEventDebug() << "Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << static_cast<int>(buttons); + } + + int pressedButtons = (m_lastButtonState ^ buttons) & buttons; + for (auto button : supportedButtons) { + if (pressedButtons & button) { + QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons, + button, QEvent::MouseButtonPress); + qScreenEventDebug() << "Qt mouse press, w=" << w << ", (" << localPoint.x() + << "," << localPoint.y() << "), b=" << button; + } + } } if (wheelDelta) { // Screen only supports a single wheel, so we will assume Vertical orientation for // now since that is pretty much standard. - QWindowSystemInterface::handleWheelEvent(w, localPoint, globalPoint, wheelDelta, Qt::Vertical); - qScreenEventDebug() << "Qt wheel, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), d=" << static_cast<int>(wheelDelta); + QPoint angleDelta(0, wheelDelta); + QWindowSystemInterface::handleWheelEvent(w, localPoint, globalPoint, QPoint(), angleDelta); + qScreenEventDebug() << "Qt wheel, w=" << w << ", (" << localPoint.x() << "," + << localPoint.y() << "), d=" << static_cast<int>(wheelDelta); } } |