LWN.net Logo

Shortening the rope

Shortening the rope

Posted Apr 7, 2009 1:21 UTC (Tue) by bronson (subscriber, #4806)
In reply to: Shortening the rope by nix
Parent article: Shortening the rope

A grab is when you type and type and click and click and nothing happens, yes? When that happens, I switch to a console and back (Ctrl-Alt-F1, Ctrl-Alt-F7 unless you're on Jaunty or F10) and usually that breaks it. If not, I switch back to the console and start hunting processes. Usually I get some innocent processes before I bag the bad guy but the damage tends to be pretty light.

If there's a keystroke that would save me the trouble I'd love to know it! Google doesn't seem to know how to release grab.


(Log in to post comments)

Shortening the rope

Posted Apr 7, 2009 6:25 UTC (Tue) by nix (subscriber, #2304) [Link]

X hs three major types of grabs: keyboard grabs, pointer grabs, and server
grabs. Keyboard and pointer grabs cause input (from the keyboard or the
mouse) to be directed to that window alone until the grab is released
(there are lots of options, controlling what happens to the keyboard when
the pointer is grabbed, whether to confine the pointer to the window, and
so on). You can arrange to invoke grabs after particular button presses or
releases, or particular keystrokes. This stuff is used e.g. when you hold
down a button on a menu (the grab is released when you release the button)
or when you start a selection in some text editor and yank the pointer off
the edge of the window while holding the button down: even though the
pointer is no longer in the window, pointer events are still going to the
window. That's a grab.

If the application fails to release the grab, events will keep going to
that window, and it's likely to get rather confused (plus, of course,
events won't go anywhere else so you'll be a bit messed up).

Server grabs are much harsher. If you grab the X server, all connections
other than the grabbed connection are ignored until the server is
ungrabbed. This strikes me as a terribly bad idea (if the grab isn't
released sharpish it's indistinguishable from a server lockup). I'm not
sure why this request even exists. Anyone know? What use is it?

... regarding breaking grabs, I can't find the documentation or code for
this feature in recent xorg-xserver trees. Maybe I dreamed it...

Shortening the rope

Posted Apr 7, 2009 11:54 UTC (Tue) by nix (subscriber, #2304) [Link]

Hah! No! See <https://www.redhat.com/archives/fedora-devel-list/2009-Ma...>.

Gone in xserver 1.6 though.

Shortening the rope

Posted Apr 10, 2009 4:49 UTC (Fri) by njs (guest, #40338) [Link]

>I'm not sure why this request even exists. Anyone know? What use is it?

Because it's how you say "perform this sequence of operations atomically". The most recent example I happen to have seen is in the XSETTINGS spec where it notes you need a server grab at one point to avoid a race condition, but just in general, X is all about multiple apps working in parallel on a bunch of shared state, and sometimes you need a locking primitive.

It's also used for various hacks (e.g. if your wm does rubber-band resizes, it'll grab the server to prevent other windows redrawing themselves over the rubber band, apps that want you to enter a password will sometimes grab the server to prevent shenanigans, ...).

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds