44

Sometimes Firefox doesn't release the mouse after dragging, so I need to kill the application to force it to release its pointer grab.

Is there any command to force an application to ungrab the pointer without killing it?

Ariyan
  • 2,106
  • 2
    If you have the command line you can try to disable and re-enable the mouse. See this wiki page. I'm not sure it works, especially if the reason for the freeze is related to a Javascript issue. – Paolo Jun 10 '12 at 21:09
  • @Guandalino: I have command line (By opening another terminal by pressing Alt+F2); I will test this in the next occurrence of the problem, Thanks – Ariyan Jun 10 '12 at 21:13
  • 2
  • I started having this problem with Firefox 13, and a web search brought me to this question. Are you by any chance using the Tree Style Tabs extension? It seems to be some problem with dragging tabs. – Juliano Jun 12 '12 at 22:53
  • @Juliano: I didn't used Tree Style tabs ext. ! And Up now I didn't seen problem again so I didn't tried solutions too. – Ariyan Jun 19 '12 at 06:35
  • Can the pointer grabbing problem described here and the problem described as "pointer not moving anymore" there have the same source: https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-input-synaptics/+bug/830099 , https://bugs.launchpad.net/xserver-xorg-input-synaptics/+bug/1035208 , https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-input-synaptics/+bug/1037586 . With that problem, switching to another linux virtual console and back to X helped. Does switching virtual consoles help with "grabbing"? – imz -- Ivan Zakharyaschev Nov 17 '12 at 19:40
  • It also happened to me using OpenShot while dragging an audio track. Freezed the XFCE4 session for minutes and I had to kill OpenShot to use again my right or left click. – Valerio Bozz Feb 04 '21 at 10:33

4 Answers4

60

On modern-ish X.org installations, there is an XF86Ungrab keysym, which causes the server to release all active pointer or keyboard grabs. You can make the server break all grabs by enabling break action XKB option, then generating the keysym either with a command or with the keyboard. With xdotool:

setxkbmap -option grab:break_actions
xdotool key XF86Ungrab

On some systems, the XF86Ungrab keysym is bound to the key combination Ctrl+Alt+Keypad /. However this possibility is often turned off because it could allow bypassing a screensaver).

alamar
  • 369
  • Do I have to run the above command every time, or at every boot, or just once? – Aaron Franke Aug 14 '18 at 17:17
  • @AaronFranke Run this command when the problem occurs. – Gilles 'SO- stop being evil' Aug 14 '18 at 19:04
  • This answer saved me! on Debian 11 with XFCE4. I think mouse was captured by VirtualBox but am not 100% sure. Thank you. – likebike May 07 '23 at 01:10
  • $.02 KDE by default maps Ctrl-Alt-KPDiv to XF86Ungrab (which doesn't do anything unless grab breaking is enabled, which is that setxkbmap option). Break out of grab can be (permanently) enabled in Input Devices -> Keyboard -> Advnaced -> Compatibility Options. And xkill is great for testing if grab breaking works. – Pawel Veselov May 08 '23 at 18:30
  • Thanks, very useful solution for this Xfce bug to avoid restarting the session (tested on Debian 11): https://unix.stackexchange.com/questions/50426/xfce-hangs-with-hand-cursor – baptx Aug 25 '23 at 19:17
9

I answered this on Super User, and am quoting it here:

[As Gilles noted,] In fact, it is possible to do this (at least with recent versions of X).

You can do this by pressing the XF86Ungrab key, introduced in this commit.

By default, this keysym is not bound to any physical key or key combination (it was disabled in 2012 after it was reported as a security hole, since it allows anyone to bypass lock screens by breaking their grabs). On some other setups it is bound to a shortcut that uses the number pad. Obviously, that won't work on laptops that lack a keypad.

But you can still activate the keysym using xdotool:

xdotool key XF86Ungrab

This works with X.org version 2:1.11.4-0ubuntu10.8 on Ubuntu Precise.

0

This may be like killing a fly with a hammer, but my desperate solution was to just use htop to locate and kill the program that locked up my mouse pointer. Sorry, after writing this, I noticed your question explicitly says "without killing it".

Background:

I had the same issue happen to me in File-Roller. I tried to extract a file within an archive by dragging it to PCManFM in Awesome Window Manager. My mouse pointer changed to a grab-pointer-icon, and I couldn't click on anything. It was so frustrating.

Steps to Kill Process:

  1. Launch Terminal - Hit the hotkeys for launching a terminal, which are super+enter in Awesome, but are typically ctrl+alt+t in most desktop environments.
  2. Run htop - type "htop" (without quotes) and press enter.
  3. Find the Process - In my case, I pressed F3 and typed "roller" (without quotes). This located and selected the file-roller process.
  4. Kill The Process - Press F9 and select "SIGTERM" to kill the process.

This may not be the best way to do it, but it worked for me and it is easy to remember in a pinch.

Lonnie Best
  • 5,123
-9

Ctrl + G will release mouse focus in most situations.

Alexios
  • 19,157
llua
  • 6,900
  • Sorry I'd like to understand better, is this a linux specific thing or firefox? – Paolo Jun 10 '12 at 22:23
  • Linux, not completely sure, but i think it is a xorg function. I use it often to release focus from fullscreen videogames. – llua Jun 10 '12 at 22:36
  • 2
    I doubt that this work; it is a single modifier plus a key, these combinations are used for applications (e.g. firefox activates "Find" box with this) and not for something like X (X uses keys like Alt+Ctrl+Backspace)! after that I tried it in a normal drag and drop and nothing happened! – Ariyan Jun 11 '12 at 00:48
  • 4
    That is not the case in any version of Firefox that I've seen, and it is definitely not the case “in most situations”: many applications use Ctrl+G for their own purposes, there is no such X-wide binding. – Gilles 'SO- stop being evil' Jun 11 '12 at 00:49