Fixing Chromium/Chrome Ignoring Touch Input on Linux
dimanche 7 juin 2015 à 19:54Recent versions of Chromium (and, presumably, Google Chrome) appear to be capable of differentiating between input from a touch screen, and input from a mouse. The problem is, on Linux, you’ll often find the capability a counter-productive one, since chromium sometimes outright IGNORES all touch input, rendering chromium utterly inoperable with a touchscreen. Mouse and touchpad operates chromium okay? Touchscreen operates other applications okay but you can’t so much as click a link on Chromium? You’re probably experiencing what I’m talking about.
There’s a report here, but it doesn’t seem to be going anywhere at the moment. Apparently Ubuntu carries a patch that tries to fix this, and I’m not sure how well it works, but at least on OpenSUSE we appear to be on our own. Fortunately, it’s possible to workaround, based on a suggestion in the comments.
First, on the terminal, type
xinput list
You should get a listing that looks like
⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ Atmel Atmel maXTouch Digitizer id=10 [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=13 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus id=7 [slave keyboard (3)] ↳ Power Button id=8 [slave keyboard (3)] ↳ Lenovo EasyCamera id=9 [slave keyboard (3)] ↳ Ideapad extra buttons id=11 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=12 [slave keyboard (3)]
You need to look for the name of your touch screen hardware. In the above case, that is “Atmel Atmel maXTouch Digitizer”. Note the id number for the hardware on the right, 10 in the above case.
What you need to do is pass this id as a parameter to Chromium/Chrome. Like so:
chromium --touch-devices=10
Replace 10 of course with the id of your device. Launched this way, touch input should actually work reasonably on Chromium. In particular – you can switch tabs with touch, touch links to visit them, and even touch-scroll.
Of course, it’s a little tedious to do this every time you want to start Chromium. Fortunately, it’s not hard to put it all in a script. Like so:
#!/bin/bash
SCREEN=`xinput list | awk '/maXTouch/ { gsub(".*id=",""); print $1 }'`
exec chromium --touch-devices=$SCREEN
Of course, you’ll need to change ‘maXTouch’ above to a suitable identifier for your particular device, but running the script should start Chromium in touch-usable state. If you want, you can even modify your application menu entry to call this script instead of the Chromium binary directly.