15

In Ubuntu 12.04, my mouse clicks when I release the button.

What happens (bad): I right click (mousedown), the context menu appears, when I release the mouse button (mouseup), the item under the cursor is clicked.

What should happen (good): I right click (mousedown), the context menu appears, nothing happens when I release the button. To click an item in the context menu, I click it normally with the right mouse button.

I have experienced this behavior in Chrome, the file browser, and in gnome terminal. The mouse is a Razer DeathAdder (but I'm just running whatever drivers Ubuntu picked automatically), and if it matters, I'm using the AMD/ATI graphics drivers.

4 Answers4

5

Here is my fix:

First, you need to compile and install sxhkd, from here:

https://github.com/baskerville/sxhkd

which is a really cool program.

Then, in your ~/.config/sxhkd/sxhkdrc add this recipe:

~button3
  for id in `xinput list | grep 'slave  pointer' | grep -v XTEST | sed -e 's/.*id=\([0-9]\+\).*/\1/'`; do xinput set-prop $id "Device Enabled" 0; done; \  
  xte 'mouseup 3' 'mousermove 0 -1'; \ 
  sleep 0.3; \
  for id in `xinput list | grep 'slave  pointer' | grep -v XTEST | sed -e 's/.*id=\([0-9]\+\).*/\1/'`; do xinput set-prop $id "Device Enabled" 1; done

How this works, sxhkd captures the right click event with its xcb listener, and replays it back, this is what the tilde is for. After this, we turn off the touchpad, move the mouse cursor one pixel up so that the first entry is not highlighted, sleep for 300ms to ignore any finger dragging after the click that throws off the position, and reenable the pointer devices.

This works perfectly on the chromebook I am setting up.

UPDATE: I changed the sxhkd recipe to work with all pointer input devices, not just touchpads.

2

If you do not move your mouse in the meanwhile, there should not be any "menu item under cursor". The context menu opens such that its left upper corner is at the cursor, and there is a margin below to the next menu item.

However, if on mouse-button-release there is a menu item under the cursor, the desired behavior is to launch that menu item. This his how you (or at least many people) normally proceed: mouse-button-down, move the cursor to the desired menu item, mouse-button-release to activate that item.

If there is no menu-item under cursor after mouse-button-down, then the behavior is as you described: mouse-button-release does not destroy the context menu.

So maybe your mouse is very sensitive, and a button-down event is accompanied by a cursor move?

January
  • 37,208
1

This is the default behavior. You will experience the same thing even in Nautilus, which is the default manager. Actually, you will experience it everywhere. If you right click somewhere and you see a context menu, and, without releasing your right click, you hover above an action of the context menu and then release it, the corresponding action will be launched.

I can confirm this in all the programs I tried it into, thus, this is the default behavior under Ubuntu (and I find it handy, rather than having to manually left click to an action of the context menu)

hytromo
  • 4,891
0

I had similar problem. It can be very annoying and can cause random clicks on options in context menu, causing unexpected behaviors, especially when You got used to releasing right mouse button and then clicking again to select context menu option like it is in Windows
This is the solution that works best for me - installing easystroke application
This solution works a bit differently than You described in the section "What should happen". Context menu appears only after You release right mouse button, not after click.

  • When You click and hold and drag right mouse button then nothing happens and context menu isn't shown
  • when You click and hold right mouse button then context menu isn't shown until You release right mouse button
  • After releasing right mouse button You can quickly hover over the context menu and no option will be randomly selected (which can happen when You don't use this solution)
  • After releasing right mouse button You can select any option with left mouse button or right mouse button

This is easystroke repository, it has many forks
https://github.com/thjaeger/easystroke
install above from source or install this .deb package from fork
https://github.com/higersky/easystroke/releases/tag/0.6.0-3
sudo apt install ./easystroke_0.6.0-3_amd64.deb
After installing run
easystroke show

I recommend setting these preferences in the easystroke application for convenience

  • Gesture Button set to Button 3, by clicking right mouse button on displayed gray rectangle after clicking Gesture Button
  • Timeout profile set to Timeout Off
  • Method to show gestures set to None
  • uncheck Show tray icon, so that system tray is cleaner without 1 unnecessary icon
  • uncheck Autostart easystroke, because there is better way to start this application without showing its window at Linux start-up
  • create a Linux start-up script to launch easystroke in background without showing its GUI

in bash script
easystroke hide &
or in python script

subprocess.Popen(
    ['easystroke', 'hide'],
    stdout=subprocess.DEVNULL,
    stderr=subprocess.DEVNULL,
    start_new_session=True,
    preexec_fn=os.setsid(),
    )