From f90d8f3fe7e39a20b93a2ddfe0704bc48f3bd5f9 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 24 Jun 2009 15:06:00 +0200 Subject: Multi-touch, Cocoa: Make sure that touch points are ordered. --- src/gui/kernel/qmultitouch_mac.mm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qmultitouch_mac.mm b/src/gui/kernel/qmultitouch_mac.mm index d9cb8b6..cae3672 100644 --- a/src/gui/kernel/qmultitouch_mac.mm +++ b/src/gui/kernel/qmultitouch_mac.mm @@ -132,7 +132,7 @@ Qt::TouchPointState QCocoaTouch::toTouchPointState(NSTouchPhase nsState) QList QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch) { - QList touchPoints; + QMap touchPoints; NSSet *ended = [event touchesMatchingPhase:NSTouchPhaseEnded | NSTouchPhaseCancelled inView:nil]; NSSet *active = [event touchesMatchingPhase:NSTouchPhaseBegan | NSTouchPhaseMoved | NSTouchPhaseStationary @@ -150,7 +150,7 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch) if (qcocoaTouch) { qcocoaTouch->updateTouchData(touch, [touch phase]); if (!_updateInternalStateOnly) - touchPoints.append(qcocoaTouch->_touchPoint); + touchPoints.insert(qcocoaTouch->_touchPoint.id(), qcocoaTouch->_touchPoint); delete qcocoaTouch; } } @@ -170,7 +170,7 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch) else qcocoaTouch->updateTouchData(touch, wasUpdateInternalStateOnly ? NSTouchPhaseBegan : [touch phase]); if (!_updateInternalStateOnly) - touchPoints.append(qcocoaTouch->_touchPoint); + touchPoints.insert(qcocoaTouch->_touchPoint.id(), qcocoaTouch->_touchPoint); } // Next: sadly, we need to check that our touch hash is in @@ -184,13 +184,13 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch) foreach (QCocoaTouch *qcocoaTouch, _currentTouches.values()) { if (!_updateInternalStateOnly) { qcocoaTouch->_touchPoint.setState(Qt::TouchPointReleased); - touchPoints.append(qcocoaTouch->_touchPoint); + touchPoints.insert(qcocoaTouch->_touchPoint.id(), qcocoaTouch->_touchPoint); } delete qcocoaTouch; } _currentTouches.clear(); _updateInternalStateOnly = !acceptSingleTouch; - return touchPoints; + return touchPoints.values(); } // Finally: If this call _started_ to reject single @@ -200,7 +200,7 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch) if (_updateInternalStateOnly && !wasUpdateInternalStateOnly && !_currentTouches.isEmpty()) { QCocoaTouch *qcocoaTouch = _currentTouches.values().first(); qcocoaTouch->_touchPoint.setState(Qt::TouchPointReleased); - touchPoints.append(qcocoaTouch->_touchPoint); + touchPoints.insert(qcocoaTouch->_touchPoint.id(), qcocoaTouch->_touchPoint); // Since this last touch also will end up beeing the first // touch (if the user adds a second finger without lifting // the first), we promote it to be the primary touch: @@ -208,7 +208,7 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch) _idAssignmentCount = 1; } - return touchPoints; + return touchPoints.values(); } #endif -- cgit v0.12