[PATCH v2 2/2] End physically active touches when device is disabled
Peter Hutterer
peter.hutterer at who-t.net
Wed May 23 20:24:28 PDT 2012
On Fri, May 18, 2012 at 02:05:02PM -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>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Cheers,
Peter
> ---
> Changes since v1:
> * Block signals while ending touches
> * Process all enqueued input events before processing still-active touches
> * Move function to dix/touch.c and prefix with "Touch"
>
> dix/devices.c | 1 +
> dix/touch.c | 28 ++++++++++++++++++++++++++++
> include/input.h | 1 +
> 3 files changed, 30 insertions(+)
>
> diff --git a/dix/devices.c b/dix/devices.c
> index 0c62a01..dc5f51c 100644
> --- a/dix/devices.c
> +++ b/dix/devices.c
> @@ -437,6 +437,7 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
> if (*prev != dev)
> return FALSE;
>
> + TouchEndPhysicallyActiveTouches(dev);
> ReleaseButtonsAndKeys(dev);
> SyncRemoveDeviceIdleTime(dev->idle_counter);
> dev->idle_counter = NULL;
> diff --git a/dix/touch.c b/dix/touch.c
> index 401cb98..c9f72a9 100644
> --- a/dix/touch.c
> +++ b/dix/touch.c
> @@ -1028,3 +1028,31 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
>
> return TouchListenerAcceptReject(dev, ti, i, mode);
> }
> +
> +/**
> + * End physically active touches for a device.
> + */
> +void
> +TouchEndPhysicallyActiveTouches(DeviceIntPtr dev)
> +{
> + InternalEvent *eventlist = InitEventList(GetMaximumEventsNum());
> + int i;
> +
> + OsBlockSignals();
> + mieqProcessInputEvents();
> + 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);
> + }
> + }
> + OsReleaseSignals();
> +
> + FreeEventList(eventlist, GetMaximumEventsNum());
> +}
> diff --git a/include/input.h b/include/input.h
> index bcf98a6..c702929 100644
> --- a/include/input.h
> +++ b/include/input.h
> @@ -579,6 +579,7 @@ extern int TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti,
> int listener, int mode);
> extern int TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
> uint32_t touchid, Window grab_window, XID *error);
> +extern void TouchEndPhysicallyActiveTouches(DeviceIntPtr dev);
>
> /* misc event helpers */
> extern Mask GetEventMask(DeviceIntPtr dev, xEvent *ev, InputClientsPtr clients);
> --
> 1.7.9.5
>
More information about the xorg-devel
mailing list