diff options
author | José Expósito <jose.exposito89@gmail.com> | 2023-08-31 16:35:32 +0200 |
---|---|---|
committer | José Expósito <jose.exposito89@gmail.com> | 2023-08-31 16:46:46 +0200 |
commit | bb1e4a493f6961144ec62ff4f6533936bed38444 (patch) | |
tree | adcf5e25d9e0a41c7b8dd78720157b13096ad803 | |
parent | 17e556503dfb119d714a71cd747125bb64724258 (diff) |
evdev: Log bug when releasing key with count 0
libinput keeps an internal key count. It is increased by 1 when the key
is pressed and decreased by one when the key is released.
The count should never be negative, however a user found an issue while
running Sway and hit an assert.
Replace the assert with a log to avoid the crash.
Fix https://gitlab.freedesktop.org/libinput/libinput/-/issues/928
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
-rw-r--r-- | src/evdev.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/evdev.c b/src/evdev.c index 73b394b0..cb49edad 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -135,8 +135,14 @@ evdev_update_key_down_count(struct evdev_device *device, if (pressed) { key_count = ++device->key_count[code]; } else { - assert(device->key_count[code] > 0); - key_count = --device->key_count[code]; + if (device->key_count[code] > 0) { + key_count = --device->key_count[code]; + } else { + evdev_log_bug_libinput(device, + "releasing key %s with count %d\n", + libevdev_event_code_get_name(EV_KEY, code), + device->key_count[code]); + } } if (key_count > 32) { |