summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <[email protected]>2023-11-08 15:33:29 -0700
committerQt Cherry-pick Bot <[email protected]>2023-11-10 05:22:37 +0000
commit9d7b8fade43194ab72e562d8d39b2dd7aa2e29ea (patch)
tree1feb3cc35749b1f2a0a2dc4f5fc4a0f0db0843f7
parentb69996caab654c5cdcd4074019a379eccdf1d89f (diff)
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 Reviewed-by: Tor Arne Vestbø <[email protected]> (cherry picked from commit 68369237bfefc81410a0d8d7389ed5e0fba0b421) Reviewed-by: Qt Cherry-pick Bot <[email protected]> (cherry picked from commit 35da0bb56e92687e5b57b77d5361c06d7983e80e)
-rw-r--r--src/plugins/platforms/ios/quiview.mm10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index 979de6a313f..7b1de0ae71f 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -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);