Right click issues that seem to predate my time in Linux

I haven’t done a super exhaustive test on this personally, but I’ve been perpetually having an annoying issue with all mice on all (dozens) of the PC’s I’ve tested over the years on many DE’s. My experience is on Ubuntu, but I found an Arch forum post from 2009 explaining my exact issue. I’ve found a bunch of things online and it seems as if every single one of them have responders that simply don’t comprehend the actual issue and therefore are unable to resolve anything. So, on to the actual issue at hand:

If you right click (seemingly anywhere on any program, desktop, anything that brings up a menu) and your click lasts at minimum maybe 200ms - 300ms or more, if you release the right click button while hovering over a menu item it will be selected as if left clicked. The only way to deal with it is to either always use it in that fashion, hold right click and wave around to your item you want to select and release right click to select something on purpose, or hope you don’t let go hovering over a menu item if you accidentally right click.

If you right click particularly fast (maybe ~100ms or less, completely fictitious numbers) or don’t move a single pixel while right clicking then the menu comes up without selecting anything because it isn’t highlighting a menu item. However, if you do highlight an item and right click again, it selects it as if you left clicked it!

That last part is the crux of the situation for me. The fact that it is a default that right click could EVER confirm ANYTHING is purely rage-inducing. I totally get it for accessibility, They probably should push more of the accessibility features on live ISO’s and/or have it come up at the beginning of installers so those in need have the tools available as soon as possible. That would be fantastic, but having this as a default is completely insane to me.

I can’t tell you how many times I’ve had this issue bite me. I’m very much a normie when it comes to Linux. I’ve never worked in IT, I mostly use the browser, Steam, and some open source games. If it’s possible to pull up a right click menu on something then this bug is 100% capable of screwing everything up with an accidental right click or unclick. Numerous mice and laptops all have the same issue. I haven’t tried every distro created to see if there is an outlier without this issue, but I’ve bounced around most of the Ubuntu side of things since 2014 and it has been a persistent problem. I’ve been running Lubuntu 22.04 and it still persists, so it remains unfixed.

I’m going to go out on a limb here and guess it must be some sort of input issue. Perhaps some config file that has been copied and recopied for over a decade bringing that ludicrous default input method with it. If anyone knows of any way to make it so right click can NEVER make a positive selection anywhere, or at least not in the right click menu, and have it work system wide, I would be grateful. I really don’t want an answer only affecting one program. Even if a config option fixes it for Firefox where I spend most of my time, and therefore most of my issues happen there, that doesn’t get to the meat of the issue. It also passes the buck which means I individually get a half baked fix and everyone else who has to deal with this problem has to suffer until they can find a solution. Given the lack of understanding when other people have brought this up I can’t help but think plenty of people are just dealing with this and can’t find any solutions.

I’m of the belief that there is likely a very simple solution but I’m entirely too preoccupied with learning a ton of other things and can’t spend a week learning about input configs to fix a single thing for myself in isolation. Even if I did, I would post it here to be ignored til the end of time, so I figured I’d rope in people much better at this than myself and get some sort of conversation going, even if the result is ‘just deal with it’ like everyone has been doing since at least 2009.

1 Like

I understand your frustration, but my first thought is that your right-click action, the actual movement of your finger, is moving the mouse, or you are right-clicking while moving the mouse. I don’t think there’s some config you’ve copied across OS’s and installs.

I imagine you’d find it difficult to unlearn the muscle memory, but I suggest switching hands, without changing the button assignments. I’m right handed but use the mouse in the left hand because it’s better for a touch typist’s shoulders (thanks to the keypads pushing the mouse out to the right). If you’re right handed, using the mouse in the left hand makes the index finger used for right-click, and that may alleviate your issue.

The biggest issue is that this is accepted “normal” behaviour, and as such all toolkits (ie: QT, GTK) implement it. Even if one does provide an option to disable context menu selection with the right mouse button, you may launch an application using a different toolkit and then you’re back to the same issue.

No, this is standard system design, it’s completely intentional as many people use it in the click hold & release pattern. If you ever used a mac classic (or later perhaps too) you will know that this is how all the menus must be used and as such has become standard.

A cursory search yields some bug reports asking for it to be made a little less sensitive, but none have been implemented, let alone a disable option. Your best bet is to make a case to the toolkit developers (QT/GTK) to add such an option, but it’s pretty unlikely to happen as this is the first time in 30+ years I have heard of anyone ever wanting such a feature, it’s pretty niche.

3 Likes

In 18’ish years of using Linux I never noticed this. I hold right mouse button and left click to select something in the menu or left click outside the menu to close it. Now I got a whole new way to mess things up… :smiley:

I can see it now, I start letting go of right click to select something and accidentally start just letting go to close the menu…

1 Like

I’m aware parts of my problem are 100% my fault. Moving from mostly using my desk to mostly using my bed computer setup is absurd and greatly exacerbated the issue. I was also super thankful I made my setup when I fell last year and spent all of spring in bed. Pro’s and con’s to everything.

Out of curiosity, does this also happen on Windows, and has it always? I moved from WinXP to Linux Mint after XP stopped getting support. I genuinely don’t remember it there and if it has never been there then I really don’t understand how right click to select became default on desktop operating systems. Maybe because of how people use cell phones? I strongly dislike cell phones to be perfectly honest and wouldn’t be the least bit surprised if yet another thing in the world has been bastardized by cell phone culture.

I wonder how many people have been using computers for years and have accidentally had this bite them and they didn’t even realize what went wrong. Have you ever have a computer just derp on you in a way that didn’t even seem possible? I had this happen early on in Mint and it took me a while to fully comprehend how it worked and how widespread it was. If more people were aware then I would probably be at the back of a long line of much angrier people. I’m just mildly irritated because it seems like an insane default and I’d bet a nickel that tons of people have no clue the mouse operates this way.

Also, if right clicking is purposely set to select items in a right click menu, is it also purposely made that merely releasing right click also selects things? Not that an answer is going to make me suddenly like this. If it really is something implemented by multiple tool kits and not just some input config setting then I guess there isn’t any point in me dwelling on this any further. I appreciate the insight.

1 Like

No, right click drag is a select operation, the context menu doesn’t open until the button is released.

Edit: I do admit this to me makes more sense as I came from the Windows platform to Linux. Remember though that the linux toolkit/desktop is not modelled after Windows, but rather has it’s origin with unix/xerox (uwm/twm, etc) or more recently metacity.

2 Likes

double right click is a feature not a bug.
its the right click, right click run has been part of every object desktop ive run since windows 3.1.
its for lefties using ambidextrous mice

if you right click on an object in a folder you get the context menu, if you again right click on an action in the context folder, the action will be performed just like if you clicked the left button.
its a usability shortcut for lefties as i said.

so yeah i think its always been a feature on object desktops.

2 Likes

So it’s basically an accessibility feature for a small subsection of the population foisted on everyone. It also isn’t handled by the mouse driver or some input configuration files as I have come to learn, so this is simply never going to change in my lifetime. I can live with it even if I don’t like it.

The fact that it also make a selection on click release is by far the most egregious aspect to me. I can accept a lot of things, including something being grandfathered into a future world doing things the way grandpappy did it ‘just cuz’, even if I don’t think that is a smart way to go about things. Having a single action like one click do two actions (open menu on click, select highlighted item on release if you accidentally move a couple pixels over in the process) with no way to change it an no information easily accessible anywhere to at least warn you of this reality is, in my estimation, a kick in the balls.

I didn’t understand why this was a thing. I still don’t understand why it continues to exist. There is no easy fix which is what I was hoping to find and share with others. Without a viable solution to share this thread is done. Thanks everybody!

1 Like

not really foisted…
if you have a lefty in your office you dont wanna have to go into the mouse config to swap the buttons over every time they use a machine that a right hander was using.

Surely, don’t do that, just get the lefties to use the buttons as they are. When I became a “lefty” mouser decades ago I quickly gave up on swapping the buttons as a nuisance I didn’t need.

1 Like

I’m with you and agree the feature shouldn’t exist… or at minimum it should be an accessibility feature that needs to be enabled. But honestly I didn’t even know the feature existed until today after reading this thread and doing some right-clicking tests on my desktop. I’ve been using linux almost exclusively for the past 6 yrs and I don’t think I’ve ever accidentally selected something through right-click/drag. When I do make a mistake, it’s because the mouse pointer didn’t track to where I anticipated it to be… but it’s always me left clicking on the wrong option.

I wonder how much has to do with growing up using Windows vs Linux? I used Windows for almost 25 years before linux and it was never an option. My muscle memory tells me to “park” the mouse before double or right clicking. It would be a challenge to retrain my brain to right-click/drag at this point.

1 Like

im not saying it was a good feature, just a legacy one :smiley:

This was part of why I posted here in the first place. The threads I saw elsewhere while searching had people give a very basic explanation that seemed to describe this. The answers were, “Oh your doing things wrong, That’s just a weird quirk to whatever program you are using, That’s Firefox go to about:config” and the fix always seemed to not comprehend the problem whatsoever.

I’m someone who has burned easily over a hundred hours replying to people to try to help, only to be told either my solution has no relevance to their problem because they didn’t explain themselves, or they already tried my solution and clearly I’m a moron for thinking they didn’t already do that. You’re here asking for help and don’t explain you tried all the basics then I give you a wall of text filled with basics! I’m overly verbose because it will scare off anyone not really interested and not waste the time of people who want to help.

But the best part is that it’s so easy to completely miss that the mouse works this way and end up with very rare, completely random, seemingly unrelated effects if you aren’t paying very close attention. I noticed it early on, and between my less than ideal current mouse pad situation (it’s a dead Amazon tablet laying on my bed), plus my mother and her Logitech marble mouse (with much worse wrist and tremor issues than I have) also having this confuse her, I figured it was about time to see if there was a simple solution. I’m always going on about how nearly everything people commonly do in this world starts because of something logical, but never gets reevaluated as the world changes.

It would be glorious if someone came out with a fake Linux news piece saying some group like Ubuntu were going to change mice so they work this way (with people being oblivious to it already working this way). I bet people would crawl out of the woodwork screaming “Ubuntu is the worst! Lay off my mouse!” even though it’s already default and most Ubuntu bashers never use Ubuntu. There’s certainly no shortage of funny ongoings in the Linux world and this would be a real hoot.

In any event I just wanted to seek answers and try to share what what I saw. I would have put effort in to running around and spreading the good word if there was an easy button for this, but c’est la vie.

1 Like

Sorry for posting in an old topic. Just leaving this information here in case anyone stumbles upon similar problem in the future.
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
For instance in Linux with KDE there is a “leave” option in context menu, it is quite easy to hover over it accidentally and then this problematic glitch can cause Linux OS to shutdown making You lose any unsaved work.
There are other actions in context menu in various applications that can delete unsaved work or do things unexpectedly that user wouldn’t want to do.

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

There is easystroke repository in github, it has many forks
After installation of easystroke, 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(),
)

There is no need to force some groups of users to learn new habits. Software is flexible. For each group of users, a separate part of software can be created. So that everyone is happy.

1 Like

I’ve been using Group Speed Dial in Firefox and it’s kind of funny how it works. The menu for the add-on comes up when you press down, doesn’t select a menu item if you highlight and release, but if I right click again over it, the Firefox menu pops up with the original function I was having issues with.

Recently I’ve been using a desk so it hasn’t been an issue. I still can’t help but think if I hadn’t had that experience, I would occasionally have things selected that I never wanted to happen and would still be clueless as to why it was happening. This could be especially devastating if you are using a file manager, and this thread is the only place in my 11+ year Linux journey that I have ever heard mention of this mouse function. Best of all, it’s not consistent, even when seemingly using the same program. I still feel like it’s one of those, “Well grandpappy did it and he was right to do so!” and the rest of the world forgot.

At some point I’ll have to try out that easystroke application, I appreciate the response!

1 Like

Hi, sorry for bothering guys in this topic, just one last post from me for the future viewers of this website

I wrote a Python script that is a solution to this problem. It grabs mouse cursor in place after right mouse button is clicked and shows context menu only after right mouse cursor is released.

This Python script uses X library and works in X11 Windows system. It may not work in Wayland. To check if you are running X11 or Wayland you can run below command:
echo $XDG_SESSION_TYPE # prints “x11” or “wayland”
This script also uses Xinput2.0 and XTest extensions of X library. So to be able to run this you need to install these this way:
pip install python-xlib

This script has below features:
• mouse cursor is not hidden during the grab
• mouse cursor is warped back to original location after right mouse release
• context menu is always shown even when mouse cursor has been dragged when holding right mouse button
• script has a whitelisted processes list, which disables/enables mouse cursor grabs when whitelisted process is detected/undetected respectively. You can modify the whitelist in script’s code

Explanation on how this script works:
• Script opens X Display, and checks if XTest and XInput2.0 extensions are available.
• It sets listening SubstructureNotify X events to detect changes in windows hierarchy to determine if whitelisted process window got opened and if mouse cursor grabbing should be enabled/disabled.
• It starts X event listening loop which also listens to XI_ButtonPress and XI_ButtonReleaseevents using XInput extension when passive grab is enabled
• Passive grab is set for right mouse button, which locks mouse cursor in place when XI_ButtonPress event is received. Original right mouse click location is saved.
Passive grab is set for all pointer devices which can be seen using this command xinput list, these devices are named as “X slave pointer”
• Mouse cursor is unlocked on XI_ButtonRelease event. Passive grab is disabled for a short moment to be able to warp mouse cursor back to the original click location and to deliver simulated right mouse click and release actions to X Server.

Below is full Python script:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os, signal
from typing import List, Tuple
from Xlib import X, display # using X11 Windows System library
from Xlib.ext import xinput, xtest # xinput used for grabbing input devices, xtest used for delivering simulated clicks and releases
from Xlib.error import BadAccess  # raised on mouse cursor grab conflicts between applications
from pyglet.libs.x11.xlib import GenericEvent # for XInput2.0 events which are of generic type

x_display = display.Display() # currently used X display
root_window = x_display.screen().root # top-level window in X windows hierarchy
verbose_flag: bool = True # if True then print all logs to stdout
running: bool = True
pressed: bool = False
grab_enabled: bool = False
original_xy: Tuple[int, int] = (0, 0) # original location of right mouse button click
xinput_opcode: int = 131 # code used by XInput2.0 function calls, usually 131
Right_Mouse_Button : int = 3  # X Window constant for right mouse button = 3
Whitelisted_Processes: List[str] = [ # processes for which right mouse button grabbing feature is turned off
  "blender", "autodesk", "wineserver", "wine", "wine64", "wine-preloader", "wine64-preloader",
  "explorer.exe", "services.exe", "winedevice.exe", "plugplay.exe", "rpcss.exe",
]

def is_process_running(processes: List[str]) -> bool:
  try: # /proc directory contains all processes information in folders for each process
    for pid_dir in os.listdir("/proc"): # loop over all entries in /proc folder
      if not pid_dir.isdigit(): continue # if folder name has letters in it then it is not a process info, then skip it
      # processes' directories in /proc folder have pids as their names
      with open(os.path.join("/proc", pid_dir, "comm"), "r", encoding="utf-8", errors="replace") as cmd_file:
        process_name = cmd_file.readline().strip() # full path to process comm file, which has only 1 line = process name
      if process_name and process_name in processes:
        return True
  except (FileNotFoundError, PermissionError, OSError):
    return False
  return False

def enable_cursor_grabbing(dpy: display.Display, root) -> None:
  global xinput_opcode
  reply = xinput.XIQueryDevice(dpy.display, deviceid=xinput.AllDevices, opcode=xinput_opcode)
  if reply is None or reply.devices is None: raise RuntimeError("Failed to query XInput2 devices.")
  for device in reply.devices:
    # only X devices marked as X slave pointer (mouse) (as in xinput list command) are important and being grabbed by this function
    if device.use != xinput.SlavePointer: continue
    try: # below function doesn't grab mouse cursor instantly, it sets listening to button events and then grabs it in position when xinput.ButtonPress event is received
      # reply = xinput.passive_grab_device( # alternative wrapper function call in python-xlib
      xinput.XIPassiveGrabDevice(display=dpy.display, opcode=xinput_opcode, time=X.CurrentTime,
        grab_window=root, cursor=X.NONE, detail=Right_Mouse_Button, deviceid=device.deviceid,
        modifiers=[xinput.AnyModifier], mask=xinput.ButtonReleaseMask, grab_type=xinput.GrabtypeButton,
        grab_mode=xinput.GrabModeAsync, paired_device_mode=xinput.GrabModeAsync, owner_events=False,
      ) # no need to provide xinput.ButtonPress in mask, because XIPassiveGrabDevice() function causes implicit listening to xinput.ButtonPress events
      dpy.flush() # provide only xinput.ButtonReleaseMask in mask to listen for this event during passive grab after right mouse button click
      global grab_enabled; grab_enabled = True
    except BadAccess:
      if verbose_flag: print("[XI2] xinput.XIPassiveGrabDevice denied (BadAccess).")
    except Exception as exception:
      if verbose_flag: print(f"[XI2] xinput.XIPassiveGrabDevice failed: {exception}")

def disable_cursor_grabbing(dpy: display.Display, root) -> None:
  global xinput_opcode
  reply = xinput.XIQueryDevice(dpy.display, deviceid=xinput.AllDevices, opcode=xinput_opcode)
  if reply is None or reply.devices is None: raise RuntimeError("Failed to query XInput2 devices.")
  for device in reply.devices:
    # only X devices marked as X slave pointer (mouse) (as in xinput list command) are important and being ungrabbed by this function
    if device.use != xinput.SlavePointer: continue
    try:
      # reply = xinput.passive_ungrab_device( # alternative wrapper function call in python-xlib
      xinput.XIPassiveUngrabDevice(display=dpy.display, opcode=xinput_opcode, grab_window=root,
        detail=Right_Mouse_Button, deviceid=device.deviceid, grab_type=xinput.GrabtypeButton,
        modifiers=[xinput.AnyModifier],
      )
      dpy.flush()
      global grab_enabled; grab_enabled = False
    except Exception as exception:
      if verbose_flag: print(f"[XI2] xinput.XIPassiveUngrabDevice failed: {exception}")

def x_extension_check(dpy: display.Display) -> None:
  ext_info = dpy.query_extension('XTEST')
  if ext_info is not None and ext_info.present:
    if verbose_flag: print("XTest extension is available.")
  else: raise RuntimeError("XTest extension not available.")
  ext_info = dpy.query_extension('XInputExtension')
  if ext_info and ext_info.present:
    if verbose_flag: print("XInput extension is available.")
  else: raise RuntimeError("XInput extension not available.")
  global xinput_opcode; xinput_opcode = ext_info.major_opcode
  reply = xinput.XIQueryVersion(dpy.display, major_version=2, minor_version=0, opcode=xinput_opcode)
  if reply is None or reply.major_version < 2:
    raise RuntimeError("XInput2.0 not available (need at least 2.0).")

def event_loop(dpy: display.Display, root) -> None:
  global running, pressed, grab_enabled, original_xy
  while running:
    if grab_enabled and is_process_running(Whitelisted_Processes):
      if verbose_flag: print("Whitelisted process detected, disabling right mouse button grabbing.")
      disable_cursor_grabbing(dpy, root)
    elif (not grab_enabled) and (not is_process_running(Whitelisted_Processes)):
      if verbose_flag: print("Whitelisted process undetected, enabling right mouse button grabbing.")
      enable_cursor_grabbing(dpy, root)

    x_event = dpy.next_event() # blocking call that suspends current thread until next X event is received
    if verbose_flag: print(f"Received X event: {x_event}") # X event code IDs are defined in X.h file
    # generic events are generated only for key presses and key releases, only when passive grab is enabled
    if x_event.type == GenericEvent and x_event.extension == xinput_opcode:
      if verbose_flag: print(f"Received XI Extension event with code ID: {x_event.evtype}") # 4 = xinput.ButtonPress, 5 = xinput.ButtonRelease
      if x_event.data and x_event.data.detail == Right_Mouse_Button:
        if x_event.evtype == xinput.ButtonPress and pressed == False:
          # saving right mouse click location, no need to do anything else here, because mouse cursor will be automatically grabbed by XIPassiveGrabDevice listener on xinput.ButtonPress event
          original_xy = (int(x_event.data.root_x), int(x_event.data.root_y))
          if verbose_flag: print(f"[XI2] right mouse button pressed: holding pointer lock at position: {original_xy}");
          pressed = True
        elif x_event.evtype == xinput.ButtonRelease and pressed == True:
          if verbose_flag: print("[XI2] right mouse button released: showing context menu and releasing pointer lock.")
          disable_cursor_grabbing(dpy, root) # release of grab lock and start of the short interval with no grab where simulated mouse click and release is delivered
          root.warp_pointer(*original_xy) # fix for a glitch that sometimes the cursor can be invisibly moved away even when mouse cursor is visually locked in the same position
          dpy.flush() # Ensure the changes are immediately flushed to X display
          xtest.fake_input(dpy, X.ButtonPress, Right_Mouse_Button) # simulate right mouse button click in the short interval with no passive grab
          xtest.fake_input(dpy, X.ButtonRelease, Right_Mouse_Button) # simulate right mouse button release in the short interval with no passive grab
          dpy.flush() # Ensure the changes are immediately flushed to X display
          enable_cursor_grabbing(dpy, root) # end of the short interval with no grab where simulated mouse click and release is delivered
          pressed = False

def handle_signal(signal_id, _) -> None:
  signals = {signal.SIGINT: "SIGINT", signal.SIGTERM: "SIGTERM"}
  if verbose_flag: print(f"Received {signals[signal_id]} signal, exiting gracefully.")
  global running; running = False
  os._exit(0)

def main() -> int:
  signal.signal(signal.SIGINT, handle_signal)  # handler to exit application gracefully on signal
  signal.signal(signal.SIGTERM, handle_signal)  # handler to exit application gracefully on signal

  x_extension_check(x_display)
  # this line is used to trigger X events when windows hierarchy change to determine if right mouse button grabbing is necessary when whitelisted windows are being created or closed
  root_window.change_attributes(event_mask=X.SubstructureNotifyMask)
  x_display.flush()
  if verbose_flag: print("Listening for right mouse button press and release X events, Ctrl+C to exit.")
  event_loop(x_display, root_window)

  disable_cursor_grabbing(x_display, root_window)
  x_display.close()
  return 0

if __name__ == "__main__":
  raise SystemExit(main())