On Sep 8, 2008, at 2:09 AM, Anselm R Garbe wrote:

2008/9/8 Donald Chai <[EMAIL PROTECTED]>:
Actually, this is a totally unrelated problem. The problem is that
XGrabKeyboard generates focus events (XGrabKeyboard is called by the X
server after establishing the passive grab with XGrabKey).

So, all keyboard shortcuts cause the window under the mouse to briefly get focus. I've used Metacity (the GNOME WM) with focus-follows-mouse, and it
doesn't have this behavior when I Alt-Tab.

I can't see why grabbing keys is an issue here. focus() only triggers
a button grab on the old and new client which might causing this issue
here. In Gnome WM you don't see this, because button grab's aren't
necessary on a focus() basis, since it reparents the client windows
and hence can keep the passive button grab for the whole lifetime of a
client window on the frame window. So I fear, you/we have to live with
this side effect.

I find it strange that the extra focus events only happen for me; or maybe I'm just the only one who's bothered by it. (I see the same thing in wmii and awesome too.)

From looking at the ion2 code, I figured out that XGrabKey with grab_window=root is the cause of the problem. If I instead call XGrabKey on all of root's children, no spurious focus events are generated. The following patch seems to fix things.

I add my own background layer to capture keypresses, so "xsetroot - bg" will no longer work. :(

Attachment: grabkeyfix.patch
Description: Binary data

Reply via email to