In the extension, Splashed!, I was able to keep the splash window as topmost using
js-ctypes. The approach I currently have
here works only for Windows, I haven't explored any solutions yet for the other platforms.
The following code should be sufficient enough to make the caller XUL window topmost, at least on Windows:
Code: Select all
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/ctypes.jsm");
try {
let lib = ctypes.open("user32.dll");
let setWindowPos = lib.declare("SetWindowPos",
ctypes.winapi_abi,
ctypes.bool,
ctypes.voidptr_t,
ctypes.int32_t,
ctypes.int32_t,
ctypes.int32_t,
ctypes.int32_t,
ctypes.int32_t,
ctypes.uint32_t);
let baseWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.treeOwner
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIBaseWindow);
let hWndString = baseWindow.nativeHandle;
let hWnd = ctypes.voidptr_t(ctypes.UInt64(hWndString));
setWindowPos(hWnd, -1, 0, 0, 0, 0, 19);
lib.close();
} catch (e) {}