diff options
author | Samuli Piippo <samuli.piippo@qt.io> | 2020-08-10 13:44:48 +0300 |
---|---|---|
committer | Samuli Piippo <samuli.piippo@qt.io> | 2020-08-12 12:17:10 +0300 |
commit | b92ea7db490933fd8385d7f3f3da272b79cdb023 (patch) | |
tree | bec818a9ddd7089487e95312fca4dce3b0c1c617 /src/plugins/platforms/qnx | |
parent | 3e25d09b08cc817f8f991fbf2420618516dd9061 (diff) |
QNX: register mouse input device
Use the new QWSI APIs that take a registered input device.
Task-number: QTBUG-85852
Change-Id: Iefb8239a60ff819172ba64f35f120cdc6975257f
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/plugins/platforms/qnx')
-rw-r--r-- | src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp | 34 | ||||
-rw-r--r-- | src/plugins/platforms/qnx/qqnxscreeneventhandler.h | 1 |
2 files changed, 27 insertions, 8 deletions
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index f922f8bb45..7e971b2d66 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -141,15 +141,25 @@ QQnxScreenEventHandler::QQnxScreenEventHandler(QQnxIntegration *integration) , m_lastButtonState(Qt::NoButton) , m_lastMouseWindow(0) , m_touchDevice(0) + , m_mouseDevice(0) , m_eventThread(0) , m_focusLostTimer(-1) { // Create a touch device - m_touchDevice = new QPointingDevice; - m_touchDevice->setType(QInputDevice::DeviceType::TouchScreen); - m_touchDevice->setCapabilities(QPointingDevice::Capability::Position | QPointingDevice::Capability::Area | QPointingDevice::Capability::Pressure | QPointingDevice::Capability::NormalizedPosition); + m_touchDevice = new QPointingDevice( + QLatin1String("touchscreen"), 1, QInputDevice::DeviceType::TouchScreen, + QPointingDevice::PointerType::Finger, + QPointingDevice::Capability::Position | QPointingDevice::Capability::Area + | QPointingDevice::Capability::Pressure + | QPointingDevice::Capability::NormalizedPosition, + MaximumTouchPoints, 8); QWindowSystemInterface::registerInputDevice(m_touchDevice); + m_mouseDevice = new QPointingDevice(QLatin1String("mouse"), 2, QInputDevice::DeviceType::Mouse, + QPointingDevice::PointerType::Generic, + QPointingDevice::Capability::Position, 1, 8); + QWindowSystemInterface::registerInputDevice(m_mouseDevice); + // initialize array of touch points for (int i = 0; i < MaximumTouchPoints; i++) { @@ -377,6 +387,10 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event) screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheelDelta), "Failed to query event wheel delta"); + long long timestamp; + Q_SCREEN_CHECKERROR(screen_get_event_property_llv(event, SCREEN_PROPERTY_TIMESTAMP, ×tamp), + "Failed to get timestamp"); + // Map window handle to top-level QWindow QWindow *w = QQnxIntegration::instance()->window(qnxWindow); @@ -431,8 +445,9 @@ 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) { - QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons, - Qt::NoButton, QEvent::MouseMove); + QWindowSystemInterface::handleMouseEvent(w, timestamp, m_mouseDevice, localPoint, + globalPoint, buttons, Qt::NoButton, + QEvent::MouseMove); qScreenEventDebug() << "Qt mouse move, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << static_cast<int>(buttons); } @@ -446,7 +461,8 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event) int releasedButtons = (m_lastButtonState ^ buttons) & ~buttons; for (auto button : supportedButtons) { if (releasedButtons & button) { - QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons, + QWindowSystemInterface::handleMouseEvent(w, timestamp, m_mouseDevice, + localPoint, globalPoint, buttons, button, QEvent::MouseButtonRelease); qScreenEventDebug() << "Qt mouse release, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << button; @@ -460,7 +476,8 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event) int pressedButtons = (m_lastButtonState ^ buttons) & buttons; for (auto button : supportedButtons) { if (pressedButtons & button) { - QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons, + QWindowSystemInterface::handleMouseEvent(w, timestamp, m_mouseDevice, + localPoint, globalPoint, buttons, button, QEvent::MouseButtonPress); qScreenEventDebug() << "Qt mouse press, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << button; @@ -472,7 +489,8 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event) // Screen only supports a single wheel, so we will assume Vertical orientation for // now since that is pretty much standard. QPoint angleDelta(0, wheelDelta); - QWindowSystemInterface::handleWheelEvent(w, localPoint, globalPoint, QPoint(), angleDelta); + QWindowSystemInterface::handleWheelEvent(w, timestamp, m_mouseDevice, localPoint, + globalPoint, QPoint(), angleDelta); qScreenEventDebug() << "Qt wheel, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), d=" << static_cast<int>(wheelDelta); } diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h index c20905fe0d..e7ee5e8118 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h @@ -98,6 +98,7 @@ private: Qt::MouseButtons m_lastButtonState; screen_window_t m_lastMouseWindow; QPointingDevice *m_touchDevice; + QPointingDevice *m_mouseDevice; QWindowSystemInterface::TouchPoint m_touchPoints[MaximumTouchPoints]; QList<QQnxScreenEventFilter*> m_eventFilters; QQnxScreenEventThread *m_eventThread; |