57

I have noticed that touchscreen doesn't work in FireFox on Ubuntu 16 desktop (on a touchscreen laptop), which is a major bummer as I am a FireFox guy and the browser is 90% of what I use my personal computer for. Note that it works on non-linux FireFox and it works in Chrome/Chromium on Ubuntu.

I have done some research on this and found a lot of people with the same complaint 2 - 3 years back. In those cases the consensus was typically that FireFox just lacked some necessary technology to support this (some say GTK 3, others said something else). However they claimed that this issue was already fixed in the pre-released FF v50. Now FF 50 is out and I'm running it but it still doesn't work.

Is there something I can add, an Alpha / Beta / Dev / Nightly version I can use, or something I can do to Ubuntu itself to get this to work?

Archisman Panigrahi
  • 25,210
  • 17
  • 90
  • 185
Hack-R
  • 967
  • 2
  • 12
  • 21

6 Answers6

59

This worked for me (firefox 57.0.4, Arch Linux):

  1. open about:config in firefox to set dom.w3c_touch_events.enabled=1 (default is 2).

  2. edit /etc/security/pam_env.conf and add MOZ_USE_XINPUT2 DEFAULT=1

  3. reboot and restart firefox

(see also How can I get Firefox to recognize multitouch gestures on a touch screen? )

50ty
  • 706
  • 6
  • 2
  • 19
    didn't need to edit `about:config`, setting the environment variable was enough. On FF60. – 3ventic May 21 '18 at 08:21
  • 3
    this works except you want to disable the gestures to zoom as well. it's annoying to use 2-finger scroll and while you're scrolling it zooms in/out on the content. You can do this by adding `-disable` to the end of the values for `browser.gesture.pinch.in` and `browser.gesture.pinch.out` for example `cmd_fullZoomReduce-disable` –  Sep 30 '18 at 00:30
  • Thanks. This worked in my Ubuntu 20.04 Thinkpad T440. – daparic Aug 13 '20 at 05:54
  • The default dom.w3c_touch_events.enabled value of 2 seems to work just fine (Ubuntu 20.04 LTS and FF 80.0.1) – kiko Sep 09 '20 at 04:41
  • worked for me on, pop os 21.04 with gnome version 3.38.5 – Lupos Oct 29 '21 at 09:25
  • no need for reboot, just log out an in again – rubo77 Aug 30 '22 at 09:13
42

Found this solution elsewhere: if I start firefox from the command line with

env MOZ_USE_XINPUT2=1 firefox

then touchscreen scrolling works for me. To avoid having to start firefox from the command line, you can edit the Unity app launcher exec code to include this. Default .desktop resides in /usr/share/applications but we'll copy it over to our home folder so that the changes we make are immune to be overriden by the package manager on update.

cp /usr/share/applications/firefox.desktop ~/.local/share/applications/
gedit ~/.local/share/applications/firefox.desktop

find the Exec line in the [Desktop Entry] section and change it to

Exec=env MOZ_USE_XINPUT2=1 firefox %u

Change the other exec lines too, if you feel like it. Those affect the options in the right-click menu.

EDIT: At some point this stopped working (I think because of an extension I installed). To fix it, I had to go to about:config in the browser, right-click, add a new boolean browser.tabs.remote.force-enable set to true. Warning: this is not recommended and could break stuff.

Adding a comment from Jeff G, you may also need to go to about:configand set dom.w3c_touch_events.enabled = 1.

AsgerHB
  • 75
  • 7
Ian Hincks
  • 2,761
  • 2
  • 26
  • 22
  • 3
    In conjunction with XINPUT2=1, you might also need to go to `about:config` to set `dom.w3c_touch_events.enabled=1` (default was 2). In my experience this enabled two-finger scrolling, while one finger still selects text. – Jeff G Mar 19 '17 at 02:49
  • 3
    Note that you need to make sure you have a thing called e10s enabled. To find out if you do, open `about:support` and look for 'Multiprocess Windows'. – BudgieInWA Jul 07 '17 at 08:13
  • 4
    There's also an (admittedly pretty stupid) alternate way to handle setting `MOZ_USE_XINPUT2` - just add `MOZ_USE_XINPUT2 DEFAULT=1` to `/etc/security/pam_env.conf` and then never worry about it again (probably) – rookie1024 Nov 26 '17 at 00:00
  • This worked without further modification for me on Firefox 57. Great! – DaVince Jan 04 '18 at 00:48
  • @JeffG This doesn't work for me. I put MOZ_USE_XINPUT2 DEFAULT=1 in the /etc/security/pam_env.conf. No matter which touch_events value I pick (1 or 2), one finger is always scrolling. On FF68 – HD189733b Aug 22 '19 at 04:40
  • Note that you have to close all running Firefox instances before launching Firefox again with this envvar. And note also that the `env` is unnecessary, it's just an envvar and you can just run `MOZ_USE_XINPUT2=1 firefox`. – Jack M Nov 11 '19 at 20:25
  • 2
    I would strongly recommend to never change package-managed files like the launchers in `/usr/share/applications/*.desktop`, because not only do they affect all users on the system and require root rights to change, they will also most likely get reverted again on the next software update. Also launching GUI apps as root like `sudo gedit` is bad because it easily messes up ownership of files in your home directory (e.g. caches, settings of that application) and breaks it when you try to use it normally again. – Byte Commander Apr 09 '20 at 22:13
  • 3
    You should instead of this all place a copy of the .desktop file in your user's `~/.local/share/applications/` folder and change it to your liking in there, as regular user without sudo. – Byte Commander Apr 09 '20 at 22:14
  • Doesn't work with Firefox 76.0.1 under Ubuntu 20.04... I actually get errors when starting Firefox now (it works, but gives me an error every time it starts). – Gregory Opera May 20 '20 at 10:54
4

I found a browser plugin called Grab and Drag which adds this functionality to FireFox.

Hack-R
  • 967
  • 2
  • 12
  • 21
  • 2
    Do you mean [this add-on](https://addons.mozilla.org/en-US/firefox/addon/grab-and-drag/)? – Pablo Bianchi Jul 09 '17 at 19:41
  • @PabloBianchi Yep that's the one – Hack-R Jul 09 '17 at 20:21
  • 2
    Grab and Drag appears to be designed for touch-only or pen-only computers. If you'd still like to use the mouse to select text etc., it's rather too drastic a solution. The `MOZ_USE_XINPUT2` works great, enabling kinetic scrolling, fling and drag-to-scroll. – Leif Arne Storset Oct 24 '17 at 08:33
  • @LeifArneStorset Seems to work for me, but I'll definitely check out the other solution as well, thanks – Hack-R Oct 24 '17 at 21:31
  • The add-on's page seems to be deleted =( – xjcl Apr 03 '19 at 00:44
3

Firefox on Ubuntu 22.04 (Wayland)

To enable touchscreen finger scrolling in Firefox on Ubuntu 22.04 under Wayland display server you can enable Firefox Wayland support with the environment variable MOZ_ENABLE_WAYLAND.

Test from terminal with the following (close Firefox first):

MOZ_ENABLE_WAYLAND=1 firefox

To permanently set this, add to your profile settings:

echo "export MOZ_ENABLE_WAYLAND=1" >> ~/.profile

This environment variable should be the default on 22.10 onwards so not needed

Cas
  • 8,427
  • 5
  • 69
  • 108
2

Found (yet) another Firefox add-on that lets you do that. Hope this one remains available for longer than the other two suggested.

ScrollAnywhere

Once added, you have to go to Options > General and check the "Left button" box. I works for me on Ubuntu 18.04 LTS and Firefox 78.0.1 (64-bit)

Álvaro
  • 121
  • 3
1

Install the "Drag to Scroll" plugin. https://addons.mozilla.org/en-US/firefox/addon/drag_scroll/