From 7967e1740cd5b001c6aadbe2a4ce66d4e9cd8907 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Tue, 25 Aug 2020 20:04:23 +0200 Subject: [PATCH] Fixed #7372: Setting "altGrAliasing" to "false" disables AltGr (#7400) ## Summary of the Pull Request Previously, if `altGrAliasing` was disabled, all `Ctrl+Alt` combinations were considered to be aliases of `AltGr` including `AltGr` itself and thus considered as key and not character events. But `AltGr` should not be treated as an alias of itself of course, as that prevents one from entering `AltGr` combinations entirely. ## PR Checklist * [x] Closes #7372 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx ## Validation Steps Performed * Activate a German keyboard layout * Run `showkey -a` in WSL * **Ensure** that `AltGr+Q` produces `@` * **Ensure** that `Ctrl+Alt+Q` produces `@` * Disable `altGrAliasing` * **Ensure** that `AltGr+Q` produces `@` * **Ensure** that `Ctrl+Alt+Q` produces `^[^Q` (cherry picked from commit ac310d98b7d2d101eac624976721558a221dd4d5) --- src/cascadia/TerminalCore/Terminal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp index f6b3950a262..55d238d401b 100644 --- a/src/cascadia/TerminalCore/Terminal.cpp +++ b/src/cascadia/TerminalCore/Terminal.cpp @@ -457,7 +457,6 @@ bool Terminal::SendKeyEvent(const WORD vkey, } const auto isAltOnlyPressed = states.IsAltPressed() && !states.IsCtrlPressed(); - const auto isSuppressedAltGrAlias = !_altGrAliasing && states.IsAltPressed() && states.IsCtrlPressed(); // DON'T manually handle Alt+Space - the system will use this to bring up // the system menu for restore, min/maximize, size, move, close. @@ -477,6 +476,7 @@ bool Terminal::SendKeyEvent(const WORD vkey, // as TerminalInput::HandleKey will then fall back to using the vkey which // is the underlying ASCII character (e.g. A-Z) on the keyboard in our case. // See GH#5525/GH#6211 for more details + const auto isSuppressedAltGrAlias = !_altGrAliasing && states.IsAltPressed() && states.IsCtrlPressed() && !states.IsAltGrPressed(); const auto ch = isSuppressedAltGrAlias ? UNICODE_NULL : _CharacterFromKeyEvent(vkey, scanCode, states); // Delegate it to the character event handler if this key event can be