[PATCH libinput 7/8] evdev: ignore excessive releases of a button or key

Peter Hutterer peter.hutterer at who-t.net
Tue Aug 19 20:18:55 PDT 2014


When we're suspending a touchpad, several events triggered by timers may still
be waiting in the background. We still need to release all buttons/keys
immediately though so we get an uneven number of release events: one from
release_pressed_keys() and one when the timers expire and send the release
event through the normal channels.

Don't assert if we're already on a press-count of 0, simply ignore it and
discard the event.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
I'm not 100% sure on this one. It's the easy solution, but until we know the
general direction I didn't want to implement the full solution.
What's needed here are hooks for suspending/resuming in the dispatch structs
so that the touchpad code can cancel anything currently happening and reset
the state. For the normal fallback_dispatch the hooks can just release keys
and touches.

 src/evdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 6bbea92..755e7a1 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -74,8 +74,10 @@ update_key_down_count(struct evdev_device *device, int code, int pressed)
 	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
+			return -1;
 	}
 
 	if (key_count > 32) {
-- 
1.9.3



More information about the wayland-devel mailing list