mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 07:01:30 +00:00
[idd] helper: use registry boolean helper instead of duplication
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
This commit is contained in:
@@ -220,98 +220,65 @@ LSTATUS CRegistrySettings::setDefaultRefresh(DWORD refresh100uHz)
|
||||
(DWORD)((value.size() + 1) * sizeof(wchar_t)));
|
||||
}
|
||||
|
||||
std::optional<bool> CRegistrySettings::getNoGPU()
|
||||
std::optional<bool> CRegistrySettings::readBooleanSetting(LPCWSTR szName, bool fallback)
|
||||
{
|
||||
DWORD result, cbData = sizeof result;
|
||||
|
||||
LSTATUS status = RegGetValue(hKey, nullptr, L"NoGPU", RRF_RT_REG_DWORD, nullptr, &result, &cbData);
|
||||
LSTATUS status = RegGetValue(hKey, nullptr, szName, RRF_RT_REG_DWORD, nullptr, &result, &cbData);
|
||||
switch (status)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
return !!result;
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
return false;
|
||||
return fallback;
|
||||
default:
|
||||
DEBUG_ERROR_HR(status, "RegGetValue(NoGPU)");
|
||||
DEBUG_ERROR_HR(status, "RegGetValue(%S)", szName);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
LSTATUS CRegistrySettings::writeBooleanSetting(LPCWSTR szName, bool value)
|
||||
{
|
||||
DWORD dwValue = value;
|
||||
return RegSetValueEx(hKey, szName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(DWORD));
|
||||
}
|
||||
|
||||
std::optional<bool> CRegistrySettings::getNoGPU()
|
||||
{
|
||||
return readBooleanSetting(L"NoGPU");
|
||||
}
|
||||
|
||||
LSTATUS CRegistrySettings::setNoGPU(bool noGPU)
|
||||
{
|
||||
DWORD dwValue = noGPU;
|
||||
return RegSetValueEx(hKey, L"NoGPU", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(DWORD));
|
||||
return writeBooleanSetting(L"NoGPU", noGPU);
|
||||
}
|
||||
|
||||
std::optional<bool> CRegistrySettings::getExclusiveMonitor()
|
||||
{
|
||||
DWORD result, cbData = sizeof result;
|
||||
|
||||
LSTATUS status = RegGetValue(hKey, nullptr, L"ExclusiveMonitor", RRF_RT_REG_DWORD, nullptr, &result, &cbData);
|
||||
switch (status)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
return !!result;
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
return true;
|
||||
default:
|
||||
DEBUG_ERROR_HR(status, "RegGetValue(ExclusiveMonitor)");
|
||||
return {};
|
||||
}
|
||||
return readBooleanSetting(L"ExclusiveMonitor", true);
|
||||
}
|
||||
|
||||
LSTATUS CRegistrySettings::setExclusiveMonitor(bool exclusive)
|
||||
{
|
||||
DWORD dwValue = exclusive;
|
||||
return RegSetValueEx(hKey, L"ExclusiveMonitor", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(DWORD));
|
||||
return writeBooleanSetting(L"ExclusiveMonitor", exclusive);
|
||||
}
|
||||
|
||||
std::optional<bool> CRegistrySettings::getForceFullDirectCopy()
|
||||
{
|
||||
DWORD result, cbData = sizeof result;
|
||||
|
||||
LSTATUS status = RegGetValue(hKey, nullptr, L"ForceFullDirectCopy",
|
||||
RRF_RT_REG_DWORD, nullptr, &result, &cbData);
|
||||
switch (status)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
return !!result;
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
return false;
|
||||
default:
|
||||
DEBUG_ERROR_HR(status, "RegGetValue(ForceFullDirectCopy)");
|
||||
return {};
|
||||
}
|
||||
return readBooleanSetting(L"ForceFullDirectCopy");
|
||||
}
|
||||
|
||||
LSTATUS CRegistrySettings::setForceFullDirectCopy(bool forceFullCopy)
|
||||
{
|
||||
DWORD dwValue = forceFullCopy;
|
||||
return RegSetValueEx(hKey, L"ForceFullDirectCopy", 0, REG_DWORD,
|
||||
(LPBYTE)&dwValue, sizeof(DWORD));
|
||||
return writeBooleanSetting(L"ForceFullDirectCopy", forceFullCopy);
|
||||
}
|
||||
|
||||
std::optional<bool> CRegistrySettings::getForceIndirectCopy()
|
||||
{
|
||||
DWORD result, cbData = sizeof result;
|
||||
|
||||
LSTATUS status = RegGetValue(hKey, nullptr, L"ForceIndirectCopy",
|
||||
RRF_RT_REG_DWORD, nullptr, &result, &cbData);
|
||||
switch (status)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
return !!result;
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
return false;
|
||||
default:
|
||||
DEBUG_ERROR_HR(status, "RegGetValue(ForceIndirectCopy)");
|
||||
return {};
|
||||
}
|
||||
return readBooleanSetting(L"ForceIndirectCopy");
|
||||
}
|
||||
|
||||
LSTATUS CRegistrySettings::setForceIndirectCopy(bool forceIndirectCopy)
|
||||
{
|
||||
DWORD dwValue = forceIndirectCopy;
|
||||
return RegSetValueEx(hKey, L"ForceIndirectCopy", 0, REG_DWORD,
|
||||
(LPBYTE)&dwValue, sizeof(DWORD));
|
||||
return writeBooleanSetting(L"ForceIndirectCopy", forceIndirectCopy);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ struct DisplayMode {
|
||||
class CRegistrySettings {
|
||||
HKEY hKey;
|
||||
|
||||
std::optional<bool> readBooleanSetting(LPCWSTR szName, bool fallback = false);
|
||||
LSTATUS writeBooleanSetting(LPCWSTR szName, bool value);
|
||||
|
||||
public:
|
||||
CRegistrySettings();
|
||||
~CRegistrySettings();
|
||||
|
||||
Reference in New Issue
Block a user