3

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!

malfunctioning
  • 435
  • 1
  • 3
  • 10
  • I don't know that you can do this with `xprop`. This might be a lower-level property of the window but my X11 is rusty. – Etan Reisner Apr 23 '15 at 23:23
  • Thank you Etan. I can change a lot of properties of an X11 window with `xprop`, and I have seen `WM_HINTS` being set via `xprop` before, but the examples of this are very rare. I use it more to set `WM_NAME`, `WM_ROLE`, etc. – malfunctioning Apr 24 '15 at 11:15

1 Answers1

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.

Sam Varshavchik
  • 114,536
  • 5
  • 94
  • 148
  • 2
    The OP's question appears to be regarding applications which cannot readily be modified, i.e., configuring existing applications. – Thomas Dickey Apr 24 '15 at 08:57
  • Thank you Sam and Thomas. Yes, Thomas is correct. I'm not talking about programmatically changing settings to do this when creating windows in my code. I'm talking about using the X11 facilities through user commands to change X11 window properties, like Thomas said. – malfunctioning Apr 24 '15 at 10:53
  • I guess that's what Sam addressed in his last paragraph too. – malfunctioning Apr 24 '15 at 11:02
  • So the main problem is that WM_HINTS doesn't appear to be widely documented. Maybe reading the source code is necessary. – malfunctioning Apr 24 '15 at 11:03
  • 1
    The xprop source code is fairly readable once you look at it for a bit as I recall. The source certainly helps find the format string it uses and what you would need to set it (I don't know if that'll work though). If my shell history is accurate the default format string for `WM_HINTS` is `32mbcxxiixx`. – Etan Reisner Apr 24 '15 at 11:49
  • If you code can figure out another application's window's XID (xcb_window_t if you're using XCB, etc...), you should be able to, somewhat rudely, modify another window's properties and event masks. My reading of X docs does not find any explicit restrictions on messing with your own windows only. In fact, I'd say that in order for window managers to do their job, they have to mess around with other app windows. – Sam Varshavchik Apr 25 '15 at 01:32
  • 1
    Do you mean "No Input"? How exactly is that done? Can you post the code? – BЈовић Jan 15 '18 at 14:48
  • So how you 'set the input focus hints for your window to "NoFocus"' exactly? – Velkan Feb 17 '21 at 12:30