Winit: Fast `Shift` releasing can break `ReceivedCharacter` on wayland

Created on 28 Jun 2019  路  5Comments  路  Source: rust-windowing/winit

os: Linux Wayland

After releasing Shift modifier some extra characters were received.

Can be reproduced with cargo run --example window from the latest master. Just press shift type a,s,d and release shift while releasing d. So you should get something similar to the next log (you can observe "strange" d character in the end of the log).

NewEvents(WaitCancelled { start: Instant { tv_sec: 1918, tv_nsec: 833369033 }, requested_resume: None })
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 42, state: Pressed, virtual_keycode: Some(LShift), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
EventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 1918, tv_nsec: 953443768 }, requested_resume: None })
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 30, state: Pressed, virtual_keycode: Some(A), modifiers: ModifiersState { shift: true, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: ReceivedCharacter('A') }
EventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 1919, tv_nsec: 13417572 }, requested_resume: None })
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 31, state: Pressed, virtual_keycode: Some(S), modifiers: ModifiersState { shift: true, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: ReceivedCharacter('S') }
EventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 1919, tv_nsec: 33396611 }, requested_resume: None })
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 32, state: Pressed, virtual_keycode: Some(D), modifiers: ModifiersState { shift: true, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: ReceivedCharacter('D') }
EventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 1919, tv_nsec: 83312871 }, requested_resume: None })
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 42, state: Released, virtual_keycode: Some(LShift), modifiers: ModifiersState { shift: true, ctrl: false, alt: false, logo: false } } } }
EventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 1919, tv_nsec: 113305802 }, requested_resume: None })
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 30, state: Released, virtual_keycode: Some(A), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
EventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 1919, tv_nsec: 123306710 }, requested_resume: None })
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 31, state: Released, virtual_keycode: Some(S), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
EventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 1919, tv_nsec: 193313156 }, requested_resume: None })
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 32, state: Released, virtual_keycode: Some(D), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
EventsCleared
NewEvents(WaitCancelled { start: Instant { tv_sec: 1919, tv_nsec: 283692239 }, requested_resume: None })
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 32, state: Pressed, virtual_keycode: Some(D), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Wayland(WindowId(93939495357520))), event: ReceivedCharacter('d') }
EventsCleared
Wayland needs investigation bug

Most helpful comment

I can reproduce, and this seems to be an SCTK bug. The rapid succession of actions:

  • press SHIFT
  • press E
  • release SHIFT
  • release E

causes the key repeat handling code to fire erroneously.

All 5 comments

Isn't that just that you kept d pressed long enough that key repetition started?

@vberger I don't think so, I've initially discovered it while testing this alacritty PR on wayland, I was receiving extra characters after each fast shift press (some times multiple of them). It happens only with shift and this wasn't presented on glutin = 0.21 + winit = 0.19.1.

I've retested window example with repeat_delay 10000 in sway and I was steel getting the issue.

I can reproduce, and this seems to be an SCTK bug. The rapid succession of actions:

  • press SHIFT
  • press E
  • release SHIFT
  • release E

causes the key repeat handling code to fire erroneously.

A new version of SCTK has been released and should fix the issue. Can you confirm? (you'll need to run cargo update)

@vberger Seems like it is fixed now. Thanks!

Was this page helpful?
0 / 5 - 0 ratings