-
Notifications
You must be signed in to change notification settings - Fork 6k
[Win32, Keyboard] Store keyboard message session #31047
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. |
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.
|
|
||
| struct PendingEvent { | ||
| uint32_t key; | ||
| uint16_t key; |
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.
Could you use the Windows type here (i.e. SHORT), and for the others that are derived from Windows struct values?
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.
At some point we have to convert the Win32 types to fixed-width types. My idea here is that, the members of Win32Message preserve the original value, since they are to be redispatched, while the members of PendingEvent should be fixed-width values, since they are processed values and will be send to OnKey of the platform-independent FlutterWindowsView.
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 agree that the change here (or many of the numerical types) is debatable. WPARAM is technically uint64 nowadays in a 64-bit system, but the API dated back to the 32-bit era, and practically the virtual code never exceeds 16 bit.
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.
Sure, and I'm sure that practically it makes no difference, but from a correctness standpoint it would be better to use the system defined types instead of making the (yes, perfectly valid) assumptions about the sizes of the types.
I'm OK with making the assumptions, though, if you think that the documentation value of showing the type sizes is important enough to trump the correctness.
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 might be sufficient to have a compile-time static_assert that sizeof(SHORT) == sizeof(uint16_t).
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've replaced the types of key and action to win32 types since they directly come from win32 values. Others are extracted from lparam and have explicitly defined width, so I'm keeping their types.

This PR creates a new concept called "session", which consists of a list of messages (typically 1 to 3) that should be processed together, such as a key down message followed by char messages. The messages of the session are now stored (instead of separate char code or key code) until the end of the session, and are passed along with
PendingEvent. This replaces some arbitrary members or static variable with a more meaningful member, and allows redispatching messages in a better way in the future.This PR also clears up the logic of
HandleMessageand adds a few comments.This PR should not need new tests since it's only a refactor.
This is one of the many steps to refactor the windows keyboard system.
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.