| 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 COMPONENTS_MUS_WS_WINDOW_TREE_H_ | 5 #ifndef COMPONENTS_MUS_WS_WINDOW_TREE_H_ |
| 6 #define COMPONENTS_MUS_WS_WINDOW_TREE_H_ | 6 #define COMPONENTS_MUS_WS_WINDOW_TREE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 class Event; | 34 class Event; |
| 35 } | 35 } |
| 36 | 36 |
| 37 namespace mus { | 37 namespace mus { |
| 38 namespace ws { | 38 namespace ws { |
| 39 | 39 |
| 40 class AccessPolicy; | 40 class AccessPolicy; |
| 41 class DisplayManager; | 41 class DisplayManager; |
| 42 class Display; | 42 class Display; |
| 43 class EventMatcher; | 43 class EventMatcher; |
| 44 class GlobalWindowManagerState; | |
| 45 class ServerWindow; | 44 class ServerWindow; |
| 46 class TargetedEvent; | 45 class TargetedEvent; |
| 46 class WindowManagerDisplayRoot; |
| 47 class WindowManagerState; | 47 class WindowManagerState; |
| 48 class WindowServer; | 48 class WindowServer; |
| 49 class WindowTreeTest; | 49 class WindowTreeTest; |
| 50 | 50 |
| 51 namespace test { | 51 namespace test { |
| 52 class WindowTreeTestApi; | 52 class WindowTreeTestApi; |
| 53 } | 53 } |
| 54 | 54 |
| 55 // WindowTree represents a view onto portions of the window tree. The parts of | 55 // WindowTree represents a view onto portions of the window tree. The parts of |
| 56 // the tree exposed to the client start at the root windows. A WindowTree may | 56 // the tree exposed to the client start at the root windows. A WindowTree may |
| (...skipping 10 matching lines...) Expand all Loading... |
| 67 public: | 67 public: |
| 68 WindowTree(WindowServer* window_server, | 68 WindowTree(WindowServer* window_server, |
| 69 const UserId& user_id, | 69 const UserId& user_id, |
| 70 ServerWindow* root, | 70 ServerWindow* root, |
| 71 std::unique_ptr<AccessPolicy> access_policy); | 71 std::unique_ptr<AccessPolicy> access_policy); |
| 72 ~WindowTree() override; | 72 ~WindowTree() override; |
| 73 | 73 |
| 74 void Init(std::unique_ptr<WindowTreeBinding> binding, | 74 void Init(std::unique_ptr<WindowTreeBinding> binding, |
| 75 mojom::WindowTreePtr tree); | 75 mojom::WindowTreePtr tree); |
| 76 | 76 |
| 77 // Called if this WindowTree hosts the WindowManager. This happens if | 77 // Called if this WindowTree hosts a WindowManager. |
| 78 // this WindowTree serves as the root of a WindowTreeHost. | |
| 79 void ConfigureWindowManager(); | 78 void ConfigureWindowManager(); |
| 80 | 79 |
| 81 ClientSpecificId id() const { return id_; } | 80 ClientSpecificId id() const { return id_; } |
| 82 | 81 |
| 83 const UserId& user_id() const { return user_id_; } | 82 const UserId& user_id() const { return user_id_; } |
| 84 | 83 |
| 85 mojom::WindowTreeClient* client() { return binding_->client(); } | 84 mojom::WindowTreeClient* client() { return binding_->client(); } |
| 86 | 85 |
| 87 // Returns the Window with the specified id. | 86 // Returns the Window with the specified id. |
| 88 ServerWindow* GetWindow(const WindowId& id) { | 87 ServerWindow* GetWindow(const WindowId& id) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 117 const std::string& name() const { return name_; } | 116 const std::string& name() const { return name_; } |
| 118 | 117 |
| 119 bool janky() const { return janky_; } | 118 bool janky() const { return janky_; } |
| 120 | 119 |
| 121 const Display* GetDisplay(const ServerWindow* window) const; | 120 const Display* GetDisplay(const ServerWindow* window) const; |
| 122 Display* GetDisplay(const ServerWindow* window) { | 121 Display* GetDisplay(const ServerWindow* window) { |
| 123 return const_cast<Display*>( | 122 return const_cast<Display*>( |
| 124 const_cast<const WindowTree*>(this)->GetDisplay(window)); | 123 const_cast<const WindowTree*>(this)->GetDisplay(window)); |
| 125 } | 124 } |
| 126 | 125 |
| 127 const WindowManagerState* GetWindowManagerState( | 126 const WindowManagerDisplayRoot* GetWindowManagerDisplayRoot( |
| 128 const ServerWindow* window) const; | 127 const ServerWindow* window) const; |
| 129 WindowManagerState* GetWindowManagerState(const ServerWindow* window) { | 128 WindowManagerDisplayRoot* GetWindowManagerDisplayRoot( |
| 130 return const_cast<WindowManagerState*>( | 129 const ServerWindow* window) { |
| 131 const_cast<const WindowTree*>(this)->GetWindowManagerState(window)); | 130 return const_cast<WindowManagerDisplayRoot*>( |
| 131 const_cast<const WindowTree*>(this)->GetWindowManagerDisplayRoot( |
| 132 window)); |
| 132 } | 133 } |
| 133 GlobalWindowManagerState* global_window_manager_state() { | 134 WindowManagerState* window_manager_state() { |
| 134 return global_window_manager_state_.get(); | 135 return window_manager_state_.get(); |
| 135 } | 136 } |
| 136 | 137 |
| 137 DisplayManager* display_manager(); | 138 DisplayManager* display_manager(); |
| 138 const DisplayManager* display_manager() const; | 139 const DisplayManager* display_manager() const; |
| 139 | 140 |
| 141 WindowServer* window_server() { return window_server_; } |
| 142 const WindowServer* window_server() const { return window_server_; } |
| 143 |
| 140 // Adds a new root to this tree. This is only valid for window managers. | 144 // Adds a new root to this tree. This is only valid for window managers. |
| 141 void AddRootForWindowManager(const ServerWindow* root); | 145 void AddRootForWindowManager(const ServerWindow* root); |
| 142 | 146 |
| 143 // Invoked when a tree is about to be destroyed. | 147 // Invoked when a tree is about to be destroyed. |
| 144 void OnWindowDestroyingTreeImpl(WindowTree* tree); | 148 void OnWindowDestroyingTreeImpl(WindowTree* tree); |
| 145 | 149 |
| 146 // These functions are synchronous variants of those defined in the mojom. The | 150 // These functions are synchronous variants of those defined in the mojom. The |
| 147 // WindowTree implementations all call into these. See the mojom for details. | 151 // WindowTree implementations all call into these. See the mojom for details. |
| 148 bool SetCapture(const ClientWindowId& client_window_id); | 152 bool SetCapture(const ClientWindowId& client_window_id); |
| 149 bool NewWindow(const ClientWindowId& client_window_id, | 153 bool NewWindow(const ClientWindowId& client_window_id, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 }; | 250 }; |
| 247 | 251 |
| 248 enum class RemoveRootReason { | 252 enum class RemoveRootReason { |
| 249 // The window is being removed. | 253 // The window is being removed. |
| 250 DELETED, | 254 DELETED, |
| 251 | 255 |
| 252 // Another client is being embedded in the window. | 256 // Another client is being embedded in the window. |
| 253 EMBED, | 257 EMBED, |
| 254 }; | 258 }; |
| 255 | 259 |
| 256 // Used when this tree is the window manager. | |
| 257 WindowManagerState* GetWindowManagerStateForWindowManager(); | |
| 258 | |
| 259 bool ShouldRouteToWindowManager(const ServerWindow* window) const; | 260 bool ShouldRouteToWindowManager(const ServerWindow* window) const; |
| 260 | 261 |
| 261 ClientWindowId ClientWindowIdForWindow(const ServerWindow* window) const; | 262 ClientWindowId ClientWindowIdForWindow(const ServerWindow* window) const; |
| 262 | 263 |
| 263 // Returns true if |id| is a valid WindowId for a new window. | 264 // Returns true if |id| is a valid WindowId for a new window. |
| 264 bool IsValidIdForNewWindow(const ClientWindowId& id) const; | 265 bool IsValidIdForNewWindow(const ClientWindowId& id) const; |
| 265 | 266 |
| 266 WindowId GenerateNewWindowId(); | 267 WindowId GenerateNewWindowId(); |
| 267 | 268 |
| 268 // These functions return true if the corresponding mojom function is allowed | 269 // These functions return true if the corresponding mojom function is allowed |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 uint32_t event_observer_id_ = 0; | 468 uint32_t event_observer_id_ = 0; |
| 468 | 469 |
| 469 // WindowManager the current event came from. | 470 // WindowManager the current event came from. |
| 470 WindowManagerState* event_source_wms_ = nullptr; | 471 WindowManagerState* event_source_wms_ = nullptr; |
| 471 | 472 |
| 472 std::queue<std::unique_ptr<TargetedEvent>> event_queue_; | 473 std::queue<std::unique_ptr<TargetedEvent>> event_queue_; |
| 473 | 474 |
| 474 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManagerClient>> | 475 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManagerClient>> |
| 475 window_manager_internal_client_binding_; | 476 window_manager_internal_client_binding_; |
| 476 mojom::WindowManager* window_manager_internal_; | 477 mojom::WindowManager* window_manager_internal_; |
| 477 std::unique_ptr<GlobalWindowManagerState> global_window_manager_state_; | 478 std::unique_ptr<WindowManagerState> window_manager_state_; |
| 478 | 479 |
| 479 std::unique_ptr<WaitingForTopLevelWindowInfo> | 480 std::unique_ptr<WaitingForTopLevelWindowInfo> |
| 480 waiting_for_top_level_window_info_; | 481 waiting_for_top_level_window_info_; |
| 481 | 482 |
| 482 DISALLOW_COPY_AND_ASSIGN(WindowTree); | 483 DISALLOW_COPY_AND_ASSIGN(WindowTree); |
| 483 }; | 484 }; |
| 484 | 485 |
| 485 } // namespace ws | 486 } // namespace ws |
| 486 } // namespace mus | 487 } // namespace mus |
| 487 | 488 |
| 488 #endif // COMPONENTS_MUS_WS_WINDOW_TREE_H_ | 489 #endif // COMPONENTS_MUS_WS_WINDOW_TREE_H_ |
| OLD | NEW |