| 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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> |
| 7 #include <queue> | 8 #include <queue> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "ash/ash_touch_exploration_manager_chromeos.h" | 11 #include "ash/ash_touch_exploration_manager_chromeos.h" |
| 11 #include "ash/aura/aura_layout_manager_adapter.h" | 12 #include "ash/aura/aura_layout_manager_adapter.h" |
| 12 #include "ash/common/ash_constants.h" | 13 #include "ash/common/ash_constants.h" |
| 13 #include "ash/common/ash_switches.h" | 14 #include "ash/common/ash_switches.h" |
| 14 #include "ash/common/focus_cycler.h" | 15 #include "ash/common/focus_cycler.h" |
| 15 #include "ash/common/login_status.h" | 16 #include "ash/common/login_status.h" |
| 16 #include "ash/common/session/session_state_delegate.h" | 17 #include "ash/common/session/session_state_delegate.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 return true; | 265 return true; |
| 265 | 266 |
| 266 aura::WindowMus* window_mus = | 267 aura::WindowMus* window_mus = |
| 267 aura::WindowMus::Get(WmWindow::GetAuraWindow(window)); | 268 aura::WindowMus::Get(WmWindow::GetAuraWindow(window)); |
| 268 return Shell::window_tree_client()->WasCreatedByThisClient(window_mus) || | 269 return Shell::window_tree_client()->WasCreatedByThisClient(window_mus) || |
| 269 Shell::window_tree_client()->IsRoot(window_mus); | 270 Shell::window_tree_client()->IsRoot(window_mus); |
| 270 } | 271 } |
| 271 | 272 |
| 272 } // namespace | 273 } // namespace |
| 273 | 274 |
| 275 // static |
| 276 std::vector<RootWindowController*>* |
| 277 RootWindowController::root_window_controllers_ = nullptr; |
| 278 |
| 274 RootWindowController::~RootWindowController() { | 279 RootWindowController::~RootWindowController() { |
| 275 Shutdown(); | 280 Shutdown(); |
| 276 ash_host_.reset(); | 281 ash_host_.reset(); |
| 277 mus_window_tree_host_.reset(); | 282 mus_window_tree_host_.reset(); |
| 278 // The CaptureClient needs to be around for as long as the RootWindow is | 283 // The CaptureClient needs to be around for as long as the RootWindow is |
| 279 // valid. | 284 // valid. |
| 280 capture_client_.reset(); | 285 capture_client_.reset(); |
| 281 if (animating_wallpaper_widget_controller_.get()) | 286 if (animating_wallpaper_widget_controller_.get()) |
| 282 animating_wallpaper_widget_controller_->StopAnimating(); | 287 animating_wallpaper_widget_controller_->StopAnimating(); |
| 288 root_window_controllers_->erase(std::find(root_window_controllers_->begin(), |
| 289 root_window_controllers_->end(), |
| 290 this)); |
| 283 } | 291 } |
| 284 | 292 |
| 285 void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) { | 293 void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) { |
| 286 RootWindowController* controller = new RootWindowController(host, nullptr); | 294 RootWindowController* controller = new RootWindowController(host, nullptr); |
| 287 controller->Init(RootWindowType::PRIMARY); | 295 controller->Init(RootWindowType::PRIMARY); |
| 288 } | 296 } |
| 289 | 297 |
| 290 void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) { | 298 void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) { |
| 291 RootWindowController* controller = new RootWindowController(host, nullptr); | 299 RootWindowController* controller = new RootWindowController(host, nullptr); |
| 292 controller->Init(RootWindowType::SECONDARY); | 300 controller->Init(RootWindowType::SECONDARY); |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 | 749 |
| 742 RootWindowController::RootWindowController( | 750 RootWindowController::RootWindowController( |
| 743 AshWindowTreeHost* ash_host, | 751 AshWindowTreeHost* ash_host, |
| 744 aura::WindowTreeHost* window_tree_host) | 752 aura::WindowTreeHost* window_tree_host) |
| 745 : ash_host_(ash_host), | 753 : ash_host_(ash_host), |
| 746 mus_window_tree_host_(window_tree_host), | 754 mus_window_tree_host_(window_tree_host), |
| 747 window_tree_host_(ash_host ? ash_host->AsWindowTreeHost() | 755 window_tree_host_(ash_host ? ash_host->AsWindowTreeHost() |
| 748 : window_tree_host), | 756 : window_tree_host), |
| 749 wm_shelf_(base::MakeUnique<WmShelf>()) { | 757 wm_shelf_(base::MakeUnique<WmShelf>()) { |
| 750 DCHECK((ash_host && !window_tree_host) || (!ash_host && window_tree_host)); | 758 DCHECK((ash_host && !window_tree_host) || (!ash_host && window_tree_host)); |
| 759 |
| 760 if (!root_window_controllers_) |
| 761 root_window_controllers_ = new std::vector<RootWindowController*>; |
| 762 root_window_controllers_->push_back(this); |
| 763 |
| 751 aura::Window* root_window = GetRootWindow(); | 764 aura::Window* root_window = GetRootWindow(); |
| 752 GetRootWindowSettings(root_window)->controller = this; | 765 GetRootWindowSettings(root_window)->controller = this; |
| 753 | 766 |
| 754 stacking_controller_.reset(new StackingController); | 767 stacking_controller_.reset(new StackingController); |
| 755 aura::client::SetWindowParentingClient(root_window, | 768 aura::client::SetWindowParentingClient(root_window, |
| 756 stacking_controller_.get()); | 769 stacking_controller_.get()); |
| 757 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); | 770 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); |
| 758 } | 771 } |
| 759 | 772 |
| 760 void RootWindowController::Init(RootWindowType root_window_type) { | 773 void RootWindowController::Init(RootWindowType root_window_type) { |
| 761 aura::Window* root_window = GetRootWindow(); | 774 aura::Window* root_window = GetRootWindow(); |
| 762 WmShell* wm_shell = WmShell::Get(); | 775 WmShell* wm_shell = WmShell::Get(); |
| 763 Shell* shell = nullptr; | 776 Shell* shell = Shell::GetInstance(); |
| 764 if (!wm_shell->IsRunningInMash()) { | 777 shell->InitRootWindow(root_window); |
| 765 shell = Shell::GetInstance(); | |
| 766 shell->InitRootWindow(root_window); | |
| 767 } | |
| 768 | 778 |
| 769 CreateContainers(); | 779 CreateContainers(); |
| 770 | 780 |
| 771 CreateSystemWallpaper(root_window_type); | 781 CreateSystemWallpaper(root_window_type); |
| 772 | 782 |
| 773 InitLayoutManagers(); | 783 InitLayoutManagers(); |
| 774 InitTouchHuds(); | 784 InitTouchHuds(); |
| 775 | 785 |
| 776 if (wm_shell->GetPrimaryRootWindowController() | 786 if (wm_shell->GetPrimaryRootWindowController() |
| 777 ->GetSystemModalLayoutManager(nullptr) | 787 ->GetSystemModalLayoutManager(nullptr) |
| 778 ->has_window_dimmer()) { | 788 ->has_window_dimmer()) { |
| 779 GetSystemModalLayoutManager(nullptr)->CreateModalBackground(); | 789 GetSystemModalLayoutManager(nullptr)->CreateModalBackground(); |
| 780 } | 790 } |
| 781 | 791 |
| 782 wm_shell->AddShellObserver(this); | 792 wm_shell->AddShellObserver(this); |
| 783 | 793 |
| 784 root_window_layout_manager_->OnWindowResized(); | 794 root_window_layout_manager_->OnWindowResized(); |
| 785 if (root_window_type == RootWindowType::PRIMARY) { | 795 if (root_window_type == RootWindowType::PRIMARY) { |
| 786 if (!wm_shell->IsRunningInMash()) | 796 if (!wm_shell->IsRunningInMash()) |
| 787 shell->InitKeyboard(); | 797 shell->InitKeyboard(); |
| 788 } else { | 798 } else { |
| 789 window_tree_host_->Show(); | 799 window_tree_host_->Show(); |
| 790 | 800 |
| 791 // Create a shelf if a user is already logged in. | 801 // Create a shelf if a user is already logged in. |
| 792 if (wm_shell->GetSessionStateDelegate()->NumberOfLoggedInUsers()) | 802 if (wm_shell->GetSessionStateDelegate()->NumberOfLoggedInUsers()) |
| 793 CreateShelf(); | 803 CreateShelf(); |
| 794 | 804 |
| 795 // Notify shell observers about new root window. | 805 // Notify shell observers about new root window. |
| 796 if (!wm_shell->IsRunningInMash()) | 806 shell->OnRootWindowAdded(WmWindow::Get(root_window)); |
| 797 shell->OnRootWindowAdded(WmWindow::Get(root_window)); | |
| 798 } | 807 } |
| 799 | 808 |
| 800 // TODO: AshTouchExplorationManager doesn't work with mus. | 809 // TODO: AshTouchExplorationManager doesn't work with mus. |
| 801 // http://crbug.com/679782 | 810 // http://crbug.com/679782 |
| 802 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 811 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 803 switches::kAshDisableTouchExplorationMode) && | 812 switches::kAshDisableTouchExplorationMode) && |
| 804 !wm_shell->IsRunningInMash()) { | 813 !wm_shell->IsRunningInMash()) { |
| 805 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); | 814 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); |
| 806 } | 815 } |
| 807 } | 816 } |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 EnableTouchHudProjection(); | 1140 EnableTouchHudProjection(); |
| 1132 else | 1141 else |
| 1133 DisableTouchHudProjection(); | 1142 DisableTouchHudProjection(); |
| 1134 } | 1143 } |
| 1135 | 1144 |
| 1136 RootWindowController* GetRootWindowController(const aura::Window* root_window) { | 1145 RootWindowController* GetRootWindowController(const aura::Window* root_window) { |
| 1137 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; | 1146 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; |
| 1138 } | 1147 } |
| 1139 | 1148 |
| 1140 } // namespace ash | 1149 } // namespace ash |
| OLD | NEW |