[PATCH 1/2] Replay touch begin event in entirety

Peter Hutterer peter.hutterer at who-t.net
Sun Jan 15 20:59:18 PST 2012


sorry, my mail server was down most of the weekend, this one got stuck.

On Wed, Jan 11, 2012 at 07:38:11AM -0800, Chase Douglas wrote:
> The current code partially reconstructs the touch begin event when
> replaying touch history. This change ensures the original begin event
> is replayed, including valuators beyond X and Y.
> 
> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
> ---
> This looks like code that is there for a specific reason, but I can't
> figure it out. Peter, do you know why you treated begin events
> differently?
> 
>  dix/touch.c |   28 ++++++++--------------------
>  1 files changed, 8 insertions(+), 20 deletions(-)
> 
> diff --git a/dix/touch.c b/dix/touch.c
> index db0bf33..3766af5 100644
> --- a/dix/touch.c
> +++ b/dix/touch.c
> @@ -481,33 +481,21 @@ TouchEventHistoryPush(TouchPointInfoPtr ti, const DeviceEvent *ev)
>  void
>  TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource)
>  {
> -    InternalEvent *tel = InitEventList(GetMaximumEventsNum());
> -    ValuatorMask *mask = valuator_mask_new(0);
> -    int i, nev;
> -    int flags;
> +    int i;
>  
>      if (!ti->history)
>          return;
>  
> -    valuator_mask_set_double(mask, 0, ti->history[0].valuators.data[0]);
> -    valuator_mask_set_double(mask, 1, ti->history[0].valuators.data[1]);
> -
> -    flags = TOUCH_CLIENT_ID|TOUCH_REPLAYING;
> -    if (ti->emulate_pointer)
> -        flags |= TOUCH_POINTER_EMULATED;
> -    /* send fake begin event to next owner */
> -    nev = GetTouchEvents(tel, dev, ti->client_id, XI_TouchBegin, flags, mask);
> -    for (i = 0; i < nev; i++)
> -        DeliverTouchEvents(dev, ti, tel + i, resource);
> -
> -    valuator_mask_free(&mask);
> -    FreeEventList(tel, GetMaximumEventsNum());
> -
> -    /* First event was TouchBegin, already replayed that one */
> -    for (i = 1; i < ti->history_elements; i++)
> +    for (i = 0; i < ti->history_elements; i++)
>      {
>          DeviceEvent *ev = &ti->history[i];
> +
>          ev->flags |= TOUCH_REPLAYING;
> +        if (ev->type == ET_TouchBegin)
> +            ev->flags |= TOUCH_CLIENT_ID;
> +        if (ti->emulate_pointer)
> +            ev->flags |= TOUCH_POINTER_EMULATED;
> +
>          DeliverTouchEvents(dev, ti, (InternalEvent*)ev, resource);
>      }
>  }
> -- 
> 1.7.7.3

yeah, there is a time window before replaying where another device may have
been used, in which case you need to generate a DeviceChangedEvent (which 
GetTouchEvents() does). Other than that, I think it's mainly because
it was moved from TouchEventRejected to here. And the original code goes
back to Daniel's original patch which didn't feature the event history yet,
so the event had to be generated there. A bit more history with some things
being introduced step-by-step, this never got updated. I think the potential
need for the DCE is still there though.

Cheers,
  Peter


More information about the xorg-devel mailing list