| 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" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 void ShellPortMash::Shutdown() { | 163 void ShellPortMash::Shutdown() { |
| 164 if (added_display_observer_) | 164 if (added_display_observer_) |
| 165 Shell::Get()->window_tree_host_manager()->RemoveObserver(this); | 165 Shell::Get()->window_tree_host_manager()->RemoveObserver(this); |
| 166 | 166 |
| 167 if (mus_state_) | 167 if (mus_state_) |
| 168 mus_state_->pointer_watcher_adapter.reset(); | 168 mus_state_->pointer_watcher_adapter.reset(); |
| 169 | 169 |
| 170 ShellPort::Shutdown(); | 170 ShellPort::Shutdown(); |
| 171 | 171 |
| 172 // TODO(sky): Config::MASH should use WindowTreeHostManager too. | 172 if (Shell::ShouldEnableSimplifiedDisplayManagement()) |
| 173 if (GetAshConfig() == Config::MUS) | |
| 174 Shell::Get()->window_tree_host_manager()->Shutdown(); | 173 Shell::Get()->window_tree_host_manager()->Shutdown(); |
| 175 else | 174 else |
| 176 window_manager_->DeleteAllRootWindowControllers(); | 175 window_manager_->DeleteAllRootWindowControllers(); |
| 177 } | 176 } |
| 178 | 177 |
| 179 Config ShellPortMash::GetAshConfig() const { | 178 Config ShellPortMash::GetAshConfig() const { |
| 180 return window_manager_->config(); | 179 return window_manager_->config(); |
| 181 } | 180 } |
| 182 | 181 |
| 183 aura::Window* ShellPortMash::GetPrimaryRootWindow() { | 182 aura::Window* ShellPortMash::GetPrimaryRootWindow() { |
| 184 if (GetAshConfig() == Config::MUS) | 183 if (Shell::ShouldEnableSimplifiedDisplayManagement()) |
| 185 return Shell::Get()->window_tree_host_manager()->GetPrimaryRootWindow(); | 184 return Shell::Get()->window_tree_host_manager()->GetPrimaryRootWindow(); |
| 186 // NOTE: This is called before the RootWindowController has been created, so | 185 // NOTE: This is called before the RootWindowController has been created, so |
| 187 // it can't call through to RootWindowController to get all windows. | 186 // it can't call through to RootWindowController to get all windows. |
| 188 return primary_root_window_; | 187 return primary_root_window_; |
| 189 } | 188 } |
| 190 | 189 |
| 191 aura::Window* ShellPortMash::GetRootWindowForDisplayId(int64_t display_id) { | 190 aura::Window* ShellPortMash::GetRootWindowForDisplayId(int64_t display_id) { |
| 192 if (GetAshConfig() == Config::MUS) { | 191 if (Shell::ShouldEnableSimplifiedDisplayManagement()) { |
| 193 return Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId( | 192 return Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId( |
| 194 display_id); | 193 display_id); |
| 195 } | 194 } |
| 196 RootWindowController* root_window_controller = | 195 RootWindowController* root_window_controller = |
| 197 GetRootWindowControllerWithDisplayId(display_id); | 196 GetRootWindowControllerWithDisplayId(display_id); |
| 198 return root_window_controller ? root_window_controller->GetRootWindow() | 197 return root_window_controller ? root_window_controller->GetRootWindow() |
| 199 : nullptr; | 198 : nullptr; |
| 200 } | 199 } |
| 201 | 200 |
| 202 const display::ManagedDisplayInfo& ShellPortMash::GetDisplayInfo( | 201 const display::ManagedDisplayInfo& ShellPortMash::GetDisplayInfo( |
| 203 int64_t display_id) const { | 202 int64_t display_id) const { |
| 204 // TODO(sky): mash should use this too http://crbug.com/718860. | 203 if (Shell::ShouldEnableSimplifiedDisplayManagement()) |
| 205 if (GetAshConfig() == Config::MUS) | |
| 206 return Shell::Get()->display_manager()->GetDisplayInfo(display_id); | 204 return Shell::Get()->display_manager()->GetDisplayInfo(display_id); |
| 207 | 205 |
| 208 // TODO(mash): implement http://crbug.com/622480. | 206 // TODO(mash): implement http://crbug.com/622480. |
| 209 NOTIMPLEMENTED(); | 207 NOTIMPLEMENTED(); |
| 210 static display::ManagedDisplayInfo fake_info; | 208 static display::ManagedDisplayInfo fake_info; |
| 211 return fake_info; | 209 return fake_info; |
| 212 } | 210 } |
| 213 | 211 |
| 214 bool ShellPortMash::IsActiveDisplayId(int64_t display_id) const { | 212 bool ShellPortMash::IsActiveDisplayId(int64_t display_id) const { |
| 215 // TODO(sky): mash should use this too http://crbug.com/718860. | 213 if (Shell::ShouldEnableSimplifiedDisplayManagement()) |
| 216 if (GetAshConfig() == Config::MUS) | |
| 217 return Shell::Get()->display_manager()->IsActiveDisplayId(display_id); | 214 return Shell::Get()->display_manager()->IsActiveDisplayId(display_id); |
| 218 | 215 |
| 219 // TODO(mash): implement http://crbug.com/622480. | 216 // TODO(mash): implement http://crbug.com/622480. |
| 220 NOTIMPLEMENTED(); | 217 NOTIMPLEMENTED(); |
| 221 return true; | 218 return true; |
| 222 } | 219 } |
| 223 | 220 |
| 224 display::Display ShellPortMash::GetFirstDisplay() const { | 221 display::Display ShellPortMash::GetFirstDisplay() const { |
| 225 // TODO(sky): mash should use this too http://crbug.com/718860. | 222 if (Shell::ShouldEnableSimplifiedDisplayManagement()) { |
| 226 if (GetAshConfig() == Config::MUS) { | |
| 227 return Shell::Get() | 223 return Shell::Get() |
| 228 ->display_manager() | 224 ->display_manager() |
| 229 ->software_mirroring_display_list()[0]; | 225 ->software_mirroring_display_list()[0]; |
| 230 } | 226 } |
| 231 | 227 |
| 232 // TODO(mash): implement http://crbug.com/622480. | 228 // TODO(mash): implement http://crbug.com/622480. |
| 233 NOTIMPLEMENTED(); | 229 NOTIMPLEMENTED(); |
| 234 return display::Screen::GetScreen()->GetPrimaryDisplay(); | 230 return display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 235 } | 231 } |
| 236 | 232 |
| 237 bool ShellPortMash::IsInUnifiedMode() const { | 233 bool ShellPortMash::IsInUnifiedMode() const { |
| 238 // TODO(sky): mash should use this too http://crbug.com/718860. | 234 if (Shell::ShouldEnableSimplifiedDisplayManagement()) |
| 239 if (GetAshConfig() == Config::MUS) | |
| 240 return Shell::Get()->display_manager()->IsInUnifiedMode(); | 235 return Shell::Get()->display_manager()->IsInUnifiedMode(); |
| 241 | 236 |
| 242 // TODO(mash): implement http://crbug.com/622480. | 237 // TODO(mash): implement http://crbug.com/622480. |
| 243 NOTIMPLEMENTED(); | 238 NOTIMPLEMENTED(); |
| 244 return false; | 239 return false; |
| 245 } | 240 } |
| 246 | 241 |
| 247 bool ShellPortMash::IsInUnifiedModeIgnoreMirroring() const { | 242 bool ShellPortMash::IsInUnifiedModeIgnoreMirroring() const { |
| 248 // TODO(sky): mash should use this too http://crbug.com/718860. | 243 if (Shell::ShouldEnableSimplifiedDisplayManagement()) { |
| 249 if (GetAshConfig() == Config::MUS) { | |
| 250 return Shell::Get() | 244 return Shell::Get() |
| 251 ->display_manager() | 245 ->display_manager() |
| 252 ->current_default_multi_display_mode() == | 246 ->current_default_multi_display_mode() == |
| 253 display::DisplayManager::UNIFIED; | 247 display::DisplayManager::UNIFIED; |
| 254 } | 248 } |
| 255 | 249 |
| 256 // TODO(mash): implement http://crbug.com/622480. | 250 // TODO(mash): implement http://crbug.com/622480. |
| 257 NOTIMPLEMENTED(); | 251 NOTIMPLEMENTED(); |
| 258 return false; | 252 return false; |
| 259 } | 253 } |
| 260 | 254 |
| 261 void ShellPortMash::SetDisplayWorkAreaInsets(WmWindow* window, | 255 void ShellPortMash::SetDisplayWorkAreaInsets(WmWindow* window, |
| 262 const gfx::Insets& insets) { | 256 const gfx::Insets& insets) { |
| 263 if (GetAshConfig() == Config::MUS) { | 257 if (Shell::ShouldEnableSimplifiedDisplayManagement()) { |
| 264 Shell::Get() | 258 Shell::Get() |
| 265 ->window_tree_host_manager() | 259 ->window_tree_host_manager() |
| 266 ->UpdateWorkAreaOfDisplayNearestWindow(window->aura_window(), insets); | 260 ->UpdateWorkAreaOfDisplayNearestWindow(window->aura_window(), insets); |
| 267 return; | 261 return; |
| 268 } | 262 } |
| 269 window_manager_->screen()->SetWorkAreaInsets(window->aura_window(), insets); | 263 window_manager_->screen()->SetWorkAreaInsets(window->aura_window(), insets); |
| 270 } | 264 } |
| 271 | 265 |
| 272 std::unique_ptr<display::TouchTransformSetter> | 266 std::unique_ptr<display::TouchTransformSetter> |
| 273 ShellPortMash::CreateTouchTransformDelegate() { | 267 ShellPortMash::CreateTouchTransformDelegate() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 297 std::move(cursor)); | 291 std::move(cursor)); |
| 298 } | 292 } |
| 299 | 293 |
| 300 bool ShellPortMash::IsMouseEventsEnabled() { | 294 bool ShellPortMash::IsMouseEventsEnabled() { |
| 301 // TODO: http://crbug.com/637853 | 295 // TODO: http://crbug.com/637853 |
| 302 NOTIMPLEMENTED(); | 296 NOTIMPLEMENTED(); |
| 303 return true; | 297 return true; |
| 304 } | 298 } |
| 305 | 299 |
| 306 std::vector<WmWindow*> ShellPortMash::GetAllRootWindows() { | 300 std::vector<WmWindow*> ShellPortMash::GetAllRootWindows() { |
| 307 if (GetAshConfig() == Config::MUS) { | 301 if (Shell::ShouldEnableSimplifiedDisplayManagement()) { |
| 308 aura::Window::Windows root_windows = | 302 aura::Window::Windows root_windows = |
| 309 Shell::Get()->window_tree_host_manager()->GetAllRootWindows(); | 303 Shell::Get()->window_tree_host_manager()->GetAllRootWindows(); |
| 310 std::vector<WmWindow*> wm_windows(root_windows.size()); | 304 std::vector<WmWindow*> wm_windows(root_windows.size()); |
| 311 for (size_t i = 0; i < root_windows.size(); ++i) | 305 for (size_t i = 0; i < root_windows.size(); ++i) |
| 312 wm_windows[i] = WmWindow::Get(root_windows[i]); | 306 wm_windows[i] = WmWindow::Get(root_windows[i]); |
| 313 return wm_windows; | 307 return wm_windows; |
| 314 } | 308 } |
| 315 std::vector<WmWindow*> root_windows; | 309 std::vector<WmWindow*> root_windows; |
| 316 for (RootWindowController* root_window_controller : | 310 for (RootWindowController* root_window_controller : |
| 317 RootWindowController::root_window_controllers()) { | 311 RootWindowController::root_window_controllers()) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 return base::MakeUnique<wm::MaximizeModeEventHandlerAura>(); | 368 return base::MakeUnique<wm::MaximizeModeEventHandlerAura>(); |
| 375 | 369 |
| 376 // TODO: need support for window manager to get events before client: | 370 // TODO: need support for window manager to get events before client: |
| 377 // http://crbug.com/624157. | 371 // http://crbug.com/624157. |
| 378 NOTIMPLEMENTED(); | 372 NOTIMPLEMENTED(); |
| 379 return nullptr; | 373 return nullptr; |
| 380 } | 374 } |
| 381 | 375 |
| 382 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> | 376 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> |
| 383 ShellPortMash::CreateScopedDisableInternalMouseAndKeyboard() { | 377 ShellPortMash::CreateScopedDisableInternalMouseAndKeyboard() { |
| 384 if (GetAshConfig() == Config::MUS) { | 378 if (Shell::ShouldEnableSimplifiedDisplayManagement()) { |
| 385 #if defined(USE_OZONE) | 379 #if defined(USE_OZONE) |
| 386 return base::MakeUnique<ScopedDisableInternalMouseAndKeyboardOzone>(); | 380 return base::MakeUnique<ScopedDisableInternalMouseAndKeyboardOzone>(); |
| 387 #else | 381 #else |
| 388 // TODO: remove this conditional. Bots build this config, but it is never | 382 // TODO: remove this conditional. Bots build this config, but it is never |
| 389 // actually used. http://crbug.com/671355. | 383 // actually used. http://crbug.com/671355. |
| 390 NOTREACHED(); | 384 NOTREACHED(); |
| 391 return nullptr; | 385 return nullptr; |
| 392 #endif | 386 #endif |
| 393 } | 387 } |
| 394 | 388 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 NOTIMPLEMENTED(); | 420 NOTIMPLEMENTED(); |
| 427 return std::unique_ptr<KeyEventWatcher>(); | 421 return std::unique_ptr<KeyEventWatcher>(); |
| 428 } | 422 } |
| 429 | 423 |
| 430 SessionStateDelegate* ShellPortMash::GetSessionStateDelegate() { | 424 SessionStateDelegate* ShellPortMash::GetSessionStateDelegate() { |
| 431 return session_state_delegate_ ? session_state_delegate_.get() | 425 return session_state_delegate_ ? session_state_delegate_.get() |
| 432 : Shell::Get()->session_state_delegate(); | 426 : Shell::Get()->session_state_delegate(); |
| 433 } | 427 } |
| 434 | 428 |
| 435 void ShellPortMash::AddDisplayObserver(WmDisplayObserver* observer) { | 429 void ShellPortMash::AddDisplayObserver(WmDisplayObserver* observer) { |
| 436 // TODO(sky): mash should use the same code as mus/classic and | 430 // TODO(sky): WmDisplayObserver should be removed; http://crbug.com/718860. |
| 437 // WmDisplayObserver should be removed; http://crbug.com/718860. | 431 if (!Shell::ShouldEnableSimplifiedDisplayManagement()) { |
| 438 if (GetAshConfig() == Config::MASH) { | |
| 439 NOTIMPLEMENTED(); | 432 NOTIMPLEMENTED(); |
| 440 return; | 433 return; |
| 441 } | 434 } |
| 442 if (!added_display_observer_) { | 435 if (!added_display_observer_) { |
| 443 added_display_observer_ = true; | 436 added_display_observer_ = true; |
| 444 Shell::Get()->window_tree_host_manager()->AddObserver(this); | 437 Shell::Get()->window_tree_host_manager()->AddObserver(this); |
| 445 } | 438 } |
| 446 display_observers_.AddObserver(observer); | 439 display_observers_.AddObserver(observer); |
| 447 } | 440 } |
| 448 | 441 |
| 449 void ShellPortMash::RemoveDisplayObserver(WmDisplayObserver* observer) { | 442 void ShellPortMash::RemoveDisplayObserver(WmDisplayObserver* observer) { |
| 450 // TODO(sky): mash should use the same code as mus/classic and | 443 // TODO(sky): WmDisplayObserver should be removed; http://crbug.com/718860. |
| 451 // WmDisplayObserver should be removed; http://crbug.com/718860. | 444 if (!Shell::ShouldEnableSimplifiedDisplayManagement()) { |
| 452 if (GetAshConfig() == Config::MASH) { | |
| 453 NOTIMPLEMENTED(); | 445 NOTIMPLEMENTED(); |
| 454 return; | 446 return; |
| 455 } | 447 } |
| 456 display_observers_.RemoveObserver(observer); | 448 display_observers_.RemoveObserver(observer); |
| 457 } | 449 } |
| 458 | 450 |
| 459 void ShellPortMash::AddPointerWatcher(views::PointerWatcher* watcher, | 451 void ShellPortMash::AddPointerWatcher(views::PointerWatcher* watcher, |
| 460 views::PointerWatcherEventTypes events) { | 452 views::PointerWatcherEventTypes events) { |
| 461 if (GetAshConfig() == Config::MUS) { | 453 if (GetAshConfig() == Config::MUS) { |
| 462 mus_state_->pointer_watcher_adapter->AddPointerWatcher(watcher, events); | 454 mus_state_->pointer_watcher_adapter->AddPointerWatcher(watcher, events); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 // In Config::MUS PointerWatcherAdapter must be created when this function is | 510 // In Config::MUS PointerWatcherAdapter must be created when this function is |
| 519 // called (it is order dependent), that is not the case with Config::MASH. | 511 // called (it is order dependent), that is not the case with Config::MASH. |
| 520 if (GetAshConfig() == Config::MUS) { | 512 if (GetAshConfig() == Config::MUS) { |
| 521 mus_state_->pointer_watcher_adapter = | 513 mus_state_->pointer_watcher_adapter = |
| 522 base::MakeUnique<PointerWatcherAdapter>(); | 514 base::MakeUnique<PointerWatcherAdapter>(); |
| 523 } | 515 } |
| 524 } | 516 } |
| 525 | 517 |
| 526 std::unique_ptr<AshWindowTreeHost> ShellPortMash::CreateAshWindowTreeHost( | 518 std::unique_ptr<AshWindowTreeHost> ShellPortMash::CreateAshWindowTreeHost( |
| 527 const AshWindowTreeHostInitParams& init_params) { | 519 const AshWindowTreeHostInitParams& init_params) { |
| 528 // TODO(sky): make this work for mash too. | 520 if (!Shell::ShouldEnableSimplifiedDisplayManagement()) |
| 529 if (GetAshConfig() != Config::MUS) | |
| 530 return nullptr; | 521 return nullptr; |
| 531 | 522 |
| 532 std::unique_ptr<aura::DisplayInitParams> display_params = | 523 std::unique_ptr<aura::DisplayInitParams> display_params = |
| 533 base::MakeUnique<aura::DisplayInitParams>(); | 524 base::MakeUnique<aura::DisplayInitParams>(); |
| 534 display_params->viewport_metrics.bounds_in_pixels = | 525 display_params->viewport_metrics.bounds_in_pixels = |
| 535 init_params.initial_bounds; | 526 init_params.initial_bounds; |
| 536 display_params->viewport_metrics.device_scale_factor = | 527 display_params->viewport_metrics.device_scale_factor = |
| 537 init_params.device_scale_factor; | 528 init_params.device_scale_factor; |
| 538 display_params->viewport_metrics.ui_scale_factor = | 529 display_params->viewport_metrics.ui_scale_factor = |
| 539 init_params.ui_scale_factor; | 530 init_params.ui_scale_factor; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 559 // TODO: To avoid lots of IPC AddActivationParent() should take an array. | 550 // TODO: To avoid lots of IPC AddActivationParent() should take an array. |
| 560 // http://crbug.com/682048. | 551 // http://crbug.com/682048. |
| 561 aura::Window* root_window = root_window_controller->GetRootWindow(); | 552 aura::Window* root_window = root_window_controller->GetRootWindow(); |
| 562 for (size_t i = 0; i < kNumActivatableShellWindowIds; ++i) { | 553 for (size_t i = 0; i < kNumActivatableShellWindowIds; ++i) { |
| 563 window_manager_->window_manager_client()->AddActivationParent( | 554 window_manager_->window_manager_client()->AddActivationParent( |
| 564 root_window->GetChildById(kActivatableShellWindowIds[i])); | 555 root_window->GetChildById(kActivatableShellWindowIds[i])); |
| 565 } | 556 } |
| 566 } | 557 } |
| 567 | 558 |
| 568 void ShellPortMash::CreatePrimaryHost() { | 559 void ShellPortMash::CreatePrimaryHost() { |
| 569 if (GetAshConfig() == Config::MASH) | 560 if (!Shell::ShouldEnableSimplifiedDisplayManagement()) |
| 570 return; | 561 return; |
| 571 | 562 |
| 572 DCHECK_EQ(Config::MUS, GetAshConfig()); | |
| 573 Shell::Get()->window_tree_host_manager()->Start(); | 563 Shell::Get()->window_tree_host_manager()->Start(); |
| 574 AshWindowTreeHostInitParams ash_init_params; | 564 AshWindowTreeHostInitParams ash_init_params; |
| 575 Shell::Get()->window_tree_host_manager()->CreatePrimaryHost(ash_init_params); | 565 Shell::Get()->window_tree_host_manager()->CreatePrimaryHost(ash_init_params); |
| 576 } | 566 } |
| 577 | 567 |
| 578 void ShellPortMash::InitHosts(const ShellInitParams& init_params) { | 568 void ShellPortMash::InitHosts(const ShellInitParams& init_params) { |
| 579 if (GetAshConfig() == Config::MUS) { | 569 if (Shell::ShouldEnableSimplifiedDisplayManagement()) { |
| 580 Shell::Get()->window_tree_host_manager()->InitHosts(); | 570 Shell::Get()->window_tree_host_manager()->InitHosts(); |
| 581 } else { | 571 } else { |
| 582 window_manager_->CreatePrimaryRootWindowController( | 572 window_manager_->CreatePrimaryRootWindowController( |
| 583 base::WrapUnique(init_params.primary_window_tree_host)); | 573 base::WrapUnique(init_params.primary_window_tree_host)); |
| 584 } | 574 } |
| 585 } | 575 } |
| 586 | 576 |
| 587 std::unique_ptr<display::NativeDisplayDelegate> | 577 std::unique_ptr<display::NativeDisplayDelegate> |
| 588 ShellPortMash::CreateNativeDisplayDelegate() { | 578 ShellPortMash::CreateNativeDisplayDelegate() { |
| 589 #if defined(USE_OZONE) | 579 #if defined(USE_OZONE) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 observer.OnDisplayConfigurationChanging(); | 625 observer.OnDisplayConfigurationChanging(); |
| 636 } | 626 } |
| 637 | 627 |
| 638 void ShellPortMash::OnDisplayConfigurationChanged() { | 628 void ShellPortMash::OnDisplayConfigurationChanged() { |
| 639 for (auto& observer : display_observers_) | 629 for (auto& observer : display_observers_) |
| 640 observer.OnDisplayConfigurationChanged(); | 630 observer.OnDisplayConfigurationChanged(); |
| 641 } | 631 } |
| 642 | 632 |
| 643 } // namespace mus | 633 } // namespace mus |
| 644 } // namespace ash | 634 } // namespace ash |
| OLD | NEW |