| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shell.h" | 5 #include "ash/shell.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 return root_window ? root_window->GetRootWindowController() : nullptr; | 237 return root_window ? root_window->GetRootWindowController() : nullptr; |
| 238 } | 238 } |
| 239 | 239 |
| 240 // static | 240 // static |
| 241 aura::Window* Shell::GetPrimaryRootWindow() { | 241 aura::Window* Shell::GetPrimaryRootWindow() { |
| 242 CHECK(HasInstance()); | 242 CHECK(HasInstance()); |
| 243 return instance_->wm_shell_->GetPrimaryRootWindow()->aura_window(); | 243 return instance_->wm_shell_->GetPrimaryRootWindow()->aura_window(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 // static | 246 // static |
| 247 aura::Window* Shell::GetTargetRootWindow() { | 247 aura::Window* Shell::GetRootWindowForNewWindows() { |
| 248 CHECK(WmShell::HasInstance()); | 248 CHECK(Shell::HasInstance()); |
| 249 return WmWindow::GetAuraWindow(WmShell::Get()->GetRootWindowForNewWindows()); | 249 return WmWindow::GetAuraWindow(Shell::GetWmRootWindowForNewWindows()); |
| 250 } | 250 } |
| 251 | 251 |
| 252 // static | 252 // static |
| 253 int64_t Shell::GetTargetDisplayId() { | 253 WmWindow* Shell::GetWmRootWindowForNewWindows() { |
| 254 return display::Screen::GetScreen() | 254 CHECK(Shell::HasInstance()); |
| 255 ->GetDisplayNearestWindow(GetTargetRootWindow()) | 255 Shell* shell = Shell::GetInstance(); |
| 256 .id(); | 256 if (shell->scoped_root_window_for_new_windows_) |
| 257 return shell->scoped_root_window_for_new_windows_; |
| 258 return shell->root_window_for_new_windows_; |
| 257 } | 259 } |
| 258 | 260 |
| 259 // static | 261 // static |
| 260 aura::Window::Windows Shell::GetAllRootWindows() { | 262 aura::Window::Windows Shell::GetAllRootWindows() { |
| 261 CHECK(HasInstance()); | 263 CHECK(HasInstance()); |
| 262 aura::Window::Windows windows; | 264 aura::Window::Windows windows; |
| 263 for (WmWindow* window : instance_->wm_shell_->GetAllRootWindows()) | 265 for (WmWindow* window : instance_->wm_shell_->GetAllRootWindows()) |
| 264 windows.push_back(window->aura_window()); | 266 windows.push_back(window->aura_window()); |
| 265 return windows; | 267 return windows; |
| 266 } | 268 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 keyboard::KeyboardController::ResetInstance(nullptr); | 343 keyboard::KeyboardController::ResetInstance(nullptr); |
| 342 } | 344 } |
| 343 | 345 |
| 344 bool Shell::ShouldSaveDisplaySettings() { | 346 bool Shell::ShouldSaveDisplaySettings() { |
| 345 DCHECK(!wm_shell_->IsRunningInMash()); | 347 DCHECK(!wm_shell_->IsRunningInMash()); |
| 346 return !( | 348 return !( |
| 347 screen_orientation_controller_->ignore_display_configuration_updates() || | 349 screen_orientation_controller_->ignore_display_configuration_updates() || |
| 348 resolution_notification_controller_->DoesNotificationTimeout()); | 350 resolution_notification_controller_->DoesNotificationTimeout()); |
| 349 } | 351 } |
| 350 | 352 |
| 353 aura::client::ActivationClient* Shell::activation_client() { |
| 354 return focus_controller_.get(); |
| 355 } |
| 356 |
| 351 void Shell::UpdateShelfVisibility() { | 357 void Shell::UpdateShelfVisibility() { |
| 352 for (WmWindow* root : wm_shell_->GetAllRootWindows()) | 358 for (WmWindow* root : wm_shell_->GetAllRootWindows()) |
| 353 root->GetRootWindowController()->GetShelf()->UpdateVisibilityState(); | 359 root->GetRootWindowController()->GetShelf()->UpdateVisibilityState(); |
| 354 } | 360 } |
| 355 | 361 |
| 356 WebNotificationTray* Shell::GetWebNotificationTray() { | 362 WebNotificationTray* Shell::GetWebNotificationTray() { |
| 357 return GetPrimaryRootWindowController() | 363 return GetPrimaryRootWindowController() |
| 358 ->GetStatusAreaWidget() | 364 ->GetStatusAreaWidget() |
| 359 ->web_notification_tray(); | 365 ->web_notification_tray(); |
| 360 } | 366 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 ->workspace_controller() | 402 ->workspace_controller() |
| 397 ->DoInitialAnimation(); | 403 ->DoInitialAnimation(); |
| 398 } | 404 } |
| 399 | 405 |
| 400 //////////////////////////////////////////////////////////////////////////////// | 406 //////////////////////////////////////////////////////////////////////////////// |
| 401 // Shell, private: | 407 // Shell, private: |
| 402 | 408 |
| 403 Shell::Shell(std::unique_ptr<WmShell> wm_shell) | 409 Shell::Shell(std::unique_ptr<WmShell> wm_shell) |
| 404 : wm_shell_(std::move(wm_shell)), | 410 : wm_shell_(std::move(wm_shell)), |
| 405 link_handler_model_factory_(nullptr), | 411 link_handler_model_factory_(nullptr), |
| 406 activation_client_(nullptr), | |
| 407 display_configurator_(new display::DisplayConfigurator()), | 412 display_configurator_(new display::DisplayConfigurator()), |
| 408 native_cursor_manager_(nullptr), | 413 native_cursor_manager_(nullptr), |
| 409 simulate_modal_window_open_for_testing_(false), | 414 simulate_modal_window_open_for_testing_(false), |
| 410 is_touch_hud_projection_enabled_(false) { | 415 is_touch_hud_projection_enabled_(false) { |
| 411 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash | 416 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash |
| 412 // state on WmShellAura. http://crbug.com/671246. | 417 // state on WmShellAura. http://crbug.com/671246. |
| 413 | 418 |
| 414 if (!wm_shell_->IsRunningInMash()) { | 419 if (!wm_shell_->IsRunningInMash()) { |
| 415 gpu_support_.reset(wm_shell_->delegate()->CreateGPUSupport()); | 420 gpu_support_.reset(wm_shell_->delegate()->CreateGPUSupport()); |
| 416 display_manager_.reset(ScreenAsh::CreateDisplayManager()); | 421 display_manager_.reset(ScreenAsh::CreateDisplayManager()); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since | 549 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since |
| 545 // destruction | 550 // destruction |
| 546 // of its owned RootWindowControllers relies on the value. | 551 // of its owned RootWindowControllers relies on the value. |
| 547 ScreenAsh::CreateScreenForShutdown(); | 552 ScreenAsh::CreateScreenForShutdown(); |
| 548 display_configuration_controller_.reset(); | 553 display_configuration_controller_.reset(); |
| 549 | 554 |
| 550 // AppListDelegateImpl depends upon AppList. | 555 // AppListDelegateImpl depends upon AppList. |
| 551 app_list_delegate_impl_.reset(); | 556 app_list_delegate_impl_.reset(); |
| 552 | 557 |
| 553 wm_shell_->Shutdown(); | 558 wm_shell_->Shutdown(); |
| 554 // Depends on |focus_client_|, so must be destroyed before. | 559 // Depends on |focus_controller_|, so must be destroyed before. |
| 555 window_tree_host_manager_.reset(); | 560 window_tree_host_manager_.reset(); |
| 556 focus_client_.reset(); | 561 focus_controller_->RemoveObserver(this); |
| 562 focus_controller_.reset(); |
| 557 screen_position_controller_.reset(); | 563 screen_position_controller_.reset(); |
| 558 | 564 |
| 559 keyboard::KeyboardController::ResetInstance(nullptr); | 565 keyboard::KeyboardController::ResetInstance(nullptr); |
| 560 | 566 |
| 561 display_color_manager_.reset(); | 567 display_color_manager_.reset(); |
| 562 if (display_change_observer_) | 568 if (display_change_observer_) |
| 563 display_configurator_->RemoveObserver(display_change_observer_.get()); | 569 display_configurator_->RemoveObserver(display_change_observer_.get()); |
| 564 if (display_error_observer_) | 570 if (display_error_observer_) |
| 565 display_configurator_->RemoveObserver(display_error_observer_.get()); | 571 display_configurator_->RemoveObserver(display_error_observer_.get()); |
| 566 if (projecting_observer_) { | 572 if (projecting_observer_) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 } | 673 } |
| 668 | 674 |
| 669 // The WindowModalityController needs to be at the front of the input event | 675 // The WindowModalityController needs to be at the front of the input event |
| 670 // pretarget handler list to ensure that it processes input events when modal | 676 // pretarget handler list to ensure that it processes input events when modal |
| 671 // windows are active. | 677 // windows are active. |
| 672 window_modality_controller_.reset(new ::wm::WindowModalityController(this)); | 678 window_modality_controller_.reset(new ::wm::WindowModalityController(this)); |
| 673 | 679 |
| 674 env_filter_.reset(new ::wm::CompoundEventFilter); | 680 env_filter_.reset(new ::wm::CompoundEventFilter); |
| 675 AddPreTargetHandler(env_filter_.get()); | 681 AddPreTargetHandler(env_filter_.get()); |
| 676 | 682 |
| 677 wm::AshFocusRules* focus_rules = new wm::AshFocusRules(); | 683 // FocusController takes ownership of AshFocusRules. |
| 678 | 684 focus_controller_ = |
| 679 ::wm::FocusController* focus_controller = | 685 base::MakeUnique<::wm::FocusController>(new wm::AshFocusRules()); |
| 680 new ::wm::FocusController(focus_rules); | 686 focus_controller_->AddObserver(this); |
| 681 focus_client_.reset(focus_controller); | |
| 682 activation_client_ = focus_controller; | |
| 683 // TODO(sky): Shell should implement ActivationChangeObserver, not WmShell. | |
| 684 activation_client_->AddObserver(wm_shell_.get()); | |
| 685 | 687 |
| 686 screen_position_controller_.reset(new ScreenPositionController); | 688 screen_position_controller_.reset(new ScreenPositionController); |
| 687 | 689 |
| 688 wm_shell_->CreatePrimaryHost(); | 690 wm_shell_->CreatePrimaryHost(); |
| 689 wm_shell_->set_root_window_for_new_windows( | 691 root_window_for_new_windows_ = WmWindow::Get(GetPrimaryRootWindow()); |
| 690 WmWindow::Get(GetPrimaryRootWindow())); | |
| 691 | 692 |
| 692 if (!is_mash) { | 693 if (!is_mash) { |
| 693 resolution_notification_controller_.reset( | 694 resolution_notification_controller_.reset( |
| 694 new ResolutionNotificationController); | 695 new ResolutionNotificationController); |
| 695 } | 696 } |
| 696 | 697 |
| 697 if (cursor_manager_) { | 698 if (cursor_manager_) { |
| 698 cursor_manager_->SetDisplay( | 699 cursor_manager_->SetDisplay( |
| 699 display::Screen::GetScreen()->GetPrimaryDisplay()); | 700 display::Screen::GetScreen()->GetPrimaryDisplay()); |
| 700 } | 701 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 | 806 |
| 806 event_client_.reset(new EventClientImpl); | 807 event_client_.reset(new EventClientImpl); |
| 807 | 808 |
| 808 session_state_delegate_.reset( | 809 session_state_delegate_.reset( |
| 809 wm_shell_->delegate()->CreateSessionStateDelegate()); | 810 wm_shell_->delegate()->CreateSessionStateDelegate()); |
| 810 // Must occur after Shell has installed its early pre-target handlers (for | 811 // Must occur after Shell has installed its early pre-target handlers (for |
| 811 // example, WindowModalityController). | 812 // example, WindowModalityController). |
| 812 wm_shell_->CreatePointerWatcherAdapter(); | 813 wm_shell_->CreatePointerWatcherAdapter(); |
| 813 | 814 |
| 814 resize_shadow_controller_.reset(new ResizeShadowController()); | 815 resize_shadow_controller_.reset(new ResizeShadowController()); |
| 815 shadow_controller_.reset(new ::wm::ShadowController(activation_client_)); | 816 shadow_controller_.reset(new ::wm::ShadowController(focus_controller_.get())); |
| 816 | 817 |
| 817 wm_shell_->SetSystemTrayDelegate( | 818 wm_shell_->SetSystemTrayDelegate( |
| 818 base::WrapUnique(wm_shell_->delegate()->CreateSystemTrayDelegate())); | 819 base::WrapUnique(wm_shell_->delegate()->CreateSystemTrayDelegate())); |
| 819 | 820 |
| 820 // Create AshTouchTransformController before | 821 // Create AshTouchTransformController before |
| 821 // WindowTreeHostManager::InitDisplays() | 822 // WindowTreeHostManager::InitDisplays() |
| 822 // since AshTouchTransformController listens on | 823 // since AshTouchTransformController listens on |
| 823 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). | 824 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). |
| 824 if (!is_mash) { | 825 if (!is_mash) { |
| 825 touch_transformer_controller_.reset(new AshTouchTransformController( | 826 touch_transformer_controller_.reset(new AshTouchTransformController( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 } | 886 } |
| 886 } | 887 } |
| 887 keyboard::KeyboardController::ResetInstance( | 888 keyboard::KeyboardController::ResetInstance( |
| 888 new keyboard::KeyboardController( | 889 new keyboard::KeyboardController( |
| 889 wm_shell_->delegate()->CreateKeyboardUI(), | 890 wm_shell_->delegate()->CreateKeyboardUI(), |
| 890 virtual_keyboard_controller_.get())); | 891 virtual_keyboard_controller_.get())); |
| 891 } | 892 } |
| 892 } | 893 } |
| 893 | 894 |
| 894 void Shell::InitRootWindow(aura::Window* root_window) { | 895 void Shell::InitRootWindow(aura::Window* root_window) { |
| 895 DCHECK(activation_client_); | 896 DCHECK(focus_controller_); |
| 896 DCHECK(visibility_controller_.get()); | 897 DCHECK(visibility_controller_.get()); |
| 897 DCHECK(drag_drop_controller_.get()); | 898 DCHECK(drag_drop_controller_.get()); |
| 898 | 899 |
| 899 aura::client::SetFocusClient(root_window, focus_client_.get()); | 900 aura::client::SetFocusClient(root_window, focus_controller_.get()); |
| 900 aura::client::SetActivationClient(root_window, activation_client_); | 901 aura::client::SetActivationClient(root_window, focus_controller_.get()); |
| 901 ::wm::FocusController* focus_controller = | 902 root_window->AddPreTargetHandler(focus_controller_.get()); |
| 902 static_cast<::wm::FocusController*>(activation_client_); | |
| 903 root_window->AddPreTargetHandler(focus_controller); | |
| 904 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); | 903 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
| 905 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); | 904 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
| 906 aura::client::SetScreenPositionClient(root_window, | 905 aura::client::SetScreenPositionClient(root_window, |
| 907 screen_position_controller_.get()); | 906 screen_position_controller_.get()); |
| 908 aura::client::SetCursorClient(root_window, cursor_manager_.get()); | 907 aura::client::SetCursorClient(root_window, cursor_manager_.get()); |
| 909 aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); | 908 aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); |
| 910 aura::client::SetEventClient(root_window, event_client_.get()); | 909 aura::client::SetEventClient(root_window, event_client_.get()); |
| 911 | 910 |
| 912 aura::client::SetWindowMoveClient(root_window, | 911 aura::client::SetWindowMoveClient(root_window, |
| 913 toplevel_window_event_handler_.get()); | 912 toplevel_window_event_handler_.get()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 | 951 |
| 953 std::unique_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const { | 952 std::unique_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const { |
| 954 return std::unique_ptr<ui::EventTargetIterator>(); | 953 return std::unique_ptr<ui::EventTargetIterator>(); |
| 955 } | 954 } |
| 956 | 955 |
| 957 ui::EventTargeter* Shell::GetEventTargeter() { | 956 ui::EventTargeter* Shell::GetEventTargeter() { |
| 958 NOTREACHED(); | 957 NOTREACHED(); |
| 959 return nullptr; | 958 return nullptr; |
| 960 } | 959 } |
| 961 | 960 |
| 961 void Shell::OnWindowActivated( |
| 962 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 963 aura::Window* gained_active, |
| 964 aura::Window* lost_active) { |
| 965 WmWindow* gained_active_wm = WmWindow::Get(gained_active); |
| 966 if (gained_active_wm) |
| 967 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); |
| 968 } |
| 969 |
| 962 } // namespace ash | 970 } // namespace ash |
| OLD | NEW |