Fix alt+space opening system menu and sending keys to terminal (#10988)

If both of the following are true

1. alt+space is not explicitly unbound
2. alt+space is not bound to a command

Then the window procedure will handle the alt+space to open up the context menu.
In this case, we need to make sure we don't send the keys to terminal.

Closes #10935
This commit is contained in:
PankajBhojwani 2021-08-24 07:07:45 -07:00 committed by GitHub
parent c53fe1c2bf
commit b1131263cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -900,6 +900,24 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return;
}
if (vkey == VK_SPACE && modifiers.IsAltPressed())
{
if (const auto bindings = _settings.KeyBindings())
{
if (!bindings.IsKeyChordExplicitlyUnbound({ modifiers.IsCtrlPressed(), modifiers.IsAltPressed(), modifiers.IsShiftPressed(), modifiers.IsWinPressed(), vkey, scanCode }))
{
// If we get here, it means that
// 1. we do not have a command bound to alt+space
// 2. alt+space was not explicitly unbound
// That means that XAML handled the alt+space to open up the context menu, and
// so we don't want to send anything to the terminal
// TODO GH#11018: Add a new "openSystemMenu" keybinding
e.Handled(true);
return;
}
}
}
if (_TrySendKeyEvent(vkey, scanCode, modifiers, keyDown))
{
e.Handled(true);