合并触摸patch1

This commit is contained in:
韩品龙 2023-05-24 13:43:45 +08:00
parent 666891139d
commit 2ac5249eb0
2 changed files with 23 additions and 3 deletions

View File

@ -3058,6 +3058,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
Qt::MouseButton button = Qt::NoButton; Qt::MouseButton button = Qt::NoButton;
Qt::MouseButtons buttons = Qt::LeftButton; Qt::MouseButtons buttons = Qt::LeftButton;
if (eventType == QEvent::TouchBegin && m_fakeMouseSourcePointId < 0) if (eventType == QEvent::TouchBegin && m_fakeMouseSourcePointId < 0)
|| (touchPoints.count() == 1 && m_fakeMouseSourcePointId != touchPoints.first().id()))
m_fakeMouseSourcePointId = touchPoints.first().id(); m_fakeMouseSourcePointId = touchPoints.first().id();
for (const auto &touchPoint : touchPoints) { for (const auto &touchPoint : touchPoints) {
if (touchPoint.id() == m_fakeMouseSourcePointId) { if (touchPoint.id() == m_fakeMouseSourcePointId) {

View File

@ -286,9 +286,11 @@ void QXcbConnection::xi2SetupDevices()
m_tabletData.clear(); m_tabletData.clear();
#endif #endif
m_scrollingDevices.clear(); m_scrollingDevices.clear();
m_touchDevices.clear();
m_xiMasterPointerIds.clear(); m_xiMasterPointerIds.clear();
// FIXBUG: #123235 触摸过程中插拔usb键盘/鼠标导致触摸失效
QList<quint16> deviceIds;
auto reply = Q_XCB_REPLY(xcb_input_xi_query_device, xcb_connection(), XCB_INPUT_DEVICE_ALL); auto reply = Q_XCB_REPLY(xcb_input_xi_query_device, xcb_connection(), XCB_INPUT_DEVICE_ALL);
if (!reply) { if (!reply) {
qCDebug(lcQpaXInputDevices) << "failed to query devices"; qCDebug(lcQpaXInputDevices) << "failed to query devices";
@ -303,8 +305,21 @@ void QXcbConnection::xi2SetupDevices()
continue; continue;
} }
// only slave pointer devices are relevant here // only slave pointer devices are relevant here
if (deviceInfo->type == XCB_INPUT_DEVICE_TYPE_SLAVE_POINTER)
xi2SetupDevice(deviceInfo, false); // FIXBUG: #123235 触摸过程中插拔usb键盘/鼠标导致触摸失效
if (deviceInfo->type == XCB_INPUT_DEVICE_TYPE_SLAVE_POINTER) {
if (!m_touchDevices.contains(deviceInfo->deviceid)) {
xi2SetupDevice(deviceInfo, false);
}
deviceIds.append(deviceInfo->deviceid);
}
}
// FIXBUG: #123235 触摸过程中插拔usb键盘/鼠标导致触摸失效的问题
for (const auto &touchDeviceId : m_touchDevices.keys()) {
if (!deviceIds.contains(touchDeviceId)) {
m_touchDevices.remove(touchDeviceId);
}
} }
if (m_xiMasterPointerIds.size() > 1) if (m_xiMasterPointerIds.size() > 1)
@ -593,6 +608,10 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event)
fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event); fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event);
if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)) if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event))
xi2ProcessTouch(xiDeviceEvent, platformWindow); xi2ProcessTouch(xiDeviceEvent, platformWindow);
else { // When the window cannot be matched, delete it from touchPoints
if (TouchDeviceData *dev = touchDeviceForId(xiDeviceEvent->sourceid))
dev->touchPoints.remove((xiDeviceEvent->detail % INT_MAX));
}
break; break;
} }
} else if (xiEnterEvent && !xi2MouseEventsDisabled() && eventListener) { } else if (xiEnterEvent && !xi2MouseEventsDisabled() && eventListener) {