mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-06-04 05:44:47 +00:00
[idd] all: add default refresh rate setting support
This commit is contained in:
committed by
Geoffrey McRae
parent
c2add993ac
commit
65005c0dc0
@@ -46,6 +46,7 @@ struct LGPipeMsg
|
||||
{
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t refresh;
|
||||
}
|
||||
displayMode;
|
||||
};
|
||||
|
||||
@@ -202,7 +202,7 @@ void CIndirectDeviceContext::OnAssignSwapChain()
|
||||
if (m_doSetMode)
|
||||
{
|
||||
m_doSetMode = false;
|
||||
g_pipe.SetDisplayMode(m_setMode.width, m_setMode.height); //FIXME: refresh
|
||||
g_pipe.SetDisplayMode(m_setMode.width, m_setMode.height, m_setMode.refresh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ void CIndirectDeviceContext::SetResolution(int width, int height)
|
||||
{
|
||||
m_setMode.width = width;
|
||||
m_setMode.height = height;
|
||||
m_setMode.refresh = 120; //FIXME
|
||||
m_setMode.refresh = g_settings.GetDefaultRefresh();
|
||||
m_setMode.preferred = true;
|
||||
g_settings.SetExtraMode(m_setMode);
|
||||
|
||||
|
||||
@@ -162,15 +162,16 @@ void CPipeServer::SetCursorPos(uint32_t x, uint32_t y)
|
||||
WriteMsg(msg);
|
||||
}
|
||||
|
||||
void CPipeServer::SetDisplayMode(uint32_t width, uint32_t height)
|
||||
void CPipeServer::SetDisplayMode(uint32_t width, uint32_t height, uint32_t refresh)
|
||||
{
|
||||
if (!m_connected)
|
||||
return;
|
||||
|
||||
LGPipeMsg msg;
|
||||
msg.size = sizeof(msg);
|
||||
msg.type = LGPipeMsg::SETDISPLAYMODE;
|
||||
msg.displayMode.width = width;
|
||||
msg.displayMode.height = height;
|
||||
msg.size = sizeof(msg);
|
||||
msg.type = LGPipeMsg::SETDISPLAYMODE;
|
||||
msg.displayMode.width = width;
|
||||
msg.displayMode.height = height;
|
||||
msg.displayMode.refresh = refresh;
|
||||
WriteMsg(msg);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class CPipeServer
|
||||
void DeInit();
|
||||
|
||||
void SetCursorPos(uint32_t x, uint32_t y);
|
||||
void SetDisplayMode(uint32_t width, uint32_t height);
|
||||
void SetDisplayMode(uint32_t width, uint32_t height, uint32_t refresh);
|
||||
};
|
||||
|
||||
extern CPipeServer g_pipe;
|
||||
@@ -166,6 +166,26 @@ bool CSettings::GetExtraMode(DisplayMode& mode)
|
||||
return ParseModeString(extraMode, mode);
|
||||
}
|
||||
|
||||
unsigned CSettings::GetDefaultRefresh() const
|
||||
{
|
||||
DWORD refresh = 60;
|
||||
DWORD cb = sizeof(refresh);
|
||||
HKEY hKey = nullptr;
|
||||
|
||||
LONG st = RegOpenKeyExW(HKEY_LOCAL_MACHINE, LGIDD_REGKEY, 0, KEY_QUERY_VALUE, &hKey);
|
||||
if (st == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD type = 0;
|
||||
st = RegGetValueW(hKey, nullptr, L"DefaultRefresh", RRF_RT_REG_DWORD, &type, &refresh, &cb);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
if (st != ERROR_SUCCESS || refresh < 30 || refresh > 1000)
|
||||
return 60;
|
||||
|
||||
return refresh;
|
||||
}
|
||||
|
||||
bool CSettings::ReadModesValue(std::vector<std::wstring> &out) const
|
||||
{
|
||||
HKEY hKey = nullptr;
|
||||
|
||||
@@ -41,6 +41,7 @@ class CSettings
|
||||
const DisplayModes& GetDisplayModes() { return m_displayModes; }
|
||||
void SetExtraMode(const DisplayMode & mode);
|
||||
bool GetExtraMode(DisplayMode & mode);
|
||||
unsigned GetDefaultRefresh() const;
|
||||
|
||||
private:
|
||||
DisplayModes m_displayModes;
|
||||
|
||||
@@ -290,10 +290,11 @@ void CPipeClient::HandleSetCursorPos(const LGPipeMsg& msg)
|
||||
void CPipeClient::HandleSetDisplayMode(const LGPipeMsg& msg)
|
||||
{
|
||||
DEVMODE dm = {};
|
||||
dm.dmSize = sizeof(dm);
|
||||
dm.dmPelsWidth = msg.displayMode.width;
|
||||
dm.dmPelsHeight = msg.displayMode.height;
|
||||
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||
dm.dmSize = sizeof(dm);
|
||||
dm.dmPelsWidth = msg.displayMode.width;
|
||||
dm.dmPelsHeight = msg.displayMode.height;
|
||||
dm.dmDisplayFrequency = msg.displayMode.refresh;
|
||||
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
|
||||
|
||||
LONG result = ChangeDisplaySettingsEx(NULL, &dm, NULL, CDS_UPDATEREGISTRY, NULL);
|
||||
if (result != DISP_CHANGE_SUCCESSFUL)
|
||||
|
||||
Reference in New Issue
Block a user