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>
This commit is contained in:
parent
3e25d09b08
commit
b92ea7db49
@ -141,15 +141,25 @@ QQnxScreenEventHandler::QQnxScreenEventHandler(QQnxIntegration *integration)
|
|||||||
, m_lastButtonState(Qt::NoButton)
|
, m_lastButtonState(Qt::NoButton)
|
||||||
, m_lastMouseWindow(0)
|
, m_lastMouseWindow(0)
|
||||||
, m_touchDevice(0)
|
, m_touchDevice(0)
|
||||||
|
, m_mouseDevice(0)
|
||||||
, m_eventThread(0)
|
, m_eventThread(0)
|
||||||
, m_focusLostTimer(-1)
|
, m_focusLostTimer(-1)
|
||||||
{
|
{
|
||||||
// Create a touch device
|
// Create a touch device
|
||||||
m_touchDevice = new QPointingDevice;
|
m_touchDevice = new QPointingDevice(
|
||||||
m_touchDevice->setType(QInputDevice::DeviceType::TouchScreen);
|
QLatin1String("touchscreen"), 1, QInputDevice::DeviceType::TouchScreen,
|
||||||
m_touchDevice->setCapabilities(QPointingDevice::Capability::Position | QPointingDevice::Capability::Area | QPointingDevice::Capability::Pressure | QPointingDevice::Capability::NormalizedPosition);
|
QPointingDevice::PointerType::Finger,
|
||||||
|
QPointingDevice::Capability::Position | QPointingDevice::Capability::Area
|
||||||
|
| QPointingDevice::Capability::Pressure
|
||||||
|
| QPointingDevice::Capability::NormalizedPosition,
|
||||||
|
MaximumTouchPoints, 8);
|
||||||
QWindowSystemInterface::registerInputDevice(m_touchDevice);
|
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
|
// initialize array of touch points
|
||||||
for (int i = 0; i < MaximumTouchPoints; i++) {
|
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),
|
screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheelDelta),
|
||||||
"Failed to query event wheel delta");
|
"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
|
// Map window handle to top-level QWindow
|
||||||
QWindow *w = QQnxIntegration::instance()->window(qnxWindow);
|
QWindow *w = QQnxIntegration::instance()->window(qnxWindow);
|
||||||
|
|
||||||
@ -431,8 +445,9 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event)
|
|||||||
if (w) {
|
if (w) {
|
||||||
// Inject mouse event into Qt only if something has changed.
|
// Inject mouse event into Qt only if something has changed.
|
||||||
if (m_lastGlobalMousePoint != globalPoint || m_lastLocalMousePoint != localPoint) {
|
if (m_lastGlobalMousePoint != globalPoint || m_lastLocalMousePoint != localPoint) {
|
||||||
QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons,
|
QWindowSystemInterface::handleMouseEvent(w, timestamp, m_mouseDevice, localPoint,
|
||||||
Qt::NoButton, QEvent::MouseMove);
|
globalPoint, buttons, Qt::NoButton,
|
||||||
|
QEvent::MouseMove);
|
||||||
qScreenEventDebug() << "Qt mouse move, w=" << w << ", (" << localPoint.x() << ","
|
qScreenEventDebug() << "Qt mouse move, w=" << w << ", (" << localPoint.x() << ","
|
||||||
<< localPoint.y() << "), b=" << static_cast<int>(buttons);
|
<< localPoint.y() << "), b=" << static_cast<int>(buttons);
|
||||||
}
|
}
|
||||||
@ -446,7 +461,8 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event)
|
|||||||
int releasedButtons = (m_lastButtonState ^ buttons) & ~buttons;
|
int releasedButtons = (m_lastButtonState ^ buttons) & ~buttons;
|
||||||
for (auto button : supportedButtons) {
|
for (auto button : supportedButtons) {
|
||||||
if (releasedButtons & button) {
|
if (releasedButtons & button) {
|
||||||
QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons,
|
QWindowSystemInterface::handleMouseEvent(w, timestamp, m_mouseDevice,
|
||||||
|
localPoint, globalPoint, buttons,
|
||||||
button, QEvent::MouseButtonRelease);
|
button, QEvent::MouseButtonRelease);
|
||||||
qScreenEventDebug() << "Qt mouse release, w=" << w << ", (" << localPoint.x()
|
qScreenEventDebug() << "Qt mouse release, w=" << w << ", (" << localPoint.x()
|
||||||
<< "," << localPoint.y() << "), b=" << button;
|
<< "," << localPoint.y() << "), b=" << button;
|
||||||
@ -460,7 +476,8 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event)
|
|||||||
int pressedButtons = (m_lastButtonState ^ buttons) & buttons;
|
int pressedButtons = (m_lastButtonState ^ buttons) & buttons;
|
||||||
for (auto button : supportedButtons) {
|
for (auto button : supportedButtons) {
|
||||||
if (pressedButtons & button) {
|
if (pressedButtons & button) {
|
||||||
QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons,
|
QWindowSystemInterface::handleMouseEvent(w, timestamp, m_mouseDevice,
|
||||||
|
localPoint, globalPoint, buttons,
|
||||||
button, QEvent::MouseButtonPress);
|
button, QEvent::MouseButtonPress);
|
||||||
qScreenEventDebug() << "Qt mouse press, w=" << w << ", (" << localPoint.x()
|
qScreenEventDebug() << "Qt mouse press, w=" << w << ", (" << localPoint.x()
|
||||||
<< "," << localPoint.y() << "), b=" << button;
|
<< "," << 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
|
// Screen only supports a single wheel, so we will assume Vertical orientation for
|
||||||
// now since that is pretty much standard.
|
// now since that is pretty much standard.
|
||||||
QPoint angleDelta(0, wheelDelta);
|
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() << ","
|
qScreenEventDebug() << "Qt wheel, w=" << w << ", (" << localPoint.x() << ","
|
||||||
<< localPoint.y() << "), d=" << static_cast<int>(wheelDelta);
|
<< localPoint.y() << "), d=" << static_cast<int>(wheelDelta);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,7 @@ private:
|
|||||||
Qt::MouseButtons m_lastButtonState;
|
Qt::MouseButtons m_lastButtonState;
|
||||||
screen_window_t m_lastMouseWindow;
|
screen_window_t m_lastMouseWindow;
|
||||||
QPointingDevice *m_touchDevice;
|
QPointingDevice *m_touchDevice;
|
||||||
|
QPointingDevice *m_mouseDevice;
|
||||||
QWindowSystemInterface::TouchPoint m_touchPoints[MaximumTouchPoints];
|
QWindowSystemInterface::TouchPoint m_touchPoints[MaximumTouchPoints];
|
||||||
QList<QQnxScreenEventFilter*> m_eventFilters;
|
QList<QQnxScreenEventFilter*> m_eventFilters;
|
||||||
QQnxScreenEventThread *m_eventThread;
|
QQnxScreenEventThread *m_eventThread;
|
||||||
|
Loading…
Reference in New Issue
Block a user