X Window 系统上的顶级窗口

发布于 2024-08-24 20:28:45 字数 311 浏览 2 评论 0原文

我想在屏幕上打印Linux下顶级窗口的信息。

我使用 xlib 函数。我成功地从根窗口递归打印有关显示的所有元素的所有信息。

但我只需要顶级窗口。我没有找到什么好的过滤方法。

来自维基百科:

顶层窗口正是 根窗口的直接子窗口。

根据这个定义,我的列表中有一些窗口,例如:gnome-session、seahorse-daemon、notify-osd 或图标,但我不需要它们。

我还找到了一个函数:XmuClientWindow,但我不明白它的目标。

I want to print on the screen the information about Top level windows under Linux.

I use the xlib functions. I successfully recurse from the root window to print all the informations about all the element on display.

But I need only the Top-Level window. I don't find any good way to filter.

From wikipedia :

The top-level windows are exactly the
direct subwindows of the root window.

With that definition , I have some windows like: gnome-session, seahorse-daemon,notify-osd or icons, on my list and i don't want them.

I also find a function : XmuClientWindow, but I don't understand its goal.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

少女情怀诗 2024-08-31 20:28:45

让我们看看我是否正确理解你想要什么。顶层窗口是根窗口的直接子窗口,或者是虚拟根窗口的某些窗口管理器 - 请参阅 根窗口(维基百科),您似乎已经找到了。该文章还告诉您如何查找虚拟根窗口列表。您可以在根或虚拟根上使用 XQueryTree 来查找子窗口列表。

一旦你有了这个列表,你可能需要应用大量令人讨厌的启发式方法来找到你感兴趣的窗口。 XmuClientWindow 将告诉您哪个应用程序窗口(如果有)与您的顶级窗口关联。应用程序创建窗口,窗口管理器reparent它们成为顶级窗口的子窗口,他们创建用于容纳窗户装饰和物品(最大化按钮、关闭按钮、调整手柄大小)。从客户端/应用程序窗口读取扩展窗口管理器提示可以告诉您诸如您是否正在处理特殊窗口(停靠栏、面板等)之类的信息。您可能还想查看应用程序窗口上的窗口管理器提示(XGetWMHints(3)、XGetWMNormalHints(3)、XGetWMSizeHints(3))来决定您是否感兴趣 - 窗口管理器会创建许多您需要的瞬态窗口。可能不关心。

请参阅无缝代码 VirtualBox Guest Additions 是查看顶层窗口的示例。

Let's see if I understand correctly what you want. The top level windows are the direct children of the root window, or with some window managers of a virtual root window - see Root Window (Wikipedia), which you seem to have found already. That article also tells you how to find the list of virtual root windows. You can use XQueryTree on the root or a virtual root to find the list of child windows.

Once you have that list you will probably need to apply lots of nasty heuristics to find the windows which interest you. XmuClientWindow will tell you which application window (if any) is associated with your top-level window. Applications create windows, and window managers reparent them to be children of a top-level window which they create to hold window decorations and things (maximise button, close button, resize handles). Reading the extended window manager hints from the client/application window can tell you things like whether you are dealing with a special window (dock, panel, whatever). You may also want to look at the window manager hints on the application window (XGetWMHints(3), XGetWMNormalHints(3), XGetWMSizeHints(3)) to decide whether it interests you or not - Window managers create a lot of transient windows that you probably don't care about.

See the seamless code in the VirtualBox Guest Additions for an example of looking through top-level windows.

篱下浅笙歌 2024-08-31 20:28:45
wmctrl -l 

这个简单的命令将列出 root 下的所有顶级窗口。

wmctrl -l 

This simple command will list all toplevel windows under root.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文