summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens.qnx@kdab.com>2012-05-21 12:52:26 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-24 14:46:48 +0200
commit600eee0481b068493212aff2dd51fad882de62e2 (patch)
tree8217a84fbcf47b8df6aef60d47e232c1db1a1125 /src
parent48e104aa1d7e3e8b42f239126fee756c6c920a1a (diff)
Provide convenience method to resize maximized windows
Maximized/fullscreen windows geometry should follow screen geometry, so provide a convenience method implementing this behavior. It is meant to be used in platform plugins where the platform doesn't automatically resize said windows on screen geometry changes. Change-Id: Id9128fee1ddf587a7d96aa294d2d1e6eb6d6d11b Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qplatformscreen.h2
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.cpp28
2 files changed, 30 insertions, 0 deletions
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<QPlatformScreenPrivate> 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<QWindow*> 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