mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-06-10 00:34:31 +00:00
[idd] helper: allow no GPU warning to be configured
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include "CGroupBox.h"
|
#include "CGroupBox.h"
|
||||||
#include "CEditWidget.h"
|
#include "CEditWidget.h"
|
||||||
#include "CButton.h"
|
#include "CButton.h"
|
||||||
|
#include "CCheckbox.h"
|
||||||
#include <CDebug.h>
|
#include <CDebug.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
@@ -51,6 +52,7 @@ CConfigWindow::CConfigWindow() : m_scale(1)
|
|||||||
{
|
{
|
||||||
m_modes = m_settings.getModes();
|
m_modes = m_settings.getModes();
|
||||||
m_defaultRefresh = m_settings.getDefaultRefresh();
|
m_defaultRefresh = m_settings.getDefaultRefresh();
|
||||||
|
m_noGPU = m_settings.getNoGPU();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CreateWindowEx(0, MAKEINTATOM(s_atom), L"Looking Glass IDD Configuration",
|
if (!CreateWindowEx(0, MAKEINTATOM(s_atom), L"Looking Glass IDD Configuration",
|
||||||
@@ -90,6 +92,7 @@ void CConfigWindow::updateFont()
|
|||||||
*m_version, *m_modeGroup, *m_modeBox, *m_widthLabel, *m_heightLabel, *m_refreshLabel,
|
*m_version, *m_modeGroup, *m_modeBox, *m_widthLabel, *m_heightLabel, *m_refreshLabel,
|
||||||
*m_modeWidth, *m_modeHeight, *m_modeRefresh, *m_modeUpdate, *m_modeDelete,
|
*m_modeWidth, *m_modeHeight, *m_modeRefresh, *m_modeUpdate, *m_modeDelete,
|
||||||
*m_autosizeGroup, *m_defRefreshLabel, *m_defRefresh, *m_defRefreshHz,
|
*m_autosizeGroup, *m_defRefreshLabel, *m_defRefresh, *m_defRefreshHz,
|
||||||
|
*m_prefGroup, *m_prefNoGPU,
|
||||||
}))
|
}))
|
||||||
SendMessage(child, WM_SETFONT, (WPARAM)m_font.Get(), 1);
|
SendMessage(child, WM_SETFONT, (WPARAM)m_font.Get(), 1);
|
||||||
}
|
}
|
||||||
@@ -167,6 +170,12 @@ LRESULT CConfigWindow::onCreate()
|
|||||||
else
|
else
|
||||||
m_defRefresh->disable();
|
m_defRefresh->disable();
|
||||||
|
|
||||||
|
m_prefGroup.reset(new CGroupBox(L"Preferences", WS_CHILD | WS_VISIBLE, m_hwnd));
|
||||||
|
m_prefNoGPU.reset(new CCheckbox(L"Disable no GPU warning", WS_CHILD | WS_VISIBLE, m_hwnd));
|
||||||
|
|
||||||
|
if (m_noGPU)
|
||||||
|
m_prefNoGPU->setChecked(*m_noGPU);
|
||||||
|
|
||||||
LONG width, height;
|
LONG width, height;
|
||||||
getMinimumSize(width, height);
|
getMinimumSize(width, height);
|
||||||
SetWindowPos(m_hwnd, NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER);
|
SetWindowPos(m_hwnd, NULL, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER);
|
||||||
@@ -203,6 +212,9 @@ LRESULT CConfigWindow::onResize(DWORD width, DWORD height)
|
|||||||
pos.pinTopLeft(*m_defRefreshLabel, 236, 64, 95, 20);
|
pos.pinTopLeft(*m_defRefreshLabel, 236, 64, 95, 20);
|
||||||
pos.pinTopLeft(*m_defRefresh, 331, 64, 63, 20);
|
pos.pinTopLeft(*m_defRefresh, 331, 64, 63, 20);
|
||||||
pos.pinTopLeft(*m_defRefreshHz, 398, 64, 16, 20);
|
pos.pinTopLeft(*m_defRefreshHz, 398, 64, 16, 20);
|
||||||
|
|
||||||
|
pos.pinTopLeft(*m_prefGroup, 224, 100, 200, 52);
|
||||||
|
pos.pinTopLeft(*m_prefNoGPU, 236, 124, 176, 20);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,11 +243,11 @@ void CConfigWindow::onModeListSelectChange()
|
|||||||
|
|
||||||
LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
||||||
{
|
{
|
||||||
if (hwnd == *m_modeBox && code == LBN_SELCHANGE && m_modes)
|
if (m_modeBox && hwnd == *m_modeBox && code == LBN_SELCHANGE && m_modes)
|
||||||
{
|
{
|
||||||
onModeListSelectChange();
|
onModeListSelectChange();
|
||||||
}
|
}
|
||||||
else if (hwnd == *m_modeUpdate && code == BN_CLICKED && m_modes)
|
else if (m_modeUpdate && hwnd == *m_modeUpdate && code == BN_CLICKED && m_modes)
|
||||||
{
|
{
|
||||||
int sel = m_modeBox->getSel();
|
int sel = m_modeBox->getSel();
|
||||||
if (sel == LB_ERR)
|
if (sel == LB_ERR)
|
||||||
@@ -264,7 +276,7 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
|||||||
if (result != ERROR_SUCCESS)
|
if (result != ERROR_SUCCESS)
|
||||||
DEBUG_ERROR_HR((HRESULT) result, "Failed to save modes");
|
DEBUG_ERROR_HR((HRESULT) result, "Failed to save modes");
|
||||||
}
|
}
|
||||||
else if (hwnd == *m_modeDelete && code == BN_CLICKED && m_modes)
|
else if (m_modeDelete && hwnd == *m_modeDelete && code == BN_CLICKED && m_modes)
|
||||||
{
|
{
|
||||||
int sel = m_modeBox->getSel();
|
int sel = m_modeBox->getSel();
|
||||||
if (sel == LB_ERR)
|
if (sel == LB_ERR)
|
||||||
@@ -281,7 +293,7 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
|||||||
updateModeList();
|
updateModeList();
|
||||||
onModeListSelectChange();
|
onModeListSelectChange();
|
||||||
}
|
}
|
||||||
else if (hwnd == *m_defRefresh && code == EN_CHANGE && m_defaultRefresh)
|
else if (m_defRefresh && hwnd == *m_defRefresh && code == EN_CHANGE && m_defaultRefresh)
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
try
|
try
|
||||||
@@ -298,5 +310,12 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
|||||||
if (result != ERROR_SUCCESS)
|
if (result != ERROR_SUCCESS)
|
||||||
DEBUG_ERROR_HR((HRESULT)result, "Failed to default refresh");
|
DEBUG_ERROR_HR((HRESULT)result, "Failed to default refresh");
|
||||||
}
|
}
|
||||||
|
else if (m_prefNoGPU && hwnd == *m_prefNoGPU && code == BN_CLICKED && m_noGPU)
|
||||||
|
{
|
||||||
|
DEBUG_INFO("GPU button clicked");
|
||||||
|
*m_noGPU ^= true;
|
||||||
|
m_settings.setNoGPU(*m_noGPU);
|
||||||
|
m_prefNoGPU->setChecked(*m_noGPU);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class CListBox;
|
|||||||
class CGroupBox;
|
class CGroupBox;
|
||||||
class CEditWidget;
|
class CEditWidget;
|
||||||
class CButton;
|
class CButton;
|
||||||
|
class CCheckbox;
|
||||||
|
|
||||||
class CConfigWindow : public CWindow
|
class CConfigWindow : public CWindow
|
||||||
{
|
{
|
||||||
@@ -57,12 +58,16 @@ class CConfigWindow : public CWindow
|
|||||||
std::unique_ptr<CEditWidget> m_defRefresh;
|
std::unique_ptr<CEditWidget> m_defRefresh;
|
||||||
std::unique_ptr<CStaticWidget> m_defRefreshHz;
|
std::unique_ptr<CStaticWidget> m_defRefreshHz;
|
||||||
|
|
||||||
|
std::unique_ptr<CGroupBox> m_prefGroup;
|
||||||
|
std::unique_ptr<CCheckbox> m_prefNoGPU;
|
||||||
|
|
||||||
std::function<void()> m_onDestroy;
|
std::function<void()> m_onDestroy;
|
||||||
double m_scale;
|
double m_scale;
|
||||||
Microsoft::WRL::Wrappers::HandleT<FontTraits> m_font;
|
Microsoft::WRL::Wrappers::HandleT<FontTraits> m_font;
|
||||||
CRegistrySettings m_settings;
|
CRegistrySettings m_settings;
|
||||||
std::optional<std::vector<DisplayMode>> m_modes;
|
std::optional<std::vector<DisplayMode>> m_modes;
|
||||||
std::optional<DWORD> m_defaultRefresh;
|
std::optional<DWORD> m_defaultRefresh;
|
||||||
|
std::optional<bool> m_noGPU;
|
||||||
|
|
||||||
void getMinimumSize(LONG &width, LONG &height);
|
void getMinimumSize(LONG &width, LONG &height);
|
||||||
void updateFont();
|
void updateFont();
|
||||||
|
|||||||
Reference in New Issue
Block a user