-
Notifications
You must be signed in to change notification settings - Fork 891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS: Only check is_repeat to send ReceivedCharacter. Fixes #1488 #1489
macOS: Only check is_repeat to send ReceivedCharacter. Fixes #1488 #1489
Conversation
Oh super interesting! This is fixed as well with the proposed pull request #1449. Maybe they should be merged? |
Yes, I also merged master 38fcceb into #1449 and built alacritty with it. It solves the alacritty key repeat issue alacritty/alacritty#2788 that this pull request (#1489) was created to solve, but #1449 does it in a better way. #1449 would also resolve issue #1488. This pull request (#1489) should be closed in lieu of #1449. |
Well, it's been a while, Alacritty still has the key repetition bug that would be fixed by this pull-request. This pull-request would've been superseded by #1449 but alas that has yet to be ironed out. I think this should be reconsidered. |
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.
Hi @jayache80! You are right, this PR should be merged as the other one is stuck currently. However there are two things:
- Considering that state.is_key_down was only used for this purpse, please remove it's declaration from
ViewState
and all other places it shows up. - Given that it's not at all obvious why it is okay to remove this condition, please add the following explanation to the commit message:
`is_key_down` was only set to true when `insertText` was called. Therefore
`is_keydown` actually meant to store whether the most recently pressed key
generated an `insertText` event, at which, winit produces a `ReceivedCharacter`.
The issue is that `insertText` is *not* called for “key repeat”, but winit wants
to send `ReceivedCharacter` events for “key repeat” too. To solve this, the
`is_key_down` variable was then checked in the `key_down` function to determine
whether it was valid to produce repeated `ReceivedCharacter` events during “key
repeat”. However this check is not needed since `ReceivedCharacter` must always
be called if the key event has a non-empty `characters` property.
Furthermore `is_key_down` didn’t actually store whether the previously pressed
character had an `insertText` event, because it was incorrectly set to false on
every “key up”. This meant that if two keys were pressed consecutively then the
first was released, then `is_key_down` was set to false even if the most recent
keypress did actually produce an `insertText`.
13764bb
to
f6ad9d7
Compare
@ArturKovacs I've rebased the branch off latest master and ripped out |
Awesome! I forgot one thing last time: please add an entry to
|
f6ad9d7
to
86cc66f
Compare
Fixes rust-windowing#1488. `is_key_down` was only set to true when `insertText` was called. Therefore `is_key_down` was actually meant to store whether the most recently pressed key generated an `insertText` event, at which, winit produces a `ReceivedCharacter`. The issue is that `insertText` is *not* called for "key repeat", but winit wants to send `ReceivedCharacter` events for "key repeat" too. To solve this, the `is_key_down` variable was then checked in the `key_down` function to determine whether it was valid to produce repeated `ReceivedCharacter` events during "key repeat". However this check is not needed since `ReceivedCharacter` must always be called if the key event has a non-empty `characters` property. Furthermore `is_key_down` didn't actually store whether the previously pressed character had an `insertText` event, because it was incorrectly set to false on every "key up". This meant that if two keys were pressed consecutively and then the first was released, then `is_key_down` was set to false even if the most recent keypress did actually produce an `insertText`. Update changelog.
Added an entry to the changelog (amended to the commit). Is the title of this pull-request still appropriate, or should I edit the title? |
It is somewhat obscure but I'm not sure how it could be improved, so I'll leave this up to you |
Checking state.is_key_down is redundant, since we are handling keyDown.
Moreover, state.is_key_down can be affected by a previous repeated key's
keyUp.
cargo fmt
has been run on this branchcargo doc
builds successfullyCHANGELOG.md
if knowledge of this change could be valuable to users