Skip to content

Commit

Permalink
QNX: register mouse input device
Browse files Browse the repository at this point in the history
Use the new QWSI APIs that take a registered input device.

Task-number: QTBUG-85852
Change-Id: Iefb8239a60ff819172ba64f35f120cdc6975257f
Reviewed-by: Ville Voutilainen <[email protected]>
Reviewed-by: James McDonnell <[email protected]>
Reviewed-by: Shawn Rutledge <[email protected]>
  • Loading branch information
sapiippo committed Aug 12, 2020
1 parent 3e25d09 commit b92ea7d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {

Expand Down Expand Up @@ -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, &timestamp),
"Failed to get timestamp");

// Map window handle to top-level QWindow
QWindow *w = QQnxIntegration::instance()->window(qnxWindow);

Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/platforms/qnx/qqnxscreeneventhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private Q_SLOTS:
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;
Expand Down

0 comments on commit b92ea7d

Please sign in to comment.