# mouse wheel strange behavior with firefox



## mhmdchebbi (Sep 2, 2016)

Hi All

I have FreeBSD 10.3 installed in VirtualBox with MATE on Linux mint. When I browse Firefox and scroll up to the top of a page with mouse wheel I get back to the previous page.

I tried some mouse configuration on xorg.conf the problem still.

Here the configuration I found on some mailing list:


```
/etc/rc.conf
moused_enable="NO"

/etc/X11/xorg.conf
Section "InputDevice"
  Identifier  "Mouse0"
  Driver  "mouse"
  Option  "Protocol" "Auto"
  Option  "Device" "/dev/sysmouse"
EndSection

~/.xinitrc
xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7 10 11"
```


----------



## Snurg (Sep 2, 2016)

As a cat owner I agree with you that mice wheels are just annoying.
The cat hairs in it make them oversensible.
They begin moving erratically in no time.

Thus I have written a script to deactivate them.
Just call it from your .xinitrc 


```
#!/usr/local/bin/perl
use strict;

# get output of "xinput list"
my $xinp = `xinput list`;
# get the sysmouse id
(my $smid) = $xinp =~ /^.*sysmouse\s+id=(\d)\s+.*$/gm;
# now get info for sysmouse device
$xinp = `xinput list $smid`;
# get the information in the "Button labels" line
(my $bl) = $xinp =~ /^\s+Button labels:\s(.*)$/gm;
# separate the button descriptions
my @btnt = split(/\"\s\"/, $bl);
# now get the button map
my @bmap = split(' ', `xinput get-button-map $smid`);
# build the command string to be executed
my $cmd = "xinput set-button-map $smid";
for (my $bid = 0; $bid < scalar @bmap; $bid++) {
  $cmd .= ' ' . ($btnt[$bid] =~ /.*Wheel.*/ ? '0' : $bmap[$bid]);
}
# finally turn off the wheels :)
`$cmd`;
```


----------



## Juha Nurmela (Sep 2, 2016)

Puzzled, the mouse driver would not know if a firefox window was midpage or pegged at the top? Isn't this a GUI setting somewhere, mate or firefox?

Juha


----------



## SirDice (Sep 2, 2016)

mhmdchebbi said:


> I have FreeBSD 10.3 installed in VirtualBox with MATE on Linux mint. When I browse Firefox and scroll up to the top of a page with mouse wheel I get back to the previous page.


Firefox in the Linux VM or Firefox on the FreeBSD host?


----------



## mhmdchebbi (Sep 2, 2016)

Firefox installed on FreeBSD 10.3 and FreeBSD  installed on Linux VirtualBox.


----------



## SirDice (Sep 2, 2016)

Within the VirtualBox settings make sure the "Pointing Device" isn't set to "USB Tablet". I've noticed it doesn't work too good with a FreeBSD guest. PS/2 should be fine. Then make sure to add to /etc/rc.conf:

```
moused_enable="YES"
```


----------



## mhmdchebbi (Sep 2, 2016)

hi sirdice the setting are as you say.

Snurg: i put the script and the problem still persist.


----------



## Snurg (Sep 2, 2016)

mhmdchebbi:
So the problem seems to persist even with deactivated mouse wheel. There might be other mappings that interfere.
I should maybe add some diagnostic output options to my script that show the complete button mapping so one can see whether there is something unusual.

Like SirDiceI guess that there might be some pointer device settings you might have to modify in the VirtualBox settings. But as my laptop with virtualbox just died, I cannot look into it now.


----------



## nosheep (Mar 15, 2017)

Same issue here

EDIT 2:

Host: VirtualBox 5.1.14 on Windows 8.1 x64
Guest: FreeBSD 11.0 x64


```
$ uname -a
FreeBSD beastie 11.0-RELEASE-p8 FreeBSD 11.0-RELEASE-p8 #0: Wed Feb 22 06:12:04UTC 2017     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
```

EDIT 1: I try to fix the issue with a configuration of X11 in /usr/local/etc/X11/xorg.conf.d/vbox-mouse.conf

Template:


```
Section "InputClass"
  Identifier "MouseDefaults"
  MatchIsPointer "on"
  ... (options here)
EndSection
```

Options I tried to put off the wheel's behavior:


```
Option "Protocol" "Auto"
# Also tried with: Logitech, PS/2, SysMouse
```


```
Option "Buttons" "2"
# Also tried with: 3
```


```
Option "ZAxisMapping" "X"
# Also tried with: Y
```

None of these options fix the issue, the scroll up always simulate a _go back_.


----------



## drhowarddrfine (Mar 16, 2017)

fwiw, I used to notice this problem until recently without being in a VM. I can't say it's gone. I just haven't noticed or thought about it till now. Not all the time. Just occasionally, especially on fast mouse wheel spins.


----------



## barrandrea (Jul 25, 2017)

Same issue with this configuration:


Host: Versione 5.1.24 r117012 (Qt5.6.2) on Windows 10 x64
Guest: FreeBSD 11.0 x64


```
FreeBSD freebsd-vm 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 01:43:23 UTC 2016     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
```

Nowaday I can't find any fix for this issue...


----------



## forester (Aug 14, 2017)

I got same issue on my FreeBSD virtualbox guest on my Redhat Linux.


```
FreeBSD FreeBSD 11.1-RELEASE-p1 FreeBSD 11.1-RELEASE-p1 #0: Wed Aug  9 11:55:48 UTC 2017     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
```


----------



## Le Gluon du Net (Oct 7, 2017)

Hello, I installed FreeBSD 11.1 on Virtualbox 5.1.28 and this annoying bug is still present. Where do I have to report a bug? FreeBSD? Xorg? Virtualbox?
I don't think it is a virtualbox bug, because this bug appear even before I installed the virtualbox-ose-additions.
It seems to be a Xorg bug where the mousewheel is associated with a mouse button...


----------



## Le Gluon du Net (Oct 8, 2017)

After two days of search all over the internet, I finally found a workaround to this bug.
Look at this discussion on VirtualBox Forum:
https://forums.virtualbox.org/viewtopic.php?f=4&t=80912
Like Oclair I tested my mouse action with xev and I obtained the same result as him: if I use my mousewheel up and down, sometimes xorg translates this action with button 8 and 9 instead of 4 and 5.
Next I searched a workaround to ask Xorg to ignore 8 and 9 button of my mouse, I found the solution here:
https://unix.stackexchange.com/questions/20550/how-to-disable-the-forward-back-buttons-on-my-mouse
Like explained in this article, I installed xmodmap, it found 10 button to my mouse, more than I need lol
So I put this .xmodmap file to disable button 8 to 10:

```
! Disable buttons 8 to 10
pointer = 1 2 3 4 5 6 7 0 0 0
```
And it works!!! Now enjoy Firefox mousewheel without forward/back annoying bug


----------



## barrandrea (Oct 8, 2017)

Le Gluon du Net said:


> After two days of search all over the internet, I finally found a workaround to this bug.
> Look at this discussion on VirtualBox Forum:
> https://forums.virtualbox.org/viewtopic.php?f=4&t=80912
> Like Oclair I tested my mouse action with xev and I obtained the same result as him: if I use my mousewheel up and down, sometimes xorg translates this action with button 8 and 9 instead of 4 and 5.
> ...



It work perfectly!!!! Thank you so much!


----------



## bran.damon (May 2, 2020)

I can confirm that this issue still exists - in my case in an XFCE desktop environment on a FreeBSD guest OS on a Windows host in VirtualBox - and disabling one single mouse pointer mapping with xmodmap indeed solved it. My mapping used to be:
`xmodmap -pp`

```
There are 12 pointer buttons defined.

    Physical        Button
     Button          Code
        1              1
        2              2
        3              3
        4              4
        5              5
        6              6
        7              7
        8              8
        9              9
       10             10
       11             11
       12             12
```

Then I disabled button 8:
`xmodmap -e "pointer = 1 2 3 4 5 6 7 0 9 10 11 12"`
And the output of `xmodmap -pp` is now:

```
There are 12 pointer buttons defined.

    Physical        Button
     Button          Code
        1              1
        2              2
        3              3
        4              4
        5              5
        6              6
        7              7
        8              0
        9              9
       10             10
       11             11
       12             12
```
Now Firefox works as it should.


----------



## Deleted member 69948 (Nov 18, 2021)

I had this exact issue and this fixed it but whenever I restart the issue comes back and I have to reapply it. How do I get it to save? I'm on a VirtualBox.


----------



## Deleted member 69948 (Nov 19, 2021)

Gitman said:


> I had this exact issue and this fixed it but whenever I restart the issue comes back and I have to reapply it. How do I get it to save? I'm on a VirtualBox.


Well, I'm still getting the issue in Firefox. Because of course. It doesn't always happen like before but it does still happen sometimes. Any other suggestions to stop it altogether?


----------



## bu_mi (Mar 20, 2022)

Bran.damon's solution works (which also means the issue is also present) in 2022! Thanks.


----------



## freezr (Mar 21, 2022)

This is my fix for XFCE4 and Virtualbox:


```
/usr/local/bin/xmodmap -e "pointer = 1 2 3 4 5 6 7 0 0 0 11 12"
```


----------



## FreeBSDArcade (Apr 26, 2022)

On Firefox Browser about:config, search for mousebutton and disable the 4th.


----------



## train4499 (Jul 1, 2022)

So after much research, I tried this and it worked for me.

Install  xmodmap.

Create a file named .xmodmap in your home directory.

Edit the .xmodmap file and add


```
pointer = 1 2 3 4 5 6 7 0 0 0 11 12
```

Save the file.

Edit the .profile file in your home directory and add


```
/usr/local/bin/xmodmap /home/<user>/.xmodmap
```

I used the full path just to be sure. Replace <user> with your login name.

Save the file.

The fixed the problem for me and it works even after a reboot. My shell is /bin/sh if that make a difference.


----------

