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>
This commit is contained in:
parent
4139b6d029
commit
e14fe5f848
@ -695,19 +695,19 @@ bool QWindowsScreenManager::isSingleScreen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline int indexOfMonitor(const QWindowsScreenManager::WindowsScreenList &screens,
|
static inline int indexOfMonitor(const QWindowsScreenManager::WindowsScreenList &screens,
|
||||||
const QString &deviceName)
|
const QString &serialNumberIn)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < screens.size(); ++i)
|
for (int i = 0; i < screens.size(); ++i)
|
||||||
if (screens.at(i)->data().deviceName == deviceName)
|
if (screens.at(i)->data().serialNumber == serialNumberIn)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int indexOfMonitor(const WindowsScreenDataList &screenData,
|
static inline int indexOfMonitor(const WindowsScreenDataList &screenData,
|
||||||
const QString &deviceName)
|
const QString &serialNumberIn)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < screenData.size(); ++i)
|
for (int i = 0; i < screenData.size(); ++i)
|
||||||
if (screenData.at(i).deviceName == deviceName)
|
if (screenData.at(i).serialNumber == serialNumberIn)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -773,7 +773,7 @@ bool QWindowsScreenManager::handleScreenChanges()
|
|||||||
const bool lockScreen = newDataList.size() == 1 && (newDataList.front().flags & QWindowsScreenData::LockScreen);
|
const bool lockScreen = newDataList.size() == 1 && (newDataList.front().flags & QWindowsScreenData::LockScreen);
|
||||||
bool primaryScreenChanged = false;
|
bool primaryScreenChanged = false;
|
||||||
for (const QWindowsScreenData &newData : newDataList) {
|
for (const QWindowsScreenData &newData : newDataList) {
|
||||||
const int existingIndex = indexOfMonitor(m_screens, newData.deviceName);
|
const int existingIndex = indexOfMonitor(m_screens, newData.serialNumber);
|
||||||
if (existingIndex != -1) {
|
if (existingIndex != -1) {
|
||||||
m_screens.at(existingIndex)->handleChanges(newData);
|
m_screens.at(existingIndex)->handleChanges(newData);
|
||||||
if (existingIndex == 0)
|
if (existingIndex == 0)
|
||||||
@ -790,7 +790,7 @@ bool QWindowsScreenManager::handleScreenChanges()
|
|||||||
// temporary lock screen to avoid window recreation (QTBUG-33062).
|
// temporary lock screen to avoid window recreation (QTBUG-33062).
|
||||||
if (!lockScreen) {
|
if (!lockScreen) {
|
||||||
for (int i = m_screens.size() - 1; i >= 0; --i) {
|
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);
|
removeScreen(i);
|
||||||
} // for existing screens
|
} // for existing screens
|
||||||
} // not lock screen
|
} // not lock screen
|
||||||
|
Loading…
x
Reference in New Issue
Block a user