summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/platforms/ios/qiosglobal.h2
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm10
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm11
3 files changed, 19 insertions, 4 deletions
diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h
index 3fe426c901..cd265c0603 100644
--- a/src/plugins/platforms/ios/qiosglobal.h
+++ b/src/plugins/platforms/ios/qiosglobal.h
@@ -54,6 +54,8 @@ QIOSViewController *rootViewController();
CGRect toCGRect(const QRect &rect);
QRect fromCGRect(const CGRect &rect);
+CGPoint toCGPoint(const QPoint &point);
+QPoint fromCGPoint(const CGPoint &point);
Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation);
UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation);
QRect fromPortraitToPrimary(const QRect &rect);
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index 712968d216..4657b73a10 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -75,6 +75,16 @@ QRect fromCGRect(const CGRect &rect)
return QRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
}
+CGPoint toCGPoint(const QPoint &point)
+{
+ return CGPointMake(point.x(), point.y());
+}
+
+QPoint fromCGPoint(const CGPoint &point)
+{
+ return QPoint(point.x, point.y);
+}
+
Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation)
{
Qt::ScreenOrientation qtOrientation;
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index e95f392655..e4fb5e2e1c 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -177,10 +177,13 @@
touchPoint.pressure = 0.0;
// Set position
- CGPoint location = [touch locationInView:self];
- touchPoint.area = QRectF(location.x, location.y, 0, 0);
- QSize viewSize = fromCGRect(self.frame).size();
- touchPoint.normalPosition = QPointF(location.x / viewSize.width(), location.y / viewSize.height());
+ QRect viewGeometry = fromCGRect(self.frame);
+ QPoint touchViewLocation = fromCGPoint([touch 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);
}
}