start | find | index | login or register | edit
2007-06-11
by earl, 6335 days ago
at some point, X.org, firefox and horizontal scrolling hardware meet. what follows is a lengthy post on this otherwise utterly irrelevant topic. go figure.

in X, vertical mousewheel scrolling is indicated via button events 4 (up) and 5 (down). firefox handles these events as it should. firefox further uses buttons 6 and 7 for page backward/forward navigation, and until recent X versions, this was all working fine as well. but recent X.org versions (6.9 and higher) use button events 6 and 7 for horizontal mousewheel scrolling, leaving events 8, 9 and higher for side buttons. so here we got a problem: firefox responds to 6 7 but X sends 8 9.

note that this is a "nobody's fault" situation. changing firefox's mousewheel.horizscroll.withnokey.action config to 0 actually makes it scroll horizontally when X sends horizontal scroll events. it's only that the default settings "abuse" horizontal scrolling events for history navigation; a thing lots of people stumbled over when they got their first 4-way scrollwheel mouse.

well, great! but i don't need no horizontal scrolling. i want my side buttons bound to back/forward and not have horizontal scrolling interfere with that! now the proper way would most likely be to do application specific remapping and map mouse events 8 and 9 to key events Alt-Left and Alt-Right, for firefox. the easier way, however, is to instruct X to get the horizontal scrolling events out of the way.

the mousewheel is called the "z axis" in X jargon, so the default ZAxisMapping in current X is 4 5 6 7, meaning that button events 4,5,6,7 will be sent for mousewheel motion to the left,right,up,down respectively.

now, if you don't have/want/need horizontal mousescrolling, but want your side buttons to work with firefox to move backward/foward through the page history, you need to do some remapping. if you don't have a horizontal mousewheel, just restrain ZAxisMapping to 4 5 and tell X that all the other events are from real buttons by setting ButtonMapping to e.g. 1 2 3 6 7.

if you actually have a 4-way mousewheel, you can simply remap the horizontal mousewheel events to 8 9, which will free up 6 7 for buttons. this can be done by setting ZAxisMapping to 4 5 8 9. this also comes handy for mice without a mousewheel, where you may want to use a button to emulate mousewheel functionality: keeping this button pressed and moving the mouse will then result in mousewheel events. mosewheel emulation is especially useful for e.g. a thinkpad trackpoint. you may even set a timeout, so that you won't actually lose the functionality of the button you use for emulation.

finally, as an example, let's use the pseudo-device /dev/input/mice that combines all mouse input. this lets us create an uber-config that nicely plays with e.g. a trackpoint and an external mouse:


Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
Option "CorePointer" "on"
Option "Device" "/dev/input/mice"
Option "Protocol" "ExplorerPS/2"
Option "Emulate3Buttons" "on"
Option "EmulateWheel" "on"
Option "EmulateWheelButton" "2"
Option "EmulateWheelTimeout" "300"
Option "ZAxisMapping" "4 5 8 9"
Option "YAxisMapping" "4 5"
Option "XAxisMapping" "8 9"
Option "ButtonMapping" "1 2 3 6 7"
EndSection


y- and x-axis in the above actually refers to the mousewheel axes. so we map horizontal scrolling to 8 and 9. we also don't have to care if the external mouse is actually able to do horizontal scrolling natively as emulation using the middle button is enabled for all mice.

this setup plays nicely with firefox and doesn't swallow horizontal scrolling events completely. never mind that i've yet to find a case when i need this pesky horizontal scrolling (or even an app i use that supports them properly).

as mentioned before, there is an alternative solution using the venerable imwheel to do application specific remapping. so for firefox, you'd remap button events 8 and 9 to key events Alt-Left/Alt-Right. this would theoretically allow other applications that properly support X.org 7's 4-way mousewheel scrolling to still work fine. go google, if you want/need that -- i personally prefer having one moving piece less to look after.
powered by vanilla
echo earlZstrainYat|tr ZY @.
earl.strain.at • esa3 • online for 8625 days • c'est un vanilla site