Get Firefox Window ID (WId) under X11

I am trying to figure out how to get the Firefox X11 WId (window id) from the Firefox add-on / extension.

Checked nsIWindowMediator, nsIXULBrowserWindow, nsIXULWindowbut not found.

I would prefer not to use the usual (ab) method with Xlib to search in the window tree that matches the attributes of the current window, such as type, type, etc.

0
source share
1 answer

I think the only place you can get it is nsIEmbeddingSiteWindow.siteWindow (its type is GtkWidget*on Linux, it should be possible to get the window id from this). Getting an instance nsIEmbeddingSiteWindowfor a top-level window is relatively simple:

Components.utils.import("resource://gre/modules/Services.jsm");

var embedding = Services.ww.getChromeForWindow(window)
                  .QueryInterface(Components.interfaces.nsIEmbeddingSiteWindow);

The problem is that the property is siteWindowmarked with an annotator [noscript]- it is not accessible from JavaScript. So I had to use the XPCOM binary component (written in C ++) in order to actually get this property. I don't know if this is right for you. The only alternative is to search the window tree.

0
source

Source: https://habr.com/ru/post/1756804/


All Articles