-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Alt-Numpad handling #17637
Conversation
This comment has been minimized.
This comment has been minimized.
if (vkey == VK_MENU && !down) | ||
{ | ||
// Manually generate an Alt KeyUp event into the key bindings or terminal. | ||
// This is required as part of GH#6421. | ||
(void)_TrySendKeyEvent(VK_MENU, scanCode, modifiers, false); | ||
handled = true; | ||
} | ||
else if ((vkey == VK_F7 || vkey == VK_SPACE) && down) | ||
{ | ||
// Manually generate an F7 event into the key bindings or terminal. | ||
// This is required as part of GH#638. | ||
// Or do so for alt+space; only send to terminal when explicitly unbound | ||
// That is part of #GH7125 | ||
auto bindings{ _core.Settings().KeyBindings() }; | ||
auto isUnbound = false; | ||
const KeyChord kc = { | ||
modifiers.IsCtrlPressed(), | ||
modifiers.IsAltPressed(), | ||
modifiers.IsShiftPressed(), | ||
modifiers.IsWinPressed(), | ||
gsl::narrow_cast<WORD>(vkey), | ||
0 | ||
}; | ||
|
||
if (bindings) | ||
{ | ||
handled = bindings.TryKeyChord(kc); | ||
|
||
if (!handled) | ||
{ | ||
isUnbound = bindings.IsKeyChordExplicitlyUnbound(kc); | ||
} | ||
} | ||
|
||
const auto sendToTerminal = vkey == VK_F7 || (vkey == VK_SPACE && isUnbound); | ||
|
||
if (!handled && sendToTerminal) | ||
{ | ||
// _TrySendKeyEvent pretends it didn't handle F7 for some unknown reason. | ||
(void)_TrySendKeyEvent(gsl::narrow_cast<WORD>(vkey), scanCode, modifiers, true); | ||
// GH#6438: Note that we're _not_ sending the key up here - that'll | ||
// get passed through XAML to our KeyUp handler normally. | ||
handled = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming these just got subsumed into the key handler, and none of this special logic to ensure the following keys work is needed?
- release alt -> send key to app (win32IM)
- F7/Space pressed -> activate key bindings, or send to terminal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a glance it looked like all of that code is covered by our generic key handling already.
Alt key up? That's a fall-through to _TrySendKeyEvent
anyway already. ✅
Alt+Space? We do a keybinding lookup, it fails, it falls through to _TrySendKeyEvent
. ✅
F7? We do a keybinding lookup, it fails, it falls through to _TrySendKeyEvent
. ✅
Seems good to me. In my testing it was.
codepage = ansi ? 1252 : 437; | ||
} | ||
|
||
// The OS code seemed to also simply cut off the last byte in the accumulator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raymond Chen documented this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was 🤏 this close to just scrapping the entire weird ACP/OEM support. It's not supported in any application that uses CP_UTF8 as its ACP anyway, so I'm not sure if there's any point for us to support it either.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
This adds an indirection for `_KeyHandler` so that `OnDirectKeyEvent` can call `_KeyHandler`. This allows us to consistently handle Alt-key-up events. Then I added custom handling for Alt+ddd (OEM), Alt+0ddd (ANSI), and Alt+'+'+xxxx (Unicode) sequences, due to the absence of Alt-key events with xaml islands and our TSF control. Closes #17327 ## Validation Steps Performed * Tested it according to https://conemu.github.io/en/AltNumpad.html * Unbind Alt+Space * Run `showkey -a` * Alt+Space generates `^[ ` * F7 generates `^[[18~` (cherry picked from commit 2fab986) Service-Card-Id: PVTI_lADOAF3p4s4AmhmszgSCpCg Service-Version: 1.21
This adds an indirection for
_KeyHandler
so thatOnDirectKeyEvent
can call
_KeyHandler
. This allows us to consistently handleAlt-key-up events. Then I added custom handling for Alt+ddd (OEM),
Alt+0ddd (ANSI), and Alt+'+'+xxxx (Unicode) sequences, due to the
absence of Alt-key events with xaml islands and our TSF control.
Closes #17327
Validation Steps Performed
showkey -a
^[
^[[18~