Mozilla Firefox and the middle mouse button

Apr 05, '05 10:38:00AM

Contributed by: octo

Ever since I started using external three-button mice, one thing has really annoyed me. For some reason, the middle mouse button does not work in Firefox. On every other platform that I've used Firefox on, the middle mouse button has been a very convenient way to open a link in a new tab or window. Needless to say, it quickly became one of those "minor kinks" that really gets to you after a while.

Since when using a single-button mouse, you can use Command-Click to open a link in a new tab or window, most people take the route of reprogramming their mice so a middle click is a Command-Click. However, if you actually use programs that use the middle button (i.e. X11), this horribly breaks things -- the middle button is normally simulated by Option-Click, and the right button is normally simulated by Command-Click.

My solution, unlike anyone else on any of dozens of web forums, was to actually look at the Firefox source code and figure out why this problem was happening. As it turns out, Firefox uses the old toolbox "Event Manager" API to handle mouse events. This API does not support multi-button mice by itself, and only handles the right button because MacOS sends a Control-Click when you press it.

The solution I came up with, while pretty much a kludge, was to stick in some code that caused Firefox to use the new Carbon Event Manager system to listen for the middle mouse button events, and dispatch them into the rest of Firefox accordingly. This was implemented as a special case, and all other mouse events were left unchanged. Here is my patched and recompiled version of Firefox 1.0.2 [6.4MB download]. I've included some notes and copies of the files I had to change, in case anyone wants to recompile it again with different options.

Ultimately, Firefox probably needs to totally re-plumb the event management portions of their code for OS X using the Carbon API. My solution here is just a quick and dirty fix.

[robg adds: I downloaded the file, but I haven't yet tested it...]

Comments (23)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050404094020388