xi: Don't deliver emulated motion when there's no owner for touch end

Pointer-emulated touch events should only be delivered to the client
that owns the sequence even if it's a core client that became the
effective owner of the sequency by selecting for pointer press and
movement.

Currently the emulated events are delivered like this already (see
TouchResourceIsOwner() check in DeliverEmulatedMotionEvent()), except in
the case of TouchEnd, in which case the generated motion event is still
delivered to some client that's not necessarily the owner of the touch
sequence.

We already know whether a touch sequence that is about to emulate a
pointer event has an owner, we just need to check that. This further
allows to simplify DeliverEmulatedMotionEvent() as it won't ever be
called for non-owned touch events.

https://bugs.freedesktop.org/show_bug.cgi?id=60394

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
Povilas Kanapickas 2020-12-20 01:11:43 +02:00 committed by Peter Hutterer
parent 365cbbfc4b
commit 3ab3083cc2
1 changed files with 8 additions and 1 deletions

View File

@ -1389,6 +1389,12 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
nevents = TouchConvertToPointerEvent(ev, &motion, &button);
BUG_RETURN_VAL(nevents == 0, BadValue);
/* Note that here we deliver only part of the events that are generated by the touch event:
*
* TouchBegin results in ButtonPress (motion is handled in DeliverEmulatedMotionEvent)
* TouchUpdate results in Motion
* TouchEnd results in ButtonRelease (motion is handled in DeliverEmulatedMotionEvent)
*/
if (nevents > 1)
ptrev = &button;
@ -1593,7 +1599,8 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev)
/* if emulate_pointer is set, emulate the motion event right
* here, so we can ignore it for button event emulation. TouchUpdate
* events which _only_ emulate motion just work normally */
if (emulate_pointer && ev->any.type != ET_TouchUpdate)
if (emulate_pointer && (ev->any.type == ET_TouchBegin ||
(ev->any.type == ET_TouchEnd && ti->num_listeners > 0)))
DeliverEmulatedMotionEvent(dev, ti, ev);
if (emulate_pointer && IsMaster(dev))