1From 29cf880dbd7a193d7a56338054ff8e857bb147fa Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Fri, 6 Mar 2020 17:20:40 +0800 4Subject: [PATCH 15/28] qscreen: Update toplevel windows' screen when needed 5 6Update toplevel windows' screen when creating new primary screen, since 7we cleared it during destroying the old one. 8 9Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 10--- 11 src/gui/kernel/qscreen.cpp | 16 ++++++++++++++++ 12 1 file changed, 16 insertions(+) 13 14diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp 15index e33d77c1..90c1fae7 100644 16--- a/src/gui/kernel/qscreen.cpp 17+++ b/src/gui/kernel/qscreen.cpp 18@@ -74,7 +74,23 @@ QScreen::QScreen(QPlatformScreen *screen) 19 : QObject(*new QScreenPrivate(), nullptr) 20 { 21 Q_D(QScreen); 22+ QScreen *primaryScreen = QGuiApplication::primaryScreen(); 23+ 24 d->setPlatformScreen(screen); 25+ 26+ if (primaryScreen) 27+ return; 28+ 29+ // Move any leftover windows to this new screen 30+ const auto allWindows = QGuiApplication::allWindows(); 31+ for (QWindow *window : allWindows) { 32+ if (!window->isTopLevel()) 33+ continue; 34+ 35+ const bool wasVisible = window->isVisible(); 36+ window->setScreen(this); 37+ window->setVisible(wasVisible); 38+ } 39 } 40 41 void QScreenPrivate::updateGeometriesWithSignals() 42-- 432.20.1 44 45