简体   繁体   English

我需要获取桌面中显示或隐藏的所有窗口的列表

[英]I need to get the list of all the windows displayed or hidden in the desktop

I'm trying to code something using X11 related libraries such as Xlib and Xrandr .我正在尝试使用 X11 相关库(例如XlibXrandr编写代码。

At first I was expecting a full coverage of the real basic functions such as retrieving the refresh rate from the monitors from Xlib alone, later on I find out that I need Xrandr for that.起初,我期待全面覆盖真正的基本功能,例如仅从Xlib检索显示器的刷新率,后来我发现我需要Xrandr

Now I need to get the list of all the windows displayed or hidden in the desktop, I'm not thinking about using Gnome/KDE/XFCE ... extensions because I know that those are just decorators for X11, but I can't really find a function or a macro that is able to enumerate the open windows in the X server.现在我需要获取桌面中显示或隐藏的所有窗口的列表,我不考虑使用 Gnome/KDE/XFCE ... 扩展,因为我知道那些只是 X11 的装饰器,但我不能真正找到能够枚举 X 服务器中打开的窗口的函数或宏。 I also need to get the ID/name of the window that is under focus.我还需要获取焦点窗口的 ID/名称。

My question is: Xlib alone is capable of doing this ?我的问题是:仅Xlib就能够做到这一点? Because from the terminology that Xlib adopts, I have my doubts that this functions could possibly even exist.因为从Xlib采用的术语来看,我怀疑这个函数可能存在。

You can get a list of child windows with XQueryTree您可以使用XQueryTree获取子窗口列表

XQueryTree - query window tree information

Status XQueryTree(Display *display, Window w, Window *root_return, Window *parent_return, Window **children_return, unsigned int *nchildren_return);

So, to get a complete list, you'll have to start with the root window and recursively call it for all the children of each window.因此,要获得完整列表,您必须从根窗口开始,并为每个窗口的所有子窗口递归调用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM