diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index cd2e5f9cb9ebdb2f9b822bf7b5fd504f7894ce82..02ac413b3b19e5c86635ff78759f8af51728120f 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -150,6 +150,8 @@ - (void)updateTouchList:(NSSet *)touches withState:(Qt::TouchPointState)state { + QRect applicationRect = fromCGRect(self.window.screen.applicationFrame); + foreach (UITouch *uiTouch, m_activeTouches.keys()) { QWindowSystemInterface::TouchPoint &touchPoint = m_activeTouches[uiTouch]; if (![touches containsObject:uiTouch]) { @@ -158,14 +160,12 @@ touchPoint.state = state; touchPoint.pressure = (state == Qt::TouchPointReleased) ? 0.0 : 1.0; - // Set position - QRect viewGeometry = fromCGRect(self.frame); - QPoint touchViewLocation = fromCGPoint([uiTouch locationInView:self]); - QPoint touchScreenLocation = touchViewLocation + viewGeometry.topLeft(); - touchPoint.area = QRectF(touchScreenLocation , QSize(0, 0)); - - CGSize fullscreenSize = self.window.rootViewController.view.bounds.size; - touchPoint.normalPosition = QPointF(touchScreenLocation.x() / fullscreenSize.width, touchScreenLocation.y() / fullscreenSize.height); + // Find the touch position relative to the window. Then calculate the screen + // position by subtracting the position of the applicationRect (since UIWindow + // does not take that into account when reporting its own frame): + QPoint touchPos = fromCGPoint([uiTouch locationInView:nil]); + touchPoint.area = QRectF(touchPos - applicationRect.topLeft(), QSize(0, 0)); + touchPoint.normalPosition = QPointF(touchPos.x() / applicationRect.width(), touchPos.y() / applicationRect.height()); } } }