From 4e400369c08db251cd489fec1229398c224d02b4 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 27 Mar 2020 16:06:11 +0000 Subject: Refactor pointer event hierarchy Some goals that have hopefully been achieved are: - make QPointerEvent and QEventPoint resemble their Qt Quick counterparts to such an extent that we can remove those wrappers and go back to delivering the original events in Qt Quick - make QEventPoint much smaller than QTouchEvent::TouchPoint, with no pimpl - remove most public setters - reduce the usage of complex constructors that take many arguments - don't repeat ourselves: move accessors and storage upwards rather than having redundant ones in subclasses - standardize the set of accessors in QPointerEvent - maintain source compatibility as much as possible: do not require modifying event-handling code in any QWidget subclass To avoid public setters we now introduce a few QMutable* subclasses. This is a bit like the Builder pattern except that it doesn't involve constructing a separate disposable object: the main event type can be cast to the mutable type at any time to enable modifications, iff the code is linked with gui-private. Therefore event classes can have less-"complete" constructors, because internal Qt code can use setters the same way it could use the ones in QTouchEvent before; and the event classes don't need many friends. Even some read-accessors can be kept private unless we are sure we want to expose them. Task-number: QTBUG-46266 Fixes: QTBUG-72173 Change-Id: I740e4e40165b7bc41223d38b200bbc2b403e07b6 Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/plugins/platforms/xcb/qxcbconnection_xi2.cpp') diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 74044db0de..dc8a533388 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -819,7 +819,7 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo if (xiDeviceEvent->event_type == XCB_INPUT_TOUCH_BEGIN) { QWindowSystemInterface::TouchPoint tp; tp.id = xiDeviceEvent->detail % INT_MAX; - tp.state = Qt::TouchPointPressed; + tp.state = QEventPoint::State::Pressed; tp.pressure = -1.0; dev->touchPoints[tp.id] = tp; } @@ -926,9 +926,9 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo dev->size.height() * screen->geometry().height() / screen->physicalSize().height(); x = dev->firstPressedPosition.x() + dx; y = dev->firstPressedPosition.y() + dy; - touchPoint.state = Qt::TouchPointMoved; + touchPoint.state = QEventPoint::State::Updated; } else if (touchPoint.area.center() != QPoint(x, y)) { - touchPoint.state = Qt::TouchPointMoved; + touchPoint.state = QEventPoint::State::Updated; if (dev->qtTouchDevice->type() == QInputDevice::DeviceType::TouchPad) dev->pointPressedPosition[touchPoint.id] = QPointF(x, y); } @@ -948,7 +948,7 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo } break; case XCB_INPUT_TOUCH_END: - touchPoint.state = Qt::TouchPointReleased; + touchPoint.state = QEventPoint::State::Released; if (dev->qtTouchDevice->type() == QInputDevice::DeviceType::TouchPad && dev->pointPressedPosition.value(touchPoint.id) == QPointF(x, y)) { qreal dx = (nx - dev->firstPressedNormalPosition.x()) * dev->size.width() * screen->geometry().width() / screen->physicalSize().width(); @@ -967,13 +967,13 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo " area " << touchPoint.area << " pressure " << touchPoint.pressure; Qt::KeyboardModifiers modifiers = keyboard()->translateModifiers(xiDeviceEvent->mods.effective); QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiDeviceEvent->time, dev->qtTouchDevice, dev->touchPoints.values(), modifiers); - if (touchPoint.state == Qt::TouchPointReleased) + if (touchPoint.state == QEventPoint::State::Released) // If a touchpoint was released, we can forget it, because the ID won't be reused. dev->touchPoints.remove(touchPoint.id); else // Make sure that we don't send TouchPointPressed/Moved in more than one QTouchEvent // with this touch point if the next XI2 event is about a different touch point. - touchPoint.state = Qt::TouchPointStationary; + touchPoint.state = QEventPoint::State::Stationary; } bool QXcbConnection::startSystemMoveResizeForTouch(xcb_window_t window, int edges) @@ -984,8 +984,8 @@ bool QXcbConnection::startSystemMoveResizeForTouch(xcb_window_t window, int edge if (deviceData.qtTouchDevice->type() == QInputDevice::DeviceType::TouchScreen) { auto pointIt = deviceData.touchPoints.constBegin(); for (; pointIt != deviceData.touchPoints.constEnd(); ++pointIt) { - Qt::TouchPointState state = pointIt.value().state; - if (state == Qt::TouchPointMoved || state == Qt::TouchPointPressed || state == Qt::TouchPointStationary) { + QEventPoint::State state = pointIt.value().state; + if (state == QEventPoint::State::Updated || state == QEventPoint::State::Pressed || state == QEventPoint::State::Stationary) { m_startSystemMoveResizeInfo.window = window; m_startSystemMoveResizeInfo.deviceid = devIt.key(); m_startSystemMoveResizeInfo.pointid = pointIt.key(); -- cgit v1.2.3