How do I obtain, and synchronize, a complete list of all X11 windows?

后端 未结 3 1685
无人及你
无人及你 2020-12-13 01:03

I want to monitor all the open windows under X11. Currently, I\'m doing this as follows:

  1. Initially walking the whole tree by recursively calling XQueryTree fro
相关标签:
3条回答
  • 2020-12-13 01:34

    X11 is a remote protocol. This means when you query the X server for any information, you always get your own copy. Your copy never changes when the X server updates its internal data structures.

    This means the tree won't suddenly change while you traverse it but when you use the information in it (like examining a window), that information might be stale (someone might have closed the window). That is why you need to do proper error handling.

    0 讨论(0)
  • 2020-12-13 01:39

    I believe that grabbing the X server (XGrabServer(3)) will prevent changes to the window hierarchy. It is a bit heavy handed though, so you should probably only do it if you really need it.

    For an example of code that walks the window hierarchy, builds up a tree, uses window events to keep it up to date, and ignores X protocol errors which are unavoidable due to races, see the file src/VBox/Additions/x11/VBoxClient/seamless-x11.cpp in the source code for VirtualBox.

    0 讨论(0)
  • 2020-12-13 01:49

    Have a look at xwininfo.

    You might also like xprop and xspy for getting more info.

    Update: Yep. Try using xwininfo and -root with either -tree or -children to get all windows involved.

    And changes can be tracked with xprop -spy.

    0 讨论(0)
提交回复
热议问题