diff options
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.cpp | 19 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.h | 1 |
3 files changed, 23 insertions, 1 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index fe73278c62..b50fe665c4 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1040,7 +1040,9 @@ QList<QScreen *> QGuiApplication::screens() The \a point is in relation to the virtualGeometry() of each set of virtual siblings. If the point maps to more than one set of virtual siblings the first - match is returned. + match is returned. If you wish to search only the virtual desktop siblings + of a known screen (for example siblings of the screen of your application + window \c QWidget::windowHandle()->screen()), use QScreen::virtualSiblingAt(). \since 5.10 */ diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 7adf3db1b8..80de561297 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -700,6 +700,25 @@ void QScreenPrivate::updatePrimaryOrientation() } /*! + Returns the screen at \a point within the set of \l QScreen::virtualSiblings(), + or \c nullptr if outside of any screen. + + The \a point is in relation to the virtualGeometry() of each set of virtual + siblings. + + \since 5.15 +*/ +QScreen *QScreen::virtualSiblingAt(const QPoint &point) +{ + const auto &siblings = virtualSiblings(); + for (QScreen *sibling : siblings) { + if (sibling->geometry().contains(point)) + return sibling; + } + return nullptr; +} + +/*! Creates and returns a pixmap constructed by grabbing the contents of the given \a window restricted by QRect(\a x, \a y, \a width, \a height). diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h index 14392d3036..88925ab731 100644 --- a/src/gui/kernel/qscreen.h +++ b/src/gui/kernel/qscreen.h @@ -125,6 +125,7 @@ public: QRect availableGeometry() const; QList<QScreen *> virtualSiblings() const; + QScreen *virtualSiblingAt(const QPoint &point); QSize virtualSize() const; QRect virtualGeometry() const; |