mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-12-14 20:18:14 +00:00
Compare commits
1 Commits
master
...
idd-defaul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e6f21f91e |
@@ -42,30 +42,3 @@ The clipboard is not working
|
|||||||
- The Spice VDAgent is available in both Spice Guest Tools, and
|
- The Spice VDAgent is available in both Spice Guest Tools, and
|
||||||
standalone as a separate installer. Check your installed programs
|
standalone as a separate installer. Check your installed programs
|
||||||
and uninstall the VDAgent if it's installed separately.
|
and uninstall the VDAgent if it's installed separately.
|
||||||
|
|
||||||
.. _keyboard_shortcuts_not_captured_on_gnome_wayland:
|
|
||||||
|
|
||||||
Keyboard shortcuts are not captured on GNOME Wayland
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Capture mode may fail to capture compositor shortcuts like
|
|
||||||
ALT+Tab or ALT+Middle Mouse - they go to GNOME instead of the guest VM.
|
|
||||||
|
|
||||||
When Looking Glass first requests to inhibit shortcuts, GNOME shows a
|
|
||||||
dialog asking for permission. If you clicked "Deny" (or dismissed the dialog),
|
|
||||||
GNOME permanently blocks the application and never shows the dialog again.
|
|
||||||
|
|
||||||
Use the ``flatpak`` command to view or grant the permission, this works even
|
|
||||||
if LookingGlass is not a Flatpak application, as GNOME stores these permissions
|
|
||||||
in Flatpak's database:
|
|
||||||
|
|
||||||
.. code:: bash
|
|
||||||
|
|
||||||
flatpak permission-set gnome shortcuts-inhibitor looking-glass-client.desktop GRANTED
|
|
||||||
|
|
||||||
To verify the permission was set:
|
|
||||||
|
|
||||||
.. code:: bash
|
|
||||||
|
|
||||||
flatpak permissions gnome shortcuts-inhibitor
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ downsampling
|
|||||||
downscaler
|
downscaler
|
||||||
downscaling
|
downscaling
|
||||||
evdev
|
evdev
|
||||||
Flatpak
|
|
||||||
framebuffer
|
framebuffer
|
||||||
fullscreen
|
fullscreen
|
||||||
gcc
|
gcc
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
static const DWORD DefaultDisplayModes[][3] =
|
|
||||||
{
|
|
||||||
{7680, 4800, 120}, {7680, 4320, 120}, {6016, 3384, 120}, {5760, 3600, 120},
|
|
||||||
{5760, 3240, 120}, {5120, 2800, 120}, {4096, 2560, 120}, {4096, 2304, 120},
|
|
||||||
{3840, 2400, 120}, {3840, 2160, 120}, {3200, 2400, 120}, {3200, 1800, 120},
|
|
||||||
{3008, 1692, 120}, {2880, 1800, 120}, {2880, 1620, 120}, {2560, 1600, 120},
|
|
||||||
{2560, 1440, 120}, {1920, 1440, 120}, {1920, 1200, 120}, {1920, 1080, 120},
|
|
||||||
{1600, 1200, 120}, {1600, 1024, 120}, {1600, 1050, 120}, {1600, 900 , 120},
|
|
||||||
{1440, 900 , 120}, {1400, 1050, 120}, {1366, 768 , 120}, {1360, 768 , 120},
|
|
||||||
{1280, 1024, 120}, {1280, 960 , 120}, {1280, 800 , 120}, {1280, 768 , 120},
|
|
||||||
{1280, 720 , 120}, {1280, 600 , 120}, {1152, 864 , 120}, {1024, 768 , 120},
|
|
||||||
{800 , 600 , 120}, {640 , 480 , 120}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const DWORD DefaultPreferredDisplayMode = 19;
|
|
||||||
@@ -17,7 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LGCommon", "LGCommon", "{AC
|
|||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
LGCommon\CDebug.cpp = LGCommon\CDebug.cpp
|
LGCommon\CDebug.cpp = LGCommon\CDebug.cpp
|
||||||
LGCommon\CDebug.h = LGCommon\CDebug.h
|
LGCommon\CDebug.h = LGCommon\CDebug.h
|
||||||
LGCommon\DefaultDisplayModes.h = LGCommon\DefaultDisplayModes.h
|
|
||||||
LGCommon\PipeMsg.h = LGCommon\PipeMsg.h
|
LGCommon\PipeMsg.h = LGCommon\PipeMsg.h
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "CSettings.h"
|
#include "CSettings.h"
|
||||||
#include "CDebug.h"
|
#include "CDebug.h"
|
||||||
#include "DefaultDisplayModes.h"
|
|
||||||
|
|
||||||
#include <wdf.h>
|
#include <wdf.h>
|
||||||
|
|
||||||
@@ -8,6 +7,22 @@ CSettings g_settings;
|
|||||||
|
|
||||||
#define LGIDD_REGKEY L"SOFTWARE\\LookingGlass\\IDD"
|
#define LGIDD_REGKEY L"SOFTWARE\\LookingGlass\\IDD"
|
||||||
|
|
||||||
|
static const DWORD DefaultDisplayModes[][3] =
|
||||||
|
{
|
||||||
|
{7680, 4800, 120}, {7680, 4320, 120}, {6016, 3384, 120}, {5760, 3600, 120},
|
||||||
|
{5760, 3240, 120}, {5120, 2800, 120}, {4096, 2560, 120}, {4096, 2304, 120},
|
||||||
|
{3840, 2400, 120}, {3840, 2160, 120}, {3200, 2400, 120}, {3200, 1800, 120},
|
||||||
|
{3008, 1692, 120}, {2880, 1800, 120}, {2880, 1620, 120}, {2560, 1600, 120},
|
||||||
|
{2560, 1440, 120}, {1920, 1440, 120}, {1920, 1200, 120}, {1920, 1080, 120},
|
||||||
|
{1600, 1200, 120}, {1600, 1024, 120}, {1600, 1050, 120}, {1600, 900 , 120},
|
||||||
|
{1440, 900 , 120}, {1400, 1050, 120}, {1366, 768 , 120}, {1360, 768 , 120},
|
||||||
|
{1280, 1024, 120}, {1280, 960 , 120}, {1280, 800 , 120}, {1280, 768 , 120},
|
||||||
|
{1280, 720 , 120}, {1280, 600 , 120}, {1152, 864 , 120}, {1024, 768 , 120},
|
||||||
|
{800 , 600 , 120}, {640 , 480 , 120}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const DWORD DefaultPreferredDisplayMode = 19;
|
||||||
|
|
||||||
CSettings::CSettings()
|
CSettings::CSettings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,10 +28,7 @@ CConfigWindow::CConfigWindow() : m_scale(1)
|
|||||||
if (error != ERROR_SUCCESS)
|
if (error != ERROR_SUCCESS)
|
||||||
DEBUG_ERROR_HR(error, "Failed to load settings");
|
DEBUG_ERROR_HR(error, "Failed to load settings");
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_modes = m_settings.getModes();
|
m_modes = m_settings.getModes();
|
||||||
m_defaultRefresh = m_settings.getDefaultRefresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CreateWindowEx(0, MAKEINTATOM(s_atom), L"Looking Glass IDD Configuration",
|
if (!CreateWindowEx(0, MAKEINTATOM(s_atom), L"Looking Glass IDD Configuration",
|
||||||
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 400,
|
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 400,
|
||||||
@@ -106,7 +103,7 @@ LRESULT CConfigWindow::onCreate()
|
|||||||
|
|
||||||
m_modeGroup.reset(new CGroupBox(L"Custom modes", WS_CHILD | WS_VISIBLE, m_hwnd));
|
m_modeGroup.reset(new CGroupBox(L"Custom modes", WS_CHILD | WS_VISIBLE, m_hwnd));
|
||||||
|
|
||||||
m_modeBox.reset(new CListBox(WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP | LBS_NOTIFY, m_hwnd));
|
m_modeBox.reset(new CListBox(WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_NOTIFY, m_hwnd));
|
||||||
if (m_modes)
|
if (m_modes)
|
||||||
updateModeList();
|
updateModeList();
|
||||||
|
|
||||||
@@ -114,25 +111,20 @@ LRESULT CConfigWindow::onCreate()
|
|||||||
m_heightLabel.reset(new CStaticWidget(L"Height:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
m_heightLabel.reset(new CStaticWidget(L"Height:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
||||||
m_refreshLabel.reset(new CStaticWidget(L"Refresh:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
m_refreshLabel.reset(new CStaticWidget(L"Refresh:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
||||||
|
|
||||||
m_modeWidth.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_NUMBER, m_hwnd));
|
m_modeWidth.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd));
|
||||||
m_modeHeight.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_NUMBER, m_hwnd));
|
m_modeHeight.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd));
|
||||||
m_modeRefresh.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_NUMBER, m_hwnd));
|
m_modeRefresh.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd));
|
||||||
|
|
||||||
m_modeUpdate.reset(new CButton(L"Save", WS_CHILD | WS_VISIBLE | WS_TABSTOP, m_hwnd));
|
m_modeUpdate.reset(new CButton(L"Save", WS_CHILD | WS_VISIBLE, m_hwnd));
|
||||||
m_modeDelete.reset(new CButton(L"Delete", WS_CHILD | WS_VISIBLE | WS_TABSTOP, m_hwnd));
|
m_modeDelete.reset(new CButton(L"Delete", WS_CHILD | WS_VISIBLE, m_hwnd));
|
||||||
EnableWindow(*m_modeUpdate, FALSE);
|
EnableWindow(*m_modeUpdate, FALSE);
|
||||||
EnableWindow(*m_modeDelete, FALSE);
|
EnableWindow(*m_modeDelete, FALSE);
|
||||||
|
|
||||||
m_autosizeGroup.reset(new CGroupBox(L"Autosizing", WS_CHILD | WS_VISIBLE, m_hwnd));
|
m_autosizeGroup.reset(new CGroupBox(L"Autosizing", WS_CHILD | WS_VISIBLE, m_hwnd));
|
||||||
m_defRefreshLabel.reset(new CStaticWidget(L"Default refresh:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
m_defRefreshLabel.reset(new CStaticWidget(L"Default refresh:", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
||||||
m_defRefresh.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT | ES_NUMBER | WS_TABSTOP, m_hwnd));
|
m_defRefresh.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT | ES_NUMBER, m_hwnd));
|
||||||
m_defRefreshHz.reset(new CStaticWidget(L"Hz", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
m_defRefreshHz.reset(new CStaticWidget(L"Hz", WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
||||||
|
|
||||||
if (m_defaultRefresh)
|
|
||||||
m_defRefresh->setNumericValue(*m_defaultRefresh);
|
|
||||||
else
|
|
||||||
m_defRefresh->disable();
|
|
||||||
|
|
||||||
RECT client = { 0, 0, (LONG)(436 * m_scale), (LONG)(300 * m_scale) };
|
RECT client = { 0, 0, (LONG)(436 * m_scale), (LONG)(300 * m_scale) };
|
||||||
AdjustWindowRect(&client, WS_OVERLAPPEDWINDOW, FALSE);
|
AdjustWindowRect(&client, WS_OVERLAPPEDWINDOW, FALSE);
|
||||||
SetWindowPos(m_hwnd, NULL, 0, 0, client.right - client.left, client.bottom - client.top, SWP_NOMOVE | SWP_NOZORDER);
|
SetWindowPos(m_hwnd, NULL, 0, 0, client.right - client.left, client.bottom - client.top, SWP_NOMOVE | SWP_NOZORDER);
|
||||||
@@ -228,7 +220,7 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
|||||||
|
|
||||||
LRESULT result = m_settings.setModes(*m_modes);
|
LRESULT result = m_settings.setModes(*m_modes);
|
||||||
if (result != ERROR_SUCCESS)
|
if (result != ERROR_SUCCESS)
|
||||||
DEBUG_ERROR_HR((HRESULT) result, "Failed to save modes");
|
DEBUG_ERROR_HR(result, "Failed to save modes");
|
||||||
}
|
}
|
||||||
else if (hwnd == *m_modeDelete && code == BN_CLICKED && m_modes)
|
else if (hwnd == *m_modeDelete && code == BN_CLICKED && m_modes)
|
||||||
{
|
{
|
||||||
@@ -242,27 +234,10 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
|||||||
|
|
||||||
LRESULT result = m_settings.setModes(*m_modes);
|
LRESULT result = m_settings.setModes(*m_modes);
|
||||||
if (result != ERROR_SUCCESS)
|
if (result != ERROR_SUCCESS)
|
||||||
DEBUG_ERROR_HR((HRESULT) result, "Failed to save modes");
|
DEBUG_ERROR_HR(result, "Failed to save modes");
|
||||||
|
|
||||||
updateModeList();
|
updateModeList();
|
||||||
onModeListSelectChange();
|
onModeListSelectChange();
|
||||||
}
|
}
|
||||||
else if (hwnd == *m_defRefresh && code == EN_CHANGE && m_defaultRefresh)
|
|
||||||
{
|
|
||||||
int value;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
value = m_defRefresh->getNumericValue();
|
|
||||||
}
|
|
||||||
catch (std::logic_error &)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_defaultRefresh = value;
|
|
||||||
LRESULT result = m_settings.setDefaultRefresh(value);
|
|
||||||
if (result != ERROR_SUCCESS)
|
|
||||||
DEBUG_ERROR_HR((HRESULT)result, "Failed to default refresh");
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class CConfigWindow : public CWindow
|
|||||||
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;
|
|
||||||
|
|
||||||
void updateFont();
|
void updateFont();
|
||||||
void updateModeList();
|
void updateModeList();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ std::wstring CEditWidget::getValue()
|
|||||||
{
|
{
|
||||||
std::wstring result;
|
std::wstring result;
|
||||||
result.resize(Edit_GetTextLength(m_hwnd));
|
result.resize(Edit_GetTextLength(m_hwnd));
|
||||||
Edit_GetText(m_hwnd, result.data(), (int) (result.size() + 1));
|
Edit_GetText(m_hwnd, result.data(), result.size() + 1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,11 +24,6 @@ int CEditWidget::getNumericValue()
|
|||||||
return std::stoi(getValue());
|
return std::stoi(getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CEditWidget::enable(bool enabled)
|
|
||||||
{
|
|
||||||
return Edit_Enable(m_hwnd, enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CEditWidget::setValue(const std::wstring &value)
|
void CEditWidget::setValue(const std::wstring &value)
|
||||||
{
|
{
|
||||||
if (!Edit_SetText(m_hwnd, value.c_str()))
|
if (!Edit_SetText(m_hwnd, value.c_str()))
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ public:
|
|||||||
std::wstring getValue();
|
std::wstring getValue();
|
||||||
int getNumericValue();
|
int getNumericValue();
|
||||||
|
|
||||||
bool enable(bool enabled = true);
|
|
||||||
bool disable() { return enable(false); }
|
|
||||||
void setValue(const std::wstring &value);
|
void setValue(const std::wstring &value);
|
||||||
void setNumericValue(int value);
|
void setNumericValue(int value);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ int CListBox::getSel()
|
|||||||
|
|
||||||
int CListBox::getData(int index)
|
int CListBox::getData(int index)
|
||||||
{
|
{
|
||||||
return (int) ListBox_GetItemData(m_hwnd, index);
|
return ListBox_GetItemData(m_hwnd, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CListBox::setSel(int index)
|
void CListBox::setSel(int index)
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ LRESULT CNotifyWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
{
|
{
|
||||||
case WM_NOTIFY_ICON:
|
case WM_NOTIFY_ICON:
|
||||||
return onNotifyIcon(LOWORD(lParam), HIWORD(lParam), GET_X_LPARAM(wParam), GET_Y_LPARAM(wParam));
|
return onNotifyIcon(LOWORD(lParam), HIWORD(lParam), GET_X_LPARAM(wParam), GET_Y_LPARAM(wParam));
|
||||||
|
|
||||||
case WM_CLEAN_UP_CONFIG:
|
case WM_CLEAN_UP_CONFIG:
|
||||||
if (m_config && !m_config->hwnd())
|
if (m_config && !m_config->hwnd())
|
||||||
{
|
{
|
||||||
@@ -59,7 +58,6 @@ LRESULT CNotifyWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
m_config.reset();
|
m_config.reset();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (s_taskbarCreated && uMsg == s_taskbarCreated)
|
if (s_taskbarCreated && uMsg == s_taskbarCreated)
|
||||||
{
|
{
|
||||||
@@ -72,9 +70,6 @@ LRESULT CNotifyWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
LRESULT CNotifyWindow::onCreate()
|
LRESULT CNotifyWindow::onCreate()
|
||||||
{
|
{
|
||||||
// Allow explorer to send us this message to register the notification icon.
|
|
||||||
ChangeWindowMessageFilterEx(m_hwnd, s_taskbarCreated, MSGFLT_ALLOW, NULL);
|
|
||||||
|
|
||||||
registerIcon();
|
registerIcon();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -134,20 +129,12 @@ void CNotifyWindow::registerIcon()
|
|||||||
StringCbCopy(m_iconData.szTip, sizeof m_iconData.szTip, L"Looking Glass (IDD)");
|
StringCbCopy(m_iconData.szTip, sizeof m_iconData.szTip, L"Looking Glass (IDD)");
|
||||||
|
|
||||||
if (!Shell_NotifyIcon(NIM_ADD, &m_iconData))
|
if (!Shell_NotifyIcon(NIM_ADD, &m_iconData))
|
||||||
{
|
|
||||||
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_ADD)");
|
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_ADD)");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Shell_NotifyIcon(NIM_SETVERSION, &m_iconData))
|
if (!Shell_NotifyIcon(NIM_SETVERSION, &m_iconData))
|
||||||
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_SETVERSION)");
|
DEBUG_ERROR_HR(GetLastError(), "Shell_NotifyIcon(NIM_SETVERSION)");
|
||||||
}
|
}
|
||||||
|
|
||||||
HWND CNotifyWindow::hwndDialog()
|
|
||||||
{
|
|
||||||
return m_config ? m_config->hwnd() : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNotifyWindow::close()
|
void CNotifyWindow::close()
|
||||||
{
|
{
|
||||||
closeRequested = true;
|
closeRequested = true;
|
||||||
|
|||||||
@@ -28,6 +28,5 @@ public:
|
|||||||
~CNotifyWindow() override;
|
~CNotifyWindow() override;
|
||||||
static bool registerClass();
|
static bool registerClass();
|
||||||
|
|
||||||
HWND hwndDialog();
|
|
||||||
void close();
|
void close();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,12 +4,8 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <CDebug.h>
|
#include <CDebug.h>
|
||||||
|
|
||||||
#include "DefaultDisplayModes.h"
|
|
||||||
|
|
||||||
#define LGIDD_REGKEY L"SOFTWARE\\LookingGlass\\IDD"
|
#define LGIDD_REGKEY L"SOFTWARE\\LookingGlass\\IDD"
|
||||||
|
|
||||||
const DWORD DEFAULT_REFRESH = 120;
|
|
||||||
|
|
||||||
CRegistrySettings::CRegistrySettings() : hKey(nullptr) {}
|
CRegistrySettings::CRegistrySettings() : hKey(nullptr) {}
|
||||||
|
|
||||||
CRegistrySettings::~CRegistrySettings()
|
CRegistrySettings::~CRegistrySettings()
|
||||||
@@ -64,25 +60,8 @@ std::optional<std::vector<DisplayMode>> CRegistrySettings::getModes()
|
|||||||
|
|
||||||
DWORD type = 0, cb = 0;
|
DWORD type = 0, cb = 0;
|
||||||
status = RegGetValue(hKey, nullptr, L"Modes", RRF_RT_REG_MULTI_SZ, &type, nullptr, &cb);
|
status = RegGetValue(hKey, nullptr, L"Modes", RRF_RT_REG_MULTI_SZ, &type, nullptr, &cb);
|
||||||
switch (status)
|
if (status != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
case ERROR_SUCCESS:
|
|
||||||
break;
|
|
||||||
case ERROR_FILE_NOT_FOUND:
|
|
||||||
{
|
|
||||||
std::vector<DisplayMode> result;
|
|
||||||
for (int i = 0; i < ARRAYSIZE(DefaultDisplayModes); ++i)
|
|
||||||
{
|
|
||||||
DisplayMode mode;
|
|
||||||
mode.width = DefaultDisplayModes[i][0];
|
|
||||||
mode.height = DefaultDisplayModes[i][1];
|
|
||||||
mode.refresh = DefaultDisplayModes[i][2];
|
|
||||||
mode.preferred = i == DefaultPreferredDisplayMode;
|
|
||||||
result.emplace_back(mode);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
DEBUG_ERROR_HR(status, "RegGetValue(Modes) length computation");
|
DEBUG_ERROR_HR(status, "RegGetValue(Modes) length computation");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -138,25 +117,3 @@ std::wstring DisplayMode::toString()
|
|||||||
serialized.push_back('*');
|
serialized.push_back('*');
|
||||||
return serialized;
|
return serialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<DWORD> CRegistrySettings::getDefaultRefresh()
|
|
||||||
{
|
|
||||||
DWORD result, cbData = sizeof result;
|
|
||||||
|
|
||||||
LSTATUS status = RegGetValue(hKey, nullptr, L"DefaultRefresh", RRF_RT_REG_DWORD, nullptr, &result, &cbData);
|
|
||||||
switch (status)
|
|
||||||
{
|
|
||||||
case ERROR_SUCCESS:
|
|
||||||
return result;
|
|
||||||
case ERROR_FILE_NOT_FOUND:
|
|
||||||
return DEFAULT_REFRESH;
|
|
||||||
default:
|
|
||||||
DEBUG_ERROR_HR(status, "RegGetValue(Modes) length computation");
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LSTATUS CRegistrySettings::setDefaultRefresh(DWORD refresh)
|
|
||||||
{
|
|
||||||
return RegSetValueEx(hKey, L"DefaultRefresh", 0, REG_DWORD, (LPBYTE) &refresh, sizeof(DWORD));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -26,7 +26,4 @@ public:
|
|||||||
|
|
||||||
std::optional<std::vector<DisplayMode>> getModes();
|
std::optional<std::vector<DisplayMode>> getModes();
|
||||||
LSTATUS setModes(const std::vector<DisplayMode> &modes);
|
LSTATUS setModes(const std::vector<DisplayMode> &modes);
|
||||||
|
|
||||||
std::optional<DWORD> getDefaultRefresh();
|
|
||||||
LSTATUS setDefaultRefresh(DWORD refresh);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -105,12 +105,8 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _
|
|||||||
MSG msg;
|
MSG msg;
|
||||||
while (GetMessage(&msg, NULL, 0, 0) > 0)
|
while (GetMessage(&msg, NULL, 0, 0) > 0)
|
||||||
{
|
{
|
||||||
HWND hDlg = window.hwndDialog();
|
TranslateMessage(&msg);
|
||||||
if (!hDlg || !IsDialogMessage(hDlg, &msg))
|
DispatchMessage(&msg);
|
||||||
{
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) UnregisterWait(hWait);
|
(void) UnregisterWait(hWait);
|
||||||
|
|||||||
Reference in New Issue
Block a user