Warning: That file was not part of the compilation database. It may have many parsing errors.

1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the plugins of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qwindowsscreen.h"
41#include "qwindowscontext.h"
42#include "qwindowswindow.h"
43#include "qwindowsintegration.h"
44#include "qwindowscursor.h"
45
46#include <QtCore/qt_windows.h>
47
48#include <QtCore/qsettings.h>
49#include <QtGui/qpixmap.h>
50#include <QtGui/qguiapplication.h>
51#include <qpa/qwindowsysteminterface.h>
52#include <private/qhighdpiscaling_p.h>
53#include <QtGui/qscreen.h>
54
55#include <QtCore/qdebug.h>
56
57QT_BEGIN_NAMESPACE
58
59static inline QDpi deviceDPI(HDC hdc)
60{
61 return QDpi(GetDeviceCaps(hdc, LOGPIXELSX), GetDeviceCaps(hdc, LOGPIXELSY));
62}
63
64static inline QDpi monitorDPI(HMONITOR hMonitor)
65{
66 if (QWindowsContext::shcoredll.isValid()) {
67 UINT dpiX;
68 UINT dpiY;
69 if (SUCCEEDED(QWindowsContext::shcoredll.getDpiForMonitor(hMonitor, 0, &dpiX, &dpiY)))
70 return QDpi(dpiX, dpiY);
71 }
72 return {0, 0};
73}
74
75using WindowsScreenDataList = QList<QWindowsScreenData>;
76
77static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
78{
79 MONITORINFOEX info;
80 memset(&info, 0, sizeof(MONITORINFOEX));
81 info.cbSize = sizeof(MONITORINFOEX);
82 if (GetMonitorInfo(hMonitor, &info) == FALSE)
83 return false;
84
85 data->hMonitor = hMonitor;
86 data->geometry = QRect(QPoint(info.rcMonitor.left, info.rcMonitor.top), QPoint(info.rcMonitor.right - 1, info.rcMonitor.bottom - 1));
87 data->availableGeometry = QRect(QPoint(info.rcWork.left, info.rcWork.top), QPoint(info.rcWork.right - 1, info.rcWork.bottom - 1));
88 data->name = QString::fromWCharArray(info.szDevice);
89 if (data->name == QLatin1String("WinDisc")) {
90 data->flags |= QWindowsScreenData::LockScreen;
91 } else {
92 if (const HDC hdc = CreateDC(info.szDevice, nullptr, nullptr, nullptr)) {
93 const QDpi dpi = monitorDPI(hMonitor);
94 data->dpi = dpi.first > 0 ? dpi : deviceDPI(hdc);
95 data->depth = GetDeviceCaps(hdc, BITSPIXEL);
96 data->format = data->depth == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
97 data->physicalSizeMM = QSizeF(GetDeviceCaps(hdc, HORZSIZE), GetDeviceCaps(hdc, VERTSIZE));
98 const int refreshRate = GetDeviceCaps(hdc, VREFRESH);
99 if (refreshRate > 1) // 0,1 means hardware default.
100 data->refreshRateHz = refreshRate;
101 DeleteDC(hdc);
102 } else {
103 qWarning("%s: Unable to obtain handle for monitor '%s', defaulting to %g DPI.",
104 __FUNCTION__, qPrintable(QString::fromWCharArray(info.szDevice)),
105 data->dpi.first);
106 } // CreateDC() failed
107 } // not lock screen
108 data->orientation = data->geometry.height() > data->geometry.width() ?
109 Qt::PortraitOrientation : Qt::LandscapeOrientation;
110 // EnumDisplayMonitors (as opposed to EnumDisplayDevices) enumerates only
111 // virtual desktop screens.
112 data->flags |= QWindowsScreenData::VirtualDesktop;
113 if (info.dwFlags & MONITORINFOF_PRIMARY)
114 data->flags |= QWindowsScreenData::PrimaryScreen;
115 return true;
116}
117
118// from QDesktopWidget, taking WindowsScreenDataList as LPARAM
119BOOL QT_WIN_CALLBACK monitorEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM p)
120{
121 QWindowsScreenData data;
122 if (monitorData(hMonitor, &data)) {
123 auto *result = reinterpret_cast<WindowsScreenDataList *>(p);
124 // QWindowSystemInterface::handleScreenAdded() documentation specifies that first
125 // added screen will be the primary screen, so order accordingly.
126 // Note that the side effect of this policy is that there is no way to change primary
127 // screen reported by Qt, unless we want to delete all existing screens and add them
128 // again whenever primary screen changes.
129 if (data.flags & QWindowsScreenData::PrimaryScreen)
130 result->prepend(data);
131 else
132 result->append(data);
133 }
134 return TRUE;
135}
136
137static inline WindowsScreenDataList monitorData()
138{
139 WindowsScreenDataList result;
140 EnumDisplayMonitors(nullptr, nullptr, monitorEnumCallback, reinterpret_cast<LPARAM>(&result));
141 return result;
142}
143
144#ifndef QT_NO_DEBUG_STREAM
145static QDebug operator<<(QDebug dbg, const QWindowsScreenData &d)
146{
147 QDebugStateSaver saver(dbg);
148 dbg.nospace();
149 dbg.noquote();
150 dbg << "Screen \"" << d.name << "\" "
151 << d.geometry.width() << 'x' << d.geometry.height() << '+' << d.geometry.x() << '+' << d.geometry.y()
152 << " avail: "
153 << d.availableGeometry.width() << 'x' << d.availableGeometry.height() << '+' << d.availableGeometry.x() << '+' << d.availableGeometry.y()
154 << " physical: " << d.physicalSizeMM.width() << 'x' << d.physicalSizeMM.height()
155 << " DPI: " << d.dpi.first << 'x' << d.dpi.second << " Depth: " << d.depth
156 << " Format: " << d.format
157 << " hMonitor: " << d.hMonitor;
158 if (d.flags & QWindowsScreenData::PrimaryScreen)
159 dbg << " primary";
160 if (d.flags & QWindowsScreenData::VirtualDesktop)
161 dbg << " virtual desktop";
162 if (d.flags & QWindowsScreenData::LockScreen)
163 dbg << " lock screen";
164 return dbg;
165}
166#endif // !QT_NO_DEBUG_STREAM
167
168/*!
169 \class QWindowsScreen
170 \brief Windows screen.
171 \sa QWindowsScreenManager
172 \internal
173 \ingroup qt-lighthouse-win
174*/
175
176QWindowsScreen::QWindowsScreen(const QWindowsScreenData &data) :
177 m_data(data)
178#ifndef QT_NO_CURSOR
179 , m_cursor(new QWindowsCursor(this))
180#endif
181{
182}
183
184Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0);
185
186QPixmap QWindowsScreen::grabWindow(WId window, int xIn, int yIn, int width, int height) const
187{
188 QSize windowSize;
189 int x = xIn;
190 int y = yIn;
191 HWND hwnd = reinterpret_cast<HWND>(window);
192 if (hwnd) {
193 RECT r;
194 GetClientRect(hwnd, &r);
195 windowSize = QSize(r.right - r.left, r.bottom - r.top);
196 } else {
197 // Grab current screen. The client rectangle of GetDesktopWindow() is the
198 // primary screen, but it is possible to grab other screens from it.
199 hwnd = GetDesktopWindow();
200 const QRect screenGeometry = geometry();
201 windowSize = screenGeometry.size();
202 x += screenGeometry.x();
203 y += screenGeometry.y();
204 }
205
206 if (width < 0)
207 width = windowSize.width() - xIn;
208 if (height < 0)
209 height = windowSize.height() - yIn;
210
211 // Create and setup bitmap
212 HDC display_dc = GetDC(nullptr);
213 HDC bitmap_dc = CreateCompatibleDC(display_dc);
214 HBITMAP bitmap = CreateCompatibleBitmap(display_dc, width, height);
215 HGDIOBJ null_bitmap = SelectObject(bitmap_dc, bitmap);
216
217 // copy data
218 HDC window_dc = GetDC(hwnd);
219 BitBlt(bitmap_dc, 0, 0, width, height, window_dc, x, y, SRCCOPY | CAPTUREBLT);
220
221 // clean up all but bitmap
222 ReleaseDC(hwnd, window_dc);
223 SelectObject(bitmap_dc, null_bitmap);
224 DeleteDC(bitmap_dc);
225
226 const QPixmap pixmap = qt_pixmapFromWinHBITMAP(bitmap);
227
228 DeleteObject(bitmap);
229 ReleaseDC(nullptr, display_dc);
230
231 return pixmap;
232}
233
234/*!
235 \brief Find a top level window taking the flags of ChildWindowFromPointEx.
236*/
237
238QWindow *QWindowsScreen::topLevelAt(const QPoint &point) const
239{
240 QWindow *result = nullptr;
241 if (QWindow *child = QWindowsScreen::windowAt(point, CWP_SKIPINVISIBLE))
242 result = QWindowsWindow::topLevelOf(child);
243 if (QWindowsContext::verbose > 1)
244 qCDebug(lcQpaWindows) <<__FUNCTION__ << point << result;
245 return result;
246}
247
248QWindow *QWindowsScreen::windowAt(const QPoint &screenPoint, unsigned flags)
249{
250 QWindow* result = nullptr;
251 if (QPlatformWindow *bw = QWindowsContext::instance()->
252 findPlatformWindowAt(GetDesktopWindow(), screenPoint, flags))
253 result = bw->window();
254 if (QWindowsContext::verbose > 1)
255 qCDebug(lcQpaWindows) <<__FUNCTION__ << screenPoint << " returns " << result;
256 return result;
257}
258
259qreal QWindowsScreen::pixelDensity() const
260{
261 // QTBUG-49195: Use logical DPI instead of physical DPI to calculate
262 // the pixel density since it is reflects the Windows UI scaling.
263 // High DPI auto scaling should be disabled when the user chooses
264 // small fonts on a High DPI monitor, resulting in lower logical DPI.
265 return qMax(1, qRound(logicalDpi().first / 96));
266}
267
268/*!
269 \brief Determine siblings in a virtual desktop system.
270
271 Self is by definition a sibling, else collect all screens
272 within virtual desktop.
273*/
274
275QList<QPlatformScreen *> QWindowsScreen::virtualSiblings() const
276{
277 QList<QPlatformScreen *> result;
278 if (m_data.flags & QWindowsScreenData::VirtualDesktop) {
279 const QWindowsScreenManager::WindowsScreenList screens
280 = QWindowsContext::instance()->screenManager().screens();
281 for (QWindowsScreen *screen : screens) {
282 if (screen->data().flags & QWindowsScreenData::VirtualDesktop)
283 result.push_back(screen);
284 }
285 } else {
286 result.push_back(const_cast<QWindowsScreen *>(this));
287 }
288 return result;
289}
290
291/*!
292 \brief Notify QWindowSystemInterface about changes of a screen and synchronize data.
293*/
294
295void QWindowsScreen::handleChanges(const QWindowsScreenData &newData)
296{
297 m_data.physicalSizeMM = newData.physicalSizeMM;
298
299 if (m_data.hMonitor != newData.hMonitor) {
300 qCDebug(lcQpaWindows) << "Monitor" << m_data.name
301 << "has had its hMonitor handle changed from"
302 << m_data.hMonitor << "to" << newData.hMonitor;
303 m_data.hMonitor = newData.hMonitor;
304 }
305
306 // QGuiApplicationPrivate::processScreenGeometryChange() checks and emits
307 // DPI and orientation as well, so, assign new values and emit DPI first.
308 const bool geometryChanged = m_data.geometry != newData.geometry
309 || m_data.availableGeometry != newData.availableGeometry;
310 const bool dpiChanged = !qFuzzyCompare(m_data.dpi.first, newData.dpi.first)
311 || !qFuzzyCompare(m_data.dpi.second, newData.dpi.second);
312 const bool orientationChanged = m_data.orientation != newData.orientation;
313 m_data.dpi = newData.dpi;
314 m_data.orientation = newData.orientation;
315 m_data.geometry = newData.geometry;
316 m_data.availableGeometry = newData.availableGeometry;
317
318 if (dpiChanged) {
319 QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(screen(),
320 newData.dpi.first,
321 newData.dpi.second);
322 }
323 if (orientationChanged)
324 QWindowSystemInterface::handleScreenOrientationChange(screen(), newData.orientation);
325 if (geometryChanged) {
326 QWindowSystemInterface::handleScreenGeometryChange(screen(),
327 newData.geometry, newData.availableGeometry);
328 }
329}
330
331HMONITOR QWindowsScreen::handle() const
332{
333 return m_data.hMonitor;
334}
335
336QRect QWindowsScreen::virtualGeometry(const QPlatformScreen *screen) // cf QScreen::virtualGeometry()
337{
338 QRect result;
339 const auto siblings = screen->virtualSiblings();
340 for (const QPlatformScreen *sibling : siblings)
341 result |= sibling->geometry();
342 return result;
343}
344
345enum OrientationPreference : DWORD // matching Win32 API ORIENTATION_PREFERENCE
346{
347 orientationPreferenceNone = 0,
348 orientationPreferenceLandscape = 0x1,
349 orientationPreferencePortrait = 0x2,
350 orientationPreferenceLandscapeFlipped = 0x4,
351 orientationPreferencePortraitFlipped = 0x8
352};
353
354bool QWindowsScreen::setOrientationPreference(Qt::ScreenOrientation o)
355{
356 bool result = false;
357 if (QWindowsContext::user32dll.setDisplayAutoRotationPreferences) {
358 DWORD orientationPreference = 0;
359 switch (o) {
360 case Qt::PrimaryOrientation:
361 orientationPreference = orientationPreferenceNone;
362 break;
363 case Qt::PortraitOrientation:
364 orientationPreference = orientationPreferencePortrait;
365 break;
366 case Qt::LandscapeOrientation:
367 orientationPreference = orientationPreferenceLandscape;
368 break;
369 case Qt::InvertedPortraitOrientation:
370 orientationPreference = orientationPreferencePortraitFlipped;
371 break;
372 case Qt::InvertedLandscapeOrientation:
373 orientationPreference = orientationPreferenceLandscapeFlipped;
374 break;
375 }
376 result = QWindowsContext::user32dll.setDisplayAutoRotationPreferences(orientationPreference);
377 }
378 return result;
379}
380
381Qt::ScreenOrientation QWindowsScreen::orientationPreference()
382{
383 Qt::ScreenOrientation result = Qt::PrimaryOrientation;
384 if (QWindowsContext::user32dll.getDisplayAutoRotationPreferences) {
385 DWORD orientationPreference = 0;
386 if (QWindowsContext::user32dll.getDisplayAutoRotationPreferences(&orientationPreference)) {
387 switch (orientationPreference) {
388 case orientationPreferenceLandscape:
389 result = Qt::LandscapeOrientation;
390 break;
391 case orientationPreferencePortrait:
392 result = Qt::PortraitOrientation;
393 break;
394 case orientationPreferenceLandscapeFlipped:
395 result = Qt::InvertedLandscapeOrientation;
396 break;
397 case orientationPreferencePortraitFlipped:
398 result = Qt::InvertedPortraitOrientation;
399 break;
400 }
401 }
402 }
403 return result;
404}
405
406/*!
407 \brief Queries ClearType settings to check the pixel layout
408*/
409QPlatformScreen::SubpixelAntialiasingType QWindowsScreen::subpixelAntialiasingTypeHint() const
410{
411 QPlatformScreen::SubpixelAntialiasingType type = QPlatformScreen::subpixelAntialiasingTypeHint();
412 if (type == QPlatformScreen::Subpixel_None) {
413 QSettings settings(QLatin1String(R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Avalon.Graphics\DISPLAY1)"),
414 QSettings::NativeFormat);
415 int registryValue = settings.value(QLatin1String("PixelStructure"), -1).toInt();
416 switch (registryValue) {
417 case 0:
418 type = QPlatformScreen::Subpixel_None;
419 break;
420 case 1:
421 type = QPlatformScreen::Subpixel_RGB;
422 break;
423 case 2:
424 type = QPlatformScreen::Subpixel_BGR;
425 break;
426 default:
427 type = QPlatformScreen::Subpixel_None;
428 break;
429 }
430 }
431 return type;
432}
433
434/*!
435 \class QWindowsScreenManager
436 \brief Manages a list of QWindowsScreen.
437
438 Listens for changes and notifies QWindowSystemInterface about changed/
439 added/deleted screens.
440
441 \sa QWindowsScreen
442 \internal
443 \ingroup qt-lighthouse-win
444*/
445
446QWindowsScreenManager::QWindowsScreenManager() = default;
447
448
449bool QWindowsScreenManager::isSingleScreen()
450{
451 return QWindowsContext::instance()->screenManager().screens().size() < 2;
452}
453
454/*!
455 \brief Triggers synchronization of screens (WM_DISPLAYCHANGE).
456
457 Subsequent events are compressed since WM_DISPLAYCHANGE is sent to
458 each top level window.
459*/
460
461bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam)
462{
463 const int newDepth = int(wParam);
464 const WORD newHorizontalResolution = LOWORD(lParam);
465 const WORD newVerticalResolution = HIWORD(lParam);
466 if (newDepth != m_lastDepth || newHorizontalResolution != m_lastHorizontalResolution
467 || newVerticalResolution != m_lastVerticalResolution) {
468 m_lastDepth = newDepth;
469 m_lastHorizontalResolution = newHorizontalResolution;
470 m_lastVerticalResolution = newVerticalResolution;
471 qCDebug(lcQpaWindows) << __FUNCTION__ << "Depth=" << newDepth
472 << ", resolution " << newHorizontalResolution << 'x' << newVerticalResolution;
473 handleScreenChanges();
474 }
475 return false;
476}
477
478static inline int indexOfMonitor(const QList<QWindowsScreen *> &screens,
479 const QString &monitorName)
480{
481 for (int i= 0; i < screens.size(); ++i)
482 if (screens.at(i)->data().name == monitorName)
483 return i;
484 return -1;
485}
486
487static inline int indexOfMonitor(const QList<QWindowsScreenData> &screenData,
488 const QString &monitorName)
489{
490 for (int i = 0; i < screenData.size(); ++i)
491 if (screenData.at(i).name == monitorName)
492 return i;
493 return -1;
494}
495
496// Move a window to a new virtual screen, accounting for varying sizes.
497static void moveToVirtualScreen(QWindow *w, const QScreen *newScreen)
498{
499 QRect geometry = w->geometry();
500 const QRect oldScreenGeometry = w->screen()->geometry();
501 const QRect newScreenGeometry = newScreen->geometry();
502 QPoint relativePosition = geometry.topLeft() - oldScreenGeometry.topLeft();
503 if (oldScreenGeometry.size() != newScreenGeometry.size()) {
504 const qreal factor =
505 qreal(QPoint(newScreenGeometry.width(), newScreenGeometry.height()).manhattanLength()) /
506 qreal(QPoint(oldScreenGeometry.width(), oldScreenGeometry.height()).manhattanLength());
507 relativePosition = (QPointF(relativePosition) * factor).toPoint();
508 }
509 geometry.moveTopLeft(relativePosition);
510 w->setGeometry(geometry);
511}
512
513void QWindowsScreenManager::removeScreen(int index)
514{
515 qCDebug(lcQpaWindows) << "Removing Monitor:" << m_screens.at(index)->data();
516 QScreen *screen = m_screens.at(index)->screen();
517 QScreen *primaryScreen = QGuiApplication::primaryScreen();
518 // QTBUG-38650: When a screen is disconnected, Windows will automatically
519 // move the Window to another screen. This will trigger a geometry change
520 // event, but unfortunately after the screen destruction signal. To prevent
521 // QtGui from automatically hiding the QWindow, pretend all Windows move to
522 // the primary screen first (which is likely the correct, final screen).
523 // QTBUG-39320: Windows does not automatically move WS_EX_TOOLWINDOW (dock) windows;
524 // move those manually.
525 if (screen != primaryScreen) {
526 unsigned movedWindowCount = 0;
527 const QWindowList tlws = QGuiApplication::topLevelWindows();
528 for (QWindow *w : tlws) {
529 if (w->screen() == screen && w->handle() && w->type() != Qt::Desktop) {
530 if (w->isVisible() && w->windowState() != Qt::WindowMinimized
531 && (QWindowsWindow::baseWindowOf(w)->exStyle() & WS_EX_TOOLWINDOW)) {
532 moveToVirtualScreen(w, primaryScreen);
533 } else {
534 QWindowSystemInterface::handleWindowScreenChanged(w, primaryScreen);
535 }
536 ++movedWindowCount;
537 }
538 }
539 if (movedWindowCount)
540 QWindowSystemInterface::flushWindowSystemEvents();
541 }
542 QWindowSystemInterface::handleScreenRemoved(m_screens.takeAt(index));
543}
544
545/*!
546 \brief Synchronizes the screen list, adds new screens, removes deleted
547 ones and propagates resolution changes to QWindowSystemInterface.
548*/
549
550bool QWindowsScreenManager::handleScreenChanges()
551{
552 // Look for changed monitors, add new ones
553 const WindowsScreenDataList newDataList = monitorData();
554 const bool lockScreen = newDataList.size() == 1 && (newDataList.front().flags & QWindowsScreenData::LockScreen);
555 for (const QWindowsScreenData &newData : newDataList) {
556 const int existingIndex = indexOfMonitor(m_screens, newData.name);
557 if (existingIndex != -1) {
558 m_screens.at(existingIndex)->handleChanges(newData);
559 } else {
560 auto *newScreen = new QWindowsScreen(newData);
561 m_screens.push_back(newScreen);
562 QWindowSystemInterface::handleScreenAdded(newScreen,
563 newData.flags & QWindowsScreenData::PrimaryScreen);
564 qCDebug(lcQpaWindows) << "New Monitor: " << newData;
565 } // exists
566 } // for new screens.
567 // Remove deleted ones but keep main monitors if we get only the
568 // temporary lock screen to avoid window recreation (QTBUG-33062).
569 if (!lockScreen) {
570 for (int i = m_screens.size() - 1; i >= 0; --i) {
571 if (indexOfMonitor(newDataList, m_screens.at(i)->data().name) == -1)
572 removeScreen(i);
573 } // for existing screens
574 } // not lock screen
575 return true;
576}
577
578void QWindowsScreenManager::clearScreens()
579{
580 // Delete screens in reverse order to avoid crash in case of multiple screens
581 while (!m_screens.isEmpty())
582 QWindowSystemInterface::handleScreenRemoved(m_screens.takeLast());
583}
584
585const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const
586{
587 for (QWindowsScreen *scr : m_screens) {
588 if (scr->geometry().contains(p))
589 return scr;
590 }
591 return nullptr;
592}
593
594const QWindowsScreen *QWindowsScreenManager::screenForHwnd(HWND hwnd) const
595{
596 HMONITOR hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL);
597 if (hMonitor == nullptr)
598 return nullptr;
599 const auto it =
600 std::find_if(m_screens.cbegin(), m_screens.cend(),
601 [hMonitor](const QWindowsScreen *s)
602 {
603 return s->data().hMonitor == hMonitor
604 && (s->data().flags & QWindowsScreenData::VirtualDesktop) != 0;
605 });
606 return it != m_screens.cend() ? *it : nullptr;
607}
608
609QT_END_NAMESPACE
610

Warning: That file was not part of the compilation database. It may have many parsing errors.