From 54182e47c36e3a5ce7c6646153b2f17102309ff9 Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Mon, 25 May 2020 16:01:39 +0300 Subject: 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 Reviewed-by: James McDonnell --- .../platforms/qnx/qqnxscreeneventhandler.cpp | 49 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'src/plugins') 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(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(w->handle()))->handleActivationEvent(); - QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons); - qScreenEventDebug() << "Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << static_cast(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(wheelDelta); + QPoint angleDelta(0, wheelDelta); + QWindowSystemInterface::handleWheelEvent(w, localPoint, globalPoint, QPoint(), angleDelta); + qScreenEventDebug() << "Qt wheel, w=" << w << ", (" << localPoint.x() << "," + << localPoint.y() << "), d=" << static_cast(wheelDelta); } } -- cgit v1.2.3