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

Jonas Ådahl jadahl at gmail.com
Thu Aug 21 12:29:42 PDT 2014


On Wed, Aug 20, 2014 at 01:18:55PM +1000, Peter Hutterer wrote:
> 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.

If suspending of the dispatch modules would guarantee to be graceful
(i.e. guarantee symmetric button presses), the auto-release function
could, partly as what you did in a previous patch, use evdev_notify_...
but do so by checking the bitmask instead of the counter in order to
only deal with the physical button presses it tracks. It'd be the
cleaner solution IMHO.


Jonas

> 
>  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
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list