[PATCH 2/2] End physically active touches when device is disabled

Peter Hutterer peter.hutterer at who-t.net
Tue May 15 17:44:56 PDT 2012


On Tue, May 15, 2012 at 01:21:55PM -0700, Chase Douglas wrote:
> Otherwise:
> 
> * We can't end the touches while device is disabled
> * New touches after enabling the device may erroneously be mapped to old
>   logical touches
> 
> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
> ---
>  dix/devices.c |   26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/dix/devices.c b/dix/devices.c
> index 7f38865..8a60cfd 100644
> --- a/dix/devices.c
> +++ b/dix/devices.c
> @@ -415,6 +415,31 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent)
>  
>  
>  /**
> + * End physically active touches for a device.
> + */
> +static void
> +EndPhysicallyActiveTouches(DeviceIntPtr dev)
> +{
> +    InternalEvent *eventlist = InitEventList(GetMaximumEventsNum());
> +    int i;
> +
> +    for (i = 0; i < dev->last.num_touches; i++) {
> +        DDXTouchPointInfoPtr ddxti = dev->last.touches + i;
> +
> +        if (ddxti->active) {
> +            int j;
> +            int nevents = GetTouchEvents(eventlist, dev, ddxti->ddx_id,
> +                                         XI_TouchEnd, 0, NULL);
> +
> +            for (j = 0; j < nevents; j++)
> +                mieqProcessDeviceEvent(dev, eventlist + j, NULL);
> +        }
> +    }
> +
> +    FreeEventList(eventlist, GetMaximumEventsNum());
> +}
> +

you'll need to OsBlockSignals() because you may still get events and that
may have funky side-effects. Should be taken care of by the callers but it's
still better to add it here too.

Also, can we move this into dix/touch.c please (including "Touch" prefix)?
that's what that file is for.

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> otherwise.


Cheers,
  Peter

> +/**
>   * Switch a device off through the driver and push it onto the off_devices
>   * list. A device will not send events while disabled. All clients are
>   * notified about the device being disabled.
> @@ -437,6 +462,7 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
>      if (*prev != dev)
>          return FALSE;
>  
> +    EndPhysicallyActiveTouches(dev);
>      ReleaseButtonsAndKeys(dev);
>      SyncRemoveDeviceIdleTime(dev->idle_counter);
>      dev->idle_counter = NULL;
> -- 
> 1.7.9.5
> 


More information about the xorg-devel mailing list