iOS: Move top level window management out of QIOSScreen to QIOSDesktopManagerView

The logic of how to deal with top level windows in the presence of rotation
or status bar changes should be confined to our custom QIOSViewController
that acts as a desktop manager for regular Qt applications.

We no longer treat windows with full-screen or maximized geometry but without
the matching window state flag as being targeted for auto-resizing. In the
future we might detect this case and warn the user that windows should have
the appropriate flags to be able to auto-resize on orientation changes.

Change-Id: Ibab09de5cf37e77c356fbf51a54a2fcec4bb5c51
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
bb10
Tor Arne Vestbø 2014-07-25 15:38:41 +02:00
parent 4f0cd0693a
commit df734769d3
3 changed files with 38 additions and 34 deletions

View File

@ -73,7 +73,6 @@ public:
UIScreen *uiScreen() const;
void updateProperties();
void layoutWindows();
public slots:
void updateStatusBarVisibility();

View File

@ -252,9 +252,6 @@ void QIOSScreen::updateProperties()
QWindowSystemInterface::handleScreenGeometryChange(screen(), m_geometry, m_availableGeometry);
}
if (screen())
layoutWindows();
}
void QIOSScreen::updateStatusBarVisibility()
@ -295,36 +292,6 @@ void QIOSScreen::updateStatusBarVisibility()
}
}
void QIOSScreen::layoutWindows()
{
QList<QWindow*> windows = QGuiApplication::topLevelWindows();
const QRect oldGeometry = screen()->geometry();
const QRect oldAvailableGeometry = screen()->availableGeometry();
const QRect newGeometry = geometry();
const QRect newAvailableGeometry = availableGeometry();
for (int i = 0; i < windows.size(); ++i) {
QWindow *window = windows.at(i);
if (platformScreenForWindow(window) != this)
continue;
QIOSWindow *platformWindow = static_cast<QIOSWindow *>(window->handle());
if (!platformWindow)
continue;
// FIXME: Handle more complex cases of no-state and/or child windows when rotating
if (window->windowState() & Qt::WindowFullScreen
|| (window->windowState() & Qt::WindowNoState && window->geometry() == oldGeometry))
platformWindow->applyGeometry(newGeometry);
else if (window->windowState() & Qt::WindowMaximized
|| (window->windowState() & Qt::WindowNoState && window->geometry() == oldAvailableGeometry))
platformWindow->applyGeometry(newAvailableGeometry);
}
}
QRect QIOSScreen::geometry() const
{
return m_geometry;

View File

@ -50,6 +50,39 @@
#include "qiosscreen.h"
#include "qiosglobal.h"
#include "qioswindow.h"
#include "quiview.h"
// -------------------------------------------------------------------------
@interface QIOSDesktopManagerView : UIView
@end
@implementation QIOSDesktopManagerView
- (void)layoutSubviews
{
for (int i = int(self.subviews.count) - 1; i >= 0; --i) {
UIView *view = static_cast<UIView *>([self.subviews objectAtIndex:i]);
if (![view isKindOfClass:[QUIView class]])
continue;
[self layoutView: static_cast<QUIView *>(view)];
}
}
- (void)layoutView:(QUIView *)view
{
QWindow *window = view.qwindow;
Q_ASSERT(window->handle());
// Re-apply window states to update geometry
if (window->windowState() & (Qt::WindowFullScreen | Qt::WindowMaximized))
window->handle()->setWindowState(window->windowState());
}
@end
// -------------------------------------------------------------------------
@implementation QIOSViewController
@ -82,6 +115,11 @@
return self;
}
- (void)loadView
{
self.view = [[[QIOSDesktopManagerView alloc] init] autorelease];
}
-(BOOL)shouldAutorotate
{
// Until a proper orientation and rotation API is in place, we always auto rotate.