如何按标题查找gtkwindow [英] How to find a gtkwindow by title

查看:120
本文介绍了如何按标题查找gtkwindow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ubuntu.我正在编写一个用于捕获gtkwindow屏幕截图的应用程序.但是现在,我无法通过窗口标题获得gtkwindow指针.有没有办法通过标题找到gtkwindow?

I'm working on the Ubuntu. I'm writing an app to capture a gtkwindow screen shot. But now, I can't get the gtkwindow pointer by the window title. Is there way to find a gtkwindow by the title?

推荐答案

Gtk没有执行此操作的API.您只能为自己创建的Windows获取GtkWindow对象.您必须做得更底层,并直接使用xlib.首先,您必须获得要用于显示的Display对象(基本上是一个表示与Xserver的连接的对象,这是必需的,因为Xclient可以一次在多个Xserver上显示窗口).如果您对获取特定屏幕没有任何其他了解,请使用gdk_x11_get_default_xdisplay()获取默认屏幕.然后,使用DefaultRootWindow()获得根窗口.要获取子窗口的列表,请使用XQueryTree().要获取要比较的窗口名称,请使用XFetchName().请注意,在X上下文中的窗口与被视为窗口的窗口并不相同.窗口管理器框架是包含实际应用程序窗口作为子窗口的窗口(有时处于多重级别),因此可能需要递归使用XQueryTree().

Gtk has no API for doing this. You only get GtkWindow objects for windows you create yourself. You have to do it more low level and use xlib directly. First you must get the Display object for the your display (basically an object representing the connection to your Xserver and is needed because an Xclient can show windows on several Xservers at once). Use gdk_x11_get_default_xdisplay() to get the default screen if you don't have any other ide of how to get a certain screen. Then you get the root window with DefaultRootWindow(). To get a list of child windows use XQueryTree(). And to get the name of the window for comparison use XFetchName(). Note that windows in the context of X is not identical to what is perceived as windows. The window manager frames are windows (sometimes in multible levels) containing the actual application windows as children so XQueryTree() might need to be used recurively.

您可能还对 libwnck 感兴趣,可以简化这一点.

You might also be interested in libwnck which can simplify this a bit.

这篇关于如何按标题查找gtkwindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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