summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-11-20 17:33:48 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-21 11:01:33 +0100
commitc62efb52b538063ab561cd5c8fceab206de7c427 (patch)
treef337b30df021e180b2b2974988aeb8c4e7788655 /src/plugins/platforms/ios
parente6d13c7f00aeeb1e52245f4f8350a665a2d50e67 (diff)
iOS: Use custom method to lay out windows instead of resizeMaximizedWindows()
Since we guard against overriding the geometry in setGeometry() when a window has a window state, we need to use a custom method to lay out windows that calls applyGeometry() instead. Change-Id: I6508e6aac6746c024a6172f709b8339b35b40994 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r--src/plugins/platforms/ios/qiosscreen.h1
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm28
-rw-r--r--src/plugins/platforms/ios/qioswindow.h4
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm16
4 files changed, 41 insertions, 8 deletions
diff --git a/src/plugins/platforms/ios/qiosscreen.h b/src/plugins/platforms/ios/qiosscreen.h
index e70ff4b1a9..9de62c5646 100644
--- a/src/plugins/platforms/ios/qiosscreen.h
+++ b/src/plugins/platforms/ios/qiosscreen.h
@@ -73,6 +73,7 @@ public:
UIScreen *uiScreen() const;
void updateProperties();
+ void layoutWindows();
private:
UIScreen *m_uiScreen;
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index de6585fd19..3c054b4b04 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -182,7 +182,33 @@ void QIOSScreen::updateProperties()
}
if (screen())
- resizeMaximizedWindows();
+ layoutWindows();
+}
+
+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;
+
+ if (window->windowState() & Qt::WindowFullScreen || window->geometry() == oldGeometry)
+ platformWindow->applyGeometry(newGeometry);
+ else if (window->windowState() & Qt::WindowMaximized || window->geometry() == oldAvailableGeometry)
+ platformWindow->applyGeometry(newAvailableGeometry);
+ }
}
QRect QIOSScreen::geometry() const
diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h
index 6e8683af00..4ebdd4635c 100644
--- a/src/plugins/platforms/ios/qioswindow.h
+++ b/src/plugins/platforms/ios/qioswindow.h
@@ -86,6 +86,8 @@ public:
WId winId() const { return WId(m_view); };
private:
+ void applyGeometry(const QRect &rect);
+
QUIView *m_view;
QRect m_normalGeometry;
@@ -97,6 +99,8 @@ private:
inline Qt::WindowType windowType() { return static_cast<Qt::WindowType>(int(window()->flags() & Qt::WindowType_Mask)); }
inline bool windowIsPopup() { return windowType() & Qt::Popup & ~Qt::Window; }
+
+ friend class QIOSScreen;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index 2413a45e11..52851439b1 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -435,6 +435,11 @@ void QIOSWindow::setGeometry(const QRect &rect)
if (window()->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen))
return;
+ applyGeometry(rect);
+}
+
+void QIOSWindow::applyGeometry(const QRect &rect)
+{
// Since we don't support transformations on the UIView, we can set the frame
// directly and let UIKit deal with translating that into bounds and center.
// Changing the size of the view will end up in a call to -[QUIView layoutSubviews]
@@ -448,21 +453,18 @@ void QIOSWindow::setWindowState(Qt::WindowState state)
// Perhaps setting QWindow to maximized should also mean that we'll show
// the statusbar, and vice versa for fullscreen?
- if (state != Qt::WindowNoState)
- m_normalGeometry = geometry();
-
switch (state) {
case Qt::WindowNoState:
- setGeometry(m_normalGeometry);
+ applyGeometry(m_normalGeometry);
break;
case Qt::WindowMaximized:
- setGeometry(screen()->availableGeometry());
+ applyGeometry(screen()->availableGeometry());
break;
case Qt::WindowFullScreen:
- setGeometry(screen()->geometry());
+ applyGeometry(screen()->geometry());
break;
case Qt::WindowMinimized:
- setGeometry(QRect());
+ applyGeometry(QRect());
break;
case Qt::WindowActive:
Q_UNREACHABLE();