Mouse clicks when I release the button

Solution 1:

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?

Solution 2:

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.

Solution 3:

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)