Casual analysis of #1752 (Emulate3Buttons issues)

Kean Johnston kean at armory.com
Fri Nov 11 00:05:50 PST 2005


Hi all,

I was going through teh release blockers for bits I could help out
with and I came across #1752, whose gory details can be found at
https://bugs.freedesktop.org/show_bug.cgi?id=1752.

I took at a look at input/mouse.c and I think I can see what the
problem is. I'd like another pair of eyes to do the same to make
sure I'm not on crack. Mice aren't my speciality :)

For the purposes of brevity I will use 'E3B' to refer to
pMse->emulate3Buttons, and 'E3SOFT' to refer to
pMse->emulate3ButtonsSoft.

In MouseCommonOptions, the first thing it does is set the value of
E3B, using a default value of FALSE. So it starts out life on the right
track. It then checks to see if the config file has *any* value for
Emulate3Buttons set, and if not, sets E3SOFT to TRUE. It looks like the
intent behind E3SOFT was to determine if the value was explicitly
set or simply set by default, so that later if it detects a middle
button click it can disable it. Or something :)

So with nothing set in the config file, we have E3B set to FALSE
and E3SOFT set to TRUE. However, if a user explicitly sets
    Option "Emulate3Buttons" "off"
in the config file, then we have E3B set to FALSE and E3SOFT set
to FALSE as well.

Now, down in MouseProc, it cheks for if (E3B || E3SOFT) and sets
wakeup handlers if that evaluates to true. Down in MoseDoPostEvent,
it checks to see if E3SOFT is set when it calls Emulate3ButtonsSoft(),
which is where it  determines that a real middle mouse button has
been pressed, displays the message letting you know that, and then
sets E3B to false. The rpoblem is, it doesn't disarm the block and
wakeup handlers, so even though it has detected that there is a
real middle button, ever click is still paying the emulation timeout
penalty.

This is why the users are experiencing the difference in behaviour
betweeen explicitly setting Emulate3Buttons to false versus having
no setting at all.

There are two ways to fix this. The first, and on the surface the
most attractive, is to have Emulate3ButtonsSoft() also disable
the block and wakeup handlers when it detects a 3rd mouse button.
The problem with this approach is that until such time was the
user actually presses a middle mouse button, a normal left or
right mouse button click is subject to the delay penatly, giving
rise to the undesirable behaviour mentioned in the bug report.

The fix I suggest is to completely eliminate the whole notion of
E3SOFT, and let the user actually enable the option if they
need it. This has the negative effect that for people with two
button mice where they currently will get 3 button emulation
without changing the config file, they now have to edit it and
enable it.

If someone other than me wants to decide which of the two options
to go with I will make the change accordingly.

Kean

-- 
Deckard: "I don't work here anymore. Give it to Holden. He's good."
Bryant : "I did. He can breathe okay as long as nobody unplugs him."
       --- Bladerunner



More information about the xorg mailing list