mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-14 22: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)
|
if (hMonitor == nullptr)
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
return RestoreMonitorDisplayMode(hMonitor)
|
return RestoreMonitorDisplayMode()
|
||||||
? D3D_OK
|
? D3D_OK
|
||||||
: D3DERR_NOTAVAILABLE;
|
: D3DERR_NOTAVAILABLE;
|
||||||
}
|
}
|
||||||
|
@ -722,7 +722,7 @@ namespace dxvk {
|
|||||||
if (!hMonitor)
|
if (!hMonitor)
|
||||||
return DXGI_ERROR_INVALID_CALL;
|
return DXGI_ERROR_INVALID_CALL;
|
||||||
|
|
||||||
return RestoreMonitorDisplayMode(hMonitor)
|
return RestoreMonitorDisplayMode()
|
||||||
? S_OK
|
? S_OK
|
||||||
: DXGI_ERROR_NOT_CURRENTLY_AVAILABLE;
|
: DXGI_ERROR_NOT_CURRENTLY_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
@ -70,19 +70,41 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL RestoreMonitorDisplayMode(
|
BOOL CALLBACK RestoreMonitorDisplayModeCallback(
|
||||||
HMONITOR hMonitor) {
|
HMONITOR hMonitor,
|
||||||
|
HDC hDC,
|
||||||
|
LPRECT pRect,
|
||||||
|
LPARAM pUserdata) {
|
||||||
|
auto success = reinterpret_cast<bool*>(pUserdata);
|
||||||
|
|
||||||
DEVMODEW devMode = { };
|
DEVMODEW devMode = { };
|
||||||
devMode.dmSize = sizeof(devMode);
|
devMode.dmSize = sizeof(devMode);
|
||||||
|
|
||||||
if (!GetMonitorDisplayMode(hMonitor, ENUM_REGISTRY_SETTINGS, &devMode))
|
if (!GetMonitorDisplayMode(hMonitor, ENUM_REGISTRY_SETTINGS, &devMode)) {
|
||||||
|
*success = false;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Logger::info(str::format("Restoring display mode: ",
|
Logger::info(str::format("Restoring display mode: ",
|
||||||
devMode.dmPelsWidth, "x", devMode.dmPelsHeight, "@",
|
devMode.dmPelsWidth, "x", devMode.dmPelsHeight, "@",
|
||||||
devMode.dmDisplayFrequency));
|
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);
|
DEVMODEW* pMode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Change display mode to registry settings
|
* \brief Change display modes to registry settings
|
||||||
*
|
|
||||||
* \param [in] hMonitor The monitor to change
|
|
||||||
* \returns \c true on success
|
* \returns \c true on success
|
||||||
*/
|
*/
|
||||||
BOOL RestoreMonitorDisplayMode(
|
BOOL RestoreMonitorDisplayMode();
|
||||||
HMONITOR hMonitor);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Queries window client size
|
* \brief Queries window client size
|
||||||
|
Loading…
x
Reference in New Issue
Block a user