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

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

Issue 2456623002: Fixes to WindowTreeHostMus (Closed)
Patch Set: std::move 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 UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ 5 #ifndef UI_AURA_MUS_WINDOW_TREE_CLIENT_H_
6 #define UI_AURA_MUS_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/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/observer_list.h" 20 #include "base/observer_list.h"
21 #include "mojo/public/cpp/bindings/associated_binding.h" 21 #include "mojo/public/cpp/bindings/associated_binding.h"
22 #include "mojo/public/cpp/bindings/strong_binding.h" 22 #include "mojo/public/cpp/bindings/strong_binding.h"
23 #include "services/ui/public/interfaces/window_tree.mojom.h" 23 #include "services/ui/public/interfaces/window_tree.mojom.h"
24 #include "ui/aura/aura_export.h" 24 #include "ui/aura/aura_export.h"
25 #include "ui/aura/client/capture_client_observer.h" 25 #include "ui/aura/client/capture_client_observer.h"
26 #include "ui/aura/client/focus_change_observer.h" 26 #include "ui/aura/client/focus_change_observer.h"
27 #include "ui/aura/mus/mus_types.h" 27 #include "ui/aura/mus/mus_types.h"
28 #include "ui/aura/mus/window_manager_delegate.h" 28 #include "ui/aura/mus/window_manager_delegate.h"
29 #include "ui/aura/mus/window_tree_host_mus_delegate.h"
29 30
30 namespace display { 31 namespace display {
31 class Display; 32 class Display;
32 } 33 }
33 34
34 namespace gfx { 35 namespace gfx {
35 class Insets; 36 class Insets;
36 } 37 }
37 38
38 namespace service_manager { 39 namespace service_manager {
39 class Connector; 40 class Connector;
40 } 41 }
41 42
42 namespace aura { 43 namespace aura {
44 class InFlightBoundsChange;
43 class InFlightCaptureChange; 45 class InFlightCaptureChange;
44 class InFlightChange; 46 class InFlightChange;
45 class InFlightFocusChange; 47 class InFlightFocusChange;
46 class InFlightPropertyChange; 48 class InFlightPropertyChange;
49 class InFlightVisibleChange;
47 class WindowMus; 50 class WindowMus;
48 class WindowPortMus; 51 class WindowPortMus;
49 struct WindowPortInitData; 52 struct WindowPortInitData;
50 struct WindowPortPropertyData; 53 struct WindowPortPropertyData;
51 class WindowTreeClientDelegate; 54 class WindowTreeClientDelegate;
52 class WindowTreeClientPrivate; 55 class WindowTreeClientPrivate;
53 class WindowTreeClientObserver; 56 class WindowTreeClientObserver;
54 class WindowTreeHost; 57 class WindowTreeHost;
55 58
56 namespace client { 59 namespace client {
57 class FocusClient; 60 class FocusClient;
58 } 61 }
59 62
60 using EventResultCallback = base::Callback<void(ui::mojom::EventResult)>; 63 using EventResultCallback = base::Callback<void(ui::mojom::EventResult)>;
61 64
62 // Manages the connection with mus. 65 // Manages the connection with mus.
63 // 66 //
64 // WindowTreeClient is owned by the creator. Generally when the delegate gets 67 // WindowTreeClient is owned by the creator. Generally when the delegate gets
65 // one of OnEmbedRootDestroyed() or OnLostConnection() it should delete the 68 // one of OnEmbedRootDestroyed() or OnLostConnection() it should delete the
66 // WindowTreeClient. 69 // WindowTreeClient.
67 // 70 //
68 // When WindowTreeClient is deleted all windows are deleted (and observers 71 // When WindowTreeClient is deleted all windows are deleted (and observers
69 // notified). 72 // notified).
70 class AURA_EXPORT WindowTreeClient 73 class AURA_EXPORT WindowTreeClient
71 : NON_EXPORTED_BASE(public ui::mojom::WindowTreeClient), 74 : NON_EXPORTED_BASE(public ui::mojom::WindowTreeClient),
72 NON_EXPORTED_BASE(public ui::mojom::WindowManager), 75 NON_EXPORTED_BASE(public ui::mojom::WindowManager),
73 public WindowManagerClient, 76 public WindowManagerClient,
74 public client::CaptureClientObserver, 77 public client::CaptureClientObserver,
75 public client::FocusChangeObserver { 78 public client::FocusChangeObserver,
79 public WindowTreeHostMusDelegate {
76 public: 80 public:
77 explicit WindowTreeClient( 81 explicit WindowTreeClient(
78 WindowTreeClientDelegate* delegate, 82 WindowTreeClientDelegate* delegate,
79 WindowManagerDelegate* window_manager_delegate = nullptr, 83 WindowManagerDelegate* window_manager_delegate = nullptr,
80 ui::mojom::WindowTreeClientRequest request = nullptr); 84 ui::mojom::WindowTreeClientRequest request = nullptr);
81 ~WindowTreeClient() override; 85 ~WindowTreeClient() override;
82 86
83 // Establishes the connection by way of the WindowTreeFactory. 87 // Establishes the connection by way of the WindowTreeFactory.
84 void ConnectViaWindowTreeFactory(service_manager::Connector* connector); 88 void ConnectViaWindowTreeFactory(service_manager::Connector* connector);
85 89
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 const base::Callback<void(bool)>& callback); 171 const base::Callback<void(bool)>& callback);
168 172
169 // Cancels a in progress window move. (If no window is currently being moved, 173 // Cancels a in progress window move. (If no window is currently being moved,
170 // does nothing.) 174 // does nothing.)
171 void CancelWindowMove(Window* window); 175 void CancelWindowMove(Window* window);
172 176
173 void AddObserver(WindowTreeClientObserver* observer); 177 void AddObserver(WindowTreeClientObserver* observer);
174 void RemoveObserver(WindowTreeClientObserver* observer); 178 void RemoveObserver(WindowTreeClientObserver* observer);
175 179
176 private: 180 private:
181 friend class InFlightBoundsChange;
177 friend class InFlightCaptureChange; 182 friend class InFlightCaptureChange;
178 friend class InFlightFocusChange; 183 friend class InFlightFocusChange;
179 friend class InFlightPropertyChange; 184 friend class InFlightPropertyChange;
185 friend class InFlightVisibleChange;
180 friend class WindowPortMus; 186 friend class WindowPortMus;
181 friend class WindowTreeClientPrivate; 187 friend class WindowTreeClientPrivate;
182 188
183 enum class WindowTreeHostType { EMBED, TOP_LEVEL, DISPLAY };
184
185 struct CurrentDragState; 189 struct CurrentDragState;
186 190
187 using IdToWindowMap = std::map<Id, WindowMus*>; 191 using IdToWindowMap = std::map<Id, WindowMus*>;
188 192
189 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. 193 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption.
190 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; 194 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>;
191 195
192 void RegisterWindowMus(WindowMus* window); 196 void RegisterWindowMus(WindowMus* window);
193 197
194 WindowMus* GetWindowByServerId(Id id); 198 WindowMus* GetWindowByServerId(Id id);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 void SetLocalPropertiesFromServerProperties( 230 void SetLocalPropertiesFromServerProperties(
227 WindowMus* window, 231 WindowMus* window,
228 const ui::mojom::WindowDataPtr& window_data); 232 const ui::mojom::WindowDataPtr& window_data);
229 233
230 // Creates a WindowTreeHostMus and returns the window associated with it. 234 // Creates a WindowTreeHostMus and returns the window associated with it.
231 // The returned window is either the content window of the WindowTreeHostMus 235 // The returned window is either the content window of the WindowTreeHostMus
232 // or the window created by WindowTreeHost. See WindowTreeHostMus for 236 // or the window created by WindowTreeHost. See WindowTreeHostMus for
233 // details. 237 // details.
234 // TODO(sky): it would be nice to always have a single window and not the 238 // TODO(sky): it would be nice to always have a single window and not the
235 // two different. That requires ownership changes to WindowTreeHost though. 239 // two different. That requires ownership changes to WindowTreeHost though.
236 Window* CreateWindowTreeHost(WindowTreeHostType type, 240 Window* CreateWindowTreeHost(RootWindowType type,
237 const ui::mojom::WindowDataPtr& window_data, 241 const ui::mojom::WindowDataPtr& window_data,
242 int64_t display_id,
238 Window* content_window); 243 Window* content_window);
239 244
240 WindowMus* NewWindowFromWindowData( 245 WindowMus* NewWindowFromWindowData(
241 WindowMus* parent, 246 WindowMus* parent,
242 const ui::mojom::WindowDataPtr& window_data); 247 const ui::mojom::WindowDataPtr& window_data);
243 248
244 // Sets the ui::mojom::WindowTree implementation. 249 // Sets the ui::mojom::WindowTree implementation.
245 void SetWindowTree(ui::mojom::WindowTreePtr window_tree_ptr); 250 void SetWindowTree(ui::mojom::WindowTreePtr window_tree_ptr);
246 251
247 // Called when the ui::mojom::WindowTree connection is lost, deletes this. 252 // Called when the ui::mojom::WindowTree connection is lost, deletes this.
(...skipping 10 matching lines...) Expand all
258 // Called by WmNewDisplayAdded(). 263 // Called by WmNewDisplayAdded().
259 WindowTreeHost* WmNewDisplayAddedImpl(const display::Display& display, 264 WindowTreeHost* WmNewDisplayAddedImpl(const display::Display& display,
260 ui::mojom::WindowDataPtr root_data, 265 ui::mojom::WindowDataPtr root_data,
261 bool parent_drawn); 266 bool parent_drawn);
262 267
263 std::unique_ptr<EventResultCallback> CreateEventResultCallback( 268 std::unique_ptr<EventResultCallback> CreateEventResultCallback(
264 int32_t event_id); 269 int32_t event_id);
265 270
266 void OnReceivedCursorLocationMemory(mojo::ScopedSharedBufferHandle handle); 271 void OnReceivedCursorLocationMemory(mojo::ScopedSharedBufferHandle handle);
267 272
273 // Called when a property needs to change as the result of a change in the
274 // server, or the server failing to accept a change.
275 void SetWindowBoundsFromServer(WindowMus* window,
276 const gfx::Rect& revert_bounds);
277 void SetWindowVisibleFromServer(WindowMus* window, bool visible);
278
268 // Following are called from WindowMus. 279 // Following are called from WindowMus.
269 std::unique_ptr<WindowPortInitData> OnWindowMusCreated(WindowMus* window); 280 std::unique_ptr<WindowPortInitData> OnWindowMusCreated(WindowMus* window);
270 void OnWindowMusInitDone(WindowMus* window, 281 void OnWindowMusInitDone(WindowMus* window,
271 std::unique_ptr<WindowPortInitData> init_data); 282 std::unique_ptr<WindowPortInitData> init_data);
272 void OnWindowMusDestroyed(WindowMus* window); 283 void OnWindowMusDestroyed(WindowMus* window);
273 void OnWindowMusBoundsChanged(WindowMus* window, 284 void OnWindowMusBoundsChanged(WindowMus* window,
274 const gfx::Rect& old_bounds, 285 const gfx::Rect& old_bounds,
275 const gfx::Rect& new_bounds); 286 const gfx::Rect& new_bounds);
276 void OnWindowMusAddChild(WindowMus* parent, WindowMus* child); 287 void OnWindowMusAddChild(WindowMus* parent, WindowMus* child);
277 void OnWindowMusRemoveChild(WindowMus* parent, WindowMus* child); 288 void OnWindowMusRemoveChild(WindowMus* parent, WindowMus* child);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 Window* window, 431 Window* window,
421 const gfx::Vector2d& offset, 432 const gfx::Vector2d& offset,
422 const gfx::Insets& hit_area) override; 433 const gfx::Insets& hit_area) override;
423 434
424 // Overriden from client::FocusChangeObserver: 435 // Overriden from client::FocusChangeObserver:
425 void OnWindowFocused(Window* gained_focus, Window* lost_focus) override; 436 void OnWindowFocused(Window* gained_focus, Window* lost_focus) override;
426 437
427 // Overriden from client::CaptureClientObserver: 438 // Overriden from client::CaptureClientObserver:
428 void OnCaptureChanged(Window* lost_capture, Window* gained_capture) override; 439 void OnCaptureChanged(Window* lost_capture, Window* gained_capture) override;
429 440
441 // Overriden from WindowTreeHostMusDelegate:
442 void SetRootWindowBounds(Window* window, gfx::Rect* bounds) override;
443
430 // The one int in |cursor_location_mapping_|. When we read from this 444 // The one int in |cursor_location_mapping_|. When we read from this
431 // location, we must always read from it atomically. 445 // location, we must always read from it atomically.
432 base::subtle::Atomic32* cursor_location_memory() { 446 base::subtle::Atomic32* cursor_location_memory() {
433 return reinterpret_cast<base::subtle::Atomic32*>( 447 return reinterpret_cast<base::subtle::Atomic32*>(
434 cursor_location_mapping_.get()); 448 cursor_location_mapping_.get());
435 } 449 }
436 450
437 // This is set once and only once when we get OnEmbed(). It gives the unique 451 // This is set once and only once when we get OnEmbed(). It gives the unique
438 // id for this client. 452 // id for this client.
439 ClientSpecificId client_id_; 453 ClientSpecificId client_id_;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 std::set<Id> drag_entered_windows_; 524 std::set<Id> drag_entered_windows_;
511 525
512 base::WeakPtrFactory<WindowTreeClient> weak_factory_; 526 base::WeakPtrFactory<WindowTreeClient> weak_factory_;
513 527
514 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); 528 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient);
515 }; 529 };
516 530
517 } // namespace aura 531 } // namespace aura
518 532
519 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ 533 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698