Fixing Mouse Wheel on Chrome in Ubuntu 18.04 Virtualbox / VMWare
Tags: ubuntu, scrolling, virtualbox, mousewheel
Published: 2019-07-23 03:02:41

This has been driving me insane for at least a year now. Like many developers I run a Virtual Machine that holds my day to day development environment (For the rare days I get to actually code!). 
One thing that has been a constant annoyance is going from the lovely smooth scrolling of Windows to a horrible messy, jagged, disjointed scrolling experience in Chrome and other apps under Ubuntu 18.04.

The problem (it turns out) was simple - `libinput` does not like trying to handle the mouse wheel at the same time as the mouse moving.

The solution seemed simple on the surface: Replace `libinput` with `evdev` and all should be solved.

Unfortunately Ubuntu 18.04 comes with its own Hardware Enablement layer, this replaces many of the standard components with version locked and layered versions that Canonical provide.

**disclaimer: this worked on my system - you might break yours!**

The first step is to remove this layer and instead install the standard versions of xorg:

```bash
sudo apt remove xserver-xorg-core-hwe-18.04 xserver-xorg-input-all-hwe-18.04 linux-generic-hwe-18.04 xserver-xorg-video-all-hwe-18.04
```

Now install the standard version of xorg and the evdev driver:

```bash
sudo apt install xserver-xorg-core xserver-xorg-input-evdev
```

Finally you need to edit the xorg config for libinput and change the driver to `evdev`:

```bash
sudo vi /usr/share/X11/xorg.conf.d/40-libinput.conf
```

and change the following line:

```
Section "InputClass"
        Identifier "libinput pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
```
to:

```
Section "InputClass"
        Identifier "libinput pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
```

This alone sorts out the "scrolling while moving" problem instantly resulting in a less jagged experience, however for some serious clout you might also want to install imwheel (https://wiki.archlinux.org/index.php/IMWheel is a good guide to getting it going)

My Config for this is:

```".*-chrome*"
None,      Up,   Button4, 2
None,      Down, Button5, 2
Control_L, Up,   Control_L|Button4
Control_L, Down, Control_L|Button5
Shift_L,   Up,   Shift_L|Button4
Shift_L,   Down, Shift_L|Button5

"^Navigator$"
None,      Up,   Button4, 2
None,      Down, Button5, 2
Control_L, Up,   Control_L|Button4
Control_L, Down, Control_L|Button5
Shift_L,   Up,   Shift_L|Button4
Shift_L,   Down, Shift_L|Button5

"^chromium$"
None,      Up,   Button4, 2
None,      Down, Button5, 2
Control_L, Up,   Control_L|Button4
Control_L, Down, Control_L|Button5
Shift_L,   Up,   Shift_L|Button4
Shift_L,   Down, Shift_L|Button5

".*gimp*"
Control_L, Up,   Control_L|Button4
Control_L, Down, Control_L|Button5
Shift_L,   Up,   Shift_L|Button4
Shift_L,   Down, Shift_L|Button5
Alt_L,     Up,   Alt_L|Button4
Alt_L,     Down, Alt_L|Button5
Control_L|Alt_L,     Up,   Control_L|Alt_L|Button4
Control_L|Alt_L,     Down, Control_L|Alt_L|Button5

".*nautilus*"
Control_L, Up,   Control_L|Button4
Control_L, Down, Control_L|Button5

```

I really hope this helps someone as this has been a massive annoyance for me.