Linux – Inconsistent and erratic mouse wheel in Linux while moving the mouse pointer

linuxmousescroll-wheel

I have Manjaro Linux in VirtualBox, and in some applications such as the terminal the mouse wheel seems not to register many of the scroll ticks. Sometimes it scrolls fine, then suddenly it scrolls only half as much or stops scrolling at all. In other applications such as Firefox, the scroll wheel always works.

After some experimentation I found that I can't scroll at all while I'm moving the mouse pointer. Yet, when I hold the pointer perfectly still, scrolling works as expected.

There are some related questions on this site, but none have this specific issue caused by moving the mouse pointer while scrolling in Linux.

Best Answer

I found this post on the VirtualBox forums in a thread that exactly describes my problem. It seems to be unrelated to VirtualBox, as VMWare shows the same behavior.

The solution that worked for me:

  1. Check that you're currently using libinput.

    $ grep "Using input" /var/log/Xorg.0.log
    [     0.000] (II) Using input driver 'libinput' for 'Power Button'
    [     0.001] (II) Using input driver 'libinput' for 'Sleep Button'
    [     0.002] (II) Using input driver 'libinput' for 'Video Bus'
    [     0.003] (II) Using input driver 'libinput' for 'VirtualBox mouse integration'
    [     0.004] (II) Using input driver 'libinput' for 'VirtualBox USB Tablet'
    [     0.005] (II) Using input driver 'libinput' for 'AT Translated Set 2 keyboard'
    [     0.006] (II) Using input driver 'libinput' for 'ImExPS/2 Generic Explorer Mouse'
    [     0.007] (II) Using input driver 'libinput' for 'VirtualBox USB Tablet'
    
  2. Install the evdev input drivers.
    On Manjaro this is found in the xf86-input-evdev package, which was already installed.

  3. Enable the evdev drivers by modifying the X11 configuration.
    In the directory /usr/share/X11/xorg.conf.d/ I already had a file 10-evdev.conf with the evdev configuration. It was just overridden by the higher-priority 40-libinput.conf configuration. So all I had to do was:

    cd /usr/share/X11/xorg.conf.d/
    sudo mv 10-evdev.conf 80-evdev.conf
    
  4. Restart.

  5. Verify that the evdev drivers are now used instead:

    $ grep "Using input" /var/log/Xorg.0.log
    [     0.000] (II) Using input driver 'evdev' for 'Power Button'
    [     0.001] (II) Using input driver 'evdev' for 'Sleep Button'
    [     0.002] (II) Using input driver 'evdev' for 'Video Bus'
    [     0.003] (II) Using input driver 'evdev' for 'VirtualBox mouse integration'
    [     0.004] (II) Using input driver 'evdev' for 'VirtualBox USB Tablet'
    [     0.005] (II) Using input driver 'evdev' for 'AT Translated Set 2 keyboard'
    [     0.006] (II) Using input driver 'evdev' for 'ImExPS/2 Generic Explorer Mouse'
    [     0.007] (II) Using input driver 'evdev' for 'VirtualBox USB Tablet'
    

    This however didn't yet fix my problem. Apparently I needed imwheel too.

  6. Install imwheel. On Arch, I had to install the imwheel AUR package.
  7. Run imwheel to verify that this fixes the issue.

    $ imwheel
    
  8. All that remained was to make imwheel run at startup. I run this command, as it only intercepts the scroll wheel:

    imwheel -b 45
    

This fixed the issues! Scrolling is now working correctly in all applications.

Related Question