45

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?

7
  • 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
    Commented Jun 10, 2012 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
    Commented Jun 10, 2012 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
    Commented Jun 12, 2012 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
    Commented Jun 19, 2012 at 6:35

4 Answers 4

61

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).

5
  • Do I have to run the above command every time, or at every boot, or just once? Commented Aug 14, 2018 at 17:17
  • @AaronFranke Run this command when the problem occurs. Commented Aug 14, 2018 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
    Commented May 7, 2023 at 1:10
  • 1
    $.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. Commented May 8, 2023 at 18:30
  • Thanks, very useful solution for this Xfce bug to avoid restarting the session (tested on Debian 11): unix.stackexchange.com/questions/50426/…
    – baptx
    Commented Aug 25, 2023 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.

-9

Ctrl + G will release mouse focus in most situations.

4
  • Sorry I'd like to understand better, is this a linux specific thing or firefox?
    – Paolo
    Commented Jun 10, 2012 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
    Commented Jun 10, 2012 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
    Commented Jun 11, 2012 at 0: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. Commented Jun 11, 2012 at 0:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .