nsIWindowMediator

IID:0659cb81-faad-11d2-8e19-b206620a657c
Inherits From:nsISupports

This interface is implemented by the following components:


Constants

PRUint32 zLevelTop = 1
PRUint32 zLevelBottom = 2
PRUint32 zLevelBelow = 3

Methods

void addListener ( nsIWindowMediatorListener listener ) [noscript] PRBool calculateZPosition ( nsIXULWindow inWindow , PRUint32 inPosition , nsIWidget inBelow , out PRUint32 outPosition , out nsIWidget outBelow ) nsISimpleEnumerator getEnumerator ( PRUnichar* windowType ) nsIDOMWindowInternal getMostRecentWindow ( PRUnichar* windowType ) nsISimpleEnumerator getXULWindowEnumerator ( PRUnichar* windowType ) [noscript] PRUint32 getZLevel ( nsIXULWindow window ) nsISimpleEnumerator getZOrderDOMWindowEnumerator ( PRUnichar* windowType , PRBool frontToBack ) nsISimpleEnumerator getZOrderXULWindowEnumerator ( PRUnichar* windowType , PRBool frontToBack ) [noscript] void registerWindow ( nsIXULWindow window ) void removeListener ( nsIWindowMediatorListener listener ) [noscript] void setZLevel ( nsIXULWindow window , PRUint32 ZLevel ) [noscript] void setZPosition ( nsIXULWindow inWindow , PRUint32 inPosition , nsIXULWindow inBelow ) [noscript] void unregisterWindow ( nsIXULWindow window ) [noscript] void updateWindowTimeStamp ( nsIXULWindow window ) [noscript] void updateWindowTitle ( nsIXULWindow window , PRUnichar* inTitle )

void addListener ( nsIWindowMediatorListener listener )

Register a listener for window status changes. keeps strong ref? (to be decided)

Arguments:
listener: the listener to register

PRBool calculateZPosition ( nsIXULWindow inWindow , PRUint32 inPosition , nsIWidget inBelow , out PRUint32 outPosition , out nsIWidget outBelow )

A window wants to be moved in z-order. Calculate whether and how it should be constrained. Note this method is advisory only: it changes nothing either in WindowMediator's internal state or with the window. Note it compares the nsIXULWindow to nsIWidgets. A pure interface would use all nsIXULWindows. But we expect this to be called from callbacks originating in native window code. They are expected to hand us comparison values which are pulled from general storage in the native widget, and may not correspond to an nsIWidget at all. For that reason this interface requires only objects one step removed from the native window (nsIWidgets), and its implementation must be very understanding of what may be completely invalid pointers in those parameters.

Arguments:
inWindow: the window in question
inPosition: requested position values: zLevelTop: topmost window. zLevelBottom: bottom. zLevelBelow: below ioBelow. (the value of ioBelow will be ignored for zLevelTop and Bottom.)
inBelow: if inPosition==zLevelBelow, the window below which inWindow wants to be placed. Otherwise this variable is ignored.
outPosition: constrained position, values like inPosition.
outBelow: if outPosition==zLevelBelow, the window below which inWindow should be placed. Otherwise this this value will be null.
Returns:
PR_TRUE if the position returned is different from the position given.

nsISimpleEnumerator getEnumerator ( PRUnichar* windowType )

Return an enumerator which iterates over all windows of type windowType from the oldest window to the youngest.

Arguments:
windowType: the returned enumerator will enumerate only windows of this type. ("type" is the |windowtype| attribute of the XML element.) If null, all windows will be enumerated.
Returns:
nsIDOMWindows

nsIDOMWindowInternal getMostRecentWindow ( PRUnichar* windowType )

This is a shortcut for simply fetching the first window in front to back order.

Arguments:
windowType: return the topmost window of this type. ("type" is the |windowtype| attribute of the XML element.) If null, return the topmost window of any type.
Returns:
the topmost window

nsISimpleEnumerator getXULWindowEnumerator ( PRUnichar* windowType )

Identical to getEnumerator except:

Arguments:
windowType
Returns:
nsIXULWindows

PRUint32 getZLevel ( nsIXULWindow window )

Return the window's Z level (as defined in nsIXULWindow).

Arguments:
window: the window in question
Returns:
aWindow's z level

nsISimpleEnumerator getZOrderDOMWindowEnumerator ( PRUnichar* windowType , PRBool frontToBack )

Return an enumerator which iterates over all windows of type windowType in their z (front-to-back) order. Note this interface makes no requirement that a window couldn't be revisited if windows are re-ordered while z-order enumerators are active.

Arguments:
windowType: the returned enumerator will enumerate only windows of this type. ("type" is the |windowtype| attribute of the XML element.) If null, all windows will be enumerated.
frontToBack: if true, the enumerator enumerates windows in order from front to back. back to front if false.
Returns:
nsIDOMWindows

nsISimpleEnumerator getZOrderXULWindowEnumerator ( PRUnichar* windowType , PRBool frontToBack )

Identical to getZOrderDOMWindowEnumerator except:

Arguments:
windowType
frontToBack
Returns:
nsIXULWindows

void registerWindow ( nsIXULWindow window )

Add the window to the list of known windows. Listeners (see addListener) will be notified through their onOpenWindow method.

Arguments:
window: the window to add

void removeListener ( nsIWindowMediatorListener listener )

Unregister a listener of window status changes.

Arguments:
listener: the listener to unregister

void setZLevel ( nsIXULWindow window , PRUint32 ZLevel )

Set the window's Z level (as defined in nsIXULWindow). The implementation will reposition the window as necessary to match its new Z level. The implementation will assume a window's Z level to be nsIXULWindow::normalZ until it has been informed of a different level.

Arguments:
window: the window in question
ZLevel: the window's new Z level

void setZPosition ( nsIXULWindow inWindow , PRUint32 inPosition , nsIXULWindow inBelow )

A window has been positioned behind another. Inform WindowMediator

Arguments:
inWindow: the window in question
inPosition: new position. values: zLevelTop: topmost window. zLevelBottom: bottom. zLevelBelow: below inBelow. (inBelow is ignored for other values of inPosition.)
inBelow: the window inWindow is behind, if zLevelBelow

void unregisterWindow ( nsIXULWindow window )

Remove the window from the list of known windows. Listeners (see addListener) will be be notified through their onCloseWindow method.

Arguments:
window: the window to remove

void updateWindowTimeStamp ( nsIXULWindow window )

Call this method when a window gains focus. It's a primitive means of determining the most recent window. It's no longer necessary and it really should be removed.

Arguments:
window: the window which has gained focus

void updateWindowTitle ( nsIXULWindow window , PRUnichar* inTitle )

Call this method when a window's title changes. Listeners (see addListener) will be notified through their onWindowTitleChange method.

Arguments:
window: the window whose title has changed
inTitle: the window's new title

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
September 4, 2005, 11:20 am refuse at wp dot pl
If you want to enumerate all HTML pages, then here is function for doing this:
function findAllHtmlDocuments() {
var ifaces = Components.interfaces;
var mediator =
Components.classes["@mozilla.org/appshell/window-mediator;1"].
getService(ifaces.nsIWindowMediator);
var winEnum = mediator.getXULWindowEnumerator(null);
while (winEnum.hasMoreElements()){
var win = winEnum.getNext();
if(!(win instanceof ifaces.nsIXULWindow)) {
continue;
}
var iface = ifaces.nsIDocShellTreeItem;
var docShellEnum = win.docShell.getDocShellEnumerator(
iface.typeAll, iface.ENUMERATE_FORWARDS);
dump("Window: (");
while(docShellEnum.hasMoreElements()) {
var docShell = docShellEnum.getNext();
if(docShell instanceof ifaces.nsIDocShell) {
var domDocument = docShell.contentViewer.DOMDocument;
if(domDocument instanceof HTMLDocument) {
dump("\n\t"+docShell);
dump("\t" + domDocument);
}
}
}
dump("\n)\n");
}
}


It will output to text console (you must have this enabled, etc.) "tree" of all Windows / HTMLDocuments.

Copyright © 1999 - 2005 XULPlanet.com