mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-14 04:29:15 +01:00
[util] Restore display modes of all monitors in RestoreMonitorDisplayMode
Fixes #2064.
This commit is contained in:
parent
e7897e8289
commit
0af7229b8e
@ -1255,7 +1255,7 @@ namespace dxvk {
|
||||
if (hMonitor == nullptr)
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
return RestoreMonitorDisplayMode(hMonitor)
|
||||
return RestoreMonitorDisplayMode()
|
||||
? D3D_OK
|
||||
: D3DERR_NOTAVAILABLE;
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ namespace dxvk {
|
||||
if (!hMonitor)
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
|
||||
return RestoreMonitorDisplayMode(hMonitor)
|
||||
return RestoreMonitorDisplayMode()
|
||||
? S_OK
|
||||
: DXGI_ERROR_NOT_CURRENTLY_AVAILABLE;
|
||||
}
|
||||
|
@ -70,19 +70,41 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
BOOL RestoreMonitorDisplayMode(
|
||||
HMONITOR hMonitor) {
|
||||
BOOL CALLBACK RestoreMonitorDisplayModeCallback(
|
||||
HMONITOR hMonitor,
|
||||
HDC hDC,
|
||||
LPRECT pRect,
|
||||
LPARAM pUserdata) {
|
||||
auto success = reinterpret_cast<bool*>(pUserdata);
|
||||
|
||||
DEVMODEW devMode = { };
|
||||
devMode.dmSize = sizeof(devMode);
|
||||
|
||||
if (!GetMonitorDisplayMode(hMonitor, ENUM_REGISTRY_SETTINGS, &devMode))
|
||||
if (!GetMonitorDisplayMode(hMonitor, ENUM_REGISTRY_SETTINGS, &devMode)) {
|
||||
*success = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Logger::info(str::format("Restoring display mode: ",
|
||||
devMode.dmPelsWidth, "x", devMode.dmPelsHeight, "@",
|
||||
devMode.dmDisplayFrequency));
|
||||
|
||||
return SetMonitorDisplayMode(hMonitor, &devMode);
|
||||
if (!SetMonitorDisplayMode(hMonitor, &devMode)) {
|
||||
*success = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BOOL RestoreMonitorDisplayMode() {
|
||||
bool success = true;
|
||||
bool result = ::EnumDisplayMonitors(nullptr, nullptr,
|
||||
&RestoreMonitorDisplayModeCallback,
|
||||
reinterpret_cast<LPARAM>(&success));
|
||||
|
||||
return result && success;
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,13 +36,10 @@ namespace dxvk {
|
||||
DEVMODEW* pMode);
|
||||
|
||||
/**
|
||||
* \brief Change display mode to registry settings
|
||||
*
|
||||
* \param [in] hMonitor The monitor to change
|
||||
* \brief Change display modes to registry settings
|
||||
* \returns \c true on success
|
||||
*/
|
||||
BOOL RestoreMonitorDisplayMode(
|
||||
HMONITOR hMonitor);
|
||||
BOOL RestoreMonitorDisplayMode();
|
||||
|
||||
/**
|
||||
* \brief Queries window client size
|
||||
|
Loading…
x
Reference in New Issue
Block a user