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?
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).
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 key XF86Ungrab
This works with X.org version 2:1.11.4-0ubuntu10.8 on Ubuntu Precise.