summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/quiview.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/ios/quiview.mm')
-rw-r--r--src/plugins/platforms/ios/quiview.mm29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index 444017f4c7..4e720941f9 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -223,26 +223,29 @@
- (void)updateTouchList:(NSSet *)touches withState:(Qt::TouchPointState)state
{
- // We deliver touch events in global coordinates. But global in this respect
- // means the same coordinate system that we use for describing the geometry
- // of the top level QWindow we're inside. And that would be the coordinate
- // system of the superview of the UIView that backs that window:
- QPlatformWindow *topLevel = m_qioswindow;
- while (QPlatformWindow *topLevelParent = topLevel->parent())
- topLevel = topLevelParent;
- UIView *rootView = reinterpret_cast<UIView *>(topLevel->winId()).superview;
- CGSize rootViewSize = rootView.frame.size;
-
foreach (UITouch *uiTouch, m_activeTouches.keys()) {
QWindowSystemInterface::TouchPoint &touchPoint = m_activeTouches[uiTouch];
if (![touches containsObject:uiTouch]) {
touchPoint.state = Qt::TouchPointStationary;
} else {
touchPoint.state = state;
+
+ // Touch positions are expected to be in QScreen global coordinates, and
+ // as we already have the QWindow positioned at the right place, we can
+ // just map from the local view position to global coordinates.
+ QPoint localViewPosition = fromCGPoint([uiTouch locationInView:self]).toPoint();
+ QPoint globalScreenPosition = m_qioswindow->mapToGlobal(localViewPosition);
+
+ touchPoint.area = QRectF(globalScreenPosition, QSize(0, 0));
+
+ // FIXME: Do we really need to support QTouchDevice::NormalizedPosition?
+ QSize screenSize = m_qioswindow->screen()->geometry().size();
+ touchPoint.normalPosition = QPointF(globalScreenPosition.x() / screenSize.width(),
+ globalScreenPosition.y() / screenSize.height());
+
+ // We don't claim that our touch device supports QTouchDevice::Pressure,
+ // but fill in a meaningfull value in case clients use it anyways.
touchPoint.pressure = (state == Qt::TouchPointReleased) ? 0.0 : 1.0;
- QPoint touchPos = fromCGPoint([uiTouch locationInView:rootView]).toPoint();
- touchPoint.area = QRectF(touchPos, QSize(0, 0));
- touchPoint.normalPosition = QPointF(touchPos.x() / rootViewSize.width, touchPos.y() / rootViewSize.height);
}
}
}