[idd] config: reload persisted display modes

Rebuild the driver's cached mode list before replugging the monitor so
Windows enumerates the settings saved by the helper.

Keep saved mode refresh rates intact and update only ExtraMode to the
configured default refresh.
This commit is contained in:
Geoffrey McRae
2026-08-06 23:05:45 +10:00
parent 05599ffd02
commit a279a87bdb
5 changed files with 65 additions and 13 deletions

View File

@@ -76,7 +76,7 @@ CSettings::DisplayModes CSettings::LoadModes()
return displayModes;
}
void CSettings::SetExtraMode(const DisplayMode& mode)
bool CSettings::SetExtraMode(const DisplayMode& mode)
{
WCHAR buf[64];
_snwprintf_s(buf, _countof(buf), _TRUNCATE, L"%ux%u@%u%s",
@@ -94,15 +94,24 @@ void CSettings::SetExtraMode(const DisplayMode& mode)
if (ec != ERROR_SUCCESS)
{
DEBUG_INFO("Failed to write key");
return;
DEBUG_ERROR_HR(ec, "Failed to open settings key for ExtraMode");
return false;
}
const WCHAR* valueName = L"ExtraMode";
const DWORD cb = (DWORD)((wcslen(buf) + 1) * sizeof(WCHAR));
RegSetValueExW(hKey, valueName, 0, REG_SZ, (const BYTE*)buf, cb);
ec = RegSetValueExW(hKey, valueName, 0, REG_SZ,
(const BYTE*)buf, cb);
RegCloseKey(hKey);
if (ec != ERROR_SUCCESS)
{
DEBUG_ERROR_HR(ec, "Failed to write ExtraMode");
return false;
}
return true;
}
std::wstring CSettings::ReadStringValue(const wchar_t* name, const wchar_t* defaultValue)