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;
|
UIScreen *uiScreen() const;
|
||||||
|
|
||||||
void updateProperties();
|
void updateProperties();
|
||||||
|
void layoutWindows();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UIScreen *m_uiScreen;
|
UIScreen *m_uiScreen;
|
||||||
|
@ -182,7 +182,33 @@ void QIOSScreen::updateProperties()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (screen())
|
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
|
QRect QIOSScreen::geometry() const
|
||||||
|
@ -86,6 +86,8 @@ public:
|
|||||||
WId winId() const { return WId(m_view); };
|
WId winId() const { return WId(m_view); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void applyGeometry(const QRect &rect);
|
||||||
|
|
||||||
QUIView *m_view;
|
QUIView *m_view;
|
||||||
|
|
||||||
QRect m_normalGeometry;
|
QRect m_normalGeometry;
|
||||||
@ -97,6 +99,8 @@ private:
|
|||||||
|
|
||||||
inline Qt::WindowType windowType() { return static_cast<Qt::WindowType>(int(window()->flags() & Qt::WindowType_Mask)); }
|
inline Qt::WindowType windowType() { return static_cast<Qt::WindowType>(int(window()->flags() & Qt::WindowType_Mask)); }
|
||||||
inline bool windowIsPopup() { return windowType() & Qt::Popup & ~Qt::Window; }
|
inline bool windowIsPopup() { return windowType() & Qt::Popup & ~Qt::Window; }
|
||||||
|
|
||||||
|
friend class QIOSScreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -435,6 +435,11 @@ void QIOSWindow::setGeometry(const QRect &rect)
|
|||||||
if (window()->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen))
|
if (window()->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
applyGeometry(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QIOSWindow::applyGeometry(const QRect &rect)
|
||||||
|
{
|
||||||
// Since we don't support transformations on the UIView, we can set the frame
|
// 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.
|
// 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]
|
// 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
|
// Perhaps setting QWindow to maximized should also mean that we'll show
|
||||||
// the statusbar, and vice versa for fullscreen?
|
// the statusbar, and vice versa for fullscreen?
|
||||||
|
|
||||||
if (state != Qt::WindowNoState)
|
|
||||||
m_normalGeometry = geometry();
|
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case Qt::WindowNoState:
|
case Qt::WindowNoState:
|
||||||
setGeometry(m_normalGeometry);
|
applyGeometry(m_normalGeometry);
|
||||||
break;
|
break;
|
||||||
case Qt::WindowMaximized:
|
case Qt::WindowMaximized:
|
||||||
setGeometry(screen()->availableGeometry());
|
applyGeometry(screen()->availableGeometry());
|
||||||
break;
|
break;
|
||||||
case Qt::WindowFullScreen:
|
case Qt::WindowFullScreen:
|
||||||
setGeometry(screen()->geometry());
|
applyGeometry(screen()->geometry());
|
||||||
break;
|
break;
|
||||||
case Qt::WindowMinimized:
|
case Qt::WindowMinimized:
|
||||||
setGeometry(QRect());
|
applyGeometry(QRect());
|
||||||
break;
|
break;
|
||||||
case Qt::WindowActive:
|
case Qt::WindowActive:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
|
Loading…
Reference in New Issue
Block a user