mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-17 15:36:35 +00:00
Fixed SetTerminalInputKeyboardLayout
This commit is contained in:
1
.github/actions/spelling/expect/expect.txt
vendored
1
.github/actions/spelling/expect/expect.txt
vendored
@@ -28,7 +28,6 @@ ALIGNRIGHT
|
||||
allocing
|
||||
alpc
|
||||
ALTERNATENAME
|
||||
alternatename
|
||||
ALTF
|
||||
ALTGR
|
||||
ALTNUMPAD
|
||||
|
||||
@@ -94,6 +94,11 @@ LayoutGuard& LayoutGuard::operator=(LayoutGuard&& other) noexcept
|
||||
return *this;
|
||||
}
|
||||
|
||||
LayoutGuard::operator bool() const noexcept
|
||||
{
|
||||
return _layout != nullptr;
|
||||
}
|
||||
|
||||
LayoutGuard::operator HKL() const noexcept
|
||||
{
|
||||
return _layout;
|
||||
@@ -103,6 +108,15 @@ LayoutGuard TestHook::SetTerminalInputKeyboardLayout(const wchar_t* klid)
|
||||
{
|
||||
THROW_HR_IF_MSG(E_UNEXPECTED, g_keyboardLayout != nullptr, "Nested layout test overrides are not supported");
|
||||
|
||||
// Check if the layout is installed. LoadKeyboardLayoutW silently returns the
|
||||
// current active layout if the requested one is missing.
|
||||
const auto keyPath = fmt::format(FMT_COMPILE(L"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\{}"), klid);
|
||||
wil::unique_hkey key;
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyPath.c_str(), 0, KEY_READ, key.addressof()) != ERROR_SUCCESS)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto layout = LoadKeyboardLayoutW(klid, KLF_NOTELLSHELL);
|
||||
THROW_LAST_ERROR_IF_NULL(layout);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace TestHook
|
||||
LayoutGuard(LayoutGuard&& other) noexcept;
|
||||
LayoutGuard& operator=(LayoutGuard&& other) noexcept;
|
||||
|
||||
explicit operator bool() const noexcept;
|
||||
operator HKL() const noexcept;
|
||||
|
||||
private:
|
||||
|
||||
@@ -628,12 +628,8 @@ void InputTest::TerminalInputNullKeyTests()
|
||||
{
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
TestHook::LayoutGuard layout;
|
||||
try
|
||||
{
|
||||
layout = TestHook::SetTerminalInputKeyboardLayout(L"00000409"); // US English
|
||||
}
|
||||
catch (...)
|
||||
auto layout = TestHook::SetTerminalInputKeyboardLayout(L"00000409"); // US English
|
||||
if (!layout)
|
||||
{
|
||||
Log::Result(TestResults::Result::Skipped);
|
||||
return;
|
||||
|
||||
@@ -258,11 +258,8 @@ class KittyKeyboardProtocolTests
|
||||
|
||||
TEST_CLASS_SETUP(ClassSetup)
|
||||
{
|
||||
try
|
||||
{
|
||||
layout = TestHook::SetTerminalInputKeyboardLayout(L"0001040c"); // French (Standard, AZERTY)
|
||||
}
|
||||
catch (...)
|
||||
layout = TestHook::SetTerminalInputKeyboardLayout(L"0001040c"); // French (Standard, AZERTY)
|
||||
if (!layout)
|
||||
{
|
||||
Log::Result(TestResults::Result::Skipped);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user