1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1999
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38 #include "nsISupports.idl"
39 #include "nsISimpleEnumerator.idl"
40
41 %{C++
42 #define NS_WINDOWMEDIATOR_CID \
43 { 0x0659cb83, 0xfaad, 0x11d2, { 0x8e, 0x19, 0xb2, 0x06, 0x62, 0x0a, 0x65, 0x7c } }
44
45 #define NS_WINDOWMEDIATOR_CONTRACTID \
46 "@mozilla.org/appshell/window-mediator;1"
47 %}
48
49 interface nsIXULWindow;
50 interface nsIWidget;
51 interface nsIDOMWindowInternal;
52 interface nsIWindowMediatorListener;
53
54 [scriptable, uuid(0659cb81-faad-11d2-8e19-b206620a657c)]
55 interface nsIWindowMediator: nsISupports
56 {
57 /** Return an enumerator which iterates over all windows of type aWindowType
58 * from the oldest window to the youngest.
59 * @param aWindowType the returned enumerator will enumerate only
60 * windows of this type. ("type" is the
61 * |windowtype| attribute of the XML <window> element.)
62 * If null, all windows will be enumerated.
63 * @return an enumerator of nsIDOMWindows
64 */
65 nsISimpleEnumerator getEnumerator(in wstring aWindowType);
66
67 /** Identical to getEnumerator except:
68 * @return an enumerator of nsIXULWindows
69 */
70 nsISimpleEnumerator getXULWindowEnumerator(in wstring aWindowType);
71
72 /** Return an enumerator which iterates over all windows of type aWindowType
73 * in their z (front-to-back) order. Note this interface makes
74 * no requirement that a window couldn't be revisited if windows
75 * are re-ordered while z-order enumerators are active.
76 * @param aWindowType the returned enumerator will enumerate only
77 * windows of this type. ("type" is the
78 * |windowtype| attribute of the XML <window> element.)
79 * If null, all windows will be enumerated.
80 * @param aFrontToBack if true, the enumerator enumerates windows in order
81 * from front to back. back to front if false.
82 * @return an enumerator of nsIDOMWindows
83 */
84 nsISimpleEnumerator getZOrderDOMWindowEnumerator(in wstring aWindowType,
85 in boolean aFrontToBack);
86
87 /** Identical to getZOrderDOMWindowEnumerator except:
88 * @return an enumerator of nsIXULWindows
89 */
90 nsISimpleEnumerator getZOrderXULWindowEnumerator(in wstring aWindowType,
91 in boolean aFrontToBack);
92
93 /** This is a shortcut for simply fetching the first window in
94 * front to back order.
95 * @param aWindowType return the topmost window of this type.
96 * ("type" is the |windowtype| attribute of
97 * the XML <window> element.)
98 * If null, return the topmost window of any type.
99 * @return the topmost window
100 */
101 nsIDOMWindowInternal getMostRecentWindow(in wstring aWindowType);
102
103 /** Add the window to the list of known windows. Listeners (see
104 * addListener) will be notified through their onOpenWindow method.
105 * @param aWindow the window to add
106 */
107 [noscript] void registerWindow(in nsIXULWindow aWindow);
108
109 /** Remove the window from the list of known windows. Listeners (see
110 * addListener) will be be notified through their onCloseWindow method.
111 * @param aWindow the window to remove
112 */
113 [noscript] void unregisterWindow(in nsIXULWindow aWindow);
114
115 /** Call this method when a window gains focus. It's a primitive means of
116 * determining the most recent window. It's no longer necessary and it
117 * really should be removed.
118 * @param aWindow the window which has gained focus
119 */
120 [noscript] void updateWindowTimeStamp(in nsIXULWindow aWindow);
121
122 /** Call this method when a window's title changes. Listeners (see
123 * addListener) will be notified through their onWindowTitleChange method.
124 * @param aWindow the window whose title has changed
125 * @param inTitle the window's new title
126 */
127 [noscript] void updateWindowTitle(in nsIXULWindow aWindow,
128 in wstring inTitle );
129
130 /* z-ordering: */
131
132 const unsigned long zLevelTop = 1;
133 const unsigned long zLevelBottom = 2;
134 const unsigned long zLevelBelow = 3; // below some window
135
136 /** A window wants to be moved in z-order. Calculate whether and how
137 * it should be constrained. Note this method is advisory only:
138 * it changes nothing either in WindowMediator's internal state
139 * or with the window.
140 * Note it compares the nsIXULWindow to nsIWidgets. A pure interface
141 * would use all nsIXULWindows. But we expect this to be called from
142 * callbacks originating in native window code. They are expected to
143 * hand us comparison values which are pulled from general storage
144 * in the native widget, and may not correspond to an nsIWidget at all.
145 * For that reason this interface requires only objects one step
146 * removed from the native window (nsIWidgets), and its implementation
147 * must be very understanding of what may be completely invalid
148 * pointers in those parameters.
149 *
150 * @param inWindow the window in question
151 * @param inPosition requested position
152 * values: zLevelTop: topmost window. zLevelBottom: bottom.
153 * zLevelBelow: below ioBelow. (the value of ioBelow will
154 * be ignored for zLevelTop and Bottom.)
155 * @param inBelow if inPosition==zLevelBelow, the window
156 * below which inWindow wants to be placed. Otherwise this
157 * variable is ignored.
158 * @param outPosition constrained position, values like inPosition.
159 * @param outBelow if outPosition==zLevelBelow, the window
160 * below which inWindow should be placed. Otherwise this
161 * this value will be null.
162 * @return PR_TRUE if the position returned is different from
163 * the position given.
164 */
165
166 [noscript] boolean calculateZPosition(in nsIXULWindow inWindow,
167 in unsigned long inPosition,
168 in nsIWidget inBelow,
169 out unsigned long outPosition,
170 out nsIWidget outBelow);
171
172 /** A window has been positioned behind another. Inform WindowMediator
173 * @param inWindow the window in question
174 * @param inPosition new position. values:
175 * zLevelTop: topmost window.
176 * zLevelBottom: bottom.
177 * zLevelBelow: below inBelow. (inBelow is ignored
178 * for other values of inPosition.)
179 * @param inBelow the window inWindow is behind, if zLevelBelow
180 */
181 [noscript] void setZPosition(in nsIXULWindow inWindow,
182 in unsigned long inPosition,
183 in nsIXULWindow inBelow);
184
185 /** Return the window's Z level (as defined in nsIXULWindow).
186 * @param aWindow the window in question
187 * @return aWindow's z level
188 */
189 [noscript] PRUint32 getZLevel(in nsIXULWindow aWindow);
190
191 /** Set the window's Z level (as defined in nsIXULWindow). The implementation
192 * will reposition the window as necessary to match its new Z level.
193 * The implementation will assume a window's Z level to be
194 * nsIXULWindow::normalZ until it has been informed of a different level.
195 * @param aWindow the window in question
196 * @param aZLevel the window's new Z level
197 */
198 [noscript] void setZLevel(in nsIXULWindow aWindow, in PRUint32 aZLevel);
199
200 /** Register a listener for window status changes.
201 * keeps strong ref? (to be decided)
202 * @param aListener the listener to register
203 */
204 void addListener(in nsIWindowMediatorListener aListener);
205
206 /** Unregister a listener of window status changes.
207 * @param aListener the listener to unregister
208 */
209 void removeListener(in nsIWindowMediatorListener aListener);
210 };