Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@knopp
Copy link
Member

@knopp knopp commented Jun 30, 2021

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

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard
Copy link

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.

Copy link
Contributor

@dkwingsmt dkwingsmt left a 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).

Comment on lines 374 to 375
// 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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.

Copy link
Contributor

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.

@knopp
Copy link
Member Author

knopp commented Jul 6, 2021

@dkwingsmt, thank you for the feeddback. Can you re-review the PR?

@knopp knopp force-pushed the win_ctrl_number branch from eb49595 to 167dbb3 Compare July 6, 2021 20:17
@knopp knopp removed the needs tests label Jul 6, 2021
// 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);
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@knopp knopp added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jul 6, 2021
@fluttergithubbot fluttergithubbot merged commit b63d6e2 into flutter:master Jul 7, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 7, 2021
keycode_for_char_message_ = wparam;
break;
}
character = 0;
Copy link
Contributor

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?

Copy link
Member Author

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.

@tomm1e
Copy link

tomm1e commented Jul 10, 2021

Pressing CTRL once will make all input produce twice, pressing CTRL again will restore normal input.

input

It even persists if you close the app. Press CTRL once to activate, close the executable, launch it again, its still producing twice.

@knopp
Copy link
Member Author

knopp commented Jul 10, 2021

I can reproduce this. Not sure how I missed this but apparently on Windows all modifiers key can have the toggle bit set. From GetKeyState documentation I assumed this only applies to toggle-able keys such as CapsLock, but apparently not. I'll submit PR for this shortly.

naudzghebre pushed a commit to naudzghebre/engine that referenced this pull request Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-windows waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: CTRL + Number doesn't produce KeyDown event

5 participants