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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.