1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include
"nsISupports.idl"
7 #include
"nsISimpleEnumerator.idl"
10 #define NS_WINDOWMEDIATOR_CID \
11 { 0x79a2b7cc, 0xf05b, 0x4605, \
12 { 0xbf, 0xa0, 0xfa, 0xc5, 0x4f, 0x27, 0xee, 0xc8 } }
14 #define NS_WINDOWMEDIATOR_CONTRACTID \
15 "@mozilla.org/appshell/window-mediator;1"
18 interface mozIDOMWindow
;
19 interface mozIDOMWindowProxy
;
20 interface nsIAppWindow
;
22 interface nsIWindowMediatorListener
;
24 [scriptable
, uuid(df0da056
-357d
-427f
-bafd
-e6cbf19c9381
)]
25 interface nsIWindowMediator
: nsISupports
27 /** Return an enumerator which iterates over all windows of type aWindowType
28 * from the oldest window to the youngest.
29 * @param aWindowType the returned enumerator will enumerate only
30 * windows of this type. ("type" is the
31 * |windowtype| attribute of the XML <window> element.)
32 * If null, all windows will be enumerated.
33 * @return an enumerator of nsIDOMWindows. Note that windows close
34 * asynchronously in many cases, so windows returned from this
35 * enumerator can have .closed set to true. Caveat enumerator!
37 nsISimpleEnumerator getEnumerator
(in wstring aWindowType
);
39 /** Identical to getEnumerator except:
40 * @return an enumerator of nsIAppWindows
42 nsISimpleEnumerator getAppWindowEnumerator
(in wstring aWindowType
);
44 /** Return an enumerator which iterates over all windows of type aWindowType
45 * in their z (front-to-back) order. Note this interface makes
46 * no requirement that a window couldn't be revisited if windows
47 * are re-ordered while z-order enumerators are active.
48 * @param aWindowType the returned enumerator will enumerate only
49 * windows of this type. ("type" is the
50 * |windowtype| attribute of the XML <window> element.)
51 * If null, all windows will be enumerated.
52 * @param aFrontToBack if true, the enumerator enumerates windows in order
53 * from front to back. back to front if false.
54 * @return an enumerator of nsIAppWindows
56 nsISimpleEnumerator getZOrderAppWindowEnumerator
(in wstring aWindowType
,
57 in boolean aFrontToBack
);
59 /** This is a shortcut for simply fetching the first window in
60 * front to back order.
61 * @param aWindowType return the topmost window of this type.
62 * ("type" is the |windowtype| attribute of
63 * the XML <window> element.)
64 * If null, return the topmost window of any type.
65 * @return the topmost window
67 mozIDOMWindowProxy getMostRecentWindow
(in wstring aWindowType
);
69 /** This is a shortcut for getMostRecentWindow('navigator:browser'), but
70 * if that fails it also tries 'navigator:geckoview' and 'mail:3pane'.
72 * @return the topmost browser window
74 mozIDOMWindowProxy getMostRecentBrowserWindow
();
77 * Same as getMostRecentWindow, but ignores private browsing
80 mozIDOMWindowProxy getMostRecentNonPBWindow
(in wstring aWindowType
);
83 * Return the outer window with the given ID, if any. Can return null.
85 mozIDOMWindowProxy getOuterWindowWithId
(in unsigned long long aOuterWindowID
);
88 * Return the inner window with the given current window ID, if any.
89 * Can return null if no inner window with the ID exists or if it's not
90 * a current inner anymore.
92 mozIDOMWindow getCurrentInnerWindowWithId
(in unsigned long long aInnerWindowID
);
94 /** Add the window to the list of known windows. Listeners (see
95 * addListener) will be notified through their onOpenWindow method.
96 * @param aWindow the window to add
98 [noscript
] void registerWindow
(in nsIAppWindow aWindow
);
100 /** Remove the window from the list of known windows. Listeners (see
101 * addListener) will be be notified through their onCloseWindow method.
102 * @param aWindow the window to remove
104 [noscript
] void unregisterWindow
(in nsIAppWindow aWindow
);
106 /** Call this method when a window gains focus. It's a primitive means of
107 * determining the most recent window. It's no longer necessary and it
108 * really should be removed.
109 * @param aWindow the window which has gained focus
111 [noscript
] void updateWindowTimeStamp
(in nsIAppWindow aWindow
);
115 const unsigned long zLevelTop
= 1;
116 const unsigned long zLevelBottom
= 2;
117 const unsigned long zLevelBelow
= 3; // below some window
119 /** A window wants to be moved in z-order. Calculate whether and how
120 * it should be constrained. Note this method is advisory only:
121 * it changes nothing either in WindowMediator's internal state
122 * or with the window.
123 * Note it compares the nsIAppWindow to nsIWidgets. A pure interface
124 * would use all nsIAppWindows. But we expect this to be called from
125 * callbacks originating in native window code. They are expected to
126 * hand us comparison values which are pulled from general storage
127 * in the native widget, and may not correspond to an nsIWidget at all.
128 * For that reason this interface requires only objects one step
129 * removed from the native window (nsIWidgets), and its implementation
130 * must be very understanding of what may be completely invalid
131 * pointers in those parameters.
133 * @param inWindow the window in question
134 * @param inPosition requested position
135 * values: zLevelTop: topmost window. zLevelBottom: bottom.
136 * zLevelBelow: below ioBelow. (the value of ioBelow will
137 * be ignored for zLevelTop and Bottom.)
138 * @param inBelow if inPosition==zLevelBelow, the window
139 * below which inWindow wants to be placed. Otherwise this
140 * variable is ignored.
141 * @param outPosition constrained position, values like inPosition.
142 * @param outBelow if outPosition==zLevelBelow, the window
143 * below which inWindow should be placed. Otherwise this
144 * this value will be null.
145 * @return PR_TRUE if the position returned is different from
146 * the position given.
149 [noscript
] boolean calculateZPosition
(in nsIAppWindow inWindow
,
150 in unsigned long inPosition
,
151 in nsIWidget inBelow
,
152 out unsigned long outPosition
,
153 out nsIWidget outBelow
);
155 /** A window has been positioned behind another. Inform WindowMediator
156 * @param inWindow the window in question
157 * @param inPosition new position. values:
158 * zLevelTop: topmost window.
159 * zLevelBottom: bottom.
160 * zLevelBelow: below inBelow. (inBelow is ignored
161 * for other values of inPosition.)
162 * @param inBelow the window inWindow is behind, if zLevelBelow
164 [noscript
] void setZPosition
(in nsIAppWindow inWindow
,
165 in unsigned long inPosition
,
166 in nsIAppWindow inBelow
);
168 /** Return the window's Z level (as defined in nsIAppWindow).
169 * @param aWindow the window in question
170 * @return aWindow's z level
172 [noscript
] uint32_t getZLevel
(in nsIAppWindow aWindow
);
174 /** Set the window's Z level (as defined in nsIAppWindow). The implementation
175 * will reposition the window as necessary to match its new Z level.
176 * The implementation will assume a window's Z level to be
177 * nsIAppWindow::normalZ until it has been informed of a different level.
178 * @param aWindow the window in question
179 * @param aZLevel the window's new Z level
181 [noscript
] void setZLevel
(in nsIAppWindow aWindow
, in uint32_t aZLevel
);
183 /** Register a listener for window status changes.
184 * keeps strong ref? (to be decided)
185 * @param aListener the listener to register
187 void addListener
(in nsIWindowMediatorListener aListener
);
189 /** Unregister a listener of window status changes.
190 * @param aListener the listener to unregister
192 void removeListener
(in nsIWindowMediatorListener aListener
);