diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index 5628fe7703..d0c4a16d33 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -118,6 +118,8 @@ public: virtual QPlatformCursor *cursor() const; protected: + void resizeMaximizedWindows(); + QScopedPointer d_ptr; private: diff --git a/src/gui/kernel/qplatformscreen_qpa.cpp b/src/gui/kernel/qplatformscreen_qpa.cpp index 1fd96a80a5..e40550a633 100644 --- a/src/gui/kernel/qplatformscreen_qpa.cpp +++ b/src/gui/kernel/qplatformscreen_qpa.cpp @@ -272,4 +272,32 @@ QPlatformCursor *QPlatformScreen::cursor() const return 0; } +/*! + Convenience method to resize all the maximized and fullscreen windows + of this platform screen. +*/ +void QPlatformScreen::resizeMaximizedWindows() +{ + QList windows = QGuiApplication::allWindows(); + + // 'screen()' still has the old geometry info while 'this' has the new geometry info + const QRect oldGeometry = screen()->geometry(); + const QRect oldAvailableGeometry = screen()->availableGeometry(); + const QRect newGeometry = geometry(); + const QRect newAvailableGeometry = availableGeometry(); + + // make sure maximized and fullscreen windows are updated + for (int i = 0; i < windows.size(); ++i) { + QWindow *w = windows.at(i); + + if (platformScreenForWindow(w) != this) + continue; + + if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) + w->setGeometry(newGeometry); + else if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) + w->setGeometry(newAvailableGeometry); + } +} + QT_END_NAMESPACE