What's the difference between _NET_ACTIVE_WINDOW and XGetInputFocus() ? Do they always point to the same window? When use one over the other?
Thanks.
What's the difference between _NET_ACTIVE_WINDOW and XGetInputFocus() ? Do they always point to the same window? When use one over the other?
Thanks.
The main difference is more in setting than in getting. When setting focus (activating windows), you prefer the atom over the xlib function because then the window manager might handle your request differently - for example, if you want to activate a window that has a modal dialog up at the time, the WM might focus that dialog instead of the window itself, or if the user has disabled focus stealing, the WM might just highlight the window instead of actually focusing it.
There are a few small differences in getting too, based on the same idea, though I'm not sure exactly what all the differences are, I think it might be app specific. With programs I've written, getting the property and the focus return the same window. With Firefox though, it is returning two different windows - the active one is the window we expect, but the focus is on a hidden window instead. I don't know why it does that, but it does.
_NET_ACTIVE_WINDOW insulates you from those kind of application implementation details better than XGetInputFocus. Something like a window manager or a keyboard grabber might be interested in the specific details, but an app asking if it is active itself (or requesting to become active) ought to use the atom.
Read a bit more here too btw: http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472702304
No, they don't always point to the same thing.
_NET_ACTIVE_WINDOW is a WM thing. It will not point to a window not managed by the WM.
Input focus doesn't know or care about WMs (other than being set mostly by WMs). It can be set by any program at any time to any window: internal, override-redirect or even to an unrelated managed window (though few programs do that).
What you want to use very much depends on your exact needs. Normal apps should hardly use either. If you want to send keyboard events, use XGetInputFocus. In most other cases you probably want _NET_ACTIVE_WINDOW.
© 2022 - 2024 — McMap. All rights reserved.