Fix cursor being hidden when pressing modifier keys (#19473)

Closes #19445
This commit is contained in:
Anastasia Smigaliova
2025-10-21 16:03:59 +03:00
committed by GitHub
parent b8f35a31c2
commit b357de9897

View File

@@ -194,6 +194,22 @@ static wil::unique_mutex acquireMutexOrAttemptHandoff(const wchar_t* className,
return {};
}
static constexpr bool IsInputKey(WORD vkey) noexcept
{
return vkey != VK_CONTROL &&
vkey != VK_LCONTROL &&
vkey != VK_RCONTROL &&
vkey != VK_MENU &&
vkey != VK_LMENU &&
vkey != VK_RMENU &&
vkey != VK_SHIFT &&
vkey != VK_LSHIFT &&
vkey != VK_RSHIFT &&
vkey != VK_LWIN &&
vkey != VK_RWIN &&
vkey != VK_SNAPSHOT;
}
HWND WindowEmperor::GetMainWindow() const noexcept
{
_assertIsMainThread();
@@ -485,10 +501,16 @@ void WindowEmperor::HandleCommandlineArgs(int nCmdShow)
}
if (msg.message == WM_KEYDOWN)
{
const auto vkey = static_cast<WORD>(msg.wParam);
// Hide the cursor only when the key pressed is an input key (ignore modifier keys).
if (IsInputKey(vkey))
{
IslandWindow::HideCursor();
}
}
}
if (IslandWindow::IsCursorHidden())
{