How to prevent an X Window from receiving user inp

2019-02-25 21:08发布

问题:

I would like to create some windows on a linux desktop for simple layout purposes. I need to avoid user input going to these windows (and I suppose avoiding the windows from gaining focus should suffice for that to happen).

I think that I can do this with the xprop command, by setting the WM_HINTS property, but I haven't found specific documentation on how to do it.

By the way, for an mplayer window, I can do this by using the option -input nodefault-bindings:conf=/dev/null. I simply need a general solution which I can enforce at a low level on any application's window.

Thanks!

回答1:

A window indicates whether it wants to receive keyboard input by setting the KeyPress and KeyRelease bits in its event mask. If you do not want your window to receive keyboard input, simply do not set those event in CreateWindow()'s event mask. See http://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#requests:ChangeWindowAttributes for more information.

Additionally, you should also set the input focus hints for your window to "NoFocus", as described in section 4.1.7 of ICCCM: http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.7

If you want to fiddle with other applications' windows, you should be able to change their attributes and hints, although this may result in undesirable behavior and/or side effects.