获取X11下的Firefox窗口标识(WId) [英] Get a Firefox's window id (WId) under X11
问题描述
检出 nsIWindowMediator
, nsIXULBrowserWindow
, nsIXULWindow
,但还没有找到。
我宁愿不使用(ab)的常用方式来使用Xlib在窗口树中搜索匹配当前窗口的属性(如标题,类型等)的窗口树。
我认为唯一可以得到它的地方是 nsIEmbeddingSiteWindow.siteWindow (其类型为 GtkWidget *
在Linux上,应该可以从中获得窗口ID)。为顶级窗口获取 nsIEmbeddingSiteWindow
实例相对简单: > Components.utils.import( 资源://gre/modules/Services.jsm);
var embedding = Services.ww.getChromeForWindow(window)
.QueryInterface(Components.interfaces.nsIEmbeddingSiteWindow);
问题在于 siteWindow
属性是标记为 [noscript]
annotator - 不能从JavaScript访问。所以我不得不使用二进制XPCOM组件(用C ++编写)来实际检索该属性。不知道这是否是一个可以接受的解决方案。唯一的选择应该是搜索窗口树。
I'm trying to find out how to get a Firefox's X11 WId (window id) from within a Firefox addon/extension.
Checked out nsIWindowMediator
, nsIXULBrowserWindow
, nsIXULWindow
but haven't found it.
I'd rather not go the usual way of (ab)using Xlib to search the window tree for one that matches the attributes of the current window like title, type and so on.
I think that the only place where you can get it is nsIEmbeddingSiteWindow.siteWindow (its type is GtkWidget*
on Linux, it should be possible to get the window id from that). Getting an nsIEmbeddingSiteWindow
instance for a top-level window is relatively straightforward:
Components.utils.import("resource://gre/modules/Services.jsm");
var embedding = Services.ww.getChromeForWindow(window)
.QueryInterface(Components.interfaces.nsIEmbeddingSiteWindow);
The problem is that the siteWindow
property is marked with the [noscript]
annotator - it isn't accessible from JavaScript. So I had to use a binary XPCOM component (written in C++) to actually retrieve that property. Don't know whether that's an acceptable solution for you. The only alternative should be searching the window tree indeed.
这篇关于获取X11下的Firefox窗口标识(WId)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!