Skip to content
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

Fix phantom key presses in winit on focus change (#13299) #13696

Merged
merged 3 commits into from
Jun 17, 2024

Commits on Jun 5, 2024

  1. Fix phantom key presses in winit on focus change (bevyengine#13299)

    On Linux/X11, changing focus into a winit window will produce winit
    KeyboardInput events with a "is_synthetic=true" flag that are not
    intended to be used. Bevy erroneously passes them on to the user,
    resulting in phantom key presses.
    
    This patch properly filters them out.
    
    For example, pressing Alt+Tab to focus a bevy winit window results in a
    permanently stuck Tab key until the user presses Tab once again to
    produce a winit KeyboardInput release event.
    
    The Tab key press event that causes this problem is "synthetic", should
    not be used according to the winit devs, and simply ignoring it fixes
    this problem.
    
    Reference: https://docs.rs/winit/0.30.0/winit/event/enum.WindowEvent.html#variant.KeyboardInput.field.is_synthetic
    Relevant discussion: rust-windowing/winit#3543
    
    Synthetic key **releases** are still evaluated though, as they are
    essential for correct release key handling. For example, if the user
    binds the key combination Alt+1 to the action "move the window to
    workspace 1", places the bevy game in workspace 2, focuses the game and
    presses Alt+1, then the key release event for the "1" key will be
    synthetic. If we would filter out all synthetic keys, the bevy game
    would think that the 1 key remains pressed forever, until the user
    manually presses+releases the key again inside bevy.
    hut committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    dd5103e View commit details
    Browse the repository at this point in the history
  2. Simplification

    hut committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    4ea92d7 View commit details
    Browse the repository at this point in the history

Commits on Jun 6, 2024

  1. Configuration menu
    Copy the full SHA
    fe986cc View commit details
    Browse the repository at this point in the history