Skip to content

Add wl_keyboard key repeat events

Andri Yngvason requested to merge andri/wayland:compositor-side-key-repeat into main

This allows the compositor to take over the responsibility of repeating keys.

Moving this responsibility from the client is a simple way to solve the following problem with remote desktop applications such as VNC:

  • A remote desktop client is typing on the keyboard.
  • The user experiences intermittent latency, perhaps due to packet loss.
  • When the user presses a key down, but the up event is delayed for longer than the down event, this can result in unintended key repetition because the wayland client received the up event too late.

If the remote desktop client is made responsible for key repetition instead, this problem will not occur.

We could use inject a sequence of up & down to simulate repeat events, but this is likely to break some applications such as video games. Thus, repeat events must be explicitly signalled.

This was discussed on IRC today, and here is a summary of that discussion:

  • I raised the topic by pointing to the following issue: https://github.com/any1/wayvnc/issues/293
  • I was reminded that key repeat is client side
  • We talked about the need to add some flag to wl_keyboard to signal to the client that it should not repeat
  • Later in the discussion zamundaaa pointed out that this exists already and it's called wl_keyboard::repeat_info.
  • pq mentioned that wayland clients get timestamps with key events, so repeats can be rolled back.
  • zamundaaa pointed out that this is rarely implemented.
  • I pointed out that VNC doesn't have timestamps so it wouldn't help anyway.
  • People pondered for a bit about why clients were made responsible for this in the first place.
  • Later in the discussion daniels told us that it was done for the sake of efficiency. I.e. not having to wake up the compositor to tell the client to repeat when it can just as well have its own timer.
  • d_ed pointed to this blog post: https://www.csslayer.info/wordpress/linux/key-repetition-and-key-event-handling-issue-with-wayland-input-method-protocols/
  • Now, I wanted to know who's responsible for virtual-keyboard-v1. No one really answered that question, they just told me that changing it wouldn't help because of the missing repeat event in wl_keyboard.
  • Thus, here is an MR for the missing repeat event.

Merge request reports