我需要获取桌面中显示或隐藏的所有窗口的列表 [英] I need to get the list of all the windows displayed or hidden in the desktop

查看:28
本文介绍了我需要获取桌面中显示或隐藏的所有窗口的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 X11 相关库(例如 XlibXrandr)编写代码.

I'm trying to code something using X11 related libraries such as Xlib and Xrandr.

一开始我期待全面覆盖真正的基本功能,例如仅从 Xlib 检索显示器的刷新率,后来我发现我需要 Xrandr.

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.

现在我需要获取桌面中显示或隐藏的所有窗口的列表,我不考虑使用 Gnome/KDE/XFCE ... 扩展,因为我知道那些只是 X11 的装饰器,但我无法真正找到能够枚举 X 服务器中打开的窗口的函数或宏.我还需要获取焦点所在窗口的 ID/名称.

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. I also need to get the ID/name of the window that is under focus.

我的问题是:只有 Xlib 才能做到这一点?因为从Xlib采用的术语来看,我怀疑这个函数可能存在.

My question is: Xlib alone is capable of doing this ? Because from the terminology that Xlib adopts, I have my doubts that this functions could possibly even exist.

推荐答案

您可以使用 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.

这篇关于我需要获取桌面中显示或隐藏的所有窗口的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆