diff --git a/src/wsi/win32/wsi_monitor_win32.cpp b/src/wsi/win32/wsi_monitor_win32.cpp index c9c2bef9b..ae4a0ff35 100644 --- a/src/wsi/win32/wsi_monitor_win32.cpp +++ b/src/wsi/win32/wsi_monitor_win32.cpp @@ -18,7 +18,7 @@ namespace dxvk::wsi { } struct MonitorEnumInfo { - const WCHAR *gdiDeviceName; + std::set *gdiDeviceNames; UINT iMonitorId; HMONITOR oMonitor; }; @@ -30,13 +30,13 @@ namespace dxvk::wsi { LPARAM lp) { auto data = reinterpret_cast(lp); - if (data->gdiDeviceName) + if (data->gdiDeviceNames) { MONITORINFOEXW monitorInfo; monitorInfo.cbSize = sizeof(monitorInfo); GetMonitorInfoW(hmon, (MONITORINFO *)&monitorInfo); - if (wcscmp(data->gdiDeviceName, monitorInfo.szDevice)) + if (data->gdiDeviceNames->find(monitorInfo.szDevice) == data->gdiDeviceNames->end()) return TRUE; } if (data->iMonitorId--) @@ -49,7 +49,7 @@ namespace dxvk::wsi { MonitorEnumInfo info; info.iMonitorId = index; info.oMonitor = nullptr; - info.gdiDeviceName = nullptr; + info.gdiDeviceNames = nullptr; ::EnumDisplayMonitors( nullptr, nullptr, &MonitorEnumProc, @@ -65,6 +65,7 @@ namespace dxvk::wsi { std::vector paths; std::vector modes; std::set> sources; + std::set gdiDeviceNames; UINT32 pathCount = 0; UINT32 modeCount = 0; LONG result; @@ -93,6 +94,7 @@ namespace dxvk::wsi { MonitorEnumInfo info; info.iMonitorId = index; info.oMonitor = nullptr; + info.gdiDeviceNames = &gdiDeviceNames; for (const auto &path : paths) { uint32_t i; @@ -121,16 +123,12 @@ namespace dxvk::wsi { return enumMonitors(index); } - info.gdiDeviceName = deviceName.viewGdiDeviceName; - - ::EnumDisplayMonitors( - nullptr, nullptr, &MonitorEnumProc, - reinterpret_cast(&info)); - - if (info.oMonitor != nullptr) - return info.oMonitor; + gdiDeviceNames.insert(deviceName.viewGdiDeviceName); } - return nullptr; + ::EnumDisplayMonitors( + nullptr, nullptr, &MonitorEnumProc, + reinterpret_cast(&info)); + return info.oMonitor; }