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>
This commit is contained in:
parent
e6d13c7f00
commit
c62efb52b5
@ -73,6 +73,7 @@ public:
|
||||
UIScreen *uiScreen() const;
|
||||
|
||||
void updateProperties();
|
||||
void layoutWindows();
|
||||
|
||||
private:
|
||||
UIScreen *m_uiScreen;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user