michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: #include "nsISimpleEnumerator.idl" michael@0: michael@0: %{C++ michael@0: #define NS_WINDOWMEDIATOR_CID \ michael@0: { 0x79a2b7cc, 0xf05b, 0x4605, \ michael@0: { 0xbf, 0xa0, 0xfa, 0xc5, 0x4f, 0x27, 0xee, 0xc8 } } michael@0: michael@0: #define NS_WINDOWMEDIATOR_CONTRACTID \ michael@0: "@mozilla.org/appshell/window-mediator;1" michael@0: %} michael@0: michael@0: interface nsIXULWindow; michael@0: interface nsIWidget; michael@0: interface nsIDOMWindow; michael@0: interface nsIWindowMediatorListener; michael@0: michael@0: [scriptable, uuid(30cda5a1-a6df-4f32-9a73-0e59a32928c5)] michael@0: interface nsIWindowMediator: nsISupports michael@0: { michael@0: /** Return an enumerator which iterates over all windows of type aWindowType michael@0: * from the oldest window to the youngest. michael@0: * @param aWindowType the returned enumerator will enumerate only michael@0: * windows of this type. ("type" is the michael@0: * |windowtype| attribute of the XML element.) michael@0: * If null, all windows will be enumerated. michael@0: * @return an enumerator of nsIDOMWindows. Note that windows close michael@0: * asynchronously in many cases, so windows returned from this michael@0: * enumerator can have .closed set to true. Caveat enumerator! michael@0: */ michael@0: nsISimpleEnumerator getEnumerator(in wstring aWindowType); michael@0: michael@0: /** Identical to getEnumerator except: michael@0: * @return an enumerator of nsIXULWindows michael@0: */ michael@0: nsISimpleEnumerator getXULWindowEnumerator(in wstring aWindowType); michael@0: michael@0: /** Return an enumerator which iterates over all windows of type aWindowType michael@0: * in their z (front-to-back) order. Note this interface makes michael@0: * no requirement that a window couldn't be revisited if windows michael@0: * are re-ordered while z-order enumerators are active. michael@0: * @param aWindowType the returned enumerator will enumerate only michael@0: * windows of this type. ("type" is the michael@0: * |windowtype| attribute of the XML element.) michael@0: * If null, all windows will be enumerated. michael@0: * @param aFrontToBack if true, the enumerator enumerates windows in order michael@0: * from front to back. back to front if false. michael@0: * @return an enumerator of nsIDOMWindows michael@0: */ michael@0: nsISimpleEnumerator getZOrderDOMWindowEnumerator(in wstring aWindowType, michael@0: in boolean aFrontToBack); michael@0: michael@0: /** Identical to getZOrderDOMWindowEnumerator except: michael@0: * @return an enumerator of nsIXULWindows michael@0: */ michael@0: nsISimpleEnumerator getZOrderXULWindowEnumerator(in wstring aWindowType, michael@0: in boolean aFrontToBack); michael@0: michael@0: /** This is a shortcut for simply fetching the first window in michael@0: * front to back order. michael@0: * @param aWindowType return the topmost window of this type. michael@0: * ("type" is the |windowtype| attribute of michael@0: * the XML element.) michael@0: * If null, return the topmost window of any type. michael@0: * @return the topmost window michael@0: */ michael@0: nsIDOMWindow getMostRecentWindow(in wstring aWindowType); michael@0: michael@0: /** michael@0: * Return the outer window with the given ID, if any. Can return null. michael@0: */ michael@0: nsIDOMWindow getOuterWindowWithId(in unsigned long long aOuterWindowID); michael@0: michael@0: /** michael@0: * Return the outer window with the given current window ID, if any. michael@0: * Can return null if no inner window with the ID exists or if it's not michael@0: * a current inner anymore. michael@0: */ michael@0: nsIDOMWindow getCurrentInnerWindowWithId(in unsigned long long aInnerWindowID); michael@0: michael@0: /** Add the window to the list of known windows. Listeners (see michael@0: * addListener) will be notified through their onOpenWindow method. michael@0: * @param aWindow the window to add michael@0: */ michael@0: [noscript] void registerWindow(in nsIXULWindow aWindow); michael@0: michael@0: /** Remove the window from the list of known windows. Listeners (see michael@0: * addListener) will be be notified through their onCloseWindow method. michael@0: * @param aWindow the window to remove michael@0: */ michael@0: [noscript] void unregisterWindow(in nsIXULWindow aWindow); michael@0: michael@0: /** Call this method when a window gains focus. It's a primitive means of michael@0: * determining the most recent window. It's no longer necessary and it michael@0: * really should be removed. michael@0: * @param aWindow the window which has gained focus michael@0: */ michael@0: [noscript] void updateWindowTimeStamp(in nsIXULWindow aWindow); michael@0: michael@0: /** Call this method when a window's title changes. Listeners (see michael@0: * addListener) will be notified through their onWindowTitleChange method. michael@0: * @param aWindow the window whose title has changed michael@0: * @param inTitle the window's new title michael@0: */ michael@0: [noscript] void updateWindowTitle(in nsIXULWindow aWindow, michael@0: in wstring inTitle ); michael@0: michael@0: /* z-ordering: */ michael@0: michael@0: const unsigned long zLevelTop = 1; michael@0: const unsigned long zLevelBottom = 2; michael@0: const unsigned long zLevelBelow = 3; // below some window michael@0: michael@0: /** A window wants to be moved in z-order. Calculate whether and how michael@0: * it should be constrained. Note this method is advisory only: michael@0: * it changes nothing either in WindowMediator's internal state michael@0: * or with the window. michael@0: * Note it compares the nsIXULWindow to nsIWidgets. A pure interface michael@0: * would use all nsIXULWindows. But we expect this to be called from michael@0: * callbacks originating in native window code. They are expected to michael@0: * hand us comparison values which are pulled from general storage michael@0: * in the native widget, and may not correspond to an nsIWidget at all. michael@0: * For that reason this interface requires only objects one step michael@0: * removed from the native window (nsIWidgets), and its implementation michael@0: * must be very understanding of what may be completely invalid michael@0: * pointers in those parameters. michael@0: * michael@0: * @param inWindow the window in question michael@0: * @param inPosition requested position michael@0: * values: zLevelTop: topmost window. zLevelBottom: bottom. michael@0: * zLevelBelow: below ioBelow. (the value of ioBelow will michael@0: * be ignored for zLevelTop and Bottom.) michael@0: * @param inBelow if inPosition==zLevelBelow, the window michael@0: * below which inWindow wants to be placed. Otherwise this michael@0: * variable is ignored. michael@0: * @param outPosition constrained position, values like inPosition. michael@0: * @param outBelow if outPosition==zLevelBelow, the window michael@0: * below which inWindow should be placed. Otherwise this michael@0: * this value will be null. michael@0: * @return PR_TRUE if the position returned is different from michael@0: * the position given. michael@0: */ michael@0: michael@0: [noscript] boolean calculateZPosition(in nsIXULWindow inWindow, michael@0: in unsigned long inPosition, michael@0: in nsIWidget inBelow, michael@0: out unsigned long outPosition, michael@0: out nsIWidget outBelow); michael@0: michael@0: /** A window has been positioned behind another. Inform WindowMediator michael@0: * @param inWindow the window in question michael@0: * @param inPosition new position. values: michael@0: * zLevelTop: topmost window. michael@0: * zLevelBottom: bottom. michael@0: * zLevelBelow: below inBelow. (inBelow is ignored michael@0: * for other values of inPosition.) michael@0: * @param inBelow the window inWindow is behind, if zLevelBelow michael@0: */ michael@0: [noscript] void setZPosition(in nsIXULWindow inWindow, michael@0: in unsigned long inPosition, michael@0: in nsIXULWindow inBelow); michael@0: michael@0: /** Return the window's Z level (as defined in nsIXULWindow). michael@0: * @param aWindow the window in question michael@0: * @return aWindow's z level michael@0: */ michael@0: [noscript] uint32_t getZLevel(in nsIXULWindow aWindow); michael@0: michael@0: /** Set the window's Z level (as defined in nsIXULWindow). The implementation michael@0: * will reposition the window as necessary to match its new Z level. michael@0: * The implementation will assume a window's Z level to be michael@0: * nsIXULWindow::normalZ until it has been informed of a different level. michael@0: * @param aWindow the window in question michael@0: * @param aZLevel the window's new Z level michael@0: */ michael@0: [noscript] void setZLevel(in nsIXULWindow aWindow, in uint32_t aZLevel); michael@0: michael@0: /** Register a listener for window status changes. michael@0: * keeps strong ref? (to be decided) michael@0: * @param aListener the listener to register michael@0: */ michael@0: void addListener(in nsIWindowMediatorListener aListener); michael@0: michael@0: /** Unregister a listener of window status changes. michael@0: * @param aListener the listener to unregister michael@0: */ michael@0: void removeListener(in nsIWindowMediatorListener aListener); michael@0: };