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

Side by Side Diff: ui/aura/mus/window_tree_client.h

Issue 2445163002: Make aura work with mus (Closed)
Patch Set: split out Created 4 years, 1 month 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ 5 #ifndef UI_AURA_MUS_WINDOW_TREE_CLIENT_H_
6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ 6 #define UI_AURA_MUS_WINDOW_TREE_CLIENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/atomicops.h" 16 #include "base/atomicops.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "mojo/public/cpp/bindings/associated_binding.h" 20 #include "mojo/public/cpp/bindings/associated_binding.h"
21 #include "mojo/public/cpp/bindings/strong_binding.h" 21 #include "mojo/public/cpp/bindings/strong_binding.h"
22 #include "services/ui/common/types.h"
23 #include "services/ui/public/cpp/window.h"
24 #include "services/ui/public/cpp/window_manager_delegate.h"
25 #include "services/ui/public/interfaces/window_tree.mojom.h" 22 #include "services/ui/public/interfaces/window_tree.mojom.h"
23 #include "ui/aura/aura_export.h"
24 #include "ui/aura/client/capture_client_observer.h"
25 #include "ui/aura/client/focus_change_observer.h"
26 #include "ui/aura/mus/mus_types.h"
27 #include "ui/aura/mus/window_manager_delegate.h"
26 28
27 namespace display { 29 namespace display {
28 class Display; 30 class Display;
29 } 31 }
30 32
31 namespace gfx { 33 namespace gfx {
32 class Insets; 34 class Insets;
33 class Size;
34 } 35 }
35 36
36 namespace service_manager { 37 namespace service_manager {
37 class Connector; 38 class Connector;
38 } 39 }
39 40
40 namespace ui { 41 namespace aura {
42 class InFlightCaptureChange;
41 class InFlightChange; 43 class InFlightChange;
44 class InFlightFocusChange;
45 class InFlightPropertyChange;
46 class WindowMus;
47 class WindowPortMus;
48 struct WindowPortInitData;
49 struct WindowPortPropertyData;
42 class WindowTreeClientDelegate; 50 class WindowTreeClientDelegate;
43 class WindowTreeClientPrivate; 51 class WindowTreeClientPrivate;
44 class WindowTreeClientObserver; 52 class WindowTreeClientObserver;
45 enum class ChangeType; 53 class WindowTreeHost;
54
55 namespace client {
56 class FocusClient;
57 }
58
59 using EventResultCallback = base::Callback<void(ui::mojom::EventResult)>;
46 60
47 // Manages the connection with mus. 61 // Manages the connection with mus.
48 // 62 //
49 // WindowTreeClient is owned by the creator. Generally when the delegate gets 63 // WindowTreeClient is owned by the creator. Generally when the delegate gets
50 // one of OnEmbedRootDestroyed() or OnLostConnection() it should delete the 64 // one of OnEmbedRootDestroyed() or OnLostConnection() it should delete the
51 // WindowTreeClient. 65 // WindowTreeClient.
52 // 66 //
53 // When WindowTreeClient is deleted all windows are deleted (and observers 67 // When WindowTreeClient is deleted all windows are deleted (and observers
54 // notified). 68 // notified).
55 class WindowTreeClient : public mojom::WindowTreeClient, 69 class AURA_EXPORT WindowTreeClient : public ui::mojom::WindowTreeClient,
56 public mojom::WindowManager, 70 public ui::mojom::WindowManager,
57 public WindowManagerClient { 71 public WindowManagerClient,
72 public client::CaptureClientObserver,
73 public client::FocusChangeObserver {
58 public: 74 public:
59 explicit WindowTreeClient( 75 explicit WindowTreeClient(
60 WindowTreeClientDelegate* delegate, 76 WindowTreeClientDelegate* delegate,
61 WindowManagerDelegate* window_manager_delegate = nullptr, 77 WindowManagerDelegate* window_manager_delegate = nullptr,
62 mojom::WindowTreeClientRequest request = nullptr); 78 ui::mojom::WindowTreeClientRequest request = nullptr);
63 ~WindowTreeClient() override; 79 ~WindowTreeClient() override;
64 80
65 // Establishes the connection by way of the WindowTreeFactory. 81 // Establishes the connection by way of the WindowTreeFactory.
66 void ConnectViaWindowTreeFactory(service_manager::Connector* connector); 82 void ConnectViaWindowTreeFactory(service_manager::Connector* connector);
67 83
68 // Establishes the connection by way of WindowManagerWindowTreeFactory. 84 // Establishes the connection by way of WindowManagerWindowTreeFactory.
69 void ConnectAsWindowManager(service_manager::Connector* connector); 85 void ConnectAsWindowManager(service_manager::Connector* connector);
70 86
71 // Wait for OnEmbed(), returning when done. 87 // Wait for OnEmbed(), returning when done.
72 void WaitForEmbed(); 88 void WaitForEmbed();
73 89
74 bool connected() const { return tree_ != nullptr; } 90 bool connected() const { return tree_ != nullptr; }
75 ClientSpecificId client_id() const { return client_id_; } 91 ClientSpecificId client_id() const { return client_id_; }
76 92
77 // API exposed to the window implementations that pushes local changes to the 93 void SetClientArea(Window* window,
78 // service.
79 void DestroyWindow(Window* window);
80
81 // These methods take TransportIds. For windows owned by the current client,
82 // the client id high word can be zero. In all cases, the TransportId 0x1
83 // refers to the root window.
84 void AddChild(Window* parent, Id child_id);
85 void RemoveChild(Window* parent, Id child_id);
86
87 void AddTransientWindow(Window* window, Id transient_window_id);
88 void RemoveTransientWindowFromParent(Window* window);
89
90 void SetModal(Window* window);
91
92 void Reorder(Window* window,
93 Id relative_window_id,
94 mojom::OrderDirection direction);
95
96 // Returns true if the specified window was created by this client.
97 bool WasCreatedByThisClient(const Window* window) const;
98
99 void SetBounds(Window* window,
100 const gfx::Rect& old_bounds,
101 const gfx::Rect& bounds);
102 void SetCapture(Window* window);
103 void ReleaseCapture(Window* window);
104 void SetClientArea(Id window_id,
105 const gfx::Insets& client_area, 94 const gfx::Insets& client_area,
106 const std::vector<gfx::Rect>& additional_client_areas); 95 const std::vector<gfx::Rect>& additional_client_areas);
107 void SetHitTestMask(Id window_id, const gfx::Rect& mask); 96 void SetHitTestMask(Window* window, const gfx::Rect& mask);
108 void ClearHitTestMask(Id window_id); 97 void ClearHitTestMask(Window* window);
109 void SetFocus(Window* window); 98 void SetCanFocus(Window* window, bool can_focus);
110 void SetCanFocus(Id window_id, bool can_focus);
111 void SetCanAcceptDrops(Id window_id, bool can_accept_drops); 99 void SetCanAcceptDrops(Id window_id, bool can_accept_drops);
112 void SetCanAcceptEvents(Id window_id, bool can_accept_events); 100 void SetCanAcceptEvents(Id window_id, bool can_accept_events);
113 void SetPredefinedCursor(Id window_id, ui::mojom::Cursor cursor_id); 101 void SetPredefinedCursor(WindowMus* window,
114 void SetVisible(Window* window, bool visible); 102 ui::mojom::Cursor old_cursor,
115 void SetOpacity(Window* window, float opacity); 103 ui::mojom::Cursor new_cursor);
116 void SetProperty(Window* window, 104 void SetWindowTextInputState(WindowMus* window,
117 const std::string& name, 105 mojo::TextInputStatePtr state);
118 mojo::Array<uint8_t> data); 106 void SetImeVisibility(WindowMus* window,
119 void SetWindowTextInputState(Id window_id, mojo::TextInputStatePtr state);
120 void SetImeVisibility(Id window_id,
121 bool visible, 107 bool visible,
122 mojo::TextInputStatePtr state); 108 mojo::TextInputStatePtr state);
123 109
110 // TODO: this should take a window, not an id.
124 void Embed(Id window_id, 111 void Embed(Id window_id,
125 mojom::WindowTreeClientPtr client, 112 ui::mojom::WindowTreeClientPtr client,
126 uint32_t flags, 113 uint32_t flags,
127 const mojom::WindowTree::EmbedCallback& callback); 114 const ui::mojom::WindowTree::EmbedCallback& callback);
128 115
116 // TODO: this should move to WindowManager.
129 void RequestClose(Window* window); 117 void RequestClose(Window* window);
130 118
131 void AttachCompositorFrameSink( 119 void AttachCompositorFrameSink(
132 Id window_id, 120 Id window_id,
133 mojom::CompositorFrameSinkType type, 121 ui::mojom::CompositorFrameSinkType type,
134 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink, 122 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink,
135 cc::mojom::MojoCompositorFrameSinkClientPtr client); 123 cc::mojom::MojoCompositorFrameSinkClientPtr client);
136 124
137 void OnWindowSurfaceDetached(Id window_id, 125 bool IsRoot(WindowMus* window) const { return roots_.count(window) > 0; }
138 const cc::SurfaceSequence& sequence);
139
140 // Sets the input capture to |window| without notifying the server.
141 void LocalSetCapture(Window* window);
142 // Sets focus to |window| without notifying the server.
143 void LocalSetFocus(Window* window);
144
145 // Start/stop tracking windows. While tracked, they can be retrieved via
146 // WindowTreeClient::GetWindowById.
147 void AddWindow(Window* window);
148
149 bool IsRoot(Window* window) const { return roots_.count(window) > 0; }
150
151 void OnWindowDestroying(Window* window);
152
153 // Called after the window's observers have been notified of destruction (as
154 // the last step of ~Window).
155 void OnWindowDestroyed(Window* window);
156
157 Window* GetWindowByServerId(Id id);
158 126
159 // Returns the root of this connection. 127 // Returns the root of this connection.
160 const std::set<Window*>& GetRoots(); 128 std::set<Window*> GetRoots();
161 129
162 // Returns the Window with input capture; null if no window has requested 130 // Returns the Window with input capture; null if no window has requested
163 // input capture, or if another app has capture. 131 // input capture, or if another app has capture.
164 Window* GetCaptureWindow(); 132 Window* GetCaptureWindow();
165 133
166 // Returns the focused window; null if focus is not yet known or another app 134 // Returns the focused window; null if focus is not yet known or another app
167 // is focused. 135 // is focused.
168 Window* GetFocusedWindow(); 136 Window* GetFocusedWindow();
169 137
170 // Sets focus to null. This does nothing if focus is currently null.
171 void ClearFocus();
172
173 // Returns the current location of the mouse on screen. Note: this method may 138 // Returns the current location of the mouse on screen. Note: this method may
174 // race the asynchronous initialization; but in that case we return (0, 0). 139 // race the asynchronous initialization; but in that case we return (0, 0).
175 gfx::Point GetCursorScreenPoint(); 140 gfx::Point GetCursorScreenPoint();
176 141
177 // See description in window_tree.mojom. When an existing pointer watcher is 142 // See description in window_tree.mojom. When an existing pointer watcher is
178 // updated or cleared then any future events from the server for that watcher 143 // updated or cleared then any future events from the server for that watcher
179 // will be ignored. 144 // will be ignored.
180 void StartPointerWatcher(bool want_moves); 145 void StartPointerWatcher(bool want_moves);
181 void StopPointerWatcher(); 146 void StopPointerWatcher();
182 147
(...skipping 13 matching lines...) Expand all
196 // whether the move loop completed successfully. 161 // whether the move loop completed successfully.
197 void PerformWindowMove(Window* window, 162 void PerformWindowMove(Window* window,
198 ui::mojom::MoveLoopSource source, 163 ui::mojom::MoveLoopSource source,
199 const gfx::Point& cursor_location, 164 const gfx::Point& cursor_location,
200 const base::Callback<void(bool)>& callback); 165 const base::Callback<void(bool)>& callback);
201 166
202 // Cancels a in progress window move. (If no window is currently being moved, 167 // Cancels a in progress window move. (If no window is currently being moved,
203 // does nothing.) 168 // does nothing.)
204 void CancelWindowMove(Window* window); 169 void CancelWindowMove(Window* window);
205 170
206 // Creates and returns a new Window (which is owned by the window server).
207 // Windows are initially hidden, use SetVisible(true) to show.
208 Window* NewWindow() { return NewWindow(nullptr); }
209 Window* NewWindow(
210 const std::map<std::string, std::vector<uint8_t>>* properties);
211 Window* NewTopLevelWindow(
212 const std::map<std::string, std::vector<uint8_t>>* properties);
213
214 void AddObserver(WindowTreeClientObserver* observer); 171 void AddObserver(WindowTreeClientObserver* observer);
215 void RemoveObserver(WindowTreeClientObserver* observer); 172 void RemoveObserver(WindowTreeClientObserver* observer);
216 173
217 #if !defined(NDEBUG) 174 private:
218 std::string GetDebugWindowHierarchy() const; 175 friend class InFlightCaptureChange;
219 void BuildDebugInfo(const std::string& depth, 176 friend class InFlightFocusChange;
220 Window* window, 177 friend class InFlightPropertyChange;
221 std::string* result) const; 178 friend class WindowPortMus;
222 #endif 179 friend class WindowTreeClientPrivate;
223 180
224 private: 181 enum class WindowTreeHostType { EMBED, TOP_LEVEL, DISPLAY };
225 friend class WindowTreeClientPrivate;
226 182
227 struct CurrentDragState; 183 struct CurrentDragState;
228 184
229 enum class NewWindowType { 185 using IdToWindowMap = std::map<Id, WindowMus*>;
230 CHILD,
231 TOP_LEVEL,
232 };
233
234 using IdToWindowMap = std::map<Id, Window*>;
235 186
236 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. 187 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption.
237 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; 188 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>;
238 189
190 void RegisterWindowMus(WindowMus* window);
191
192 WindowMus* GetWindowByServerId(Id id);
193
194 // Returns true if the specified window was created by this client.
195 bool WasCreatedByThisClient(const WindowMus* window) const;
196
197 void SetFocusFromServer(WindowMus* window);
198 void SetFocusFromServerImpl(client::FocusClient* focus_client,
199 WindowMus* window);
200
201 void SetCaptureFromServer(WindowMus* window);
202
239 // Returns the oldest InFlightChange that matches |change|. 203 // Returns the oldest InFlightChange that matches |change|.
240 InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change); 204 InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change);
241 205
242 // See InFlightChange for details on how InFlightChanges are used. 206 // See InFlightChange for details on how InFlightChanges are used.
243 uint32_t ScheduleInFlightChange(std::unique_ptr<InFlightChange> change); 207 uint32_t ScheduleInFlightChange(std::unique_ptr<InFlightChange> change);
244 208
245 // Returns true if there is an InFlightChange that matches |change|. If there 209 // Returns true if there is an InFlightChange that matches |change|. If there
246 // is an existing change SetRevertValueFrom() is invoked on it. Returns false 210 // is an existing change SetRevertValueFrom() is invoked on it. Returns false
247 // if there is no InFlightChange matching |change|. 211 // if there is no InFlightChange matching |change|.
248 // See InFlightChange for details on how InFlightChanges are used. 212 // See InFlightChange for details on how InFlightChanges are used.
249 bool ApplyServerChangeToExistingInFlightChange(const InFlightChange& change); 213 bool ApplyServerChangeToExistingInFlightChange(const InFlightChange& change);
250 214
251 static Id server_id(const Window* window) { return window->server_id(); } 215 void BuildWindowTree(const mojo::Array<ui::mojom::WindowDataPtr>& windows,
216 WindowMus* initial_parent);
252 217
253 Window* BuildWindowTree(const mojo::Array<mojom::WindowDataPtr>& windows, 218 // Creates a WindowPortMus from the server side data.
254 Window* initial_parent); 219 // NOTE: this *must* be followed by SetLocalPropertiesFromServerProperties()
220 std::unique_ptr<WindowPortMus> CreateWindowPortMus(
221 const ui::mojom::WindowDataPtr& window_data);
255 222
256 Window* NewWindowImpl(NewWindowType type, 223 // Sets local properties on the associated Window from the server properties.
257 const Window::SharedProperties* properties); 224 void SetLocalPropertiesFromServerProperties(
225 WindowMus* window,
226 const ui::mojom::WindowDataPtr& window_data);
258 227
259 // Sets the mojom::WindowTree implementation. 228 // Creates a WindowTreeHostMus and returns the window associated with it.
260 void SetWindowTree(mojom::WindowTreePtr window_tree_ptr); 229 // The returned window is either the content window of the WindowTreeHostMus
230 // or the window created by WindowTreeHost. See WindowTreeHostMus for
231 // details.
232 // TODO(sky): it would be nice to always have a single window and not the
233 // two different. That requires ownership changes to WindowTreeHost though.
234 Window* CreateWindowTreeHost(WindowTreeHostType type,
235 const ui::mojom::WindowDataPtr& window_data,
236 Window* content_window);
261 237
262 // Called when the mojom::WindowTree connection is lost, deletes this. 238 WindowMus* NewWindowFromWindowData(
239 WindowMus* parent,
240 const ui::mojom::WindowDataPtr& window_data);
241
242 // Sets the ui::mojom::WindowTree implementation.
243 void SetWindowTree(ui::mojom::WindowTreePtr window_tree_ptr);
244
245 // Called when the ui::mojom::WindowTree connection is lost, deletes this.
263 void OnConnectionLost(); 246 void OnConnectionLost();
264 247
265 // OnEmbed() calls into this. Exposed as a separate function for testing. 248 // OnEmbed() calls into this. Exposed as a separate function for testing.
266 void OnEmbedImpl(mojom::WindowTree* window_tree, 249 void OnEmbedImpl(ui::mojom::WindowTree* window_tree,
267 ClientSpecificId client_id, 250 ClientSpecificId client_id,
268 mojom::WindowDataPtr root_data, 251 ui::mojom::WindowDataPtr root_data,
269 int64_t display_id, 252 int64_t display_id,
270 Id focused_window_id, 253 Id focused_window_id,
271 bool drawn); 254 bool drawn);
272 255
273 // Called by WmNewDisplayAdded(). 256 // Called by WmNewDisplayAdded().
274 void WmNewDisplayAddedImpl(const display::Display& display, 257 WindowTreeHost* WmNewDisplayAddedImpl(const display::Display& display,
275 mojom::WindowDataPtr root_data, 258 ui::mojom::WindowDataPtr root_data,
276 bool parent_drawn); 259 bool parent_drawn);
260
261 std::unique_ptr<EventResultCallback> CreateEventResultCallback(
262 int32_t event_id);
277 263
278 void OnReceivedCursorLocationMemory(mojo::ScopedSharedBufferHandle handle); 264 void OnReceivedCursorLocationMemory(mojo::ScopedSharedBufferHandle handle);
279 265
266 // Following are called from WindowMus.
267 std::unique_ptr<WindowPortInitData> OnWindowMusCreated(WindowMus* window);
268 void OnWindowMusInitDone(WindowMus* window,
269 std::unique_ptr<WindowPortInitData> init_data);
270 void OnWindowMusDestroyed(WindowMus* window);
271 void OnWindowMusBoundsChanged(WindowMus* window,
272 const gfx::Rect& old_bounds,
273 const gfx::Rect& new_bounds);
274 void OnWindowMusAddChild(WindowMus* parent, WindowMus* child);
275 void OnWindowMusRemoveChild(WindowMus* parent, WindowMus* child);
276 void OnWindowMusMoveChild(WindowMus* parent,
277 size_t current_index,
278 size_t dest_index);
279 void OnWindowMusSetVisible(WindowMus* window, bool visible);
280 std::unique_ptr<WindowPortPropertyData> OnWindowMusWillChangeProperty(
281 WindowMus* window,
282 const void* key);
283 void OnWindowMusPropertyChanged(WindowMus* window,
284 const void* key,
285 std::unique_ptr<WindowPortPropertyData> data);
286 void OnWindowMusSurfaceDetached(WindowMus* window,
287 const cc::SurfaceSequence& sequence);
288
280 // Callback passed from WmPerformMoveLoop(). 289 // Callback passed from WmPerformMoveLoop().
281 void OnWmMoveLoopCompleted(uint32_t change_id, bool completed); 290 void OnWmMoveLoopCompleted(uint32_t change_id, bool completed);
282 291
283 // Overridden from WindowTreeClient: 292 // Overridden from WindowTreeClient:
284 void OnEmbed(ClientSpecificId client_id, 293 void OnEmbed(ClientSpecificId client_id,
285 mojom::WindowDataPtr root, 294 ui::mojom::WindowDataPtr root,
286 mojom::WindowTreePtr tree, 295 ui::mojom::WindowTreePtr tree,
287 int64_t display_id, 296 int64_t display_id,
288 Id focused_window_id, 297 Id focused_window_id,
289 bool drawn) override; 298 bool drawn) override;
290 void OnEmbeddedAppDisconnected(Id window_id) override; 299 void OnEmbeddedAppDisconnected(Id window_id) override;
291 void OnUnembed(Id window_id) override; 300 void OnUnembed(Id window_id) override;
292 void OnCaptureChanged(Id new_capture_window_id, 301 void OnCaptureChanged(Id new_capture_window_id,
293 Id old_capture_window_id) override; 302 Id old_capture_window_id) override;
294 void OnTopLevelCreated(uint32_t change_id, 303 void OnTopLevelCreated(uint32_t change_id,
295 mojom::WindowDataPtr data, 304 ui::mojom::WindowDataPtr data,
296 int64_t display_id, 305 int64_t display_id,
297 bool drawn) override; 306 bool drawn) override;
298 void OnWindowBoundsChanged(Id window_id, 307 void OnWindowBoundsChanged(Id window_id,
299 const gfx::Rect& old_bounds, 308 const gfx::Rect& old_bounds,
300 const gfx::Rect& new_bounds) override; 309 const gfx::Rect& new_bounds) override;
301 void OnClientAreaChanged( 310 void OnClientAreaChanged(
302 uint32_t window_id, 311 uint32_t window_id,
303 const gfx::Insets& new_client_area, 312 const gfx::Insets& new_client_area,
304 mojo::Array<gfx::Rect> new_additional_client_areas) override; 313 mojo::Array<gfx::Rect> new_additional_client_areas) override;
305 void OnTransientWindowAdded(uint32_t window_id, 314 void OnTransientWindowAdded(uint32_t window_id,
306 uint32_t transient_window_id) override; 315 uint32_t transient_window_id) override;
307 void OnTransientWindowRemoved(uint32_t window_id, 316 void OnTransientWindowRemoved(uint32_t window_id,
308 uint32_t transient_window_id) override; 317 uint32_t transient_window_id) override;
309 void OnWindowHierarchyChanged( 318 void OnWindowHierarchyChanged(
310 Id window_id, 319 Id window_id,
311 Id old_parent_id, 320 Id old_parent_id,
312 Id new_parent_id, 321 Id new_parent_id,
313 mojo::Array<mojom::WindowDataPtr> windows) override; 322 mojo::Array<ui::mojom::WindowDataPtr> windows) override;
314 void OnWindowReordered(Id window_id, 323 void OnWindowReordered(Id window_id,
315 Id relative_window_id, 324 Id relative_window_id,
316 mojom::OrderDirection direction) override; 325 ui::mojom::OrderDirection direction) override;
317 void OnWindowDeleted(Id window_id) override; 326 void OnWindowDeleted(Id window_id) override;
318 void OnWindowVisibilityChanged(Id window_id, bool visible) override; 327 void OnWindowVisibilityChanged(Id window_id, bool visible) override;
319 void OnWindowOpacityChanged(Id window_id, 328 void OnWindowOpacityChanged(Id window_id,
320 float old_opacity, 329 float old_opacity,
321 float new_opacity) override; 330 float new_opacity) override;
322 void OnWindowParentDrawnStateChanged(Id window_id, bool drawn) override; 331 void OnWindowParentDrawnStateChanged(Id window_id, bool drawn) override;
323 void OnWindowSharedPropertyChanged(Id window_id, 332 void OnWindowSharedPropertyChanged(
324 const mojo::String& name, 333 Id window_id,
325 mojo::Array<uint8_t> new_data) override; 334 const mojo::String& name,
335 mojo::Array<uint8_t> transport_data) override;
326 void OnWindowInputEvent(uint32_t event_id, 336 void OnWindowInputEvent(uint32_t event_id,
327 Id window_id, 337 Id window_id,
328 std::unique_ptr<ui::Event> event, 338 std::unique_ptr<ui::Event> event,
329 bool matches_pointer_watcher) override; 339 bool matches_pointer_watcher) override;
330 void OnPointerEventObserved(std::unique_ptr<ui::Event> event, 340 void OnPointerEventObserved(std::unique_ptr<ui::Event> event,
331 uint32_t window_id) override; 341 uint32_t window_id) override;
332 void OnWindowFocused(Id focused_window_id) override; 342 void OnWindowFocused(Id focused_window_id) override;
333 void OnWindowPredefinedCursorChanged(Id window_id, 343 void OnWindowPredefinedCursorChanged(Id window_id,
334 mojom::Cursor cursor) override; 344 ui::mojom::Cursor cursor) override;
335 void OnWindowSurfaceChanged(Id window_id, 345 void OnWindowSurfaceChanged(Id window_id,
336 const cc::SurfaceId& surface_id, 346 const cc::SurfaceId& surface_id,
337 const cc::SurfaceSequence& surface_sequence, 347 const cc::SurfaceSequence& surface_sequence,
338 const gfx::Size& frame_size, 348 const gfx::Size& frame_size,
339 float device_scale_factor) override; 349 float device_scale_factor) override;
340 void OnDragDropStart( 350 void OnDragDropStart(
341 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) override; 351 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) override;
342 void OnDragEnter(Id window_id, 352 void OnDragEnter(Id window_id,
343 uint32_t event_flags, 353 uint32_t event_flags,
344 const gfx::Point& position, 354 const gfx::Point& position,
(...skipping 15 matching lines...) Expand all
360 uint32_t action_taken) override; 370 uint32_t action_taken) override;
361 void OnDragDropDone() override; 371 void OnDragDropDone() override;
362 void OnChangeCompleted(uint32_t change_id, bool success) override; 372 void OnChangeCompleted(uint32_t change_id, bool success) override;
363 void RequestClose(uint32_t window_id) override; 373 void RequestClose(uint32_t window_id) override;
364 void GetWindowManager( 374 void GetWindowManager(
365 mojo::AssociatedInterfaceRequest<WindowManager> internal) override; 375 mojo::AssociatedInterfaceRequest<WindowManager> internal) override;
366 376
367 // Overridden from WindowManager: 377 // Overridden from WindowManager:
368 void OnConnect(ClientSpecificId client_id) override; 378 void OnConnect(ClientSpecificId client_id) override;
369 void WmNewDisplayAdded(const display::Display& display, 379 void WmNewDisplayAdded(const display::Display& display,
370 mojom::WindowDataPtr root_data, 380 ui::mojom::WindowDataPtr root_data,
371 bool parent_drawn) override; 381 bool parent_drawn) override;
372 void WmDisplayRemoved(int64_t display_id) override; 382 void WmDisplayRemoved(int64_t display_id) override;
373 void WmDisplayModified(const display::Display& display) override; 383 void WmDisplayModified(const display::Display& display) override;
374 void WmSetBounds(uint32_t change_id, 384 void WmSetBounds(uint32_t change_id,
375 Id window_id, 385 Id window_id,
376 const gfx::Rect& transit_bounds) override; 386 const gfx::Rect& transit_bounds) override;
377 void WmSetProperty(uint32_t change_id, 387 void WmSetProperty(uint32_t change_id,
378 Id window_id, 388 Id window_id,
379 const mojo::String& name, 389 const mojo::String& name,
380 mojo::Array<uint8_t> transit_data) override; 390 mojo::Array<uint8_t> transit_data) override;
381 void WmCreateTopLevelWindow(uint32_t change_id, 391 void WmCreateTopLevelWindow(uint32_t change_id,
382 ClientSpecificId requesting_client_id, 392 ClientSpecificId requesting_client_id,
383 mojo::Map<mojo::String, mojo::Array<uint8_t>> 393 mojo::Map<mojo::String, mojo::Array<uint8_t>>
384 transport_properties) override; 394 transport_properties) override;
385 void WmClientJankinessChanged(ClientSpecificId client_id, 395 void WmClientJankinessChanged(ClientSpecificId client_id,
386 bool janky) override; 396 bool janky) override;
387 void WmPerformMoveLoop(uint32_t change_id, 397 void WmPerformMoveLoop(uint32_t change_id,
388 Id window_id, 398 Id window_id,
389 mojom::MoveLoopSource source, 399 ui::mojom::MoveLoopSource source,
390 const gfx::Point& cursor_location) override; 400 const gfx::Point& cursor_location) override;
391 void WmCancelMoveLoop(uint32_t window_id) override; 401 void WmCancelMoveLoop(uint32_t window_id) override;
392 void OnAccelerator(uint32_t ack_id, 402 void OnAccelerator(uint32_t ack_id,
393 uint32_t accelerator_id, 403 uint32_t accelerator_id,
394 std::unique_ptr<ui::Event> event) override; 404 std::unique_ptr<ui::Event> event) override;
395 405
396 // Overridden from WindowManagerClient: 406 // Overridden from WindowManagerClient:
397 void SetFrameDecorationValues( 407 void SetFrameDecorationValues(
398 mojom::FrameDecorationValuesPtr values) override; 408 ui::mojom::FrameDecorationValuesPtr values) override;
399 void SetNonClientCursor(Window* window, ui::mojom::Cursor cursor_id) override; 409 void SetNonClientCursor(Window* window, ui::mojom::Cursor cursor_id) override;
400 void AddAccelerator(uint32_t id, 410 void AddAccelerator(uint32_t id,
401 mojom::EventMatcherPtr event_matcher, 411 ui::mojom::EventMatcherPtr event_matcher,
402 const base::Callback<void(bool)>& callback) override; 412 const base::Callback<void(bool)>& callback) override;
403 void RemoveAccelerator(uint32_t id) override; 413 void RemoveAccelerator(uint32_t id) override;
404 void AddActivationParent(Window* window) override; 414 void AddActivationParent(Window* window) override;
405 void RemoveActivationParent(Window* window) override; 415 void RemoveActivationParent(Window* window) override;
406 void ActivateNextWindow() override; 416 void ActivateNextWindow() override;
407 void SetUnderlaySurfaceOffsetAndExtendedHitArea( 417 void SetUnderlaySurfaceOffsetAndExtendedHitArea(
408 Window* window, 418 Window* window,
409 const gfx::Vector2d& offset, 419 const gfx::Vector2d& offset,
410 const gfx::Insets& hit_area) override; 420 const gfx::Insets& hit_area) override;
411 421
422 // Overriden from client::FocusChangeObserver:
423 void OnWindowFocused(Window* gained_focus, Window* lost_focus) override;
424
425 // Overriden from client::CaptureClientObserver:
426 void OnCaptureChanged(Window* lost_capture, Window* gained_capture) override;
427
412 // The one int in |cursor_location_mapping_|. When we read from this 428 // The one int in |cursor_location_mapping_|. When we read from this
413 // location, we must always read from it atomically. 429 // location, we must always read from it atomically.
414 base::subtle::Atomic32* cursor_location_memory() { 430 base::subtle::Atomic32* cursor_location_memory() {
415 return reinterpret_cast<base::subtle::Atomic32*>( 431 return reinterpret_cast<base::subtle::Atomic32*>(
416 cursor_location_mapping_.get()); 432 cursor_location_mapping_.get());
417 } 433 }
418 434
419 // This is set once and only once when we get OnEmbed(). It gives the unique 435 // This is set once and only once when we get OnEmbed(). It gives the unique
420 // id for this client. 436 // id for this client.
421 ClientSpecificId client_id_; 437 ClientSpecificId client_id_;
422 438
423 // Id assigned to the next window created. 439 // Id assigned to the next window created.
424 ClientSpecificId next_window_id_; 440 ClientSpecificId next_window_id_;
425 441
426 // Id used for the next change id supplied to the server. 442 // Id used for the next change id supplied to the server.
427 uint32_t next_change_id_; 443 uint32_t next_change_id_;
428 InFlightMap in_flight_map_; 444 InFlightMap in_flight_map_;
429 445
430 WindowTreeClientDelegate* delegate_; 446 WindowTreeClientDelegate* delegate_;
431 447
432 WindowManagerDelegate* window_manager_delegate_; 448 WindowManagerDelegate* window_manager_delegate_;
433 449
434 std::set<Window*> roots_; 450 std::set<WindowMus*> roots_;
435 451
436 IdToWindowMap windows_; 452 IdToWindowMap windows_;
437 std::map<ClientSpecificId, std::set<Window*>> embedded_windows_; 453 std::map<ClientSpecificId, std::set<Window*>> embedded_windows_;
438 454
439 Window* capture_window_; 455 bool setting_capture_ = false;
456 WindowMus* window_setting_capture_to_ = nullptr;
457 WindowMus* capture_window_ = nullptr;
440 458
441 Window* focused_window_; 459 bool setting_focus_ = false;
460 WindowMus* window_setting_focus_to_ = nullptr;
461 WindowMus* focused_window_ = nullptr;
442 462
443 mojo::Binding<mojom::WindowTreeClient> binding_; 463 mojo::Binding<ui::mojom::WindowTreeClient> binding_;
444 mojom::WindowTreePtr tree_ptr_; 464 ui::mojom::WindowTreePtr tree_ptr_;
445 // Typically this is the value contained in |tree_ptr_|, but tests may 465 // Typically this is the value contained in |tree_ptr_|, but tests may
446 // directly set this. 466 // directly set this.
447 mojom::WindowTree* tree_; 467 ui::mojom::WindowTree* tree_;
448 468
449 // Set to true if OnEmbed() was received. 469 // Set to true if OnEmbed() was received.
450 bool is_from_embed_ = false; 470 bool is_from_embed_ = false;
451 471
452 bool in_destructor_; 472 bool in_destructor_;
453 473
454 // A mapping to shared memory that is one 32 bit integer long. The window 474 // A mapping to shared memory that is one 32 bit integer long. The window
455 // server uses this to let us synchronously read the cursor location. 475 // server uses this to let us synchronously read the cursor location.
456 mojo::ScopedSharedBufferMapping cursor_location_mapping_; 476 mojo::ScopedSharedBufferMapping cursor_location_mapping_;
457 477
458 base::ObserverList<WindowTreeClientObserver> observers_; 478 base::ObserverList<WindowTreeClientObserver> observers_;
459 479
460 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManager>> 480 std::unique_ptr<mojo::AssociatedBinding<ui::mojom::WindowManager>>
461 window_manager_internal_; 481 window_manager_internal_;
462 mojom::WindowManagerClientAssociatedPtr window_manager_internal_client_; 482 ui::mojom::WindowManagerClientAssociatedPtr window_manager_internal_client_;
463 483
464 bool has_pointer_watcher_ = false; 484 bool has_pointer_watcher_ = false;
465 485
466 // The current change id for the client. 486 // The current change id for the client.
467 uint32_t current_move_loop_change_ = 0u; 487 uint32_t current_move_loop_change_ = 0u;
468 488
469 // Callback executed when a move loop initiated by PerformWindowMove() is 489 // Callback executed when a move loop initiated by PerformWindowMove() is
470 // completed. 490 // completed.
471 base::Callback<void(bool)> on_current_move_finished_; 491 base::Callback<void(bool)> on_current_move_finished_;
472 492
(...skipping 12 matching lines...) Expand all
485 // A set of window ids for windows that we received an OnDragEnter() message 505 // A set of window ids for windows that we received an OnDragEnter() message
486 // for. We maintain this set so we know who to send OnDragFinish() messages 506 // for. We maintain this set so we know who to send OnDragFinish() messages
487 // at the end of the drag. 507 // at the end of the drag.
488 std::set<Id> drag_entered_windows_; 508 std::set<Id> drag_entered_windows_;
489 509
490 base::WeakPtrFactory<WindowTreeClient> weak_factory_; 510 base::WeakPtrFactory<WindowTreeClient> weak_factory_;
491 511
492 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); 512 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient);
493 }; 513 };
494 514
495 } // namespace ui 515 } // namespace aura
496 516
497 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ 517 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698