Friday, September 6, 2013

How to patch X Org for Touch Screens


There is an annoying bug in the touch event handling in xserver-xorg-core which affects all Linux distributions, where if you use transformation matrices (like below), only some of the events are transformed. This causes pointer down events to be transformed, and pointer up events to not, which looks like the cursor is constantly jumping from the "correct" transformed location to the untransformed location. This problem occurs often to anyone trying to rotate a touchscreen to portrait, for example. Its mentioned on the internet in various places.
An example of what you might want to do. In this example, a touchscreen is rotated to portrait, and is scaled down a bit. This is correct, but the transformations fail for some events because of the bug.



sudo xrandr --output VGA1 --rotate right --right-of LVDS1 --scale 0.66667x0.66667
sudo xinput set-prop "QUANTA OpticalTouchScreen" --type=float "Coordinate Transformation Matrix" 0 0.36 0.64 -1 0 1 0 0 1


How to fix The fix has been created, and it is floating around on the internet. Here is the patch that I found, from my Google Drive so the link doesn't vanish : x_touches.patch

How to apply the patch I've created a script to apply the patch, because you have to do this every time you upgrade your system's xserver (which is pretty often using the normal updates). Please read the script and apply to your situation, or simply save the script as a file (say, 'patch_x.sh') and run it in some 'temp' directory where you have the patch file too (must be named x_touches.patch).
Running the script involves calling 'chmod 755 patch_x.sh' first, to make it runnable, then saying './patch_x.sh'. I hope this helps someone!



#Script for patching and building xserver-xorg-core for touch screens
if [ ! -n "$1" ]
then
dpkg -s xserver-xorg-core;
echo "PLEASE CHECK EXACT VERSION NUMBER FROM THE ABOVE LISTING (e.g. 2:1.13.0-0ubuntu6.1),";
echo "THEN RUN THIS SCRIPT AGAIN WITH THE VERSION IN QUOTES";
else
echo "Getting and building xserver-xorg-core, version $1"
sudo apt-get update;
sudo apt-get install fakeroot;
sudo apt-get build-dep xserver-xorg-core;
sudo apt-get source xserver-xorg-core=$1;
cd xorg-server-*;
sudo patch -p1 -i ../x_touches.patch;
sudo dpkg-buildpackage -rfakeroot -us -uc -b
cd ..;
sudo dpkg -i xserver-xorg-core_*.deb
fi


Mikael Laine, SW Specialist - Ixonos

1 comment:

  1. KING CASINO, LLC GIVES A $100 FREE BET
    KING 도레미시디 출장샵 CASINO, https://febcasino.com/review/merit-casino/ LLC GIVES A $100 https://access777.com/ FREE BET to herzamanindir.com/ try. Visit us today and receive a $100 바카라 사이트 FREE BET! Sign up at our new site!

    ReplyDelete