OLD | NEW |
---|---|
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/shell_port_mash.h" | 5 #include "ash/mus/bridge/shell_port_mash.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/accelerators/accelerator_controller.h" | 9 #include "ash/accelerators/accelerator_controller.h" |
10 #include "ash/accelerators/accelerator_controller_delegate_aura.h" | 10 #include "ash/accelerators/accelerator_controller_delegate_aura.h" |
11 #include "ash/aura/key_event_watcher_aura.h" | 11 #include "ash/aura/key_event_watcher_aura.h" |
12 #include "ash/aura/pointer_watcher_adapter.h" | 12 #include "ash/aura/pointer_watcher_adapter.h" |
13 #include "ash/host/ash_window_tree_host.h" | 13 #include "ash/display/window_tree_host_manager.h" |
14 #include "ash/host/ash_window_tree_host_init_params.h" | |
14 #include "ash/key_event_watcher.h" | 15 #include "ash/key_event_watcher.h" |
15 #include "ash/laser/laser_pointer_controller.h" | 16 #include "ash/laser/laser_pointer_controller.h" |
16 #include "ash/magnifier/partial_magnification_controller.h" | 17 #include "ash/magnifier/partial_magnification_controller.h" |
17 #include "ash/mus/accelerators/accelerator_controller_delegate_mus.h" | 18 #include "ash/mus/accelerators/accelerator_controller_delegate_mus.h" |
18 #include "ash/mus/accelerators/accelerator_controller_registrar.h" | 19 #include "ash/mus/accelerators/accelerator_controller_registrar.h" |
20 #include "ash/mus/ash_window_tree_host_mus.h" | |
19 #include "ash/mus/bridge/immersive_handler_factory_mus.h" | 21 #include "ash/mus/bridge/immersive_handler_factory_mus.h" |
20 #include "ash/mus/bridge/workspace_event_handler_mus.h" | 22 #include "ash/mus/bridge/workspace_event_handler_mus.h" |
21 #include "ash/mus/drag_window_resizer.h" | 23 #include "ash/mus/drag_window_resizer.h" |
22 #include "ash/mus/keyboard_ui_mus.h" | 24 #include "ash/mus/keyboard_ui_mus.h" |
23 #include "ash/mus/screen_mus.h" | 25 #include "ash/mus/screen_mus.h" |
24 #include "ash/mus/window_manager.h" | 26 #include "ash/mus/window_manager.h" |
25 #include "ash/public/cpp/config.h" | 27 #include "ash/public/cpp/config.h" |
26 #include "ash/root_window_controller.h" | 28 #include "ash/root_window_controller.h" |
27 #include "ash/root_window_settings.h" | 29 #include "ash/root_window_settings.h" |
28 #include "ash/session/session_state_delegate.h" | 30 #include "ash/session/session_state_delegate.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
42 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone. h" | 44 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone. h" |
43 #include "ash/wm/mru_window_tracker.h" | 45 #include "ash/wm/mru_window_tracker.h" |
44 #include "ash/wm/window_cycle_event_filter.h" | 46 #include "ash/wm/window_cycle_event_filter.h" |
45 #include "ash/wm/window_cycle_event_filter_aura.h" | 47 #include "ash/wm/window_cycle_event_filter_aura.h" |
46 #include "ash/wm/window_resizer.h" | 48 #include "ash/wm/window_resizer.h" |
47 #include "ash/wm/window_util.h" | 49 #include "ash/wm/window_util.h" |
48 #include "ash/wm/workspace/workspace_event_handler_aura.h" | 50 #include "ash/wm/workspace/workspace_event_handler_aura.h" |
49 #include "ash/wm_window.h" | 51 #include "ash/wm_window.h" |
50 #include "base/memory/ptr_util.h" | 52 #include "base/memory/ptr_util.h" |
51 #include "components/user_manager/user_info_impl.h" | 53 #include "components/user_manager/user_info_impl.h" |
54 #include "services/ui/public/interfaces/constants.mojom.h" | |
52 #include "ui/aura/env.h" | 55 #include "ui/aura/env.h" |
56 #include "ui/aura/mus/window_manager_delegate.h" | |
53 #include "ui/aura/mus/window_tree_client.h" | 57 #include "ui/aura/mus/window_tree_client.h" |
54 #include "ui/aura/mus/window_tree_host_mus.h" | 58 #include "ui/aura/mus/window_tree_host_mus.h" |
59 #include "ui/aura/mus/window_tree_host_mus_init_params.h" | |
55 #include "ui/aura/window.h" | 60 #include "ui/aura/window.h" |
61 #include "ui/display/manager/display_manager.h" | |
56 #include "ui/display/manager/managed_display_info.h" | 62 #include "ui/display/manager/managed_display_info.h" |
57 #include "ui/display/screen.h" | 63 #include "ui/display/screen.h" |
58 #include "ui/display/types/native_display_delegate.h" | 64 #include "ui/display/types/native_display_delegate.h" |
59 #include "ui/views/mus/pointer_watcher_event_router.h" | 65 #include "ui/views/mus/pointer_watcher_event_router.h" |
60 | 66 |
67 #if defined(USE_OZONE) | |
68 #include "ui/display/manager/forwarding_display_delegate.h" | |
69 #endif | |
70 | |
61 namespace ash { | 71 namespace ash { |
62 namespace mus { | 72 namespace mus { |
63 | 73 |
64 namespace { | 74 namespace { |
65 | 75 |
66 // TODO(jamescook): After ShellDelegate is ported to ash/common use | 76 // TODO(jamescook): After ShellDelegate is ported to ash/common use |
67 // ShellDelegate::CreateSessionStateDelegate() to construct the mus version | 77 // ShellDelegate::CreateSessionStateDelegate() to construct the mus version |
68 // of SessionStateDelegate. | 78 // of SessionStateDelegate. |
69 class SessionStateDelegateStub : public SessionStateDelegate { | 79 class SessionStateDelegateStub : public SessionStateDelegate { |
70 public: | 80 public: |
(...skipping 30 matching lines...) Expand all Loading... | |
101 | 111 |
102 ShellPortMash::ShellPortMash( | 112 ShellPortMash::ShellPortMash( |
103 WmWindow* primary_root_window, | 113 WmWindow* primary_root_window, |
104 WindowManager* window_manager, | 114 WindowManager* window_manager, |
105 views::PointerWatcherEventRouter* pointer_watcher_event_router, | 115 views::PointerWatcherEventRouter* pointer_watcher_event_router, |
106 bool create_session_state_delegate_stub) | 116 bool create_session_state_delegate_stub) |
107 : window_manager_(window_manager), | 117 : window_manager_(window_manager), |
108 primary_root_window_(primary_root_window) { | 118 primary_root_window_(primary_root_window) { |
109 if (create_session_state_delegate_stub) | 119 if (create_session_state_delegate_stub) |
110 session_state_delegate_ = base::MakeUnique<SessionStateDelegateStub>(); | 120 session_state_delegate_ = base::MakeUnique<SessionStateDelegateStub>(); |
111 DCHECK(primary_root_window_); | |
112 | 121 |
113 if (GetAshConfig() == Config::MASH) { | 122 if (GetAshConfig() == Config::MASH) { |
114 mash_state_ = base::MakeUnique<MashSpecificState>(); | 123 mash_state_ = base::MakeUnique<MashSpecificState>(); |
115 mash_state_->pointer_watcher_event_router = pointer_watcher_event_router; | 124 mash_state_->pointer_watcher_event_router = pointer_watcher_event_router; |
116 mash_state_->immersive_handler_factory = | 125 mash_state_->immersive_handler_factory = |
117 base::MakeUnique<ImmersiveHandlerFactoryMus>(); | 126 base::MakeUnique<ImmersiveHandlerFactoryMus>(); |
118 } else { | 127 } else { |
119 DCHECK_EQ(Config::MUS, GetAshConfig()); | 128 DCHECK_EQ(Config::MUS, GetAshConfig()); |
120 mus_state_ = base::MakeUnique<MusSpecificState>(); | 129 mus_state_ = base::MakeUnique<MusSpecificState>(); |
121 } | 130 } |
(...skipping 24 matching lines...) Expand all Loading... | |
146 aura::WindowTreeClient* ShellPortMash::window_tree_client() { | 155 aura::WindowTreeClient* ShellPortMash::window_tree_client() { |
147 return window_manager_->window_tree_client(); | 156 return window_manager_->window_tree_client(); |
148 } | 157 } |
149 | 158 |
150 void ShellPortMash::Shutdown() { | 159 void ShellPortMash::Shutdown() { |
151 if (mus_state_) | 160 if (mus_state_) |
152 mus_state_->pointer_watcher_adapter.reset(); | 161 mus_state_->pointer_watcher_adapter.reset(); |
153 | 162 |
154 ShellPort::Shutdown(); | 163 ShellPort::Shutdown(); |
155 | 164 |
156 window_manager_->DeleteAllRootWindowControllers(); | 165 // TODO(sky): Config::MASH should use WindowTreeHostManager too. |
166 if (GetAshConfig() == Config::MUS) | |
167 Shell::Get()->window_tree_host_manager()->Shutdown(); | |
168 else | |
169 window_manager_->DeleteAllRootWindowControllers(); | |
157 } | 170 } |
158 | 171 |
159 Config ShellPortMash::GetAshConfig() const { | 172 Config ShellPortMash::GetAshConfig() const { |
160 return window_manager_->config(); | 173 return window_manager_->config(); |
161 } | 174 } |
162 | 175 |
163 WmWindow* ShellPortMash::GetPrimaryRootWindow() { | 176 WmWindow* ShellPortMash::GetPrimaryRootWindow() { |
177 if (GetAshConfig() == Config::MUS) { | |
178 return WmWindow::Get( | |
179 Shell::Get()->window_tree_host_manager()->GetPrimaryRootWindow()); | |
180 } | |
164 // NOTE: This is called before the RootWindowController has been created, so | 181 // NOTE: This is called before the RootWindowController has been created, so |
165 // it can't call through to RootWindowController to get all windows. | 182 // it can't call through to RootWindowController to get all windows. |
166 return primary_root_window_; | 183 return primary_root_window_; |
167 } | 184 } |
168 | 185 |
169 WmWindow* ShellPortMash::GetRootWindowForDisplayId(int64_t display_id) { | 186 WmWindow* ShellPortMash::GetRootWindowForDisplayId(int64_t display_id) { |
187 if (GetAshConfig() == Config::MUS) { | |
188 return WmWindow::Get( | |
189 Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId( | |
190 display_id)); | |
191 } | |
170 RootWindowController* root_window_controller = | 192 RootWindowController* root_window_controller = |
171 GetRootWindowControllerWithDisplayId(display_id); | 193 GetRootWindowControllerWithDisplayId(display_id); |
172 return root_window_controller | 194 return root_window_controller |
173 ? WmWindow::Get(root_window_controller->GetRootWindow()) | 195 ? WmWindow::Get(root_window_controller->GetRootWindow()) |
174 : nullptr; | 196 : nullptr; |
175 } | 197 } |
176 | 198 |
177 const display::ManagedDisplayInfo& ShellPortMash::GetDisplayInfo( | 199 const display::ManagedDisplayInfo& ShellPortMash::GetDisplayInfo( |
178 int64_t display_id) const { | 200 int64_t display_id) const { |
179 // TODO(mash): implement http://crbug.com/622480. | 201 // TODO(mash): implement http://crbug.com/622480. |
(...skipping 21 matching lines...) Expand all Loading... | |
201 } | 223 } |
202 | 224 |
203 bool ShellPortMash::IsInUnifiedModeIgnoreMirroring() const { | 225 bool ShellPortMash::IsInUnifiedModeIgnoreMirroring() const { |
204 // TODO(mash): implement http://crbug.com/622480. | 226 // TODO(mash): implement http://crbug.com/622480. |
205 NOTIMPLEMENTED(); | 227 NOTIMPLEMENTED(); |
206 return false; | 228 return false; |
207 } | 229 } |
208 | 230 |
209 void ShellPortMash::SetDisplayWorkAreaInsets(WmWindow* window, | 231 void ShellPortMash::SetDisplayWorkAreaInsets(WmWindow* window, |
210 const gfx::Insets& insets) { | 232 const gfx::Insets& insets) { |
233 if (GetAshConfig() == Config::MUS) { | |
234 Shell::Get() | |
235 ->window_tree_host_manager() | |
236 ->UpdateWorkAreaOfDisplayNearestWindow(window->aura_window(), insets); | |
237 return; | |
238 } | |
211 window_manager_->screen()->SetWorkAreaInsets(window->aura_window(), insets); | 239 window_manager_->screen()->SetWorkAreaInsets(window->aura_window(), insets); |
212 } | 240 } |
213 | 241 |
214 void ShellPortMash::LockCursor() { | 242 void ShellPortMash::LockCursor() { |
215 // TODO: http://crbug.com/637853 | 243 // TODO: http://crbug.com/637853 |
216 NOTIMPLEMENTED(); | 244 NOTIMPLEMENTED(); |
217 } | 245 } |
218 | 246 |
219 void ShellPortMash::UnlockCursor() { | 247 void ShellPortMash::UnlockCursor() { |
220 // TODO: http://crbug.com/637853 | 248 // TODO: http://crbug.com/637853 |
221 NOTIMPLEMENTED(); | 249 NOTIMPLEMENTED(); |
222 } | 250 } |
223 | 251 |
224 bool ShellPortMash::IsMouseEventsEnabled() { | 252 bool ShellPortMash::IsMouseEventsEnabled() { |
225 // TODO: http://crbug.com/637853 | 253 // TODO: http://crbug.com/637853 |
226 NOTIMPLEMENTED(); | 254 NOTIMPLEMENTED(); |
227 return true; | 255 return true; |
228 } | 256 } |
229 | 257 |
230 std::vector<WmWindow*> ShellPortMash::GetAllRootWindows() { | 258 std::vector<WmWindow*> ShellPortMash::GetAllRootWindows() { |
259 if (GetAshConfig() == Config::MUS) { | |
260 aura::Window::Windows root_windows = | |
261 Shell::Get()->window_tree_host_manager()->GetAllRootWindows(); | |
262 std::vector<WmWindow*> wm_windows(root_windows.size()); | |
263 for (size_t i = 0; i < root_windows.size(); ++i) | |
264 wm_windows[i] = WmWindow::Get(root_windows[i]); | |
265 return wm_windows; | |
266 } | |
231 std::vector<WmWindow*> root_windows; | 267 std::vector<WmWindow*> root_windows; |
232 for (RootWindowController* root_window_controller : | 268 for (RootWindowController* root_window_controller : |
233 RootWindowController::root_window_controllers()) { | 269 RootWindowController::root_window_controllers()) { |
234 root_windows.push_back(root_window_controller->GetWindow()); | 270 root_windows.push_back(root_window_controller->GetWindow()); |
235 } | 271 } |
236 return root_windows; | 272 return root_windows; |
237 } | 273 } |
238 | 274 |
239 void ShellPortMash::RecordGestureAction(GestureActionType action) { | 275 void ShellPortMash::RecordGestureAction(GestureActionType action) { |
240 if (GetAshConfig() == Config::MUS) { | 276 if (GetAshConfig() == Config::MUS) { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 // In Config::MUS PointerWatcherAdapter must be created when this function is | 456 // In Config::MUS PointerWatcherAdapter must be created when this function is |
421 // called (it is order dependent), that is not the case with Config::MASH. | 457 // called (it is order dependent), that is not the case with Config::MASH. |
422 if (GetAshConfig() == Config::MUS) { | 458 if (GetAshConfig() == Config::MUS) { |
423 mus_state_->pointer_watcher_adapter = | 459 mus_state_->pointer_watcher_adapter = |
424 base::MakeUnique<PointerWatcherAdapter>(); | 460 base::MakeUnique<PointerWatcherAdapter>(); |
425 } | 461 } |
426 } | 462 } |
427 | 463 |
428 std::unique_ptr<AshWindowTreeHost> ShellPortMash::CreateAshWindowTreeHost( | 464 std::unique_ptr<AshWindowTreeHost> ShellPortMash::CreateAshWindowTreeHost( |
429 const AshWindowTreeHostInitParams& init_params) { | 465 const AshWindowTreeHostInitParams& init_params) { |
430 return nullptr; | 466 // TODO(sky): make this work for mash too. |
467 if (GetAshConfig() != Config::MUS) | |
468 return nullptr; | |
469 | |
470 std::unique_ptr<aura::DisplayInitParams> display_params = | |
471 base::MakeUnique<aura::DisplayInitParams>(); | |
472 display_params->viewport_metrics.bounds_in_pixels = | |
473 init_params.initial_bounds; | |
474 display_params->viewport_metrics.device_scale_factor = | |
475 init_params.device_scale_factor; | |
476 display_params->viewport_metrics.ui_scale_factor = | |
477 init_params.ui_scale_factor; | |
478 display::Display mirrored_display = | |
479 Shell::Get()->display_manager()->GetMirroringDisplayById( | |
480 init_params.display_id); | |
481 if (mirrored_display.is_valid()) { | |
482 display_params->display = | |
483 base::MakeUnique<display::Display>(mirrored_display); | |
484 } | |
485 // TODO: wire update is_primary_display correctly. | |
486 display_params->is_primary_display = true; | |
487 aura::WindowTreeHostMusInitParams aura_init_params = | |
488 window_manager_->window_manager_client()->CreateInitParamsForNewDisplay(); | |
489 aura_init_params.display_id = init_params.display_id; | |
490 aura_init_params.display_init_params = std::move(display_params); | |
491 return base::MakeUnique<AshWindowTreeHostMus>(std::move(aura_init_params)); | |
431 } | 492 } |
432 | 493 |
433 void ShellPortMash::CreatePrimaryHost() {} | 494 void ShellPortMash::CreatePrimaryHost() { |
495 if (GetAshConfig() == Config::MASH) | |
496 return; | |
497 | |
498 DCHECK_EQ(Config::MUS, GetAshConfig()); | |
499 Shell::Get()->window_tree_host_manager()->Start(); | |
500 AshWindowTreeHostInitParams ash_init_params; | |
501 Shell::Get()->window_tree_host_manager()->CreatePrimaryHost(ash_init_params); | |
502 } | |
434 | 503 |
435 void ShellPortMash::InitHosts(const ShellInitParams& init_params) { | 504 void ShellPortMash::InitHosts(const ShellInitParams& init_params) { |
436 window_manager_->CreatePrimaryRootWindowController( | 505 if (GetAshConfig() == Config::MUS) { |
437 base::WrapUnique(init_params.primary_window_tree_host)); | 506 Shell::Get()->window_tree_host_manager()->InitHosts(); |
507 } else { | |
508 window_manager_->CreatePrimaryRootWindowController( | |
509 base::WrapUnique(init_params.primary_window_tree_host)); | |
510 } | |
438 } | 511 } |
439 | 512 |
440 std::unique_ptr<display::NativeDisplayDelegate> | 513 std::unique_ptr<display::NativeDisplayDelegate> |
441 ShellPortMash::CreateNativeDisplayDelegate() { | 514 ShellPortMash::CreateNativeDisplayDelegate() { |
515 #if defined(USE_OZONE) | |
516 display::mojom::NativeDisplayDelegatePtr native_display_delegate; | |
517 if (window_manager_->connector()) { | |
518 window_manager_->connector()->BindInterface(ui::mojom::kServiceName, | |
519 &native_display_delegate); | |
520 } | |
521 return base::MakeUnique<display::ForwardingDisplayDelegate>( | |
522 std::move(native_display_delegate)); | |
523 #else | |
524 // The bots compile this config, but it is never run. | |
525 CHECK(false); | |
kylechar
2017/04/26 16:41:44
Unrelated to this CL but should this configuration
sky
2017/04/26 19:36:41
Agreed. I'm not going to try to address that here.
| |
442 return nullptr; | 526 return nullptr; |
527 #endif | |
443 } | 528 } |
444 | 529 |
445 std::unique_ptr<AcceleratorController> | 530 std::unique_ptr<AcceleratorController> |
446 ShellPortMash::CreateAcceleratorController() { | 531 ShellPortMash::CreateAcceleratorController() { |
447 if (GetAshConfig() == Config::MUS) { | 532 if (GetAshConfig() == Config::MUS) { |
448 DCHECK(!mus_state_->accelerator_controller_delegate); | 533 DCHECK(!mus_state_->accelerator_controller_delegate); |
449 mus_state_->accelerator_controller_delegate = | 534 mus_state_->accelerator_controller_delegate = |
450 base::MakeUnique<AcceleratorControllerDelegateAura>(); | 535 base::MakeUnique<AcceleratorControllerDelegateAura>(); |
451 return base::MakeUnique<AcceleratorController>( | 536 return base::MakeUnique<AcceleratorController>( |
452 mus_state_->accelerator_controller_delegate.get(), nullptr); | 537 mus_state_->accelerator_controller_delegate.get(), nullptr); |
(...skipping 13 matching lines...) Expand all Loading... | |
466 mash_state_->accelerator_controller_registrar = | 551 mash_state_->accelerator_controller_registrar = |
467 base ::MakeUnique<AcceleratorControllerRegistrar>( | 552 base ::MakeUnique<AcceleratorControllerRegistrar>( |
468 window_manager_, accelerator_namespace_id); | 553 window_manager_, accelerator_namespace_id); |
469 return base::MakeUnique<AcceleratorController>( | 554 return base::MakeUnique<AcceleratorController>( |
470 mash_state_->accelerator_controller_delegate.get(), | 555 mash_state_->accelerator_controller_delegate.get(), |
471 mash_state_->accelerator_controller_registrar.get()); | 556 mash_state_->accelerator_controller_registrar.get()); |
472 } | 557 } |
473 | 558 |
474 } // namespace mus | 559 } // namespace mus |
475 } // namespace ash | 560 } // namespace ash |
OLD | NEW |