Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 ASH_MUS_WINDOW_MANAGER_H_ | 5 #ifndef ASH_MUS_WINDOW_MANAGER_H_ |
| 6 #define ASH_MUS_WINDOW_MANAGER_H_ | 6 #define ASH_MUS_WINDOW_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 | 12 |
| 13 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/observer_list.h" | |
| 17 #include "services/ui/common/types.h" | 16 #include "services/ui/common/types.h" |
| 18 #include "services/ui/public/interfaces/display/display_controller.mojom.h" | 17 #include "services/ui/public/interfaces/display/display_controller.mojom.h" |
| 19 #include "services/ui/public/interfaces/window_manager.mojom.h" | 18 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 20 #include "ui/aura/mus/window_manager_delegate.h" | 19 #include "ui/aura/mus/window_manager_delegate.h" |
| 21 #include "ui/aura/mus/window_tree_client_delegate.h" | 20 #include "ui/aura/mus/window_tree_client_delegate.h" |
| 22 | 21 |
| 23 namespace aura { | |
| 24 namespace client { | |
| 25 class ActivationClient; | |
| 26 } | |
| 27 } | |
| 28 | |
| 29 namespace base { | 22 namespace base { |
| 30 class SequencedWorkerPool; | 23 class SequencedWorkerPool; |
| 31 } | 24 } |
| 32 | 25 |
| 33 namespace display { | 26 namespace display { |
| 34 class Display; | 27 class Display; |
| 35 } | 28 } |
| 36 | 29 |
| 37 namespace service_manager { | 30 namespace service_manager { |
| 38 class Connector; | 31 class Connector; |
| 39 } | 32 } |
| 40 | 33 |
| 41 namespace views { | 34 namespace views { |
| 42 class PointerWatcherEventRouter; | 35 class PointerWatcherEventRouter; |
| 43 } | 36 } |
| 44 | 37 |
| 45 namespace wm { | 38 namespace wm { |
| 46 class FocusController; | |
| 47 class WMState; | 39 class WMState; |
| 48 } | 40 } |
| 49 | 41 |
| 50 namespace ash { | 42 namespace ash { |
| 51 | 43 |
| 52 class EventClientImpl; | |
| 53 class ScreenPositionController; | |
| 54 class ScreenMus; | 44 class ScreenMus; |
| 45 class SystemTrayDelegate; | |
| 55 | 46 |
| 56 namespace mus { | 47 namespace mus { |
| 57 | 48 |
| 58 class AcceleratorHandler; | 49 class AcceleratorHandler; |
| 59 class RootWindowController; | 50 class RootWindowController; |
| 60 class ShadowController; | 51 class ShadowController; |
| 61 class WindowManagerObserver; | |
| 62 class WmShellMus; | |
| 63 class WmLookupMus; | 52 class WmLookupMus; |
| 64 class WmTestHelper; | 53 class WmTestHelper; |
| 65 | 54 |
| 66 // WindowManager serves as the WindowManagerDelegate and | 55 // WindowManager serves as the WindowManagerDelegate and |
| 67 // WindowTreeClientDelegate for mash. WindowManager creates (and owns) | 56 // WindowTreeClientDelegate for mash. WindowManager creates (and owns) |
| 68 // a RootWindowController per Display. WindowManager takes ownership of | 57 // a RootWindowController per Display. WindowManager takes ownership of |
| 69 // the WindowTreeClient. | 58 // the WindowTreeClient. |
| 70 class WindowManager : public aura::WindowManagerDelegate, | 59 class WindowManager : public aura::WindowManagerDelegate, |
| 71 public aura::WindowTreeClientDelegate { | 60 public aura::WindowTreeClientDelegate { |
| 72 public: | 61 public: |
| 73 explicit WindowManager(service_manager::Connector* connector); | 62 explicit WindowManager(service_manager::Connector* connector); |
| 74 ~WindowManager() override; | 63 ~WindowManager() override; |
| 75 | 64 |
| 76 void Init(std::unique_ptr<aura::WindowTreeClient> window_tree_client, | 65 void Init(std::unique_ptr<aura::WindowTreeClient> window_tree_client, |
| 77 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool); | 66 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool); |
| 78 | 67 |
| 79 WmShellMus* shell() { return shell_.get(); } | 68 // Called during shutdown to delete all the RootWindowControllers. |
| 69 void DeleteAllRootWindowControllers(); | |
| 80 | 70 |
| 81 ScreenMus* screen() { return screen_.get(); } | 71 ScreenMus* screen() { return screen_.get(); } |
| 82 | 72 |
| 83 aura::WindowTreeClient* window_tree_client() { | 73 aura::WindowTreeClient* window_tree_client() { |
| 84 return window_tree_client_.get(); | 74 return window_tree_client_.get(); |
| 85 } | 75 } |
| 86 | 76 |
| 87 aura::WindowManagerClient* window_manager_client() { | 77 aura::WindowManagerClient* window_manager_client() { |
| 88 return window_manager_client_; | 78 return window_manager_client_; |
| 89 } | 79 } |
| 90 | 80 |
| 91 ::wm::FocusController* focus_controller() { return focus_controller_.get(); } | |
| 92 | |
| 93 aura::client::ActivationClient* activation_client(); | |
| 94 | |
| 95 service_manager::Connector* connector() { return connector_; } | 81 service_manager::Connector* connector() { return connector_; } |
| 96 | 82 |
| 97 aura::PropertyConverter* property_converter() { | 83 aura::PropertyConverter* property_converter() { |
| 98 return property_converter_.get(); | 84 return property_converter_.get(); |
| 99 } | 85 } |
| 100 | 86 |
| 101 // Creates a new top level window. | 87 // Creates a new top level window. |
| 102 aura::Window* NewTopLevelWindow( | 88 aura::Window* NewTopLevelWindow( |
| 103 ui::mojom::WindowType window_type, | 89 ui::mojom::WindowType window_type, |
| 104 std::map<std::string, std::vector<uint8_t>>* properties); | 90 std::map<std::string, std::vector<uint8_t>>* properties); |
| 105 | 91 |
| 106 std::set<RootWindowController*> GetRootWindowControllers(); | 92 std::set<RootWindowController*> GetRootWindowControllers(); |
| 107 | 93 |
| 108 // Returns the next accelerator namespace id by value in |id|. Returns true | 94 // Returns the next accelerator namespace id by value in |id|. Returns true |
| 109 // if there is another slot available, false if all slots are taken up. | 95 // if there is another slot available, false if all slots are taken up. |
| 110 bool GetNextAcceleratorNamespaceId(uint16_t* id); | 96 bool GetNextAcceleratorNamespaceId(uint16_t* id); |
| 111 void AddAcceleratorHandler(uint16_t id_namespace, | 97 void AddAcceleratorHandler(uint16_t id_namespace, |
| 112 AcceleratorHandler* handler); | 98 AcceleratorHandler* handler); |
| 113 void RemoveAcceleratorHandler(uint16_t id_namespace); | 99 void RemoveAcceleratorHandler(uint16_t id_namespace); |
| 114 | 100 |
| 115 void AddObserver(WindowManagerObserver* observer); | |
| 116 void RemoveObserver(WindowManagerObserver* observer); | |
| 117 | |
| 118 // Returns the DisplayController interface if available. Will be null if no | 101 // Returns the DisplayController interface if available. Will be null if no |
| 119 // service_manager::Connector was available, for example in some tests. | 102 // service_manager::Connector was available, for example in some tests. |
| 120 display::mojom::DisplayController* GetDisplayController(); | 103 display::mojom::DisplayController* GetDisplayController(); |
| 121 | 104 |
| 105 // Called during creation of the shell to create a RootWindowController. | |
| 106 // See comment in CreateRootWindowController() for details. | |
| 107 void CreatePrimaryRootWindowController( | |
| 108 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host); | |
| 109 | |
| 122 private: | 110 private: |
| 123 friend class WmTestHelper; | 111 friend class WmTestHelper; |
| 124 | 112 |
| 125 using RootWindowControllers = std::set<std::unique_ptr<RootWindowController>>; | 113 using RootWindowControllers = std::set<std::unique_ptr<RootWindowController>>; |
| 126 | 114 |
| 127 RootWindowController* CreateRootWindowController( | 115 // Called once the first Display has been obtained. |
| 116 void CreateShell( | |
| 117 std::unique_ptr<aura::WindowTreeHostMus> primary_window_tree_host); | |
| 118 | |
| 119 void CreateRootWindowController( | |
| 128 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, | 120 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, |
| 129 const display::Display& display, | 121 const display::Display& display, |
| 130 ash::RootWindowController::RootWindowType root_window_type); | 122 ash::RootWindowController::RootWindowType root_window_type); |
| 131 | 123 |
| 132 // Deletes the specified RootWindowController. Called when a display is | 124 // Deletes the specified RootWindowController. Called when a display is |
| 133 // removed. | 125 // removed. |in_shutdown| is true if called from Shutdown(). |
| 134 void DestroyRootWindowController( | 126 void DestroyRootWindowController(RootWindowController* root_window_controller, |
| 135 RootWindowController* root_window_controller); | 127 bool in_shutdown); |
| 136 | 128 |
| 137 void Shutdown(); | 129 void Shutdown(); |
| 138 | 130 |
| 139 RootWindowController* GetPrimaryRootWindowController(); | 131 RootWindowController* GetPrimaryRootWindowController(); |
| 140 | 132 |
| 141 // Returns the RootWindowController where new top levels are created. | 133 // Returns the RootWindowController where new top levels are created. |
| 142 // |properties| is the properties supplied during window creation. | 134 // |properties| is the properties supplied during window creation. |
| 143 RootWindowController* GetRootWindowControllerForNewTopLevelWindow( | 135 RootWindowController* GetRootWindowControllerForNewTopLevelWindow( |
| 144 std::map<std::string, std::vector<uint8_t>>* properties); | 136 std::map<std::string, std::vector<uint8_t>>* properties); |
| 145 | 137 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 void OnWmSetClientArea( | 172 void OnWmSetClientArea( |
| 181 aura::Window* window, | 173 aura::Window* window, |
| 182 const gfx::Insets& insets, | 174 const gfx::Insets& insets, |
| 183 const std::vector<gfx::Rect>& additional_client_areas) override; | 175 const std::vector<gfx::Rect>& additional_client_areas) override; |
| 184 bool IsWindowActive(aura::Window* window) override; | 176 bool IsWindowActive(aura::Window* window) override; |
| 185 void OnWmDeactivateWindow(aura::Window* window) override; | 177 void OnWmDeactivateWindow(aura::Window* window) override; |
| 186 | 178 |
| 187 service_manager::Connector* connector_; | 179 service_manager::Connector* connector_; |
| 188 display::mojom::DisplayControllerPtr display_controller_; | 180 display::mojom::DisplayControllerPtr display_controller_; |
| 189 | 181 |
| 190 std::unique_ptr<::wm::FocusController> focus_controller_; | |
| 191 std::unique_ptr<::wm::WMState> wm_state_; | 182 std::unique_ptr<::wm::WMState> wm_state_; |
| 192 std::unique_ptr<aura::PropertyConverter> property_converter_; | 183 std::unique_ptr<aura::PropertyConverter> property_converter_; |
| 193 | 184 |
| 194 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; | 185 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; |
| 195 | 186 |
| 196 aura::WindowManagerClient* window_manager_client_ = nullptr; | 187 aura::WindowManagerClient* window_manager_client_ = nullptr; |
| 197 | 188 |
| 198 std::unique_ptr<views::PointerWatcherEventRouter> | 189 std::unique_ptr<views::PointerWatcherEventRouter> |
| 199 pointer_watcher_event_router_; | 190 pointer_watcher_event_router_; |
| 200 | 191 |
| 201 std::unique_ptr<ShadowController> shadow_controller_; | 192 std::unique_ptr<ShadowController> shadow_controller_; |
| 202 | 193 |
| 203 RootWindowControllers root_window_controllers_; | 194 RootWindowControllers root_window_controllers_; |
| 204 | 195 |
| 205 base::ObserverList<WindowManagerObserver> observers_; | |
| 206 | |
| 207 std::unique_ptr<ScreenMus> screen_; | 196 std::unique_ptr<ScreenMus> screen_; |
| 208 | 197 |
| 209 std::unique_ptr<WmShellMus> shell_; | 198 bool created_shell_ = false; |
| 210 | 199 |
| 211 std::unique_ptr<WmLookupMus> lookup_; | 200 std::unique_ptr<WmLookupMus> lookup_; |
| 212 | 201 |
| 213 std::map<uint16_t, AcceleratorHandler*> accelerator_handlers_; | 202 std::map<uint16_t, AcceleratorHandler*> accelerator_handlers_; |
| 214 uint16_t next_accelerator_namespace_id_ = 0u; | 203 uint16_t next_accelerator_namespace_id_ = 0u; |
| 215 | 204 |
| 216 std::unique_ptr<EventClientImpl> event_client_; | 205 scoped_refptr<base::SequencedWorkerPool> blocking_pool_; |
| 217 | 206 |
| 218 std::unique_ptr<ScreenPositionController> screen_position_controller_; | 207 // If non-null this is used as the return value from |
| 208 // ShellDelegateMus::CreateSystemTrayDelegate(). This is only set in tests. | |
| 209 // | |
| 210 // TODO(jamescook): Pass a TestShellDelegate into WindowManager and use it to | |
| 211 // create the various test delegates rather than a mem | |
|
James Cook
2017/01/18 01:00:24
mem?
sky
2017/01/18 04:00:07
D'OH! 'member'. Updated.
| |
| 212 std::unique_ptr<SystemTrayDelegate> system_tray_delegate_; | |
|
James Cook
2017/01/18 01:00:24
system_tray_delegate_for_testing_? Then you could
sky
2017/01/18 04:00:07
I renamed, but left the comment.
| |
| 219 | 213 |
| 220 DISALLOW_COPY_AND_ASSIGN(WindowManager); | 214 DISALLOW_COPY_AND_ASSIGN(WindowManager); |
| 221 }; | 215 }; |
| 222 | 216 |
| 223 } // namespace mus | 217 } // namespace mus |
| 224 } // namespace ash | 218 } // namespace ash |
| 225 | 219 |
| 226 #endif // ASH_MUS_WINDOW_MANAGER_H_ | 220 #endif // ASH_MUS_WINDOW_MANAGER_H_ |
| OLD | NEW |