Winit: Key repeat rate on Linux, Wayland, Sway is interpreted inversely

Created on 26 Jan 2019  路  7Comments  路  Source: rust-windowing/winit

This is a copy of https://github.com/jwilm/alacritty/issues/2041 . I initially reported it there but was pointed to testing it with winit directly.


I am using Linux with Wayland with Sway.

I am setting the key repetition rate in my sway config. Per man 5 sway-input:

input \ Sets the key repeat rate in number of keypresses per second.

Alacritty is interpreting this value the wrong way.

When set to 1 I should observe one repetition per second and when set to 1000 I should observe 1000 repetitions per second. This works correctly in the browser I am typing this from (Firefox).

Alacritty seems to interpret the value as the number of milliseconds between repetitions giving me a lot of repetitions per second in the first case and 1 in the second case.

$ alacritty --version
alacritty 0.2.7
sway --version
sway version 1.0-beta.2-274-g5f45a4bb (Jan 25 2019, branch 'makepkg')

I can reproduce this problem with winit directly.

As explained in https://github.com/tomaka/winit/issues/776#issuecomment-457867696 I am using a https://github.com/tomaka/glutin example.

I am holding down the f key and from the console output I can see that the event appears with the wrong rate as described above.

WindowEvent { window_id: WindowId(Wayland(WindowId(94063627530576))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 33, state: Pressed, virtual_keycode: Some(F), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Wayland(WindowId(94063627530576))), event: ReceivedCharacter('f') }
WindowEvent { window_id: WindowId(Wayland(WindowId(94063627530576))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 33, state: Pressed, virtual_keycode: Some(F), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Wayland(WindowId(94063627530576))), event: ReceivedCharacter('f') }
Awakened
WindowEvent { window_id: WindowId(Wayland(WindowId(94063627530576))), event: KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), input: KeyboardInput { scancode: 33, state: Pressed, virtual_keycode: Some(F), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Wayland(WindowId(94063627530576))), event: ReceivedCharacter('f') }
Awakened
...
Wayland bug

All 7 comments

Found the problem in client-toolkit. Working on PR.

Yeah this is my bad, I read the wayland documentation wrong since the key repeat delay is in milliseconds. This should be fixed by https://github.com/Smithay/client-toolkit/pull/62

At the exact same time, what are the chances ahah.

Oh, you have already done it, great!

Would it be possible to update the client toolkit dependency from 0.4 to the current 0.6 which includes this bugfix?

cc @vberger

This update is contained in the eventloop-2.0 refactor. Backporting the update to master branch would be a significant amount of work (it implies an upgrade of wayland-client, which was very largely breaking) that I am not willing to do a second time.

However, I released SCTK 0.4.5 containing this fix, cargo update should bring it to you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

francesca64 picture francesca64  路  5Comments

alexheretic picture alexheretic  路  4Comments

tomaka picture tomaka  路  3Comments

JDTX picture JDTX  路  3Comments

k0nserv picture k0nserv  路  3Comments