commit 3d5e983c41a0a650c906a122b111cd5803a6e927
parent e242af0af55078242b4ee6616b500334188587a9
Author: Greg Stoll <gstoll@mozilla.com>
Date: Thu, 30 Oct 2025 13:14:43 +0000
Bug 1995165 - support new Windows shortcuts to type em and en dashes r=win-reviewers,handyman
Windows 11 25H2 adds new shortcuts to type em and en dashes (Win+Shift+Minus
and Win+Minus respectively), and these weren't working in Firefox.
The problem was that our keyboard code wasn't expecting the Windows
key (also interpreted as the Meta key) to be a modifier that could
result in a keystroke. Adding these cases means everything works as
expected.
I tested this in the URL bar, on a page with an <input> and a <textarea>,
and with a sample page that showed keyup/down/press events, and everything
looked as I expected. I also ran a try build that didn't show anything
concerning: https://treeherder.mozilla.org/jobs?repo=try&revision=e31ce53cb3738e42b06c5ab6c8d1a2c8e80a0a6b
I don't think there's a way we can add a test for this.
Differential Revision: https://phabricator.services.mozilla.com/D270531
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp
@@ -1601,7 +1601,7 @@ void NativeKey::InitWithKeyOrChar() {
this, ToString(charMsg).get()));
NS_WARNING_ASSERTION(
charMsg.hwnd == mMsg.hwnd,
- "The retrieved char message was targeted to differnet window");
+ "The retrieved char message was targeted to different window");
mFollowingCharMsgs.AppendElement(charMsg);
}
if (mFollowingCharMsgs.Length() == 1) {
@@ -3482,8 +3482,8 @@ void NativeKey::ComputeInputtingStringWithKeyboardLayout() {
mUnshiftedString.Clear();
mShiftedLatinChar = mUnshiftedLatinChar = 0;
- // XXX How about when Win key is pressed?
- if (!mModKeyState.IsControl() && !mModKeyState.IsAlt()) {
+ if (!mModKeyState.IsControl() && !mModKeyState.IsAlt() &&
+ !mModKeyState.IsWin()) {
return;
}
@@ -3592,8 +3592,8 @@ bool NativeKey::DispatchKeyPressEventsWithRetrievedCharMessages() const {
ModifierKeyState modKeyState(mModKeyState);
if (mCanIgnoreModifierStateAtKeyPress && IsFollowedByPrintableCharMessage()) {
// If eKeyPress event should cause inputting text in focused editor,
- // we need to remove Alt and Ctrl state.
- modKeyState.Unset(MODIFIER_ALT | MODIFIER_CONTROL);
+ // we need to remove Alt and Ctrl and Meta state.
+ modKeyState.Unset(MODIFIER_ALT | MODIFIER_CONTROL | MODIFIER_META);
}
// We don't need to send char message here if there are two or more retrieved
// messages because we need to set each message to each eKeyPress event.