Unfocusing a window does not clear `ButtonInput<Key>`
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Read bevy_winit/system.rs and bevy_input/src/keyboard.rs, starting at check_keyboard_focus_lost and keyboard_input_system; compare the behavior with related issue #25041. Verify that losing window focus clears all cached ButtonInput state, including Alt, after the unusual key-release sequence described.
Written by the indexing model from the issue text.
Description
Bevy version and features
0.19.0, 0.19.1, main
[Optional] Relevant system information
Linux (with "Switching to another layout > Both Alts together" set)
What you did
- Press & Release
Alt- Because of legacy linux keyboard layout swap hotkey weirdness, with the above setting,
Key::GroupPreviousis released instead ofKey::Alt.
- Because of legacy linux keyboard layout swap hotkey weirdness, with the above setting,
- Click away from the
bevywindowbevyshould now clear all keyboard state, but it missesKey::AltbecauseKeyCode::Altwas already released
What went wrong
Bevy should clear its Key states when it loses keyboard focus, but it does not.
Additional information
check_keyboard_focus_lost in bevy_winit/system.rs should normally clear Key::Alt. It does not do so because KeyCode::Alt was already cleared by the normal key up event.
keyboard_input_system in bevy_input/src/keyboard.rs should also have caught this, but key_input.release_all() is missing:
// Release all cached input to avoid having stuck input when switching between windows in os
if !keyboard_focus_lost_reader.is_empty() {
keycode_input.release_all();
keyboard_focus_lost_reader.clear();
}
I believe this issue is strongly related to #25041.
- Dominant language
- Rust
- Stars
- 48.3k
- Forks
- 4.9k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 172
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bevyengine/bevy
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
C-Docs D-Straightforward
Difficulty 1/5 Under an hour Newbie friendliness 78/100
bevyengine/bevy#25850 ·
-
A-Dev-Tools C-Bug D-Modest
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
bevyengine/bevy#25849 ·
-
A-Assets A-Text C-Feature D-Modest S-Needs-Design
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
bevyengine/bevy#25842 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bevyengine/bevy#25788 ·
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100