diff options
author | Timothée Keller <timothee.keller@qt.io> | 2023-04-17 16:20:09 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-06-07 23:32:34 +0000 |
commit | e14fe5f84843da3390bc13a8f057527fc2664e54 (patch) | |
tree | cc01ce0e8375779b1cbb3307b3aaf83b8e06276a | |
parent | 4139b6d02987f830ee3b0d8f3e39f4a7b1d8d185 (diff) |
Windows QPA: Change monitor index detection
Monitor index detection changed from comparing deviceNames to comparing
serialNumbers, to prevent the case where two monitors with identical
names might overwrite one another.
Fixes: QTBUG-112829
Change-Id: Ibfad08e178774396c4b347acfcfbdb83ed4fe332
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit f4d6d04898bcc239f4b271330ba778de69bbd893)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/plugins/platforms/windows/qwindowsscreen.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 6b85a68f69..2168e00605 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -695,19 +695,19 @@ bool QWindowsScreenManager::isSingleScreen() } static inline int indexOfMonitor(const QWindowsScreenManager::WindowsScreenList &screens, - const QString &deviceName) + const QString &serialNumberIn) { - for (int i= 0; i < screens.size(); ++i) - if (screens.at(i)->data().deviceName == deviceName) + for (int i = 0; i < screens.size(); ++i) + if (screens.at(i)->data().serialNumber == serialNumberIn) return i; return -1; } static inline int indexOfMonitor(const WindowsScreenDataList &screenData, - const QString &deviceName) + const QString &serialNumberIn) { for (int i = 0; i < screenData.size(); ++i) - if (screenData.at(i).deviceName == deviceName) + if (screenData.at(i).serialNumber == serialNumberIn) return i; return -1; } @@ -773,7 +773,7 @@ bool QWindowsScreenManager::handleScreenChanges() const bool lockScreen = newDataList.size() == 1 && (newDataList.front().flags & QWindowsScreenData::LockScreen); bool primaryScreenChanged = false; for (const QWindowsScreenData &newData : newDataList) { - const int existingIndex = indexOfMonitor(m_screens, newData.deviceName); + const int existingIndex = indexOfMonitor(m_screens, newData.serialNumber); if (existingIndex != -1) { m_screens.at(existingIndex)->handleChanges(newData); if (existingIndex == 0) @@ -790,7 +790,7 @@ bool QWindowsScreenManager::handleScreenChanges() // temporary lock screen to avoid window recreation (QTBUG-33062). if (!lockScreen) { for (int i = m_screens.size() - 1; i >= 0; --i) { - if (indexOfMonitor(newDataList, m_screens.at(i)->data().deviceName) == -1) + if (indexOfMonitor(newDataList, m_screens.at(i)->data().serialNumber) == -1) removeScreen(i); } // for existing screens } // not lock screen |