[PATCH] Xi: Honor pointer-emulating touch when setting the button mask in XIQueryDevice

Carlos Garnacho carlosg at gnome.org
Tue Jan 7 15:52:06 PST 2014


Hey,

On lun, 2014-01-06 at 15:59 +1000, Peter Hutterer wrote:
> On Fri, Jan 03, 2014 at 05:41:45PM +0100, Carlos Garnacho wrote:
> > If a touch is currently active and emulating pointer events, XIQueryDevice must
> > set the button 1 in the mask so pointer emulation is complete, as clients using
> > XI2 would get inconsistent button states wrt events if querying the device. This
> > is already handled correctly on the core protocol requests.
> 
> the behaviour for XIQueryPointer is to include the button state for
> clients < XI 2.2, but don't include it for clients that know about touch (and can
> thus handle touch). I think we should emulate the same behaviour here to be
> consistent (though I can't find the documentation for this anymore). This
> would of course mean that XI2.2+ clients can't tell if there's a
> pointer-emulating touch currently active...

Hmm, that is quite unfortunate... The background on this patch is
https://bugzilla.gnome.org/show_bug.cgi?id=709914#c20 , mutter is
querying the button state on EWMH messages to double check the button is
still pressed, but opting this out on XI2.2+ clients would still be
affecting mutter.

In this situation, mutter isn't even receiving input events at that
time, so all means to know a (pointer-emulating) touch is ongoing are
ruled out... I think this counts as a legitimate usecase of XI2.2+
client that cares of pointer emulation.

I now wonder how could this be handled, can just think of using an
special bit on the XIButtonState mask, and that of course requires
amending the spec...

  Carlos

> 
> Cheers,
>    Peter
> 
> PS: xiquerypointer.c needs the loop below instead of a just buttonsDown > 0.
> Feel free to add that patch to your list ;)
> 
>  
> > Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
> > ---
> >  Xi/xiquerydevice.c | 14 +++++++++++++-
> >  1 file changed, 13 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
> > index 4e544f0..762968a 100644
> > --- a/Xi/xiquerydevice.c
> > +++ b/Xi/xiquerydevice.c
> > @@ -261,11 +261,23 @@ ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo * info, Bool reportState)
> >      bits = (unsigned char *) &info[1];
> >      memset(bits, 0, mask_len * 4);
> >  
> > -    if (reportState)
> > +    if (reportState) {
> >          for (i = 0; i < dev->button->numButtons; i++)
> >              if (BitIsOn(dev->button->down, i))
> >                  SetBit(bits, i);
> >  
> > +        /* Cater for touch pointer-emulation */
> > +        if (dev->touch) {
> > +            for (i = 0; i < dev->touch->num_touches; i++) {
> > +                TouchPointInfoPtr ti = dev->touch->touches + i;
> > +                if (ti->active && ti->emulate_pointer) {
> > +                    SetBit(bits, 1);
> > +                    break;
> > +                }
> > +            }
> > +        }
> > +    }
> > +
> >      bits += mask_len * 4;
> >      memcpy(bits, dev->button->labels, dev->button->numButtons * sizeof(Atom));
> >  
> > -- 
> > 1.8.5.2
> > 
> > _______________________________________________
> > xorg-devel at lists.x.org: X.Org development
> > Archives: http://lists.x.org/archives/xorg-devel
> > Info: http://lists.x.org/mailman/listinfo/xorg-devel
> > 




More information about the xorg-devel mailing list