summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-09-10 14:58:49 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-09-11 17:41:15 +0000
commitad8a48e8f1b336099eab2a00c1c1e59abad8e717 (patch)
treec56551000f5804f7061f966c96d5ac4a509f4628 /src/widgets
parent037652d7a258535bd92e6950ff46398e2e74e728 (diff)
Add QGuiApplication::screenAt()
[ChangeLog][QtGui] It's now possible to retrieve the screen at a given point via QGuiApplication::screenAt(). Change-Id: Ic09514ec731d8cce5d453833e98fcd118a70600e Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io> Reviewed-by: Błażej Szczygieł <spaz16@wp.pl>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/kernel/qdesktopwidget.cpp22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp
index 6077ac38db..1b9cf88efe 100644
--- a/src/widgets/kernel/qdesktopwidget.cpp
+++ b/src/widgets/kernel/qdesktopwidget.cpp
@@ -352,26 +352,8 @@ int QDesktopWidget::screenNumber(const QPoint &p) const
int QDesktopWidgetPrivate::screenNumber(const QPoint &p)
{
- const QList<QScreen *> screens = QGuiApplication::screens();
- if (!screens.isEmpty()) {
- const QList<QScreen *> primaryScreens = screens.first()->virtualSiblings();
- // Find the screen index on the primary virtual desktop first
- foreach (QScreen *screen, primaryScreens) {
- if (screen->geometry().contains(p))
- return screens.indexOf(screen);
- }
- // If the screen index is not found on primary virtual desktop, find
- // the screen index on all screens except the first which was for
- // sure in the previous loop. Some other screens may repeat. Find
- // only when there is more than one virtual desktop.
- if (screens.count() != primaryScreens.count()) {
- for (int i = 1; i < screens.size(); ++i) {
- if (screens[i]->geometry().contains(p))
- return i;
- }
- }
- }
- return primaryScreen(); //even better would be closest screen
+ QScreen *screen = QGuiApplication::screenAt(p);
+ return screen ? QGuiApplication::screens().indexOf(screen) : primaryScreen();
}
void QDesktopWidget::resizeEvent(QResizeEvent *)