Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: components/mus/public/interfaces/window_tree.mojom

Issue 2119963002: Move mus to //services/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 module mus.mojom;
6
7 import "cc/ipc/surface_id.mojom";
8 import "components/mus/public/interfaces/cursor.mojom";
9 import "components/mus/public/interfaces/event_matcher.mojom";
10 import "components/mus/public/interfaces/mus_constants.mojom";
11 import "components/mus/public/interfaces/surface.mojom";
12 import "components/mus/public/interfaces/window_manager.mojom";
13 import "components/mus/public/interfaces/window_manager_constants.mojom";
14 import "components/mus/public/interfaces/window_tree_constants.mojom";
15 import "ui/events/mojo/event.mojom";
16 import "ui/gfx/geometry/mojo/geometry.mojom";
17 import "ui/platform_window/mojo/text_input_state.mojom";
18
19 // Windows are identified by a uint32. The upper 16 bits are the connection id,
20 // and the lower 16 the id assigned by the client.
21 //
22 // The root window is identified with a connection id of 0, and value of 1.
23 //
24 // Most functions to the WindowTree take a change_id parameter. When
25 // WindowTree completes processing of a function WindowTree calls
26 // WindowTreeClient::OnChangeCompleted() with the change_id supplied by the
27 // client and the result of the function. This allows the client to track
28 // whether the call succeeded or not. Calls are done via the client interface
29 // rather than a callback to ensure ordering. The server does not interpret the
30 // change id in anyway, it is up to the client to assign a value and use it.
31 // Generally the change id is an ever increasing integer.
32 interface WindowTree {
33 // Creates a new window with the specified id. It is up to the client to
34 // ensure the id is unique to the connection (the id need not be globally
35 // unique). Additionally the connection id (embedded in |window_id|) must
36 // match that of the connection.
37 // Errors:
38 // ERROR_CODE_VALUE_IN_USE: a window already exists with the specified id.
39 // ERROR_CODE_ILLEGAL_ARGUMENT: The connection part of |window_id| does not
40 // match the connection id of the client.
41 NewWindow(uint32 change_id,
42 uint32 window_id,
43 map<string, array<uint8>>? properties);
44
45 // Requests the WindowManager to create a new top level window. On success
46 // OnTopLevelCreated() is called with the WindowData for the new window. On
47 // failure OnChangeCompleted() is called.
48 // TODO(sky): this likely needs context, maybe in |properties|.
49 NewTopLevelWindow(uint32 change_id,
50 uint32 window_id,
51 map<string, array<uint8>> properties);
52
53 // Deletes a window. This does not recurse. No hierarchy change notifications
54 // are sent as a result of this. Only the connection that created the window
55 // can delete it.
56 DeleteWindow(uint32 change_id, uint32 window_id);
57
58 // Requests input event capture for the given |window_id|. Capture is only
59 // allowed if the window is processing an event. When a window gains capture,
60 // current input events are canceled. The given window will receive all
61 // subsequent input until an alternate window is set via SetCapture, or
62 // ReleaseCapture is called for |window_id|. OnLostCapture is called to notify
63 // of capture ending.
64 SetCapture(uint32 change_id, uint32 window_id);
65
66 // Releases input event capture for the given |window_id|. This does nothing
67 // if |window_id| does not currently have capture.
68 ReleaseCapture(uint32 change_id, uint32 window_id);
69
70 // Sets an observer that monitors all events, even if they are not targeted
71 // at a window in this tree. If an event matchs |matcher| the observer reports
72 // it to the WindowTreeClient via OnWindowInputEvent (if the event target is
73 // this window tree) or OnEventObserved (if the target is another tree). The
74 // client must supply a non-zero |observer_id|, which is reported back with
75 // observed events. Set the matcher to null to clear the observer.
76 SetEventObserver(EventMatcher? matcher, uint32 observer_id);
77
78 // Sets the specified bounds of the specified window.
79 SetWindowBounds(uint32 change_id, uint32 window_id, gfx.mojom.Rect bounds);
80
81 // Sets the client area of the specified window. The client area is specified
82 // by way of insets. Everything outside of the insets, and not in
83 // |additional_client_areas| is considered non-client area.
84 // TODO(sky): convert additional_client_areas to a path.
85 SetClientArea(uint32 window_id,
86 gfx.mojom.Insets insets,
87 array<gfx.mojom.Rect>? additional_client_areas);
88
89 // Mouse events outside a hit test mask do not hit the window. The |mask| is
90 // in window local coordinates. Pass null to clear the mask.
91 // TODO(jamescook): Convert |mask| to a path. http://crbug.com/613210
92 SetHitTestMask(uint32 window_id, gfx.mojom.Rect? mask);
93
94 // Sets the visibility of the specified window to |visible|. Connections are
95 // allowed to change the visibility of any window they have created, as well
96 // as any of their roots.
97 SetWindowVisibility(uint32 change_id, uint32 window_id, bool visible);
98
99 // Sets an individual named property. Setting an individual property to null
100 // deletes the property.
101 SetWindowProperty(uint32 change_id,
102 uint32 window_id,
103 string name,
104 array<uint8>? value);
105
106 // Sets the opacity of the specified window to |opacity|.
107 SetWindowOpacity(uint32 change_id, uint32 window_id, float opacity);
108
109 // Attaches a Surface to a particular window.
110 AttachSurface(uint32 window_id,
111 SurfaceType type,
112 Surface& surface,
113 SurfaceClient client);
114
115 // Reparents a window.
116 // This fails for any of the following reasons:
117 // . |parent| or |child| does not identify a valid window.
118 // . |child| is an ancestor of |parent|.
119 // . |child| is already a child of |parent|.
120 //
121 // This may result in a connection getting OnWindowDeleted(). See
122 // RemoveWindowFromParent for details.
123 AddWindow(uint32 change_id, uint32 parent, uint32 child);
124
125 // Removes a window from its current parent. This fails if the window is not
126 // valid or the window already has no parent.
127 //
128 // Removing a window from a parent may result in OnWindowDeleted() being sent
129 // to other connections. For example, connection A has windows 1 and 2, with 2
130 // a child of 1. Connection B has a root 1. If 2 is removed from 1 then B gets
131 // OnWindowDeleted(). This is done as window 2 is effectively no longer
132 // visible to connection B.
133 RemoveWindowFromParent(uint32 change_id, uint32 window_id);
134
135 // Ties the lifetime of |transient_window_id| to the lifetime of |window_id|.
136 // This also places |transient_window_id| on top of |window_id|.
137 // This fails for any of the following reasons:
138 // . |window_id| or |transient_window_id| does not identify a valid window.
139 // . |transient_window_id| is an ancestor of |window_id|.
140 // . |transient_window_id| is modal to system.
141 AddTransientWindow(uint32 change_id,
142 uint32 window_id,
143 uint32 transient_window_id);
144
145 // Decouples the lifetime of |transient_window_id| from its transient parent.
146 // This does not change transient window's position in the window hierarchy.
147 RemoveTransientWindowFromParent(uint32 change_id, uint32 transient_window_id);
148
149 // Sets |window_id| to be modal. If the window has a transient parent, then
150 // the window is modal to the transient parent. Otherwise, the window is modal
151 // to the system. This releases capture if necessary.
152 // This fails for any of the following reasons:
153 // . |window_id| does not identify a valid window.
154 // . Client does not have a valid user id (i.e., it is an embedded app).
155 SetModal(uint32 change_id, uint32 window_id);
156
157 // Reorders a window in its parent, relative to |relative_window_id| according
158 // to |direction|. Only the connection that created the window's parent can
159 // reorder its children.
160 ReorderWindow(uint32 change_id,
161 uint32 window_id,
162 uint32 relative_window_id,
163 OrderDirection direction);
164
165 // Returns the windows comprising the tree starting at |window_id|.
166 // |window_id| is the first result in the return value, unless |window_id| is
167 // invalid, in which case an empty vector is returned. The windows are visited
168 // using a depth first search (pre-order).
169 GetWindowTree(uint32 window_id) => (array<WindowData> windows);
170
171 // A connection may grant access to another connection by way of Embed().
172 // Embed() results in the supplied WindowTreeClient being configured with a
173 // root window of |window_id|. The supplied WindowTreeClient may create child
174 // windows and do other various tree operations (including Embed()), but does
175 // not see nor have access to any of the windows above the embed point.
176 //
177 // The caller must have created |window_id|. If not the request fails and the
178 // response is false.
179 //
180 // The embedder can dictate the behaviour of the embedded client by setting
181 // the appropriate embed flags (e.g. kEmbedFlagEmbedderInterceptsEvents).
182 //
183 // When a connection embeds a WindowTreeClient the originating connection no
184 // longer has privileges to access or see any of the children of the window.
185 // If the window had existing children the children are removed. The
186 // WindowManager gets to see the whole tree.
187 //
188 // A window may only have one embedding in it at a time. Subsequent calls to
189 // Embed() for the same window result in the currently embedded
190 // WindowTreeClient being removed. The embedded app is told this by way of
191 // OnUnembed(), which is followed by OnWindowDeleted() (as the connection no
192 // longer has access to the window).
193 //
194 // The embedder can detect when the embedded app disconnects by way of
195 // OnEmbeddedAppDisconnected().
196 //
197 // The callback returns whether the embedding was successful.
198 Embed(uint32 window_id, WindowTreeClient client, uint32 embed_flags)
199 => (bool success);
200
201 // Sets focus to the specified window, use 0 to clear focus. For a window to
202 // get focus the following has to happen: the window is drawn, the window has
203 // been marked as focusable (see SetCanFocus()) and the window is in a
204 // container the WindowManager has identified as allowing activation
205 // (see WindowManagerClient::AddActivationParent()).
206 SetFocus(uint32 change_id, uint32 window_id);
207
208 // Marks the specified window as being able to receive focus.
209 SetCanFocus(uint32 window_id, bool can_focus);
210
211 // Sets the cursor when the pointer is inside |window_id| to a system standard
212 // cursor provided by the window manager.
213 SetPredefinedCursor(uint32 change_id, uint32 window_id, Cursor cursor_id);
214
215 // TODO(erg): Additional cursor methods. Image based cursors, visibility,
216 // and cursor locking.
217
218 // Set text input state for the given window.
219 SetWindowTextInputState(uint32 window_id, mojo.TextInputState state);
220
221 // Set the input method editor UI (software keyboard, etc) visibility.
222 // If state is non-null, the specified window's text input state is updated.
223 // Otherwise the existing state is used.
224 SetImeVisibility(uint32 window_id, bool visible, mojo.TextInputState? state);
225
226 // See documentation for WindowTreeClient::OnWindowInputEvent().
227 OnWindowInputEventAck(uint32 event_id, EventResult result);
228
229 // See description of WindowManager for details.
230 GetWindowManagerClient(associated WindowManagerClient& internal);
231
232 // Returns a shared memory segment that contains two 16-bit ints packed into a
233 // single Atomic32, which represent the current location of the mouse cursor
234 // where the location is (x << 16) | y.
235 GetCursorLocationMemory() => (handle<shared_buffer> cursor_buffer);
236 };
237
238 // Changes to windows are not sent to the connection that originated the
239 // change. For example, if connection 1 changes the bounds of a window by
240 // calling SetWindowBounds(), connection 1 does not receive
241 // OnWindowBoundsChanged().
242 interface WindowTreeClient {
243 // Invoked when the client application has been embedded at |root|.
244 // See Embed() on WindowTree for more details. |tree| will be a handle back to
245 // the window manager service, unless the connection is to the root connection
246 // in which case it will be null. |parent_drawn| is true if roots parent is
247 // drawn, see OnParentDrawnStateChanged() for details. |display_id| identifies
248 // the display this root window is on.
249 OnEmbed(uint16 connection_id,
250 WindowData root,
251 WindowTree? tree,
252 int64 display_id,
253 uint32 focused_window,
254 bool parent_drawn);
255
256 // Invoked when the application embedded at |window| is disconnected. In other
257 // words the embedded app closes the connection to the server. This is called
258 // on the connection that created |window| as well as any ancestors that have
259 // the embed root policy.
260 OnEmbeddedAppDisconnected(uint32 window);
261
262 // Sent when another connection is embedded in the Window this connection was
263 // previously embedded in. See Embed() for more information.
264 OnUnembed(uint32 window);
265
266 // Sent when a window loses capture.
267 OnLostCapture(uint32 window);
268
269 // Called in response to NewTopLevelWindow() successfully completing.
270 // |parent_drawn| is true if the parent of the window is drawn, see
271 // OnDrawnStateChanged() for details. |display_id| identifies the display this
272 // window is on.
273 OnTopLevelCreated(uint32 change_id,
274 WindowData data,
275 int64 display_id,
276 bool parent_drawn);
277
278 // Invoked when a window's bounds have changed.
279 OnWindowBoundsChanged(uint32 window,
280 gfx.mojom.Rect old_bounds,
281 gfx.mojom.Rect new_bounds);
282
283 OnClientAreaChanged(uint32 window_id,
284 gfx.mojom.Insets new_client_area,
285 array<gfx.mojom.Rect> new_additional_client_areas);
286
287 OnTransientWindowAdded(uint32 window_id,
288 uint32 transient_window_id);
289
290 OnTransientWindowRemoved(uint32 window_id,
291 uint32 transient_window_id);
292
293 // Invoked when a change is done to the hierarchy. A value of 0 is used to
294 // identify a null window. For example, if the old_parent is NULL, 0 is
295 // supplied.
296 // |windows| contains any windows that are that the client has not been told
297 // about. This is not sent for hierarchy changes of windows not known to this
298 // client or not attached to the tree.
299 OnWindowHierarchyChanged(uint32 window,
300 uint32 old_parent,
301 uint32 new_parent,
302 array<WindowData> windows);
303
304 // Invoked when the order of windows within a parent changes.
305 OnWindowReordered(uint32 window_id,
306 uint32 relative_window_id,
307 OrderDirection direction);
308
309 // Invoked when a window is deleted.
310 OnWindowDeleted(uint32 window);
311
312 // Invoked when the visibility of the specified window changes.
313 OnWindowVisibilityChanged(uint32 window, bool visible);
314
315 // Invoked when the opacity of the specified window has changed.
316 OnWindowOpacityChanged(uint32 window, float old_opacity, float new_opacity);
317
318 // Invoked when the drawn state of |window|'s parent changes. The drawn state
319 // is determined by the visibility of a Window and the Windows ancestors. A
320 // Window is drawn if all ancestors are visible, not drawn if any ancestor is
321 // hidden.
322 //
323 // The initial drawn state is communicated by way of OnTopLevelCreated() or
324 // OnEmbed().
325 //
326 // This function is only called for root Windows as the drawn state of all
327 // other windows can be determined from their parent.
328 OnWindowParentDrawnStateChanged(uint32 window, bool drawn);
329
330 // Invoked when a window property is changed. If this change is a removal,
331 // |new_data| is null.
332 OnWindowSharedPropertyChanged(uint32 window,
333 string name,
334 array<uint8>? new_data);
335
336 // Invoked when an event is targeted at the specified window. The client must
337 // call WindowTree::OnWindowInputEventAck() with the same |event_id| to notify
338 // that the event has been processed, and with an EventResult value to notify
339 // if the event was consumed. |event_observer_id| is non-zero if the event
340 // also matched the active event observer for this client. The client will not
341 // receive farther events until the event is ack'ed.
342 OnWindowInputEvent(uint32 event_id,
343 uint32 window,
344 ui.mojom.Event event,
345 uint32 event_observer_id);
346
347 // Invoked when an |event| is sent via the EventObserver and not targeted at a
348 // specific window. The |event_observer_id| is the one supplied to
349 // SetEventObserver. The client should not acknowledge these events.
350 OnEventObserved(ui.mojom.Event event, uint32 event_observer_id);
351
352 // Called in two distinct cases: when a window known to the connection gains
353 // focus, or when focus moves from a window known to the connection to a
354 // window not known to the connection. In the later case |focused_window_id|
355 // is 0. As with other functions this is only called if the client did not
356 // initiate the change.
357 OnWindowFocused(uint32 focused_window_id);
358
359 OnWindowPredefinedCursorChanged(uint32 window_id, Cursor cursor_id);
360
361 // A change initiated from the client has completed. See description of
362 // change ids for details.
363 OnChangeCompleted(uint32 change_id, bool success);
364
365 // The WindowManager is requesting the specified window to close. If the
366 // client allows the change it should delete the window.
367 RequestClose(uint32 window_id);
368
369 // See description of WindowManager for details.
370 GetWindowManager(associated WindowManager& internal);
371 };
372
373 // Mus provides this interface as a way for clients to connect and obtain a
374 // WindowTree handle with a supplied WindowTreeClient handle. The
375 // WindowTreeClient has no roots, use NewTopLevelWindow() to create one.
376 interface WindowTreeFactory {
377 CreateWindowTree(WindowTree& tree_request, WindowTreeClient client);
378 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698