iOS: Make nextTouchId static, unsigned and let it overflow
If an application has two windows, and the user tries to do multi-touch gestures with different fingers in each window at the same time, we want the touchpoint IDs to be unique. m_nextTouchId was a per-window variable before; the result was that the QEventPoint delivered to the second window was replacing values (including QEventPointPrivate::window) in the persistent QEventPoint that was still being held in the first window; then when the release of the first point occurred, QGuiApplicationPrivate::processTouchEvent() saw its destination window pointer as null because the second touchpoint had already been released. QEventPoint::id is of type int, with negative values being invalid. nextTouchId is of type quint16 so that it will always be positive, and we can let it eventually overflow (wrap back to 0) rather than resetting it to 0 after each touch gesture. The only requirement is that the IDs need to be unique and positive (and typically they are sequential: that makes debug output easier to understand). Task-number: QTBUG-118909 Change-Id: Ia0f1edc9a5e2b362028bed4418fed228814cddb6 Pick-to: 6.5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 68369237bfefc81410a0d8d7389ed5e0fba0b421) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
6ac543c843
commit
35da0bb56e
@ -53,7 +53,6 @@ inline ulong getTimeStamp(UIEvent *event)
|
||||
@implementation QUIView {
|
||||
QHash<NSUInteger, QWindowSystemInterface::TouchPoint> m_activeTouches;
|
||||
UITouch *m_activePencilTouch;
|
||||
int m_nextTouchId;
|
||||
NSMutableArray<UIAccessibilityElement *> *m_accessibleElements;
|
||||
UIPanGestureRecognizer *m_scrollGestureRecognizer;
|
||||
CGPoint m_lastScrollCursorPos;
|
||||
@ -518,7 +517,10 @@ inline ulong getTimeStamp(UIEvent *event)
|
||||
{
|
||||
Q_ASSERT(!m_activeTouches.contains(touch.hash));
|
||||
#endif
|
||||
m_activeTouches[touch.hash].id = m_nextTouchId++;
|
||||
// Use window-independent touch identifiers, so that
|
||||
// multi-touch works across windows.
|
||||
static quint16 nextTouchId = 0;
|
||||
m_activeTouches[touch.hash].id = nextTouchId++;
|
||||
#if QT_CONFIG(tabletevent)
|
||||
}
|
||||
#endif
|
||||
@ -560,9 +562,6 @@ inline ulong getTimeStamp(UIEvent *event)
|
||||
// tvOS only supports single touch
|
||||
m_activeTouches.clear();
|
||||
#endif
|
||||
|
||||
if (m_activeTouches.isEmpty() && !m_activePencilTouch)
|
||||
m_nextTouchId = 0;
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
@ -595,7 +594,6 @@ inline ulong getTimeStamp(UIEvent *event)
|
||||
qWarning("Subset of active touches cancelled by UIKit");
|
||||
|
||||
m_activeTouches.clear();
|
||||
m_nextTouchId = 0;
|
||||
m_activePencilTouch = nil;
|
||||
|
||||
ulong timestamp = event ? getTimeStamp(event) : ([[NSProcessInfo processInfo] systemUptime] * 1000);
|
||||
|
Loading…
x
Reference in New Issue
Block a user