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 "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "services/ui/common/types.h" | 16 #include "services/ui/common/types.h" |
17 #include "services/ui/public/cpp/window_manager_delegate.h" | |
18 #include "services/ui/public/cpp/window_tree_client_delegate.h" | |
19 #include "services/ui/public/interfaces/display/display_controller.mojom.h" | 17 #include "services/ui/public/interfaces/display/display_controller.mojom.h" |
20 #include "services/ui/public/interfaces/window_manager.mojom.h" | 18 #include "services/ui/public/interfaces/window_manager.mojom.h" |
19 #include "ui/aura/env_observer.h" | |
20 #include "ui/aura/mus/window_manager_delegate.h" | |
21 #include "ui/aura/mus/window_tree_client_delegate.h" | |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class SequencedWorkerPool; | 24 class SequencedWorkerPool; |
24 } | 25 } |
25 | 26 |
26 namespace display { | 27 namespace display { |
27 class Display; | 28 class Display; |
28 class ScreenBase; | |
29 } | 29 } |
30 | 30 |
31 namespace service_manager { | 31 namespace service_manager { |
32 class Connector; | 32 class Connector; |
33 } | 33 } |
34 | 34 |
35 namespace views { | 35 namespace views { |
36 class PointerWatcherEventRouter; | 36 class PointerWatcherEventRouter2; |
James Cook
2016/12/05 19:21:45
Ugh. Is there a bug open to track getting rid of P
sky
2016/12/05 21:39:20
671363 (just filed)
| |
37 } | |
38 | |
39 namespace wm { | |
40 class FocusController; | |
41 class WMState; | |
37 } | 42 } |
38 | 43 |
39 namespace ash { | 44 namespace ash { |
45 | |
46 class EventClientImpl; | |
47 class ScreenPositionController; | |
48 class ScreenMus; | |
49 | |
40 namespace mus { | 50 namespace mus { |
41 | 51 |
42 class AcceleratorHandler; | 52 class AcceleratorHandler; |
43 class RootWindowController; | 53 class RootWindowController; |
44 class ShadowController; | 54 class ShadowController; |
45 class WindowManagerObserver; | 55 class WindowManagerObserver; |
46 class WmShellMus; | 56 class WmShellMus; |
47 class WmLookupMus; | 57 class WmLookupMus; |
48 class WmTestHelper; | 58 class WmTestHelper; |
49 | 59 |
50 // WindowManager serves as the WindowManagerDelegate and | 60 // WindowManager serves as the WindowManagerDelegate and |
51 // WindowTreeClientDelegate for mash. WindowManager creates (and owns) | 61 // WindowTreeClientDelegate for mash. WindowManager creates (and owns) |
52 // a RootWindowController per Display. WindowManager takes ownership of | 62 // a RootWindowController per Display. WindowManager takes ownership of |
53 // the WindowTreeClient. | 63 // the WindowTreeClient. |
54 class WindowManager : public ui::WindowManagerDelegate, | 64 class WindowManager : public aura::WindowManagerDelegate, |
55 public ui::WindowTreeClientDelegate { | 65 public aura::WindowTreeClientDelegate, |
66 public aura::EnvObserver { | |
56 public: | 67 public: |
57 explicit WindowManager(service_manager::Connector* connector); | 68 explicit WindowManager(service_manager::Connector* connector); |
58 ~WindowManager() override; | 69 ~WindowManager() override; |
59 | 70 |
60 void Init(std::unique_ptr<ui::WindowTreeClient> window_tree_client, | 71 void Init(std::unique_ptr<aura::WindowTreeClient> window_tree_client, |
61 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool); | 72 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool); |
62 | 73 |
63 WmShellMus* shell() { return shell_.get(); } | 74 WmShellMus* shell() { return shell_.get(); } |
64 | 75 |
65 display::ScreenBase* screen() { return screen_.get(); } | 76 ScreenMus* screen() { return screen_.get(); } |
66 | 77 |
67 ui::WindowTreeClient* window_tree_client() { | 78 aura::WindowTreeClient* window_tree_client() { |
68 return window_tree_client_.get(); | 79 return window_tree_client_.get(); |
69 } | 80 } |
70 | 81 |
71 ui::WindowManagerClient* window_manager_client() { | 82 aura::WindowManagerClient* window_manager_client() { |
72 return window_manager_client_; | 83 return window_manager_client_; |
73 } | 84 } |
74 | 85 |
86 ::wm::FocusController* focus_controller() { return focus_controller_.get(); } | |
87 | |
75 service_manager::Connector* connector() { return connector_; } | 88 service_manager::Connector* connector() { return connector_; } |
76 | 89 |
90 aura::PropertyConverter* property_converter() { | |
91 return property_converter_.get(); | |
92 } | |
93 | |
77 void SetScreenLocked(bool is_locked); | 94 void SetScreenLocked(bool is_locked); |
78 | 95 |
79 // Creates a new top level window. | 96 // Creates a new top level window. |
80 ui::Window* NewTopLevelWindow( | 97 aura::Window* NewTopLevelWindow( |
98 ui::mojom::WindowType window_type, | |
81 std::map<std::string, std::vector<uint8_t>>* properties); | 99 std::map<std::string, std::vector<uint8_t>>* properties); |
82 | 100 |
83 std::set<RootWindowController*> GetRootWindowControllers(); | 101 std::set<RootWindowController*> GetRootWindowControllers(); |
84 | 102 |
85 // Returns the next accelerator namespace id by value in |id|. Returns true | 103 // Returns the next accelerator namespace id by value in |id|. Returns true |
86 // if there is another slot available, false if all slots are taken up. | 104 // if there is another slot available, false if all slots are taken up. |
87 bool GetNextAcceleratorNamespaceId(uint16_t* id); | 105 bool GetNextAcceleratorNamespaceId(uint16_t* id); |
88 void AddAcceleratorHandler(uint16_t id_namespace, | 106 void AddAcceleratorHandler(uint16_t id_namespace, |
89 AcceleratorHandler* handler); | 107 AcceleratorHandler* handler); |
90 void RemoveAcceleratorHandler(uint16_t id_namespace); | 108 void RemoveAcceleratorHandler(uint16_t id_namespace); |
91 | 109 |
92 void AddObserver(WindowManagerObserver* observer); | 110 void AddObserver(WindowManagerObserver* observer); |
93 void RemoveObserver(WindowManagerObserver* observer); | 111 void RemoveObserver(WindowManagerObserver* observer); |
94 | 112 |
95 // Returns the DisplayController interface if available. Will be null if no | 113 // Returns the DisplayController interface if available. Will be null if no |
96 // service_manager::Connector was available, for example in some tests. | 114 // service_manager::Connector was available, for example in some tests. |
97 display::mojom::DisplayController* GetDisplayController(); | 115 display::mojom::DisplayController* GetDisplayController(); |
98 | 116 |
99 private: | 117 private: |
100 friend class WmTestHelper; | 118 friend class WmTestHelper; |
101 | 119 |
102 using RootWindowControllers = std::set<std::unique_ptr<RootWindowController>>; | 120 using RootWindowControllers = std::set<std::unique_ptr<RootWindowController>>; |
103 | 121 |
104 RootWindowController* CreateRootWindowController( | 122 RootWindowController* CreateRootWindowController( |
105 ui::Window* window, | 123 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, |
106 const display::Display& display); | 124 const display::Display& display); |
107 | 125 |
108 // Deletes the specified RootWindowController. Called when a display is | 126 // Deletes the specified RootWindowController. Called when a display is |
109 // removed. | 127 // removed. |
110 void DestroyRootWindowController( | 128 void DestroyRootWindowController( |
111 RootWindowController* root_window_controller); | 129 RootWindowController* root_window_controller); |
112 | 130 |
113 void Shutdown(); | 131 void Shutdown(); |
114 | 132 |
115 // Returns an iterator into |root_window_controllers_|. Returns | |
116 // root_window_controllers_.end() if |window| is not the root of a | |
117 // RootWindowController. | |
118 RootWindowControllers::iterator FindRootWindowControllerByWindow( | |
119 ui::Window* window); | |
120 | |
121 RootWindowController* GetPrimaryRootWindowController(); | 133 RootWindowController* GetPrimaryRootWindowController(); |
122 | 134 |
123 // Returns the RootWindowController where new top levels are created. | 135 // Returns the RootWindowController where new top levels are created. |
124 // |properties| is the properties supplied during window creation. | 136 // |properties| is the properties supplied during window creation. |
125 RootWindowController* GetRootWindowControllerForNewTopLevelWindow( | 137 RootWindowController* GetRootWindowControllerForNewTopLevelWindow( |
126 std::map<std::string, std::vector<uint8_t>>* properties); | 138 std::map<std::string, std::vector<uint8_t>>* properties); |
127 | 139 |
128 // WindowTreeClientDelegate: | 140 // WindowTreeClientDelegate: |
129 void OnEmbed(ui::Window* root) override; | 141 void OnEmbed( |
130 void OnEmbedRootDestroyed(ui::Window* root) override; | 142 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override; |
131 void OnLostConnection(ui::WindowTreeClient* client) override; | 143 void OnEmbedRootDestroyed(aura::Window* root) override; |
144 void OnLostConnection(aura::WindowTreeClient* client) override; | |
132 void OnPointerEventObserved(const ui::PointerEvent& event, | 145 void OnPointerEventObserved(const ui::PointerEvent& event, |
133 ui::Window* target) override; | 146 aura::Window* target) override; |
147 aura::client::CaptureClient* GetCaptureClient() override; | |
148 aura::PropertyConverter* GetPropertyConverter() override; | |
134 | 149 |
135 // WindowManagerDelegate: | 150 // WindowManagerDelegate: |
136 void SetWindowManagerClient(ui::WindowManagerClient* client) override; | 151 void SetWindowManagerClient(aura::WindowManagerClient* client) override; |
137 bool OnWmSetBounds(ui::Window* window, gfx::Rect* bounds) override; | 152 bool OnWmSetBounds(aura::Window* window, gfx::Rect* bounds) override; |
138 bool OnWmSetProperty( | 153 bool OnWmSetProperty( |
139 ui::Window* window, | 154 aura::Window* window, |
140 const std::string& name, | 155 const std::string& name, |
141 std::unique_ptr<std::vector<uint8_t>>* new_data) override; | 156 std::unique_ptr<std::vector<uint8_t>>* new_data) override; |
142 ui::Window* OnWmCreateTopLevelWindow( | 157 aura::Window* OnWmCreateTopLevelWindow( |
158 ui::mojom::WindowType window_type, | |
143 std::map<std::string, std::vector<uint8_t>>* properties) override; | 159 std::map<std::string, std::vector<uint8_t>>* properties) override; |
144 void OnWmClientJankinessChanged(const std::set<ui::Window*>& client_windows, | 160 void OnWmClientJankinessChanged(const std::set<aura::Window*>& client_windows, |
145 bool not_responding) override; | 161 bool not_responding) override; |
146 void OnWmNewDisplay(ui::Window* window, | 162 void OnWmWillCreateDisplay(const display::Display& display) override; |
163 void OnWmNewDisplay(std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, | |
147 const display::Display& display) override; | 164 const display::Display& display) override; |
148 void OnWmDisplayRemoved(ui::Window* window) override; | 165 void OnWmDisplayRemoved(aura::WindowTreeHostMus* window_tree_host) override; |
149 void OnWmDisplayModified(const display::Display& display) override; | 166 void OnWmDisplayModified(const display::Display& display) override; |
150 void OnWmPerformMoveLoop(ui::Window* window, | 167 void OnWmPerformMoveLoop(aura::Window* window, |
151 ui::mojom::MoveLoopSource source, | 168 ui::mojom::MoveLoopSource source, |
152 const gfx::Point& cursor_location, | 169 const gfx::Point& cursor_location, |
153 const base::Callback<void(bool)>& on_done) override; | 170 const base::Callback<void(bool)>& on_done) override; |
154 void OnWmCancelMoveLoop(ui::Window* window) override; | 171 void OnWmCancelMoveLoop(aura::Window* window) override; |
155 ui::mojom::EventResult OnAccelerator(uint32_t id, | 172 ui::mojom::EventResult OnAccelerator(uint32_t id, |
156 const ui::Event& event) override; | 173 const ui::Event& event) override; |
174 void OnWmSetClientArea( | |
175 aura::Window* window, | |
176 const gfx::Insets& insets, | |
177 const std::vector<gfx::Rect>& additional_client_areas) override; | |
178 | |
179 // aura::EnvObserver: | |
180 void OnWindowInitialized(aura::Window* window) override; | |
157 | 181 |
158 service_manager::Connector* connector_; | 182 service_manager::Connector* connector_; |
159 display::mojom::DisplayControllerPtr display_controller_; | 183 display::mojom::DisplayControllerPtr display_controller_; |
160 | 184 |
161 std::unique_ptr<ui::WindowTreeClient> window_tree_client_; | 185 std::unique_ptr<::wm::FocusController> focus_controller_; |
186 std::unique_ptr<::wm::WMState> wm_state_; | |
187 std::unique_ptr<aura::PropertyConverter> property_converter_; | |
162 | 188 |
163 ui::WindowManagerClient* window_manager_client_ = nullptr; | 189 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; |
164 | 190 |
165 std::unique_ptr<views::PointerWatcherEventRouter> | 191 aura::WindowManagerClient* window_manager_client_ = nullptr; |
192 | |
193 std::unique_ptr<views::PointerWatcherEventRouter2> | |
166 pointer_watcher_event_router_; | 194 pointer_watcher_event_router_; |
167 | 195 |
168 std::unique_ptr<ShadowController> shadow_controller_; | 196 std::unique_ptr<ShadowController> shadow_controller_; |
169 | 197 |
170 RootWindowControllers root_window_controllers_; | 198 RootWindowControllers root_window_controllers_; |
171 | 199 |
172 base::ObserverList<WindowManagerObserver> observers_; | 200 base::ObserverList<WindowManagerObserver> observers_; |
173 | 201 |
174 std::unique_ptr<display::ScreenBase> screen_; | 202 std::unique_ptr<ScreenMus> screen_; |
175 | 203 |
176 std::unique_ptr<WmShellMus> shell_; | 204 std::unique_ptr<WmShellMus> shell_; |
177 | 205 |
178 std::unique_ptr<WmLookupMus> lookup_; | 206 std::unique_ptr<WmLookupMus> lookup_; |
179 | 207 |
180 std::map<uint16_t, AcceleratorHandler*> accelerator_handlers_; | 208 std::map<uint16_t, AcceleratorHandler*> accelerator_handlers_; |
181 uint16_t next_accelerator_namespace_id_ = 0u; | 209 uint16_t next_accelerator_namespace_id_ = 0u; |
182 | 210 |
211 std::unique_ptr<EventClientImpl> event_client_; | |
212 | |
213 std::unique_ptr<ScreenPositionController> screen_position_controller_; | |
214 | |
183 DISALLOW_COPY_AND_ASSIGN(WindowManager); | 215 DISALLOW_COPY_AND_ASSIGN(WindowManager); |
184 }; | 216 }; |
185 | 217 |
186 } // namespace mus | 218 } // namespace mus |
187 } // namespace ash | 219 } // namespace ash |
188 | 220 |
189 #endif // ASH_MUS_WINDOW_MANAGER_H_ | 221 #endif // ASH_MUS_WINDOW_MANAGER_H_ |
OLD | NEW |