mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-12-11 18:48:14 +00:00
[idd] driver: CSettings minor refactor
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:
@@ -83,7 +83,7 @@ void CSettings::SetExtraMode(const DisplayMode& mode)
|
|||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettings::GetExtraMode(DisplayMode& mode)
|
std::wstring CSettings::ReadStringValue(const wchar_t* name, const wchar_t* default)
|
||||||
{
|
{
|
||||||
HKEY hKey = nullptr;
|
HKEY hKey = nullptr;
|
||||||
LONG ec = RegOpenKeyExW(
|
LONG ec = RegOpenKeyExW(
|
||||||
@@ -95,29 +95,38 @@ bool CSettings::GetExtraMode(DisplayMode& mode)
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (ec != ERROR_SUCCESS)
|
if (ec != ERROR_SUCCESS)
|
||||||
return false;
|
return std::wstring(default);
|
||||||
|
|
||||||
DWORD type = 0;
|
DWORD type = 0;
|
||||||
DWORD cb = 0;
|
DWORD cb = 0;
|
||||||
|
|
||||||
ec = RegQueryValueExW(hKey, L"ExtraMode", nullptr, &type, nullptr, &cb);
|
ec = RegQueryValueExW(hKey, name, nullptr, &type, nullptr, &cb);
|
||||||
if (ec != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ) || cb == 0)
|
if (ec != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ) || cb == 0)
|
||||||
{
|
{
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
return false;
|
return std::wstring(default);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<wchar_t> buf(cb / sizeof(wchar_t) + 1);
|
std::vector<wchar_t> buf(cb / sizeof(wchar_t) + 1);
|
||||||
ec = RegQueryValueExW(hKey, L"ExtraMode", nullptr, &type,
|
ec = RegQueryValueExW(hKey, name, nullptr, &type,
|
||||||
reinterpret_cast<LPBYTE>(buf.data()), &cb);
|
reinterpret_cast<LPBYTE>(buf.data()), &cb);
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
if (ec != ERROR_SUCCESS)
|
if (ec != ERROR_SUCCESS)
|
||||||
return false;
|
return std::wstring(default);
|
||||||
|
|
||||||
buf.back() = L'\0';
|
buf.back() = L'\0';
|
||||||
|
|
||||||
std::wstring s(buf.data());
|
std::wstring s(buf.data());
|
||||||
return ParseModeString(s, mode);
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSettings::GetExtraMode(DisplayMode& mode)
|
||||||
|
{
|
||||||
|
std::wstring extraMode = ReadStringValue(L"ExtraMode", NULL);
|
||||||
|
if (extraMode.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return ParseModeString(extraMode, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettings::ReadModesValue(std::vector<std::wstring> &out) const
|
bool CSettings::ReadModesValue(std::vector<std::wstring> &out) const
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class CSettings
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DisplayModes m_displayModes;
|
DisplayModes m_displayModes;
|
||||||
|
std::wstring ReadStringValue(const wchar_t* name, const wchar_t* default);
|
||||||
|
|
||||||
bool ReadModesValue(std::vector<std::wstring> &out) const;
|
bool ReadModesValue(std::vector<std::wstring> &out) const;
|
||||||
bool ParseModeString(const std::wstring& in, DisplayMode& out);
|
bool ParseModeString(const std::wstring& in, DisplayMode& out);
|
||||||
|
|||||||
Reference in New Issue
Block a user