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>bb10
parent
60768a0af9
commit
130ee40b5e
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue