summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsscreen.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-09-06 16:22:45 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-09-25 10:11:07 +0000
commitd03dba3f4abf21de842d3f1146d78ca4655c94e2 (patch)
tree5edc3983fa60cf2d03dd4ea36b74cf71ea857f29 /src/plugins/platforms/windows/qwindowsscreen.cpp
parentaa4fef88121f536f40760449fa81c03be076d68d (diff)
Windows QPA: Move function to find screen by HWND to QWindowsScreenManager
Task-number: QTBUG-62971 Change-Id: Ida0a8e758723f0f617011a89dc89c266d2506aad Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsscreen.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index 3a4793efcd..cfddb3cc71 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -566,4 +566,19 @@ const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const
return Q_NULLPTR;
}
+const QWindowsScreen *QWindowsScreenManager::screenForHwnd(HWND hwnd) const
+{
+ HMONITOR hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL);
+ if (hMonitor == NULL)
+ return nullptr;
+ const auto it =
+ std::find_if(m_screens.cbegin(), m_screens.cend(),
+ [hMonitor](const QWindowsScreen *s)
+ {
+ return s->data().hMonitor == hMonitor
+ && (s->data().flags & QWindowsScreenData::VirtualDesktop) != 0;
+ });
+ return it != m_screens.cend() ? *it : nullptr;
+}
+
QT_END_NAMESPACE