Repository navigation
[Windows] Normalize Shift key messages with a non-standard scan code - #193675
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
2cd6fad to
629162c
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a NormalizeShiftLParam helper function in the Windows keyboard manager to normalize the scan code and clear the extended bit of Shift key messages. This ensures that Shift key events originating from sources like IMEs or input injection resolve to standard physical keys and are correctly released. Corresponding unit tests have been added to verify this behavior. There are no review comments to evaluate, and no additional feedback is provided.
mattkae
left a comment
There was a problem hiding this comment.
Good by me, thanks! @loic-sharma can you ack too?
|
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
629162c to
94b0e16
Compare
loic-sharma
left a comment
There was a problem hiding this comment.
This fix looks good to me, but I left a comment on the behavior if Flutter ignores the key event and we redispatch the message.
|
auto label is removed for flutter/flutter/193675, Failed to enqueue flutter/flutter/193675 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected.. |
|
auto label is removed for flutter/flutter/193675, Failed to enqueue flutter/flutter/193675 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected.. |
|
auto label is removed for flutter/flutter/193675, Failed to enqueue flutter/flutter/193675 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected.. |
|
auto label is removed for flutter/flutter/193675, Failed to enqueue flutter/flutter/193675 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected.. |
|
I can't get the code freeze check to pass. I'll try rebasing... |
A VK_SHIFT key message with the extended bit set or with a zero scan code resolved to a non-standard physical key (windowsPlane | scancode). A regular key up for the standard physical key then had no record and was dropped, and the modifier synchronization (MK_SHIFT on mouse moves, GetKeyState on key events) only checks the standard ShiftLeft and ShiftRight records, so Shift stayed pressed in the framework indefinitely. Rewrite Shift key messages to the standard ShiftLeft or ShiftRight scan code with the extended bit cleared before resolving them. Fixes flutter#181907
Use the normalized Shift scan code for Flutter key events while retaining the original lParam in the native message session for unhandled-event redispatch. Add regression coverage for extended-bit and zero-scan-code Shift down/up messages, checking both canonical Flutter events and unchanged native message fields. Correct the existing CtrlLeftUnhandled fixture to use VK_CONTROL for its release message.
83afd20 to
6333a72
Compare
|
auto label is removed for flutter/flutter/193675, Failed to enqueue flutter/flutter/193675 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected.. |
|
auto label is removed for flutter/flutter/193675, Failed to enqueue flutter/flutter/193675 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected.. |
|
auto label is removed for flutter/flutter/193675, Failed to enqueue flutter/flutter/193675 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected.. |
flutter/flutter@d8bd864...2f09f96 2026-11-17 [email protected] Analyze every flutter create template, and fix the package_ffi lint (flutter/flutter#196165) 2026-11-17 [email protected] Roll Dart SDK from 50debf3c9757 to 26e38955d9d4 (3 revisions) (flutter/flutter#196772) 2026-11-17 [email protected] Manual roll ICU from b09986242cfb to d3c612f44146 (1 revision) (flutter/flutter#196713) 2026-11-17 [email protected] Roll Skia from 4f6b3a8d8565 to 503a380ebecc (19 revisions) (flutter/flutter#196768) 2026-11-17 [email protected] iOS: Don't mock UIView animations in keyboard spring animation test (flutter/flutter#196755) 2026-11-17 [email protected] [flutter_tools] Preserve index.html across --web-content-hash transitions (flutter/flutter#196491) 2026-11-17 [email protected] Fix TextStyle background color fade-out when lerping to null (flutter/flutter#196153) 2026-11-17 [email protected] Update desktop engine TESTOWNERS (flutter/flutter#196732) 2026-11-17 [email protected] [flutter_tools] Do not copy app-only build type properties onto library plugins (flutter/flutter#196692) 2026-11-17 [email protected] [flutter_tools] Remove service and runner ambient context getters (flutter/flutter#196571) 2026-11-17 [email protected] Bump customer tests (flutter/flutter#196740) 2026-11-17 [email protected] Take customer_testing_flame out of bringup (flutter/flutter#196570) 2026-11-17 [email protected] [devicelab] Read AssetManifest.bin from the APK in flavors_test (flutter/flutter#196736) 2026-11-17 [email protected] [flutter_tools] Fix flaky tool_tests_general by moving spawnUri tests to integration shard (flutter/flutter#195999) 2026-11-17 [email protected] Roll Dart SDK from 3e069c6fdbde to 50debf3c9757 (2 revisions) (flutter/flutter#196706) 2026-11-16 [email protected] [web] Record build finish synchronously in renderScene and fix dropped frame timings (flutter/flutter#195947) 2026-11-16 [email protected] Do not reveal obscured character when input is rejected by inputFormatters (flutter/flutter#195022) 2026-11-16 [email protected] Cla draft follow up: add waiting for response (flutter/flutter#196686) 2026-11-16 [email protected] Roll pub packages (flutter/flutter#196684) 2026-11-16 [email protected] Roll Packages from 015df97 to 4c6a7d3 (8 revisions) (flutter/flutter#196681) 2026-11-16 [email protected] Skip Vulkan impeller_unittests on macOS (flutter/flutter#196282) 2026-11-16 [email protected] Move the task runners out of Flutter Engine (flutter/flutter#196267) 2026-11-16 [email protected] [FGP] Add Flutter assets after AGP's asset merge so dotfiles are pack… (flutter/flutter#196465) 2026-11-16 [email protected] iOS: Add Obj-C model for platform view composition params (flutter/flutter#196498) 2026-11-16 [email protected] [Windows] Normalize Shift key messages with a non-standard scan code (flutter/flutter#193675) 2026-11-16 [email protected] Roll Skia from 118eaff3deb4 to 4f6b3a8d8565 (3 revisions) (flutter/flutter#196672) 2026-11-16 [email protected] Roll Dart SDK from c91e8b6674e2 to 3e069c6fdbde (4 revisions) (flutter/flutter#196669) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
On Windows, a
VK_SHIFTkey message with the extended bit set or with a zero scan code makes Shift stay pressed in the framework indefinitely. This PR fixes that.KeyboardKeyEmbedderHandler::GetPhysicalKeylooks upscancode | (extended ? 0xE000 : 0)and falls back towindowsPlane | scancode, so such a message is recorded under a non-standard physical key (0x1600000036,0x1600000000) with a Shift logical key. After that:SyncModifiersIfNeeded(MK_SHIFTonWM_MOUSEMOVE) andSynchronizeCriticalPressedStates(GetKeyState(VK_LSHIFT/VK_RSHIFT)) only check the standard ShiftLeft/ShiftRight records, so they never release it;ResolveKeyCodealso returnsMapVirtualKey(0, MAPVK_VSC_TO_VK_EX) == 0.User-visible effects: every click in a
SelectionArea/TextFieldextends the selection, Tab moves focus backwards, and the mouse wheel scrolls horizontally.The fix rewrites Shift key messages in
KeyboardManager::HandleMessageto the standard ShiftLeft (0x2a) or ShiftRight (0x36) scan code with the extended bit cleared, before anything else reads them. Messages that already have a standard scan code are left unchanged. If a zero scan code is mapped to the wrong side, the existingGetKeyStatesynchronization corrects the state on the next key event.Testing:
ShiftRightWithExtendedBitIsReleasedByRegularKeyUpandShiftWithZeroScanCodeIsReleasedByRegularKeyUpinkeyboard_unittests.cc.PostMessageof an extended/zero-scancode Shift down followed by a regular up and a mouse move leavesHardwareKeyboard.isShiftPressed == true. With it, Shift is released. RealSendInputinput (left/right Shift, Shift + gray arrows, Shift + numpad with NumLock, injected scancode 0 / extended) behaves the same with and without it. Repro details: [Windows] Shift key randomly gets stuck in a "pressed down" state forever when using TextFields #181907 (comment)Fixes #181907
Pre-launch Checklist
///).