Wrong touch event coordinates when simultaneously using a touch screen and a non-touch screen
Submitted by hjansen
Assigned to Keith Packard @keithp
Description
When using a touchscreen display in a setup with multiple screens the touch event coordinates are calculated wrongly because they are mapped to the whole display and not to the part which is shown on the touchscreen only.
This happens when I use my notebook (no touchscreen) and attach the presentation touchscreen in our conference room: touch events work, but the cursor does not move directly below my finger (the exact distance depends on where on the screen I touch the device).
Apparently, to fix this the X system needs to be told how to map the coordinates.
Currently I´m manually using the xinput command to achieve the desired behavior like so (after the touchscreen is attached): ~> xinput set-prop 15 'Coordinate Transformation Matrix' 0.54545455 0 0.45454545 0 1 0 0 0 1 (with 15 being the X device id of the touchscreen; where the touchscreen - 1920x1080 - is shown to the right of my notebook screen - 1600x900).
Unless one uses rotations, calculating the matrix (three rows with three values each; that´s why there are 9 numbers in the command line shown above) isn´t really complicated:
{screen_width / total_width} {0} {offset_x / total_width}, {0} {screen_height / total_height} {offset_y / total_height}, {0} {0} {1}
with screen_width/height being the resolution of the touchscreen, total_width/height being the total resolution of the virtual screen (so laptop + touchscreen), and offset_x/y being the positions of the touchscreen within the total space (0,0 if your screen is at the left of your laptop; laptop_width,0 if it is on the right).
It looks like the Gnome folks found a workaround: https://bugzilla.gnome.org/show_bug.cgi?id=709600
I reported the issue with KDE (as that´s what I am using), but they told me, it´s not their business: https://bugs.kde.org/show_bug.cgi?id=333099
There´s another KDE report with the same answer ("go and ask the X folks"): https://bugs.kde.org/show_bug.cgi?id=346795
There might be some helpful explanations by Martin Gräßlin in those discussions. Apparently KDE components cannot handle the problem because: "We have two not connected pieces of information: there is a touch input device, and an output. We don't know that they belong together (neither the touch screen yells "I belong to HDMI1", nor the xrandr output yells "/dev/input/event7 is my touch screen"). We just don't have that information."
I´m no expert, but Bug 38923 here on freedesktop.org might be related?
I probably did not pick the right Xorg component to assign this report to...