QPlatformScreen * QPlatformScreen::platformScreenForWidget(const QWidget *widget) { QWidget *window = widget->window(); QWidgetPrivate *windowPrivate = qt_widget_private(window); QTLWExtra * topData = windowPrivate->topData(); QPlatformIntegration *integration = QApplicationPrivate::platformIntegration(); return integration->screens()[topData->screenIndex]; }
const QRect QDesktopWidget::screenGeometry(int screenNo) const { QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); QList<QPlatformScreen *> screens = pi->screens(); if (screenNo == -1) screenNo = 0; if (screenNo < 0 || screenNo >= screens.size()) return QRect(); else return screens[screenNo]->geometry(); }
int QDesktopWidget::screenNumber(const QPoint &p) const { QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); QList<QPlatformScreen *> screens = pi->screens(); for (int i = 0; i < screens.size(); ++i) if (screens[i]->geometry().contains(p)) return i; return primaryScreen(); //even better would be closest screen }
QWidget *QApplication::topLevelAt(const QPoint &pos) { QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); QList<QPlatformScreen *> screens = pi->screens(); QList<QPlatformScreen *>::const_iterator screen = screens.constBegin(); QList<QPlatformScreen *>::const_iterator end = screens.constEnd(); // The first screen in a virtual environment should know about all top levels if (pi->isVirtualDesktop()) { QWidget *w = (*screen)->topLevelAt(pos); return w; } while (screen != end) { if ((*screen)->geometry().contains(pos)) return (*screen)->topLevelAt(pos); ++screen; } return 0; }
int QDesktopWidget::numScreens() const { QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); return qMax(pi->screens().size(), 1); }