From 3ab3083cc20534c83a5a35f0af1f2779f8df0b7b Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 20 Dec 2020 01:11:43 +0200 Subject: 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 --- Xi/exevents.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Xi') diff --git a/Xi/exevents.c b/Xi/exevents.c index 22dc214c9..193e57e22 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -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)) -- cgit v1.2.3