diff --git a/src/common/platform/win32/win32basevideo.cpp b/src/common/platform/win32/win32basevideo.cpp index d406a5d43..fc2ae67c4 100644 --- a/src/common/platform/win32/win32basevideo.cpp +++ b/src/common/platform/win32/win32basevideo.cpp @@ -48,7 +48,7 @@ #include "win32basevideo.h" #include "cmdlib.h" -CVAR(Int, vid_adapter, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Int, vid_adapter, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) //========================================================================== // @@ -69,6 +69,12 @@ Win32BaseVideo::Win32BaseVideo() // //========================================================================== +HMONITOR GetPrimaryMonitorHandle() +{ + const POINT ptZero = { 0, 0 }; + return MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY); +} + struct MonitorEnumState { int curIdx; @@ -116,24 +122,29 @@ void Win32BaseVideo::GetDisplayDeviceName() mes.curIdx = 1; mes.hFoundMonitor = nullptr; - // Could also use EnumDisplayDevices, I guess. That might work. - if (EnumDisplayMonitors(0, 0, &GetDisplayDeviceNameMonitorEnumProc, LPARAM(&mes))) + if (vid_adapter == 0) { - if (mes.hFoundMonitor) + mes.hFoundMonitor = GetPrimaryMonitorHandle(); + } + + // Could also use EnumDisplayDevices, I guess. That might work. + else EnumDisplayMonitors(0, 0, &GetDisplayDeviceNameMonitorEnumProc, LPARAM(&mes)); + + if (mes.hFoundMonitor) + { + MONITORINFOEXA mi; + + mi.cbSize = sizeof mi; + + if (GetMonitorInfoA(mes.hFoundMonitor, &mi)) { - MONITORINFOEXA mi; + strcpy(m_DisplayDeviceBuffer, mi.szDevice); + m_DisplayDeviceName = m_DisplayDeviceBuffer; - mi.cbSize = sizeof mi; - - if (GetMonitorInfoA(mes.hFoundMonitor, &mi)) - { - strcpy(m_DisplayDeviceBuffer, mi.szDevice); - m_DisplayDeviceName = m_DisplayDeviceBuffer; - - m_hMonitor = mes.hFoundMonitor; - } + m_hMonitor = mes.hFoundMonitor; } } + } //==========================================================================