Bug 78345

Summary: Passive touch grab on master device and touch event mask on slave device breaks pointer emulation
Product: xorg Reporter: Daniel d'Andrada <daniel.dandrada>
Component: Server/Input/CoreAssignee: Peter Hutterer <peter.hutterer>
Status: RESOLVED MOVED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: peter.hutterer
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://launchpad.net/bugs/1307701
https://bugreports.qt-project.org/browse/QTBUG-38625
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Xorg.log with detailed input event handling info
none
A filtered Xorg.log with only the interesting parts
none
output of xinput
none
output of xwininfo showing the whole window tree
none
xorg-integration-tests testcase
none
xorg-integration-tests testcase try 2 none

Description Daniel d'Andrada 2014-05-06 15:52:38 UTC
It happens on Ubuntu running on laptop with a touchscreen.

Scenario:

- There's a small window whose client called XISelectEvents on it for the touchscreen slave device with mask=XI_TouchBegin|XI_TouchUpdate|XI_TouchEnd (client[5290, /usr/lib/x86_64-linux-gnu/qt5/bin/qmlscene qml-demo-minimal-client.qml] in the logs).

- compiz and nautilus (which handles the desktop background) have selections and/or grabs on the master device

Actions:

1- user taps the qmlscene window. Touch events are reported to both qmlscene (from the slave device) and to compiz (from the master device). compiz rejects the touch sequence and it's not delivered to anyone else

2- user now presses on the desktop background. TouchBegin, TouchOwnership and further TouchUpdates are sent to compiz.

3- compiz rejects the touch sequence. TouchPuntToNextOwner fails to emulate a pointer and pass it to nautilus as it still thinks that touch 1 is active. And as per pointer emulation rules, only the oldest active touch is used for touch emulation. From the logs, the lines are:

"""
[  9223.917] (II)             TouchPuntToNextOwner: touch 2
[  9223.917] (II)               - Not all older pointer emulated touches have been seen yet. Oldest touch(client_id=1, active=1, pending_finish=0, emulate_pointer=1).
"""

4- user lifts his finger

So that scenario on touch 1 clearly left xserver in an inconsistent, buggy, state.
Comment 1 Daniel d'Andrada 2014-05-06 15:53:47 UTC
Created attachment 98564 [details]
Xorg.log with detailed input event handling info
Comment 2 Daniel d'Andrada 2014-05-06 15:54:25 UTC
Created attachment 98565 [details]
A filtered Xorg.log with only the interesting parts
Comment 3 Daniel d'Andrada 2014-05-06 15:54:42 UTC
Created attachment 98566 [details]
output of xinput
Comment 4 Daniel d'Andrada 2014-05-06 15:55:08 UTC
Created attachment 98567 [details]
output of xwininfo showing the whole window tree
Comment 5 Daniel d'Andrada 2014-05-06 15:57:35 UTC
For reference, those were the steps I took when recording the log

- started lightdm (and threfore X)
- logged in
- launched the Qt app (qmlscene)
- tapped on the qmlscene window
- tapped on the desktop background (nautilus)
- closed the Qt app (qmlscene)
- stopped lightdm (and threfore X)
Comment 6 Maarten Lankhorst 2014-05-07 15:09:20 UTC
Created attachment 98629 [details] [review]
xorg-integration-tests testcase

I think this reproduces the bug quite well, does this match your logs?
Comment 7 Maarten Lankhorst 2014-05-07 15:56:41 UTC
Comment on attachment 98629 [details] [review]
xorg-integration-tests testcase

Woops, test is broken, the way it was written probably doesn't reproduce this bug. Although I believe it probably matches the description of the bug. Maybe missing something?
Comment 8 Maarten Lankhorst 2014-05-08 14:10:30 UTC
Created attachment 98694 [details] [review]
xorg-integration-tests testcase try 2

Ok so I've finally isolated the problem. The problem is the XIGrabDevice on the slave pointer, which is only removed after the touch ends. When this happens the ButtonRelease call for pointer emulation is never generated, leading to the 'stuck button' bug.

Modifying qt to listen to touch events on the master fixes it and removes the need for the XIGrabDevice call. The grab was originally done to prevent pointer emulation events, but these won't get generated when we listen for touch events on the master, solving both problems.

But this is still a bug in xorg-server, regardless. :)
Comment 9 GitLab Migration User 2018-12-17 17:26:27 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xorg/xserver/issues/569.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.