iOS: update QPlatformWindow::geometry() when UIView changes size

It turns out that QWindow::geometry needs to be updated manually
by the platform plugin, and not indirectly trough
QWindowSystemInterface::handleGeometryChange as first assumed.
We now always report the _actual_ geometry of the UIView (which
also takes the status bar into account) to QWindow, and remember
the _requested_ geometry of the window to use whenever the state
of the window changes.

Change-Id: Iea940173d26fb6af701234379cae914215dae984
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
This commit is contained in:
Richard Moe Gustavsen 2012-12-10 10:18:59 +01:00 committed by Tor Arne Vestbø
parent b1cfa62ff4
commit a1c9f56552
2 changed files with 7 additions and 3 deletions

View File

@ -93,6 +93,7 @@ public:
private:
EAGLView *m_view;
QRect m_requestedGeometry;
};
QT_END_NAMESPACE

View File

@ -113,7 +113,9 @@ static QRect fromCGRect(const CGRect &rect)
qWarning() << m_qioswindow->window()
<< "is backed by a UIView that has a transform set. This is not supported.";
QWindowSystemInterface::handleGeometryChange(m_qioswindow->window(), fromCGRect(self.frame));
QRect geometry = fromCGRect(self.frame);
m_qioswindow->QPlatformWindow::setGeometry(geometry);
QWindowSystemInterface::handleGeometryChange(m_qioswindow->window(), geometry);
[super layoutSubviews];
}
@ -197,6 +199,7 @@ QT_BEGIN_NAMESPACE
QIOSWindow::QIOSWindow(QWindow *window)
: QPlatformWindow(window)
, m_view([[EAGLView alloc] initWithQIOSWindow:this])
, m_requestedGeometry(QPlatformWindow::geometry())
{
if ([[UIApplication sharedApplication].delegate isKindOfClass:[QIOSApplicationDelegate class]])
[[UIApplication sharedApplication].delegate.window.rootViewController.view addSubview:m_view];
@ -213,7 +216,7 @@ void QIOSWindow::setGeometry(const QRect &rect)
{
// If the window is in fullscreen, just bookkeep the requested
// geometry in case the window goes into Qt::WindowNoState later:
QPlatformWindow::setGeometry(rect);
m_requestedGeometry = rect;
if (window()->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen))
return;
@ -240,7 +243,7 @@ void QIOSWindow::setWindowState(Qt::WindowState state)
m_view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
break; }
default:
m_view.frame = toCGRect(geometry());
m_view.frame = toCGRect(m_requestedGeometry);
m_view.autoresizingMask = UIViewAutoresizingNone;
break;
}