Tuesday, June 1, 2010

New evdev middle mouse button emulation defaults

As a heads-up, the next version of evdev (2.5) has a changed default for the middle mouse button emulation code. It is now off by default.

First of all - what is middle mouse button emulation?
Back in the olden days, when oil was cheap and mouse buttons were the peak of technology and thus expensive, mice only had two buttons. Possibly also to confuse user because two buttons for a (on average) five-finger hand seems just the right thing to do. Anyway, I digress.

One version of copy/paste in X relies on the middle mouse button, so a way to emulate that button was implemented in the driver. When this emulation was on, a left button was held back for a timeout and if during this timeout the right button was pressed, the driver would instead post a middle button event. If the right button didn't get pressed in time, the left button event was sent after the timeout expiry.

Coffee addicts could set this timeout to multiple minutes enough to have an excuse to fuel their addiction whenever they tried to do anything with the GUI. Now, two things have happened. The price of oil has surpassed the price of mouse buttons and on virtually all mice we have shiny things like scroll wheels, side buttons and whatnot. Also, computers have gotten a lot faster and people get annoyed about lag in the UI. Holding back a mouse button event by a few milliseconds seriously reduces the number of tweets one can write.

For the last couple of releases, we had the emulation on "auto" by default. It was on, until a physical middle mouse button click was detected. At this point the driver realised the emulation wasn't needed and turned it off. Which made for interesting side-effects: if you didn't know this feature, the GUI felt snappier after a middle mouse button press - for no obvious reason.
The "auto" option was a permanent false positive, there's no really reliable method to detect if a mouse has a middle mouse button.

So I've removed that "auto" feature and defaulted to off. Result - a slightly snappier feel of the UI for a quite underused feature. Of course, there are plenty of users of this feature, so it wasn't removed completely. If you need middle button emulation, please enable it with an xorg.conf snippet or ask your favourite desktop environment to provide a convenient checkbox.


Section "InputClass"
Identifier "middle button emulation class"
MatchIsPointer "on"
Option "Emulate3Buttons" "on"
EndSection

9 comments:

  1. "Now, two things have happened. The price of oil has surpassed the price of mouse buttons and on virtually all mice we have shiny things like scroll wheels, side buttons and whatnot."

    Virtually all _mice_, sure. Have you looked at touchpads? I have two laptops in the house, and neither of them has a third hardware button.

    ReplyDelete
  2. You're right here though most touchpads are not handled by the evdev driver. This change doesn't have an effect on the synaptics driver.

    ReplyDelete
  3. Why not use auto UNLESS the device claims to send BTN_MIDDLE?

    ReplyDelete
  4. There's no reliable detection for this emulation, the kernel hardcodes 3 buttons for mice. Touchpads are a different matter but as I said they're driven by the synaptics driver.

    It's less predictable too, some devices will feel less snappy than others. I prefer the predictable behaviour here, even if it means a bit more configuration for those that need the feature.

    ReplyDelete
  5. "You're right here though most touchpads are not handled by the evdev driver. This change doesn't have an effect on the synaptics driver."

    Oh, of course. That'll probably work out fine, then.

    ReplyDelete
  6. I was wondering whether there is a way to use the Windows key on the keyboard as a middle mouse button. That would be quite handy on notebooks which don't have a middle button. Any ideas?

    ReplyDelete
  7. You what‽

    Seriously this is a major feature of X, one that hook me to GNU/Linux in my early days (and BSd and... later). I think it's probably the feature I miss the most when I'm facing a Windows computer (that and the ability to move move/resize windows wu\ithout having to reach the borders.)
    I use this feature constantly and never noticed any lack of snappiness...
    You saddened my day, dear sir...

    ReplyDelete
  8. @cycojesus you are arguing about defaults, are you aware of that? There is only one thing worse than arguing about default, right?

    ReplyDelete
  9. thanks a lot for the tips, works perfectly for the poor people trying to use both a trackball (no mid button) and linux as a user-friendly OS ...
    Sadly, editing xorg.conf and adding snipplets is way above the average user standard ...

    ReplyDelete

Comments are moderated thanks to spammers