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

Side by Side Diff: ash/mus/bridge/wm_shell_mus.cc

Issue 2633293005: Converts mash to use Shell (Closed)
Patch Set: feedback Created 3 years, 11 months 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
« no previous file with comments | « ash/mus/bridge/wm_shell_mus.h ('k') | ash/mus/keyboard_ui_mus.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "ash/mus/bridge/wm_shell_mus.h" 5 #include "ash/mus/bridge/wm_shell_mus.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/accelerators/accelerator_controller.h" 9 #include "ash/common/accelerators/accelerator_controller.h"
10 #include "ash/common/key_event_watcher.h" 10 #include "ash/common/key_event_watcher.h"
11 #include "ash/common/session/session_state_delegate.h" 11 #include "ash/common/session/session_state_delegate.h"
12 #include "ash/common/shell_delegate.h" 12 #include "ash/common/shell_delegate.h"
13 #include "ash/common/shell_observer.h" 13 #include "ash/common/shell_observer.h"
14 #include "ash/common/system/tray/system_tray_delegate.h" 14 #include "ash/common/system/tray/system_tray_delegate.h"
15 #include "ash/common/wallpaper/wallpaper_delegate.h" 15 #include "ash/common/wallpaper/wallpaper_delegate.h"
16 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h" 16 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h"
17 #include "ash/common/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard .h" 17 #include "ash/common/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard .h"
18 #include "ash/common/wm/mru_window_tracker.h" 18 #include "ash/common/wm/mru_window_tracker.h"
19 #include "ash/common/wm/window_cycle_event_filter.h" 19 #include "ash/common/wm/window_cycle_event_filter.h"
20 #include "ash/common/wm/window_resizer.h" 20 #include "ash/common/wm/window_resizer.h"
21 #include "ash/common/wm_activation_observer.h"
22 #include "ash/common/wm_window.h" 21 #include "ash/common/wm_window.h"
23 #include "ash/mus/accelerators/accelerator_controller_delegate_mus.h" 22 #include "ash/mus/accelerators/accelerator_controller_delegate_mus.h"
24 #include "ash/mus/accelerators/accelerator_controller_registrar.h" 23 #include "ash/mus/accelerators/accelerator_controller_registrar.h"
25 #include "ash/mus/bridge/immersive_handler_factory_mus.h" 24 #include "ash/mus/bridge/immersive_handler_factory_mus.h"
26 #include "ash/mus/bridge/workspace_event_handler_mus.h" 25 #include "ash/mus/bridge/workspace_event_handler_mus.h"
27 #include "ash/mus/drag_window_resizer.h" 26 #include "ash/mus/drag_window_resizer.h"
28 #include "ash/mus/keyboard_ui_mus.h" 27 #include "ash/mus/keyboard_ui_mus.h"
29 #include "ash/mus/root_window_controller.h" 28 #include "ash/mus/root_window_controller.h"
30 #include "ash/mus/window_manager.h" 29 #include "ash/mus/window_manager.h"
30 #include "ash/root_window_settings.h"
31 #include "ash/shared/immersive_fullscreen_controller.h" 31 #include "ash/shared/immersive_fullscreen_controller.h"
32 #include "ash/shell.h"
33 #include "ash/shell_init_params.h"
34 #include "ash/wm/window_util.h"
32 #include "base/memory/ptr_util.h" 35 #include "base/memory/ptr_util.h"
33 #include "components/user_manager/user_info_impl.h" 36 #include "components/user_manager/user_info_impl.h"
34 #include "ui/aura/mus/window_tree_client.h" 37 #include "ui/aura/mus/window_tree_client.h"
38 #include "ui/aura/mus/window_tree_host_mus.h"
35 #include "ui/aura/window.h" 39 #include "ui/aura/window.h"
36 #include "ui/display/manager/managed_display_info.h" 40 #include "ui/display/manager/managed_display_info.h"
37 #include "ui/display/screen.h" 41 #include "ui/display/screen.h"
38 #include "ui/views/mus/pointer_watcher_event_router.h" 42 #include "ui/views/mus/pointer_watcher_event_router.h"
39 #include "ui/wm/core/capture_controller.h" 43 #include "ui/wm/core/capture_controller.h"
40 #include "ui/wm/core/focus_controller.h" 44 #include "ui/wm/core/focus_controller.h"
41 45
42 namespace ash { 46 namespace ash {
43 namespace mus { 47 namespace mus {
44 48
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 102
99 // A pseudo user info. 103 // A pseudo user info.
100 std::unique_ptr<user_manager::UserInfo> user_info_; 104 std::unique_ptr<user_manager::UserInfo> user_info_;
101 105
102 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateStub); 106 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateStub);
103 }; 107 };
104 108
105 } // namespace 109 } // namespace
106 110
107 WmShellMus::WmShellMus( 111 WmShellMus::WmShellMus(
112 WmWindow* primary_root_window,
108 std::unique_ptr<ShellDelegate> shell_delegate, 113 std::unique_ptr<ShellDelegate> shell_delegate,
109 WindowManager* window_manager, 114 WindowManager* window_manager,
110 views::PointerWatcherEventRouter* pointer_watcher_event_router) 115 views::PointerWatcherEventRouter* pointer_watcher_event_router)
111 : WmShell(std::move(shell_delegate)), 116 : WmShell(std::move(shell_delegate)),
112 window_manager_(window_manager), 117 window_manager_(window_manager),
118 primary_root_window_(primary_root_window),
113 pointer_watcher_event_router_(pointer_watcher_event_router), 119 pointer_watcher_event_router_(pointer_watcher_event_router),
114 session_state_delegate_(new SessionStateDelegateStub) { 120 session_state_delegate_(new SessionStateDelegateStub) {
121 DCHECK(primary_root_window_);
115 WmShell::Set(this); 122 WmShell::Set(this);
116 123
117 uint16_t accelerator_namespace_id = 0u; 124 uint16_t accelerator_namespace_id = 0u;
118 const bool add_result = 125 const bool add_result =
119 window_manager->GetNextAcceleratorNamespaceId(&accelerator_namespace_id); 126 window_manager->GetNextAcceleratorNamespaceId(&accelerator_namespace_id);
120 // WmShellMus is created early on, so that this should always succeed. 127 // WmShellMus is created early on, so that this should always succeed.
121 DCHECK(add_result); 128 DCHECK(add_result);
122 accelerator_controller_delegate_.reset( 129 accelerator_controller_delegate_.reset(
123 new AcceleratorControllerDelegateMus(window_manager_)); 130 new AcceleratorControllerDelegateMus(window_manager_));
124 accelerator_controller_registrar_.reset(new AcceleratorControllerRegistrar( 131 accelerator_controller_registrar_.reset(new AcceleratorControllerRegistrar(
125 window_manager_, accelerator_namespace_id)); 132 window_manager_, accelerator_namespace_id));
126 SetAcceleratorController(base::MakeUnique<AcceleratorController>( 133 SetAcceleratorController(base::MakeUnique<AcceleratorController>(
127 accelerator_controller_delegate_.get(), 134 accelerator_controller_delegate_.get(),
128 accelerator_controller_registrar_.get())); 135 accelerator_controller_registrar_.get()));
129 immersive_handler_factory_.reset(new ImmersiveHandlerFactoryMus); 136 immersive_handler_factory_.reset(new ImmersiveHandlerFactoryMus);
130 137
131 CreateMaximizeModeController();
132
133 CreateMruWindowTracker();
134
135 SetSystemTrayDelegate(
136 base::WrapUnique(delegate()->CreateSystemTrayDelegate()));
137
138 SetKeyboardUI(KeyboardUIMus::Create(window_manager_->connector())); 138 SetKeyboardUI(KeyboardUIMus::Create(window_manager_->connector()));
139
140 wallpaper_delegate()->InitializeWallpaper();
141
142 window_manager->activation_client()->AddObserver(this);
143 } 139 }
144 140
145 WmShellMus::~WmShellMus() { 141 WmShellMus::~WmShellMus() {
146 window_manager_->activation_client()->RemoveObserver(this);
147
148 // This order mirrors that of Shell.
149
150 // Destroy maximize mode controller early on since it has some observers which
151 // need to be removed.
152 DeleteMaximizeModeController();
153 DeleteToastManager();
154 DeleteSystemTrayDelegate();
155 // Has to happen before ~MruWindowTracker.
156 DeleteWindowCycleController();
157 DeleteWindowSelectorController();
158 DeleteMruWindowTracker();
159 WmShell::Set(nullptr); 142 WmShell::Set(nullptr);
160 } 143 }
161 144
162 // static 145 // static
163 WmShellMus* WmShellMus::Get() { 146 WmShellMus* WmShellMus::Get() {
164 return static_cast<WmShellMus*>(WmShell::Get()); 147 return static_cast<WmShellMus*>(WmShell::Get());
165 } 148 }
166 149
167 void WmShellMus::AddRootWindowController(RootWindowController* controller) {
168 root_window_controllers_.push_back(controller);
169 // The first root window will be the initial root for new windows.
170 if (!GetRootWindowForNewWindows())
171 set_root_window_for_new_windows(WmWindow::Get(controller->root()));
172 }
173
174 void WmShellMus::RemoveRootWindowController(RootWindowController* controller) {
175 auto iter = std::find(root_window_controllers_.begin(),
176 root_window_controllers_.end(), controller);
177 DCHECK(iter != root_window_controllers_.end());
178 root_window_controllers_.erase(iter);
179 }
180
181 RootWindowController* WmShellMus::GetRootWindowControllerWithDisplayId( 150 RootWindowController* WmShellMus::GetRootWindowControllerWithDisplayId(
182 int64_t id) { 151 int64_t id) {
183 for (RootWindowController* root_window_controller : 152 for (ash::RootWindowController* root_window_controller :
184 root_window_controllers_) { 153 ash::RootWindowController::root_window_controllers()) {
185 if (root_window_controller->display().id() == id) 154 RootWindowSettings* settings =
186 return root_window_controller; 155 GetRootWindowSettings(root_window_controller->GetRootWindow());
156 DCHECK(settings);
157 if (settings->display_id == id) {
158 return RootWindowController::ForWindow(
159 root_window_controller->GetRootWindow());
160 }
187 } 161 }
188 NOTREACHED(); 162 NOTREACHED();
189 return nullptr; 163 return nullptr;
190 } 164 }
191 165
192 aura::WindowTreeClient* WmShellMus::window_tree_client() { 166 aura::WindowTreeClient* WmShellMus::window_tree_client() {
193 return window_manager_->window_tree_client(); 167 return window_manager_->window_tree_client();
194 } 168 }
195 169
170 void WmShellMus::Initialize(
171 const scoped_refptr<base::SequencedWorkerPool>& pool) {
172 WmShell::Initialize(pool);
173 }
174
175 void WmShellMus::Shutdown() {
176 WmShell::Shutdown();
177
178 window_manager_->DeleteAllRootWindowControllers();
179 }
180
196 bool WmShellMus::IsRunningInMash() const { 181 bool WmShellMus::IsRunningInMash() const {
197 return true; 182 return true;
198 } 183 }
199 184
200 WmWindow* WmShellMus::NewWindow(ui::wm::WindowType window_type, 185 WmWindow* WmShellMus::NewWindow(ui::wm::WindowType window_type,
201 ui::LayerType layer_type) { 186 ui::LayerType layer_type) {
202 aura::Window* window = new aura::Window(nullptr); 187 aura::Window* window = new aura::Window(nullptr);
203 window->SetType(window_type); 188 window->SetType(window_type);
204 window->Init(layer_type); 189 window->Init(layer_type);
205 return WmWindow::Get(window); 190 return WmWindow::Get(window);
206 } 191 }
207 192
208 WmWindow* WmShellMus::GetFocusedWindow() { 193 WmWindow* WmShellMus::GetFocusedWindow() {
209 // TODO: remove as both WmShells use same implementation. 194 // TODO: remove as both WmShells use same implementation.
210 return WmWindow::Get(static_cast<aura::client::FocusClient*>( 195 return WmWindow::Get(
211 window_manager_->focus_controller()) 196 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())
212 ->GetFocusedWindow()); 197 ->GetFocusedWindow());
213 } 198 }
214 199
215 WmWindow* WmShellMus::GetActiveWindow() { 200 WmWindow* WmShellMus::GetActiveWindow() {
216 // TODO: remove as both WmShells use same implementation. 201 // TODO: remove as both WmShells use same implementation.
217 return WmWindow::Get(static_cast<aura::client::ActivationClient*>( 202 return WmWindow::Get(wm::GetActiveWindow());
218 window_manager_->focus_controller())
219 ->GetActiveWindow());
220 } 203 }
221 204
222 WmWindow* WmShellMus::GetCaptureWindow() { 205 WmWindow* WmShellMus::GetCaptureWindow() {
223 // TODO: remove as both WmShells use same implementation. 206 // TODO: remove as both WmShells use same implementation.
224 return WmWindow::Get(::wm::CaptureController::Get()->GetCaptureWindow()); 207 return WmWindow::Get(::wm::CaptureController::Get()->GetCaptureWindow());
225 } 208 }
226 209
227 WmWindow* WmShellMus::GetPrimaryRootWindow() { 210 WmWindow* WmShellMus::GetPrimaryRootWindow() {
228 return WmWindow::Get(root_window_controllers_[0]->root()); 211 // NOTE: This is called before the RootWindowController has been created, so
212 // it can't call through to RootWindowController to get all windows.
213 return primary_root_window_;
229 } 214 }
230 215
231 WmWindow* WmShellMus::GetRootWindowForDisplayId(int64_t display_id) { 216 WmWindow* WmShellMus::GetRootWindowForDisplayId(int64_t display_id) {
232 return WmWindow::Get( 217 return WmWindow::Get(
233 GetRootWindowControllerWithDisplayId(display_id)->root()); 218 GetRootWindowControllerWithDisplayId(display_id)->root());
234 } 219 }
235 220
236 const display::ManagedDisplayInfo& WmShellMus::GetDisplayInfo( 221 const display::ManagedDisplayInfo& WmShellMus::GetDisplayInfo(
237 int64_t display_id) const { 222 int64_t display_id) const {
238 // TODO(mash): implement http://crbug.com/622480. 223 // TODO(mash): implement http://crbug.com/622480.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 NOTIMPLEMENTED(); 281 NOTIMPLEMENTED();
297 } 282 }
298 283
299 bool WmShellMus::IsMouseEventsEnabled() { 284 bool WmShellMus::IsMouseEventsEnabled() {
300 // TODO: http::/crbug.com/637853 285 // TODO: http::/crbug.com/637853
301 NOTIMPLEMENTED(); 286 NOTIMPLEMENTED();
302 return true; 287 return true;
303 } 288 }
304 289
305 std::vector<WmWindow*> WmShellMus::GetAllRootWindows() { 290 std::vector<WmWindow*> WmShellMus::GetAllRootWindows() {
306 std::vector<WmWindow*> wm_windows(root_window_controllers_.size()); 291 std::vector<WmWindow*> root_windows;
307 for (size_t i = 0; i < root_window_controllers_.size(); ++i) 292 for (ash::RootWindowController* root_window_controller :
308 wm_windows[i] = WmWindow::Get(root_window_controllers_[i]->root()); 293 ash::RootWindowController::root_window_controllers()) {
309 return wm_windows; 294 root_windows.push_back(root_window_controller->GetWindow());
295 }
296 return root_windows;
310 } 297 }
311 298
312 void WmShellMus::RecordGestureAction(GestureActionType action) { 299 void WmShellMus::RecordGestureAction(GestureActionType action) {
313 // TODO: http://crbug.com/616581. 300 // TODO: http://crbug.com/616581.
314 NOTIMPLEMENTED(); 301 NOTIMPLEMENTED();
315 } 302 }
316 303
317 void WmShellMus::RecordUserMetricsAction(UserMetricsAction action) { 304 void WmShellMus::RecordUserMetricsAction(UserMetricsAction action) {
318 // TODO: http://crbug.com/616581. 305 // TODO: http://crbug.com/616581.
319 NOTIMPLEMENTED(); 306 NOTIMPLEMENTED();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 363
377 void WmShellMus::OnOverviewModeEnded() { 364 void WmShellMus::OnOverviewModeEnded() {
378 for (auto& observer : *shell_observers()) 365 for (auto& observer : *shell_observers())
379 observer.OnOverviewModeEnded(); 366 observer.OnOverviewModeEnded();
380 } 367 }
381 368
382 SessionStateDelegate* WmShellMus::GetSessionStateDelegate() { 369 SessionStateDelegate* WmShellMus::GetSessionStateDelegate() {
383 return session_state_delegate_.get(); 370 return session_state_delegate_.get();
384 } 371 }
385 372
386 void WmShellMus::AddActivationObserver(WmActivationObserver* observer) {
387 activation_observers_.AddObserver(observer);
388 }
389
390 void WmShellMus::RemoveActivationObserver(WmActivationObserver* observer) {
391 activation_observers_.RemoveObserver(observer);
392 }
393
394 void WmShellMus::AddDisplayObserver(WmDisplayObserver* observer) { 373 void WmShellMus::AddDisplayObserver(WmDisplayObserver* observer) {
395 NOTIMPLEMENTED(); 374 NOTIMPLEMENTED();
396 } 375 }
397 376
398 void WmShellMus::RemoveDisplayObserver(WmDisplayObserver* observer) { 377 void WmShellMus::RemoveDisplayObserver(WmDisplayObserver* observer) {
399 NOTIMPLEMENTED(); 378 NOTIMPLEMENTED();
400 } 379 }
401 380
402 void WmShellMus::AddPointerWatcher(views::PointerWatcher* watcher, 381 void WmShellMus::AddPointerWatcher(views::PointerWatcher* watcher,
403 views::PointerWatcherEventTypes events) { 382 views::PointerWatcherEventTypes events) {
(...skipping 18 matching lines...) Expand all
422 } 401 }
423 402
424 void WmShellMus::ToggleIgnoreExternalKeyboard() { 403 void WmShellMus::ToggleIgnoreExternalKeyboard() {
425 NOTIMPLEMENTED(); 404 NOTIMPLEMENTED();
426 } 405 }
427 406
428 void WmShellMus::SetLaserPointerEnabled(bool enabled) { 407 void WmShellMus::SetLaserPointerEnabled(bool enabled) {
429 NOTIMPLEMENTED(); 408 NOTIMPLEMENTED();
430 } 409 }
431 410
432 // TODO: support OnAttemptToReactivateWindow, http://crbug.com/615114. 411 void WmShellMus::CreatePointerWatcherAdapter() {
433 // TODO: Nuke and let client code use ActivationChangeObserver directly. 412 // Only needed in WmShellAura, which has specific creation order.
434 void WmShellMus::OnWindowActivated(ActivationReason reason,
435 aura::Window* gained_active,
436 aura::Window* lost_active) {
437 WmWindow* gained_active_wm = WmWindow::Get(gained_active);
438 if (gained_active_wm)
439 set_root_window_for_new_windows(gained_active_wm->GetRootWindow());
440 WmWindow* lost_active_wm = WmWindow::Get(lost_active);
441 for (auto& observer : activation_observers_)
442 observer.OnWindowActivated(gained_active_wm, lost_active_wm);
443 } 413 }
444 414
415 void WmShellMus::CreatePrimaryHost() {}
416
417 void WmShellMus::InitHosts(const ShellInitParams& init_params) {
418 window_manager_->CreatePrimaryRootWindowController(
419 base::WrapUnique(init_params.primary_window_tree_host));
420 }
445 } // namespace mus 421 } // namespace mus
446 } // namespace ash 422 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/bridge/wm_shell_mus.h ('k') | ash/mus/keyboard_ui_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698