/*! Destroys the screen. */ QScreen::~QScreen() { if (!qApp) return; // Allow clients to manage windows that are affected by the screen going // away, before we fall back to moving them to the primary screen. emit qApp->screenRemoved(this); if (QGuiApplication::closingDown()) return; QScreen *primaryScreen = QGuiApplication::primaryScreen(); if (this == primaryScreen) return; bool movingFromVirtualSibling = primaryScreen && primaryScreen->handle()->virtualSiblings().contains(handle()); // Move any leftover windows to the primary screen const auto allWindows = QGuiApplication::allWindows(); for (QWindow *window : allWindows) { if (!window->isTopLevel() || window->screen() != this) continue; const bool wasVisible = window->isVisible(); window->setScreen(primaryScreen); // Re-show window if moved from a virtual sibling screen. Otherwise // leave it up to the application developer to show the window. if (movingFromVirtualSibling) window->setVisible(wasVisible); } }
/*! Returns the platform screen handle corresponding to this platform window, or null if the window is not associated with a screen. */ QPlatformScreen *QPlatformWindow::screen() const { QScreen *scr = window()->screen(); return scr ? scr->handle() : Q_NULLPTR; }
QKmsScreen *QKmsNativeInterface::qPlatformScreenForWindow(QWindow *window) { QScreen *screen = window ? window->screen() : QGuiApplication::primaryScreen(); return static_cast<QKmsScreen *>(screen->handle()); }