summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2013-05-23 14:17:27 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-27 15:48:13 +0200
commit130ee40b5e29267ad4c58280d700e1c72569ba12 (patch)
treed68ac21cab6a2985b4d1068f663864bca9a33b5f
parent60768a0af9f8773a46990e40051ac692521af055 (diff)
iOS: take orientation into account when reporting touch positions
This implementation will look at the orientation of the main screen to convert the touch coordinates. This will most likely change in future work, where we might look at a views view controller instead to decide orientation etc. Change-Id: Ic7875c5ecc4f21538f82a4f0467350bdf8ecc0b0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index 13815a22bf..0c3ae8e834 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -150,7 +150,8 @@
- (void)updateTouchList:(NSSet *)touches withState:(Qt::TouchPointState)state
{
- QRect applicationRect = fromCGRect(self.window.screen.applicationFrame);
+ QPlatformScreen *screen = QGuiApplication::primaryScreen()->handle();
+ QRect applicationRect = fromPortraitToPrimary(fromCGRect(self.window.screen.applicationFrame), screen);
foreach (UITouch *uiTouch, m_activeTouches.keys()) {
QWindowSystemInterface::TouchPoint &touchPoint = m_activeTouches[uiTouch];
@@ -163,8 +164,10 @@
// 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));
+ QRect touchInWindow = QRect(fromCGPoint([uiTouch locationInView:nil]), QSize(0, 0));
+ QRect touchInScreen = fromPortraitToPrimary(touchInWindow, screen);
+ QPoint touchPos = touchInScreen.topLeft() - applicationRect.topLeft();
+ touchPoint.area = QRectF(touchPos, QSize(0, 0));
touchPoint.normalPosition = QPointF(touchPos.x() / applicationRect.width(), touchPos.y() / applicationRect.height());
}
}