| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 14 matching lines...) Expand all Loading... |
| 262 // Called by WmNewDisplayAdded(). | 267 // Called by WmNewDisplayAdded(). |
| 263 WindowTreeHost* WmNewDisplayAddedImpl(const display::Display& display, | 268 WindowTreeHost* WmNewDisplayAddedImpl(const display::Display& display, |
| 264 ui::mojom::WindowDataPtr root_data, | 269 ui::mojom::WindowDataPtr root_data, |
| 265 bool parent_drawn); | 270 bool parent_drawn); |
| 266 | 271 |
| 267 std::unique_ptr<EventResultCallback> CreateEventResultCallback( | 272 std::unique_ptr<EventResultCallback> CreateEventResultCallback( |
| 268 int32_t event_id); | 273 int32_t event_id); |
| 269 | 274 |
| 270 void OnReceivedCursorLocationMemory(mojo::ScopedSharedBufferHandle handle); | 275 void OnReceivedCursorLocationMemory(mojo::ScopedSharedBufferHandle handle); |
| 271 | 276 |
| 277 // Called when a property needs to change as the result of a change in the |
| 278 // server, or the server failing to accept a change. |
| 279 void SetWindowBoundsFromServer(WindowMus* window, |
| 280 const gfx::Rect& revert_bounds); |
| 281 void SetWindowVisibleFromServer(WindowMus* window, bool visible); |
| 282 |
| 272 // Following are called from WindowMus. | 283 // Following are called from WindowMus. |
| 273 std::unique_ptr<WindowPortInitData> OnWindowMusCreated(WindowMus* window); | 284 std::unique_ptr<WindowPortInitData> OnWindowMusCreated(WindowMus* window); |
| 274 void OnWindowMusInitDone(WindowMus* window, | 285 void OnWindowMusInitDone(WindowMus* window, |
| 275 std::unique_ptr<WindowPortInitData> init_data); | 286 std::unique_ptr<WindowPortInitData> init_data); |
| 276 void OnWindowMusDestroyed(WindowMus* window); | 287 void OnWindowMusDestroyed(WindowMus* window); |
| 277 void OnWindowMusBoundsChanged(WindowMus* window, | 288 void OnWindowMusBoundsChanged(WindowMus* window, |
| 278 const gfx::Rect& old_bounds, | 289 const gfx::Rect& old_bounds, |
| 279 const gfx::Rect& new_bounds); | 290 const gfx::Rect& new_bounds); |
| 280 void OnWindowMusAddChild(WindowMus* parent, WindowMus* child); | 291 void OnWindowMusAddChild(WindowMus* parent, WindowMus* child); |
| 281 void OnWindowMusRemoveChild(WindowMus* parent, WindowMus* child); | 292 void OnWindowMusRemoveChild(WindowMus* parent, WindowMus* child); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 Window* window, | 435 Window* window, |
| 425 const gfx::Vector2d& offset, | 436 const gfx::Vector2d& offset, |
| 426 const gfx::Insets& hit_area) override; | 437 const gfx::Insets& hit_area) override; |
| 427 | 438 |
| 428 // Overriden from client::FocusChangeObserver: | 439 // Overriden from client::FocusChangeObserver: |
| 429 void OnWindowFocused(Window* gained_focus, Window* lost_focus) override; | 440 void OnWindowFocused(Window* gained_focus, Window* lost_focus) override; |
| 430 | 441 |
| 431 // Overriden from client::CaptureClientObserver: | 442 // Overriden from client::CaptureClientObserver: |
| 432 void OnCaptureChanged(Window* lost_capture, Window* gained_capture) override; | 443 void OnCaptureChanged(Window* lost_capture, Window* gained_capture) override; |
| 433 | 444 |
| 445 // Overriden from WindowTreeHostMusDelegate: |
| 446 void SetRootWindowBounds(Window* window, gfx::Rect* bounds) override; |
| 447 |
| 434 // The one int in |cursor_location_mapping_|. When we read from this | 448 // The one int in |cursor_location_mapping_|. When we read from this |
| 435 // location, we must always read from it atomically. | 449 // location, we must always read from it atomically. |
| 436 base::subtle::Atomic32* cursor_location_memory() { | 450 base::subtle::Atomic32* cursor_location_memory() { |
| 437 return reinterpret_cast<base::subtle::Atomic32*>( | 451 return reinterpret_cast<base::subtle::Atomic32*>( |
| 438 cursor_location_mapping_.get()); | 452 cursor_location_mapping_.get()); |
| 439 } | 453 } |
| 440 | 454 |
| 441 // This is set once and only once when we get OnEmbed(). It gives the unique | 455 // This is set once and only once when we get OnEmbed(). It gives the unique |
| 442 // id for this client. | 456 // id for this client. |
| 443 ClientSpecificId client_id_; | 457 ClientSpecificId client_id_; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 std::set<Id> drag_entered_windows_; | 528 std::set<Id> drag_entered_windows_; |
| 515 | 529 |
| 516 base::WeakPtrFactory<WindowTreeClient> weak_factory_; | 530 base::WeakPtrFactory<WindowTreeClient> weak_factory_; |
| 517 | 531 |
| 518 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); | 532 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); |
| 519 }; | 533 }; |
| 520 | 534 |
| 521 } // namespace aura | 535 } // namespace aura |
| 522 | 536 |
| 523 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ | 537 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ |
| OLD | NEW |