diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-07-25 15:38:41 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-09-24 11:52:50 +0200 |
commit | df734769d39ba98be798c0657174bff45c1ccf6f (patch) | |
tree | 77e9af7eef7c1b93fcb3e9c01ff177f1e263d7db | |
parent | 4f0cd0693a3aadbf3277dba0eb902db2c78f60cd (diff) |
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>
-rw-r--r-- | src/plugins/platforms/ios/qiosscreen.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosscreen.mm | 33 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosviewcontroller.mm | 38 |
3 files changed, 38 insertions, 34 deletions
diff --git a/src/plugins/platforms/ios/qiosscreen.h b/src/plugins/platforms/ios/qiosscreen.h index 9c7d53dcd6..155ad603c2 100644 --- a/src/plugins/platforms/ios/qiosscreen.h +++ b/src/plugins/platforms/ios/qiosscreen.h @@ -73,7 +73,6 @@ public: UIScreen *uiScreen() const; void updateProperties(); - void layoutWindows(); public slots: void updateStatusBarVisibility(); diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 86ef71c914..266e6848e2 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -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; diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index 940e6b075e..782c98f66e 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -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. |