-
Notifications
You must be signed in to change notification settings - Fork 6k
Do not expect WM_CHAR if control or windows key is pressed #27064
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
dkwingsmt
left a comment
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.
The change looks legit. Can you add some tests? See window_win32_unittests.cc for guidance. (Using recorded event information from manual tests would be the best).
| // As an exception with control or windows key pressed WM_CHAR may not | ||
| // come even though the event produced a character (i.e. CTRL + number). |
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.
| // As an exception with control or windows key pressed WM_CHAR may not | |
| // come even though the event produced a character (i.e. CTRL + number). | |
| // | |
| // Messages with Control or Win modifiers down are never considered as character | |
| // messages. This allows key combinations such as "CTRL + Digit" to properly | |
| // produce key down events even though `MapVirtualKey` returns a valid character. | |
| // See https://github.com/flutter/flutter/issues/85587. |
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.
Also might be better to force character to be 0 when GetKeyState(VK_CONTROL) == 0 && GetKeyState(VK_LWIN) == 0 && GetKeyState(VK_RWIN) == 0 for clarity.
|
@dkwingsmt, thank you for the feeddback. Can you re-review the PR? |
| // Expect OnKey, but not OnText, because Control + Key is not followed by | ||
| // WM_CHAR | ||
| EXPECT_CALL(window, OnKey(65, 30, WM_KEYDOWN, 0, false, true)).Times(1); | ||
| EXPECT_CALL(window, OnText(_)).Times(0); |
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.
Can you check if this test fails without the change? As far as I remember, EXPECT_CALL.Times only checks if this many calls have been called, but not extra calls.
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 not sure I understand. Without what change? This is a compltely new test. It should result in OnKey called once, and no OnText call.
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.
Without your fix to window_win32.cc. Basically, whether this test fails on master.
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.
Yes, the test fails because OnKey is not invoked on the mock without the change. It waits for WM_CHAR, which never comes.
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.
Got it. Thanks for confirming.
dkwingsmt
left a comment
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.
LGTM
| keycode_for_char_message_ = wparam; | ||
| break; | ||
| } | ||
| character = 0; |
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.
What is this line for?
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.
It was suggested here (for clarity), but somehow ended up in the wrong block :-/. Since it doesn't do anything anyway I'll make another PR to remove it.
|
I can reproduce this. Not sure how I missed this but apparently on Windows all modifiers key can have the toggle bit set. From |

Fixes flutter/flutter#85587
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.