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/cocoa/qmultitouch_mac.mm | 16 ++++++++-------- src/plugins/platforms/cocoa/qmultitouch_mac_p.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac.mm b/src/plugins/platforms/cocoa/qmultitouch_mac.mm index 7bbbb486e5..28d641b598 100644 --- a/src/plugins/platforms/cocoa/qmultitouch_mac.mm +++ b/src/plugins/platforms/cocoa/qmultitouch_mac.mm @@ -112,22 +112,22 @@ QCocoaTouch *QCocoaTouch::findQCocoaTouch(NSTouch *nstouch) return nullptr; } -Qt::TouchPointState QCocoaTouch::toTouchPointState(NSTouchPhase nsState) +QEventPoint::State QCocoaTouch::toTouchPointState(NSTouchPhase nsState) { - Qt::TouchPointState qtState = Qt::TouchPointReleased; + QEventPoint::State qtState = QEventPoint::State::Released; switch (nsState) { case NSTouchPhaseBegan: - qtState = Qt::TouchPointPressed; + qtState = QEventPoint::State::Pressed; break; case NSTouchPhaseMoved: - qtState = Qt::TouchPointMoved; + qtState = QEventPoint::State::Updated; break; case NSTouchPhaseStationary: - qtState = Qt::TouchPointStationary; + qtState = QEventPoint::State::Stationary; break; case NSTouchPhaseEnded: case NSTouchPhaseCancelled: - qtState = Qt::TouchPointReleased; + qtState = QEventPoint::State::Released; break; default: break; @@ -191,7 +191,7 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch) const auto currentTouchesSnapshot = _currentTouches; for (QCocoaTouch *qcocoaTouch : currentTouchesSnapshot) { if (!_updateInternalStateOnly) { - qcocoaTouch->_touchPoint.state = Qt::TouchPointReleased; + qcocoaTouch->_touchPoint.state = QEventPoint::State::Released; touchPoints.insert(qcocoaTouch->_touchPoint.id, qcocoaTouch->_touchPoint); } delete qcocoaTouch; @@ -207,7 +207,7 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch) if (_updateInternalStateOnly && !wasUpdateInternalStateOnly && !_currentTouches.isEmpty()) { QCocoaTouch *qcocoaTouch = _currentTouches.cbegin().value(); - qcocoaTouch->_touchPoint.state = Qt::TouchPointReleased; + qcocoaTouch->_touchPoint.state = QEventPoint::State::Released; touchPoints.insert(qcocoaTouch->_touchPoint.id, qcocoaTouch->_touchPoint); // Since this last touch also will end up being the first // touch (if the user adds a second finger without lifting diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h index 875a7d365e..ff4479fa4c 100644 --- a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h +++ b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h @@ -88,7 +88,7 @@ class QCocoaTouch void updateTouchData(NSTouch *nstouch, NSTouchPhase phase); static QCocoaTouch *findQCocoaTouch(NSTouch *nstouch); - static Qt::TouchPointState toTouchPointState(NSTouchPhase nsState); + static QEventPoint::State toTouchPointState(NSTouchPhase nsState); }; QT_END_NAMESPACE -- cgit v1.2.3