input: don’t enable keyboard repeat timer when repeat rate is zero

wayland-client-protocol.h:

  Negative values for either rate or delay are illegal. A rate of
  zero will disable any repeating (regardless of the value of
  delay).

This fixes a division-by-zero crash.
This commit is contained in:
Daniel Eklöf 2021-01-16 12:27:58 +01:00
parent cebdae4bae
commit 67ac09ab2e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 4 additions and 0 deletions

View file

@ -580,6 +580,9 @@ start_repeater(struct seat *seat, uint32_t key)
if (seat->kbd.repeat.dont_re_repeat)
return true;
if (seat->kbd.repeat.rate == 0)
return true;
struct itimerspec t = {
.it_value = {.tv_sec = 0, .tv_nsec = seat->kbd.repeat.delay * 1000000},
.it_interval = {.tv_sec = 0, .tv_nsec = 1000000000 / seat->kbd.repeat.rate},