diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-11 00:12:39 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-11 00:12:39 +0000 |
commit | 7b0f750bf7b0ccd2f0962817bab1460342d113e9 (patch) | |
tree | 89809ac408028af8ecff717caf7673e33bdd0dc7 | |
parent | 7208e05ab641d7dbc83bfc2bf202d2ece0445a74 (diff) | |
download | chromium_src-7b0f750bf7b0ccd2f0962817bab1460342d113e9.zip chromium_src-7b0f750bf7b0ccd2f0962817bab1460342d113e9.tar.gz chromium_src-7b0f750bf7b0ccd2f0962817bab1460342d113e9.tar.bz2 |
Change GetContainer to take a root window
Update the use of GetContainer to use the correct root window.
BUG=123160
TEST=no functional change. all tests must pass.
Review URL: https://chromiumcodereview.appspot.com/10540076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141384 0039d316-1c4b-4281-b951-d872f2087c98
46 files changed, 311 insertions, 200 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index 4dca2ce..b3435d3 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -42,44 +42,45 @@ #include "chromeos/monitor/output_configurator.h" #endif // defined(OS_CHROMEOS) +namespace ash { namespace { -bool HandleCycleWindowMRU(ash::WindowCycleController::Direction direction, +bool HandleCycleWindowMRU(WindowCycleController::Direction direction, bool is_alt_down) { - ash::Shell::GetInstance()-> + Shell::GetInstance()-> window_cycle_controller()->HandleCycleWindow(direction, is_alt_down); // Always report we handled the key, even if the window didn't change. return true; } -void HandleCycleWindowLinear(ash::CycleDirection direction) { - ash::Shell::GetInstance()->launcher()->CycleWindowLinear(direction); +void HandleCycleWindowLinear(CycleDirection direction) { + Shell::GetInstance()->launcher()->CycleWindowLinear(direction); } #if defined(OS_CHROMEOS) bool HandleLock() { - ash::Shell::GetInstance()->delegate()->LockScreen(); + Shell::GetInstance()->delegate()->LockScreen(); return true; } bool HandleFileManager() { - ash::Shell::GetInstance()->delegate()->OpenFileManager(); + Shell::GetInstance()->delegate()->OpenFileManager(); return true; } bool HandleCrosh() { - ash::Shell::GetInstance()->delegate()->OpenCrosh(); + Shell::GetInstance()->delegate()->OpenCrosh(); return true; } bool HandleToggleSpokenFeedback() { - ash::Shell::GetInstance()->delegate()->ToggleSpokenFeedback(); + Shell::GetInstance()->delegate()->ToggleSpokenFeedback(); return true; } #endif bool HandleExit() { - ash::ShellDelegate* delegate = ash::Shell::GetInstance()->delegate(); + ShellDelegate* delegate = Shell::GetInstance()->delegate(); if (!delegate) return false; delegate->Exit(); @@ -87,12 +88,12 @@ bool HandleExit() { } bool HandleNewTab() { - ash::Shell::GetInstance()->delegate()->NewTab(); + Shell::GetInstance()->delegate()->NewTab(); return true; } bool HandleNewWindow(bool is_incognito) { - ash::ShellDelegate* delegate = ash::Shell::GetInstance()->delegate(); + ShellDelegate* delegate = Shell::GetInstance()->delegate(); if (!delegate) return false; delegate->NewWindow(is_incognito); @@ -100,19 +101,20 @@ bool HandleNewWindow(bool is_incognito) { } bool HandleRestoreTab() { - ash::Shell::GetInstance()->delegate()->RestoreTab(); + Shell::GetInstance()->delegate()->RestoreTab(); return true; } bool HandleShowTaskManager() { - ash::Shell::GetInstance()->delegate()->ShowTaskManager(); + Shell::GetInstance()->delegate()->ShowTaskManager(); return true; } // Rotates the default window container. bool HandleRotateWindows() { - aura::Window* target = ash::Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_DefaultContainer); + aura::Window* target = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_DefaultContainer); scoped_ptr<ui::LayerAnimationSequence> screen_rotation( new ui::LayerAnimationSequence(new ui::ScreenRotation(360))); target->layer()->GetAnimator()->StartAnimation( @@ -142,36 +144,36 @@ bool HandleRotateScreen() { case 13: delta = 180; break; } i = (i + 1) % 14; - ash::Shell::GetPrimaryRootWindow()->layer()->GetAnimator()-> + Shell::GetPrimaryRootWindow()->layer()->GetAnimator()-> set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); scoped_ptr<ui::LayerAnimationSequence> screen_rotation( new ui::LayerAnimationSequence(new ui::ScreenRotation(delta))); - screen_rotation->AddObserver(ash::Shell::GetPrimaryRootWindow()); - ash::Shell::GetPrimaryRootWindow()->layer()->GetAnimator()->StartAnimation( + screen_rotation->AddObserver(Shell::GetPrimaryRootWindow()); + Shell::GetPrimaryRootWindow()->layer()->GetAnimator()->StartAnimation( screen_rotation.release()); return true; } bool HandleToggleDesktopBackgroundMode() { - ash::DesktopBackgroundController* desktop_background_controller = - ash::Shell::GetInstance()->desktop_background_controller(); + DesktopBackgroundController* desktop_background_controller = + Shell::GetInstance()->desktop_background_controller(); if (desktop_background_controller->desktop_background_mode() == - ash::DesktopBackgroundController::BACKGROUND_IMAGE) { + DesktopBackgroundController::BACKGROUND_IMAGE) { desktop_background_controller->SetDesktopBackgroundSolidColorMode(); } else { - ash::Shell::GetInstance()->user_wallpaper_delegate()-> + Shell::GetInstance()->user_wallpaper_delegate()-> SetLoggedInUserWallpaper(); } return true; } bool HandleToggleRootWindowFullScreen() { - ash::Shell::GetPrimaryRootWindow()->ToggleFullScreen(); + Shell::GetPrimaryRootWindow()->ToggleFullScreen(); return true; } bool HandlePrintLayerHierarchy() { - aura::RootWindow* root_window = ash::Shell::GetPrimaryRootWindow(); + aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); ui::PrintLayerHierarchy(root_window->layer(), root_window->last_mouse_location()); return true; @@ -180,15 +182,16 @@ bool HandlePrintLayerHierarchy() { void PrintWindowHierarchy(aura::Window* window, int indent) { std::string indent_str(indent, ' '); DLOG(INFO) << indent_str << window->name() << " type " << window->type() - << (ash::wm::IsActiveWindow(window) ? "active" : ""); + << (wm::IsActiveWindow(window) ? "active" : ""); for (size_t i = 0; i < window->children().size(); ++i) PrintWindowHierarchy(window->children()[i], indent + 3); } bool HandlePrintWindowHierarchy() { DLOG(INFO) << "Window hierarchy:"; - aura::Window* container = ash::Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_DefaultContainer); + aura::Window* container = + Shell::GetContainer(Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_DefaultContainer); PrintWindowHierarchy(container, 0); return true; } @@ -197,8 +200,6 @@ bool HandlePrintWindowHierarchy() { } // namespace -namespace ash { - //////////////////////////////////////////////////////////////////////////////// // AcceleratorController, public: diff --git a/ash/accelerators/accelerator_filter_unittest.cc b/ash/accelerators/accelerator_filter_unittest.cc index 3240f4d..723960a 100644 --- a/ash/accelerators/accelerator_filter_unittest.cc +++ b/ash/accelerators/accelerator_filter_unittest.cc @@ -76,7 +76,8 @@ TEST_F(AcceleratorFilterTest, TestFilterWithoutFocus) { // Tests if AcceleratorFilter works as expected with a focused window. TEST_F(AcceleratorFilterTest, TestFilterWithFocus) { - aura::Window* default_container = Shell::GetInstance()->GetContainer( + aura::Window* default_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); aura::test::TestWindowDelegate test_delegate; scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( diff --git a/ash/accelerators/nested_dispatcher_controller_unittest.cc b/ash/accelerators/nested_dispatcher_controller_unittest.cc index 800a27d..3837ff8 100644 --- a/ash/accelerators/nested_dispatcher_controller_unittest.cc +++ b/ash/accelerators/nested_dispatcher_controller_unittest.cc @@ -106,7 +106,8 @@ typedef AshTestBase NestedDispatcherTest; // Aura window below lock screen in z order. TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) { MockDispatcher inner_dispatcher; - aura::Window* default_container = Shell::GetInstance()->GetContainer( + aura::Window* default_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); scoped_ptr<aura::Window> associated_window(aura::test::CreateTestWindowWithId( 0, default_container)); @@ -126,7 +127,8 @@ TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) { TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) { MockDispatcher inner_dispatcher; - aura::Window* default_container = Shell::GetInstance()->GetContainer( + aura::Window* default_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); scoped_ptr<aura::Window>mock_lock_container( aura::test::CreateTestWindowWithId(0, default_container)); diff --git a/ash/focus_cycler_unittest.cc b/ash/focus_cycler_unittest.cc index a666928..3dd2482 100644 --- a/ash/focus_cycler_unittest.cc +++ b/ash/focus_cycler_unittest.cc @@ -49,9 +49,9 @@ TEST_F(FocusCyclerTest, CycleFocusBrowserOnly) { scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); // Create a single test window. - Window* default_container = - ash::Shell::GetInstance()->GetContainer( - internal::kShellWindowId_DefaultContainer); + Window* default_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_DefaultContainer); scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); wm::ActivateWindow(window0.get()); EXPECT_TRUE(wm::IsActiveWindow(window0.get())); @@ -79,9 +79,9 @@ TEST_F(FocusCyclerTest, CycleFocusForward) { launcher->SetFocusCycler(focus_cycler.get()); // Create a single test window. - Window* default_container = - ash::Shell::GetInstance()->GetContainer( - internal::kShellWindowId_DefaultContainer); + Window* default_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_DefaultContainer); scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); wm::ActivateWindow(window0.get()); EXPECT_TRUE(wm::IsActiveWindow(window0.get())); @@ -117,9 +117,9 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) { launcher->SetFocusCycler(focus_cycler.get()); // Create a single test window. - Window* default_container = - ash::Shell::GetInstance()->GetContainer( - internal::kShellWindowId_DefaultContainer); + Window* default_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_DefaultContainer); scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); wm::ActivateWindow(window0.get()); EXPECT_TRUE(wm::IsActiveWindow(window0.get())); @@ -186,9 +186,9 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) { launcher->SetFocusCycler(focus_cycler.get()); // Create a single test window. - Window* default_container = - ash::Shell::GetInstance()->GetContainer( - internal::kShellWindowId_DefaultContainer); + Window* default_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_DefaultContainer); scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); wm::ActivateWindow(window0.get()); EXPECT_TRUE(wm::IsActiveWindow(window0.get())); @@ -220,9 +220,9 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) { launcher->SetFocusCycler(focus_cycler.get()); // Create a single test window. - Window* default_container = - ash::Shell::GetInstance()->GetContainer( - internal::kShellWindowId_DefaultContainer); + Window* default_container = Shell::GetInstance()->GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_DefaultContainer); scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); wm::ActivateWindow(window0.get()); EXPECT_TRUE(wm::IsActiveWindow(window0.get())); diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc index aa0024b..f8314bc 100644 --- a/ash/launcher/launcher.cc +++ b/ash/launcher/launcher.cc @@ -116,7 +116,8 @@ Launcher::Launcher(aura::Window* window_container) params.layer_type = ui::LAYER_SOLID_COLOR; params.transparent = true; params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - params.parent = Shell::GetInstance()->GetContainer( + params.parent = Shell::GetContainer( + window_container_->GetRootWindow(), ash::internal::kShellWindowId_LauncherContainer); launcher_view_ = new internal::LauncherView(model_.get(), delegate_.get()); launcher_view_->Init(); diff --git a/ash/shell.cc b/ash/shell.cc index 51cd7bf..b7f7443 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -704,15 +704,33 @@ aura::RootWindow* Shell::GetPrimaryRootWindow() { return GetInstance()->root_window_.get(); } +// static aura::RootWindow* Shell::GetActiveRootWindow() { return GetInstance()->active_root_window_; } +// static aura::RootWindow* Shell::GetRootWindowAt(const gfx::Point& point) { // TODO(oshima): Support multiple root windows. return GetPrimaryRootWindow(); } +// static +aura::Window* Shell::GetContainer(aura::RootWindow* root_window, + int container_id) { + return root_window->GetChildById(container_id); +} + +// static +std::vector<aura::Window*> Shell::GetAllContainers(int container_id) { + // TODO(oshima): Support multiple root windows. + std::vector<aura::Window*> containers; + aura::Window* container = GetPrimaryRootWindow()->GetChildById(container_id); + if (container) + containers.push_back(container); + return containers; +} + void Shell::Init() { // Install the custom factory first so that views::FocusManagers for Tray, // Launcher, and WallPaper could be created by the factory. @@ -870,15 +888,6 @@ void Shell::Init() { screen_dimmer_.reset(new internal::ScreenDimmer(root_window)); } -aura::Window* Shell::GetContainer(int container_id) { - return const_cast<aura::Window*>( - const_cast<const Shell*>(this)->GetContainer(container_id)); -} - -const aura::Window* Shell::GetContainer(int container_id) const { - return GetPrimaryRootWindow()->GetChildById(container_id); -} - void Shell::AddEnvEventFilter(aura::EventFilter* filter) { env_filter_->AddFilter(filter); } @@ -917,7 +926,9 @@ bool Shell::IsScreenLocked() const { } bool Shell::IsModalWindowOpen() const { + // TODO(oshima): Walk though all root windows. const aura::Window* modal_container = GetContainer( + GetPrimaryRootWindow(), internal::kShellWindowId_SystemModalContainer); return !modal_container->children().empty(); } @@ -967,8 +978,9 @@ void Shell::CreateLauncher() { if (launcher_.get()) return; - aura::Window* default_container = - GetContainer(internal::kShellWindowId_DefaultContainer); + aura::Window* default_container = GetContainer( + GetPrimaryRootWindow(), + internal::kShellWindowId_DefaultContainer); launcher_.reset(new Launcher(default_container)); launcher_->SetFocusCycler(focus_cycler_.get()); @@ -1044,17 +1056,20 @@ void Shell::InitLayoutManagers() { internal::ShelfLayoutManager* shelf_layout_manager = new internal::ShelfLayoutManager(status_area_widget_); - GetContainer(internal::kShellWindowId_LauncherContainer)-> + GetContainer( + GetPrimaryRootWindow(), + internal::kShellWindowId_LauncherContainer)-> SetLayoutManager(shelf_layout_manager); shelf_ = shelf_layout_manager; internal::StatusAreaLayoutManager* status_area_layout_manager = new internal::StatusAreaLayoutManager(shelf_layout_manager); - GetContainer(internal::kShellWindowId_StatusContainer)-> + GetContainer(GetPrimaryRootWindow(), + internal::kShellWindowId_StatusContainer)-> SetLayoutManager(status_area_layout_manager); - aura::Window* default_container = - GetContainer(internal::kShellWindowId_DefaultContainer); + aura::Window* default_container = GetContainer( + GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); // Workspace manager has its own layout managers. workspace_controller_.reset( new internal::WorkspaceController(default_container)); @@ -1062,8 +1077,8 @@ void Shell::InitLayoutManagers() { shelf_layout_manager->set_workspace_manager( workspace_controller_->workspace_manager()); - aura::Window* always_on_top_container = - GetContainer(internal::kShellWindowId_AlwaysOnTopContainer); + aura::Window* always_on_top_container = GetContainer( + GetPrimaryRootWindow(), internal::kShellWindowId_AlwaysOnTopContainer); always_on_top_container->SetLayoutManager( new internal::BaseLayoutManager( always_on_top_container->GetRootWindow())); @@ -1072,6 +1087,7 @@ void Shell::InitLayoutManagers() { if (CommandLine::ForCurrentProcess()-> HasSwitch(switches::kAuraPanelManager)) { aura::Window* panel_container = GetContainer( + GetPrimaryRootWindow(), internal::kShellWindowId_PanelContainer); panel_layout_manager_ = new internal::PanelLayoutManager(panel_container); diff --git a/ash/shell.h b/ash/shell.h index 27ce5e2..5848d29 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -160,6 +160,13 @@ class ASH_EXPORT Shell : aura::CursorDelegate { // point. static aura::RootWindow* GetRootWindowAt(const gfx::Point& point); + static aura::Window* GetContainer(aura::RootWindow* root_window, + int container_id); + + // Returns the list of containers that match |container_id| in + // all root windows. + static std::vector<aura::Window*> GetAllContainers(int container_id); + void set_active_root_window(aura::RootWindow* active_root_window) { active_root_window_ = active_root_window; } @@ -168,9 +175,6 @@ class ASH_EXPORT Shell : aura::CursorDelegate { return root_window_layout_; } - aura::Window* GetContainer(int container_id); - const aura::Window* GetContainer(int container_id) const; - // Adds or removes |filter| from the aura::Env's CompoundEventFilter. void AddEnvEventFilter(aura::EventFilter* filter); void RemoveEnvEventFilter(aura::EventFilter* filter); diff --git a/ash/shell/lock_view.cc b/ash/shell/lock_view.cc index 3c90679..6b72fce 100644 --- a/ash/shell/lock_view.cc +++ b/ash/shell/lock_view.cc @@ -91,9 +91,9 @@ void CreateLockScreen() { (root_window_size.height() - ps.height()) / 2, ps.width(), ps.height()); params.delegate = lock_view; - params.parent = - Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_LockScreenContainer); + params.parent = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_LockScreenContainer); widget->Init(params); widget->SetContentsView(lock_view); widget->Show(); diff --git a/ash/shell/window_watcher.cc b/ash/shell/window_watcher.cc index cbac740..a3d99f1 100644 --- a/ash/shell/window_watcher.cc +++ b/ash/shell/window_watcher.cc @@ -15,8 +15,9 @@ namespace shell { WindowWatcher::WindowWatcher() : window_(ash::Shell::GetInstance()->launcher()->window_container()), - panel_container_(ash::Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_PanelContainer)) { + panel_container_(ash::Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_PanelContainer)) { window_->AddObserver(this); panel_container_->AddObserver(this); } diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc index 59d17c7..a5e7939 100644 --- a/ash/shell_unittest.cc +++ b/ash/shell_unittest.cc @@ -33,44 +33,46 @@ views::Widget* CreateTestWindow(const views::Widget::InitParams& params) { } aura::Window* GetDefaultContainer() { - return Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_DefaultContainer); + return Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_DefaultContainer); } aura::Window* GetAlwaysOnTopContainer() { - return Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_AlwaysOnTopContainer); + return Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_AlwaysOnTopContainer); } // Expect ALL the containers! void ExpectAllContainers() { - Shell* shell = Shell::GetInstance(); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_DefaultContainer)); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_AlwaysOnTopContainer)); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_PanelContainer)); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_LauncherContainer)); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_SystemModalContainer)); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_LockScreenContainer)); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_LockSystemModalContainer)); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_StatusContainer)); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_MenuContainer)); - EXPECT_TRUE(shell->GetContainer( - internal::kShellWindowId_DragImageAndTooltipContainer)); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_SettingBubbleContainer)); - EXPECT_TRUE( - shell->GetContainer(internal::kShellWindowId_OverlayContainer)); + aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_DesktopBackgroundContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_DefaultContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_AlwaysOnTopContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_PanelContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_LauncherContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_SystemModalContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_LockScreenContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_LockSystemModalContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_StatusContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_MenuContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_DragImageAndTooltipContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_SettingBubbleContainer)); + EXPECT_TRUE(Shell::GetContainer( + root_window, internal::kShellWindowId_OverlayContainer)); } void TestCreateWindow(views::Widget::InitParams::Type type, @@ -186,8 +188,9 @@ TEST_F(ShellTest, CreateModalWindow) { modal_widget->Show(); // It should be in modal container. - aura::Window* modal_container = Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_SystemModalContainer); + aura::Window* modal_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_SystemModalContainer); EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent()); modal_widget->Close(); @@ -207,13 +210,15 @@ TEST_F(ShellTest, CreateLockScreenModalWindow) { // Create a LockScreen window. views::Widget* lock_widget = CreateTestWindow(widget_params); - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_LockScreenContainer)-> AddChild(lock_widget->GetNativeView()); lock_widget->Show(); // It should be in LockScreen container. - aura::Window* lock_screen = Shell::GetInstance()->GetContainer( + aura::Window* lock_screen = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_LockScreenContainer); EXPECT_EQ(lock_screen, lock_widget->GetNativeWindow()->parent()); @@ -223,7 +228,8 @@ TEST_F(ShellTest, CreateLockScreenModalWindow) { lock_modal_widget->Show(); // It should be in LockScreen modal container. - aura::Window* lock_modal_container = Shell::GetInstance()->GetContainer( + aura::Window* lock_modal_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_LockSystemModalContainer); EXPECT_EQ(lock_modal_container, lock_modal_widget->GetNativeWindow()->parent()); @@ -234,7 +240,8 @@ TEST_F(ShellTest, CreateLockScreenModalWindow) { modal_widget->Show(); // It should be in non-LockScreen modal container. - aura::Window* modal_container = Shell::GetInstance()->GetContainer( + aura::Window* modal_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_SystemModalContainer); EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent()); diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc index 98e5c33..be73b5f 100644 --- a/ash/system/network/tray_network.cc +++ b/ash/system/network/tray_network.cc @@ -69,7 +69,8 @@ class NonActivatableSettingsBubble : public views::BubbleDelegateView { NonActivatableSettingsBubble(views::View* anchor, views::View* content) : views::BubbleDelegateView(anchor, views::BubbleBorder::TOP_RIGHT) { set_use_focusless(true); - set_parent_window(ash::Shell::GetInstance()->GetContainer( + set_parent_window(ash::Shell::GetContainer( + anchor->GetWidget()->GetNativeWindow()->GetRootWindow(), ash::internal::kShellWindowId_SettingBubbleContainer)); SetLayoutManager(new views::FillLayout()); AddChildView(content); diff --git a/ash/system/status_area_widget.cc b/ash/system/status_area_widget.cc index e5f8ea6..2e66512 100644 --- a/ash/system/status_area_widget.cc +++ b/ash/system/status_area_widget.cc @@ -18,7 +18,8 @@ StatusAreaWidget::StatusAreaWidget() { views::Widget::InitParams params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); params.delegate = widget_delegate_; - params.parent = Shell::GetInstance()->GetContainer( + params.parent = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_StatusContainer); params.transparent = true; Init(params); diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc index 5567b13..6a1f70c 100644 --- a/ash/system/tray/system_tray_bubble.cc +++ b/ash/system/tray/system_tray_bubble.cc @@ -297,8 +297,9 @@ SystemTrayBubbleView::SystemTrayBubbleView( max_height_(0), bubble_width_(bubble_width) { set_margin(0); - set_parent_window(ash::Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_SettingBubbleContainer)); + set_parent_window(Shell::GetContainer( + anchor->GetWidget()->GetNativeWindow()->GetRootWindow(), + internal::kShellWindowId_SettingBubbleContainer)); set_notify_enter_exit_on_child(true); SetPaintToLayer(true); SetFillsBoundsOpaquely(true); diff --git a/ash/touch/touch_observer_hud.cc b/ash/touch/touch_observer_hud.cc index b7773a5..2b976d2 100644 --- a/ash/touch/touch_observer_hud.cc +++ b/ash/touch/touch_observer_hud.cc @@ -137,7 +137,8 @@ TouchObserverHUD::TouchObserverHUD() { params.can_activate = false; params.accept_events = false; params.bounds = gfx::Rect(content->GetPreferredSize()); - params.parent = Shell::GetInstance()->GetContainer( + params.parent = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_OverlayContainer); widget_->Init(params); widget_->SetContentsView(content); diff --git a/ash/wm/activation_controller.cc b/ash/wm/activation_controller.cc index 2452eb5..668271b 100644 --- a/ash/wm/activation_controller.cc +++ b/ash/wm/activation_controller.cc @@ -43,10 +43,6 @@ const int kWindowContainerIds[] = { kShellWindowId_StatusContainer, }; -aura::Window* GetContainer(int id) { - return Shell::GetInstance()->GetContainer(id); -} - // Returns true if children of |window| can be activated. // These are the only containers in which windows can receive focus. bool SupportsChildActivation(aura::Window* window) { @@ -310,8 +306,11 @@ aura::Window* ActivationController::GetTopmostWindowToActivate( size_t current_container_index = 0; // If the container of the window losing focus is in the list, start from that // container. + aura::RootWindow* root = ignore->GetRootWindow(); + if (!root) + root = Shell::GetActiveRootWindow(); for (size_t i = 0; ignore && i < arraysize(kWindowContainerIds); i++) { - aura::Window* container = GetContainer(kWindowContainerIds[i]); + aura::Window* container = Shell::GetContainer(root, kWindowContainerIds[i]); if (container && container->Contains(ignore)) { current_container_index = i; break; @@ -322,10 +321,14 @@ aura::Window* ActivationController::GetTopmostWindowToActivate( aura::Window* window = NULL; for (; !window && current_container_index < arraysize(kWindowContainerIds); current_container_index++) { - aura::Window* container = - GetContainer(kWindowContainerIds[current_container_index]); - if (container) - window = GetTopmostWindowToActivateInContainer(container, ignore); + + aura::Window::Windows containers = + Shell::GetAllContainers(kWindowContainerIds[current_container_index]); + for (aura::Window::Windows::const_iterator iter = containers.begin(); + iter != containers.end(); + ++iter) { + window = GetTopmostWindowToActivateInContainer((*iter), ignore); + } } return window; } diff --git a/ash/wm/activation_controller_unittest.cc b/ash/wm/activation_controller_unittest.cc index 9a1e6f1..98f5195 100644 --- a/ash/wm/activation_controller_unittest.cc +++ b/ash/wm/activation_controller_unittest.cc @@ -88,7 +88,7 @@ class GetTopmostWindowToActivateTest : public ActivationControllerTest { &delegate_, id, gfx::Rect(), - Shell::GetInstance()->GetContainer(container_id)); + Shell::GetContainer(Shell::GetPrimaryRootWindow(), container_id)); delegate->SetWindow(window); return window; } diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc index f447b13a..d4c51f1 100644 --- a/ash/wm/app_list_controller.cc +++ b/ash/wm/app_list_controller.cc @@ -85,7 +85,9 @@ void AppListController::SetVisible(bool visible) { app_list::AppListView* view = new app_list::AppListView( Shell::GetInstance()->delegate()->CreateAppListViewDelegate()); view->InitAsBubble( - Shell::GetInstance()->GetContainer(kShellWindowId_AppListContainer), + Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + kShellWindowId_AppListContainer), Shell::GetInstance()->launcher()->GetAppListButtonView(), GetBubbleArrowLocation()); SetView(view); @@ -199,9 +201,11 @@ ui::GestureStatus AppListController::PreHandleGestureEvent( // AppListController, aura::FocusObserver implementation: void AppListController::OnWindowFocused(aura::Window* window) { if (view_ && is_visible_) { - aura::Window* applist_container = Shell::GetInstance()->GetContainer( + aura::Window* applist_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), kShellWindowId_AppListContainer); - aura::Window* bubble_container = Shell::GetInstance()->GetContainer( + aura::Window* bubble_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), kShellWindowId_SettingBubbleContainer); if (window->parent() != applist_container && window->parent() != bubble_container) { diff --git a/ash/wm/base_layout_manager_unittest.cc b/ash/wm/base_layout_manager_unittest.cc index 2309491..7420d23 100644 --- a/ash/wm/base_layout_manager_unittest.cc +++ b/ash/wm/base_layout_manager_unittest.cc @@ -33,7 +33,8 @@ class BaseLayoutManagerTest : public test::AshTestBase { Shell::GetPrimaryRootWindow(), gfx::Insets(1, 2, 3, 4)); Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); - aura::Window* default_container = Shell::GetInstance()->GetContainer( + aura::Window* default_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); default_container->SetLayoutManager(new internal::BaseLayoutManager( Shell::GetPrimaryRootWindow())); diff --git a/ash/wm/event_client_impl.cc b/ash/wm/event_client_impl.cc index 58b4385..1804e38 100644 --- a/ash/wm/event_client_impl.cc +++ b/ash/wm/event_client_impl.cc @@ -24,12 +24,12 @@ EventClientImpl::~EventClientImpl() { bool EventClientImpl::CanProcessEventsWithinSubtree( const aura::Window* window) const { if (Shell::GetInstance()->IsScreenLocked()) { - aura::Window* lock_screen_containers = - Shell::GetInstance()->GetContainer( - kShellWindowId_LockScreenContainersContainer); - aura::Window* lock_screen_related_containers = - Shell::GetInstance()->GetContainer( - kShellWindowId_LockScreenRelatedContainersContainer); + aura::Window* lock_screen_containers = Shell::GetContainer( + root_window_, + kShellWindowId_LockScreenContainersContainer); + aura::Window* lock_screen_related_containers = Shell::GetContainer( + root_window_, + kShellWindowId_LockScreenRelatedContainersContainer); return lock_screen_containers->Contains(window) || lock_screen_related_containers->Contains(window); } diff --git a/ash/wm/frame_painter_unittest.cc b/ash/wm/frame_painter_unittest.cc index 57ae977..d0b4bdf 100644 --- a/ash/wm/frame_painter_unittest.cc +++ b/ash/wm/frame_painter_unittest.cc @@ -20,7 +20,8 @@ using views::ImageButton; namespace { aura::Window* GetDefaultContainer() { - return ash::Shell::GetInstance()->GetContainer( + return ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_DefaultContainer); } diff --git a/ash/wm/panel_layout_manager_unittest.cc b/ash/wm/panel_layout_manager_unittest.cc index a7d0ce3..f1878ca 100644 --- a/ash/wm/panel_layout_manager_unittest.cc +++ b/ash/wm/panel_layout_manager_unittest.cc @@ -53,7 +53,8 @@ class PanelLayoutManagerTest : public ash::test::AshTestBase { } aura::Window* GetPanelContainer() { - return Shell::GetInstance()->GetContainer( + return Shell::GetContainer( + Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_PanelContainer); } diff --git a/ash/wm/partial_screenshot_view.cc b/ash/wm/partial_screenshot_view.cc index 3e492e2..64d9855 100644 --- a/ash/wm/partial_screenshot_view.cc +++ b/ash/wm/partial_screenshot_view.cc @@ -41,19 +41,20 @@ void PartialScreenshotView::StartPartialScreenshot( views::Widget* widget = new views::Widget; PartialScreenshotView* view = new PartialScreenshotView( screenshot_delegate); - + aura::RootWindow* root_window = Shell::GetActiveRootWindow(); views::Widget::InitParams params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); params.transparent = true; params.delegate = view; // The partial screenshot rectangle has to be at the real top of // the screen. - params.parent = Shell::GetInstance()->GetContainer( + params.parent = Shell::GetContainer( + root_window, internal::kShellWindowId_OverlayContainer); widget->Init(params); widget->SetContentsView(view); - widget->SetBounds(Shell::GetPrimaryRootWindow()->bounds()); + widget->SetBounds(root_window->bounds()); widget->GetNativeView()->SetName("PartialScreenshotView"); widget->StackAtTop(); widget->Show(); diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc index 8b7deb7..7f2ceac 100644 --- a/ash/wm/power_button_controller.cc +++ b/ash/wm/power_button_controller.cc @@ -161,15 +161,17 @@ void RestoreWindow(aura::Window* window) { // Fills |containers| with the containers described by |group|. void GetContainers(PowerButtonController::ContainerGroup group, aura::Window::Windows* containers) { - aura::Window* non_lock_screen_containers = - Shell::GetInstance()->GetContainer( - internal::kShellWindowId_NonLockScreenContainersContainer); - aura::Window* lock_screen_containers = - Shell::GetInstance()->GetContainer( - internal::kShellWindowId_LockScreenContainersContainer); - aura::Window* lock_screen_related_containers = - Shell::GetInstance()->GetContainer( - internal::kShellWindowId_LockScreenRelatedContainersContainer); + aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); + + aura::Window* non_lock_screen_containers = Shell::GetContainer( + root_window, + internal::kShellWindowId_NonLockScreenContainersContainer); + aura::Window* lock_screen_containers = Shell::GetContainer( + root_window, + internal::kShellWindowId_LockScreenContainersContainer); + aura::Window* lock_screen_related_containers = Shell::GetContainer( + root_window, + internal::kShellWindowId_LockScreenRelatedContainersContainer); containers->clear(); switch (group) { diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc index 65606da..d90d05f 100644 --- a/ash/wm/shelf_layout_manager_unittest.cc +++ b/ash/wm/shelf_layout_manager_unittest.cc @@ -38,8 +38,9 @@ void StepWidgetLayerAnimatorToEnd(views::Widget* widget) { } ShelfLayoutManager* GetShelfLayoutManager() { - aura::Window* window = ash::Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_LauncherContainer); + aura::Window* window = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + internal::kShellWindowId_LauncherContainer); return static_cast<ShelfLayoutManager*>(window->layout_manager()); } @@ -63,7 +64,8 @@ class ShelfLayoutManagerTest : public ash::test::AshTestBase { window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); window->SetType(aura::client::WINDOW_TYPE_NORMAL); window->Init(ui::LAYER_TEXTURED); - aura::Window* parent = Shell::GetInstance()->GetContainer( + aura::Window* parent = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); window->SetParent(parent); return window; @@ -283,7 +285,8 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, shelf->launcher_widget()->GetWindowScreenBounds().y()); - aura::Window* lock_container = Shell::GetInstance()->GetContainer( + aura::Window* lock_container = Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_LockScreenContainer); views::Widget* lock_widget = new views::Widget; diff --git a/ash/wm/stacking_controller.cc b/ash/wm/stacking_controller.cc index 42aedf6..2f5e975 100644 --- a/ash/wm/stacking_controller.cc +++ b/ash/wm/stacking_controller.cc @@ -7,7 +7,9 @@ #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/always_on_top_controller.h" +#include "ash/wm/window_properties.h" #include "ui/aura/client/aura_constants.h" +#include "ui/aura/root_window.h" #include "ui/aura/window.h" #include "ui/base/ui_base_types.h" @@ -16,7 +18,7 @@ namespace internal { namespace { aura::Window* GetContainerById(int id) { - return Shell::GetInstance()->GetContainer(id); + return Shell::GetContainer(Shell::GetActiveRootWindow(), id); } aura::Window* GetContainerForWindow(aura::Window* window) { @@ -42,10 +44,6 @@ bool IsWindowModal(aura::Window* window) { StackingController::StackingController() { aura::client::SetStackingClient(this); - always_on_top_controller_.reset(new internal::AlwaysOnTopController); - always_on_top_controller_->SetContainers( - GetContainerById(internal::kShellWindowId_DefaultContainer), - GetContainerById(internal::kShellWindowId_AlwaysOnTopContainer)); } StackingController::~StackingController() { @@ -62,7 +60,7 @@ aura::Window* StackingController::GetDefaultParent(aura::Window* window) { return GetSystemModalContainer(window); else if (IsWindowModal(window)) return GetContainerForWindow(window->transient_parent()); - return always_on_top_controller_->GetContainer(window); + return GetAlwaysOnTopController()->GetContainer(window); case aura::client::WINDOW_TYPE_PANEL: return GetContainerById(internal::kShellWindowId_PanelContainer); case aura::client::WINDOW_TYPE_MENU: @@ -113,5 +111,22 @@ aura::Window* StackingController::GetSystemModalContainer( return container; } +internal::AlwaysOnTopController* +StackingController::GetAlwaysOnTopController() { + aura::RootWindow* root_window = Shell::GetActiveRootWindow(); + internal::AlwaysOnTopController* controller = + root_window->GetProperty(internal::kAlwaysOnTopControllerKey); + if (!controller) { + controller = new internal::AlwaysOnTopController; + controller->SetContainers( + root_window->GetChildById(internal::kShellWindowId_DefaultContainer), + root_window->GetChildById( + internal::kShellWindowId_AlwaysOnTopContainer)); + // RootWindow owns the AlwaysOnTopController object. + root_window->SetProperty(kAlwaysOnTopControllerKey, controller); + } + return controller; +} + } // namespace internal } // namespace ash diff --git a/ash/wm/stacking_controller.h b/ash/wm/stacking_controller.h index 9e38216..5a3676d 100644 --- a/ash/wm/stacking_controller.h +++ b/ash/wm/stacking_controller.h @@ -32,7 +32,8 @@ class StackingController : public aura::client::StackingClient { // placed in the screen lock modal container. aura::Window* GetSystemModalContainer(aura::Window* window) const; - scoped_ptr<internal::AlwaysOnTopController> always_on_top_controller_; + // Returns the AlwaysOnTopController for the current active root window. + internal::AlwaysOnTopController* GetAlwaysOnTopController(); DISALLOW_COPY_AND_ASSIGN(StackingController); }; diff --git a/ash/wm/system_gesture_event_filter.cc b/ash/wm/system_gesture_event_filter.cc index e7800fee..98cbac9 100644 --- a/ash/wm/system_gesture_event_filter.cc +++ b/ash/wm/system_gesture_event_filter.cc @@ -79,7 +79,8 @@ Widget* CreateAffordanceWidget() { params.transparent = true; widget->Init(params); widget->SetOpacity(0xFF); - widget->GetNativeWindow()->SetParent(ash::Shell::GetInstance()->GetContainer( + widget->GetNativeWindow()->SetParent(ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_OverlayContainer)); ash::SetWindowVisibilityAnimationTransition(widget->GetNativeView(), ash::ANIMATE_HIDE); diff --git a/ash/wm/system_modal_container_layout_manager_unittest.cc b/ash/wm/system_modal_container_layout_manager_unittest.cc index 616cd1c..3eaa467 100644 --- a/ash/wm/system_modal_container_layout_manager_unittest.cc +++ b/ash/wm/system_modal_container_layout_manager_unittest.cc @@ -25,12 +25,14 @@ namespace test { namespace { aura::Window* GetModalContainer() { - return Shell::GetInstance()->GetContainer( + return Shell::GetContainer( + Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_SystemModalContainer); } aura::Window* GetDefaultContainer() { - return Shell::GetInstance()->GetContainer( + return Shell::GetContainer( + Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_DefaultContainer); } @@ -271,7 +273,8 @@ TEST_F(SystemModalContainerLayoutManagerTest, EventFocusContainers) { Shell::GetInstance()->delegate()->LockScreen(); EventTestWindow* lock_delegate = new EventTestWindow(false); scoped_ptr<aura::Window> lock(lock_delegate->OpenTestWindow( - Shell::GetInstance()->GetContainer( + Shell::GetContainer( + Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_LockScreenContainer))); EXPECT_TRUE(wm::IsActiveWindow(lock.get())); e1.ClickLeftButton(); @@ -297,7 +300,8 @@ TEST_F(SystemModalContainerLayoutManagerTest, EventFocusContainers) { // is hidden. TEST_F(SystemModalContainerLayoutManagerTest, ShowModalWhileHidden) { // Hide the lock screen. - Shell::GetInstance()->GetContainer( + Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_SystemModalContainer)->layer()->SetOpacity(0); // Create a modal window. diff --git a/ash/wm/window_animations_unittest.cc b/ash/wm/window_animations_unittest.cc index 9628db2..bf51c1e 100644 --- a/ash/wm/window_animations_unittest.cc +++ b/ash/wm/window_animations_unittest.cc @@ -23,7 +23,8 @@ typedef ash::test::AshTestBase WindowAnimationsTest; TEST_F(WindowAnimationsTest, HideShow) { aura::Window* default_container = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); scoped_ptr<aura::Window> window( aura::test::CreateTestWindowWithId(0, default_container)); @@ -60,7 +61,8 @@ TEST_F(WindowAnimationsTest, HideShow) { TEST_F(WindowAnimationsTest, ShowHide) { aura::Window* default_container = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); scoped_ptr<aura::Window> window( aura::test::CreateTestWindowWithId(0, default_container)); @@ -97,7 +99,8 @@ TEST_F(WindowAnimationsTest, ShowHide) { TEST_F(WindowAnimationsTest, LayerTargetVisibility) { aura::Window* default_container = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); scoped_ptr<aura::Window> window( aura::test::CreateTestWindowWithId(0, default_container)); @@ -113,7 +116,8 @@ TEST_F(WindowAnimationsTest, LayerTargetVisibility) { TEST_F(WindowAnimationsTest, CrossFadeToBounds) { Window* default_container = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); scoped_ptr<Window> window( aura::test::CreateTestWindowWithId(0, default_container)); diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc index a79ed88..0345c4b 100644 --- a/ash/wm/window_cycle_controller.cc +++ b/ash/wm/window_cycle_controller.cc @@ -127,8 +127,11 @@ void WindowCycleController::AltKeyReleased() { // static std::vector<aura::Window*> WindowCycleController::BuildWindowList() { - aura::Window* default_container = ash::Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_DefaultContainer); + // TODO(oshima): Figure out how this should work with multiple root + // windows. Just use active root window for now. + aura::Window* default_container = Shell::GetContainer( + Shell::GetActiveRootWindow(), + internal::kShellWindowId_DefaultContainer); WindowCycleList::WindowList windows = default_container->children(); // Removes unfocusable windows. WindowCycleList::WindowList::iterator last = diff --git a/ash/wm/window_cycle_controller_unittest.cc b/ash/wm/window_cycle_controller_unittest.cc index 006d766..79b6dc8 100644 --- a/ash/wm/window_cycle_controller_unittest.cc +++ b/ash/wm/window_cycle_controller_unittest.cc @@ -36,7 +36,8 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { // Create a single test window. Window* default_container = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); wm::ActivateWindow(window0.get()); @@ -55,7 +56,8 @@ TEST_F(WindowCycleControllerTest, SingleWindowNotActive) { // Create a single test window. Window* default_container = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); wm::ActivateWindow(window0.get()); @@ -78,7 +80,8 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindow) { // Set up several windows to use to test cycling. Create them in reverse // order so they are stacked 0 over 1 over 2. Window* default_container = - Shell::GetInstance()->GetContainer( + Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); scoped_ptr<Window> window2(CreateTestWindowWithId(2, default_container)); scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container)); @@ -164,7 +167,8 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindow) { // When a modal window is active, cycling window does not take effect. aura::Window* modal_container = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_SystemModalContainer); scoped_ptr<Window> modal_window( CreateTestWindowWithId(-2, modal_container)); @@ -186,7 +190,8 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindow) { TEST_F(WindowCycleControllerTest, MaximizedWindow) { // Create a couple of test windows. Window* default_container = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container)); @@ -210,7 +215,8 @@ TEST_F(WindowCycleControllerTest, MaximizedWindow) { TEST_F(WindowCycleControllerTest, Minimized) { // Create a couple of test windows. Window* default_container = - ash::Shell::GetInstance()->GetContainer( + Shell::GetContainer( + Shell::GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer); scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container)); diff --git a/ash/wm/window_properties.cc b/ash/wm/window_properties.cc index 4b2b80a..7f15c5b 100644 --- a/ash/wm/window_properties.cc +++ b/ash/wm/window_properties.cc @@ -4,19 +4,23 @@ #include "ash/wm/window_properties.h" +#include "ash/wm/always_on_top_controller.h" #include "ash/wm/shadow_types.h" #include "ui/aura/window_property.h" #include "ui/ui_controls/ui_controls_aura.h" // Property type for bool and ui::WindowShowState are // defined in aura. +DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::AlwaysOnTopController*); DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::ShadowType); DECLARE_WINDOW_PROPERTY_TYPE(ash::WindowPersistsAcrossAllWorkspacesType) DECLARE_WINDOW_PROPERTY_TYPE(ui_controls::UIControlsAura*) namespace ash { namespace internal { - +DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::internal::AlwaysOnTopController, + kAlwaysOnTopControllerKey, + NULL); DEFINE_WINDOW_PROPERTY_KEY( bool, kChildWindowVisibilityChangesAnimatedKey, false); DEFINE_WINDOW_PROPERTY_KEY( diff --git a/ash/wm/window_properties.h b/ash/wm/window_properties.h index 760bcd4..88c1b70 100644 --- a/ash/wm/window_properties.h +++ b/ash/wm/window_properties.h @@ -17,11 +17,17 @@ class UIControlsAura; namespace ash { namespace internal { +class AlwaysOnTopController; // Shell-specific window property keys. // Alphabetical sort. +// A Key to store AlwaysOnTopController per RootWindow. The value is +// owned by the RootWindow. +extern const aura::WindowProperty<internal::AlwaysOnTopController*>* const + kAlwaysOnTopControllerKey; + // Property set on all windows whose child windows' visibility changes are // animated. extern const aura::WindowProperty<bool>* const diff --git a/ash/wm/workspace/multi_window_resize_controller.cc b/ash/wm/workspace/multi_window_resize_controller.cc index 9ff22ea..61d140d 100644 --- a/ash/wm/workspace/multi_window_resize_controller.cc +++ b/ash/wm/workspace/multi_window_resize_controller.cc @@ -356,8 +356,9 @@ void MultiWindowResizeController::ShowNow() { views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); params.transparent = true; params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - params.parent = Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_AlwaysOnTopContainer); + params.parent = Shell::GetContainer( + Shell::GetActiveRootWindow(), + internal::kShellWindowId_AlwaysOnTopContainer); params.can_activate = false; ResizeView* view = new ResizeView(this, windows_.direction); params.delegate = new views::WidgetDelegateView; diff --git a/ash/wm/workspace/phantom_window_controller.cc b/ash/wm/workspace/phantom_window_controller.cc index 8c60765..ec535ec 100644 --- a/ash/wm/workspace/phantom_window_controller.cc +++ b/ash/wm/workspace/phantom_window_controller.cc @@ -125,8 +125,9 @@ void PhantomWindowController::CreatePhantomWidget(const gfx::Rect& bounds) { // PhantomWindowController is used by FrameMaximizeButton to highlight the // launcher button. Put the phantom in the same window as the launcher so that // the phantom is visible. - params.parent = - Shell::GetInstance()->GetContainer(kShellWindowId_LauncherContainer); + params.parent = Shell::GetContainer( + Shell::GetActiveRootWindow(), + kShellWindowId_LauncherContainer); params.can_activate = false; params.keep_on_top = true; phantom_widget_->set_focus_on_creation(false); diff --git a/ash/wm/workspace/workspace_manager_unittest.cc b/ash/wm/workspace/workspace_manager_unittest.cc index b311825..22e20f2 100644 --- a/ash/wm/workspace/workspace_manager_unittest.cc +++ b/ash/wm/workspace/workspace_manager_unittest.cc @@ -51,7 +51,9 @@ class WorkspaceManagerTest : public test::AshTestBase { } aura::Window* GetViewport() { - return Shell::GetInstance()->GetContainer(kShellWindowId_DefaultContainer); + return Shell::GetContainer( + Shell::GetPrimaryRootWindow(), + kShellWindowId_DefaultContainer); } const std::vector<Workspace*>& workspaces() const { diff --git a/chrome/browser/chromeos/login/base_login_display_host.cc b/chrome/browser/chromeos/login/base_login_display_host.cc index aa7de0e..1d88a1f 100644 --- a/chrome/browser/chromeos/login/base_login_display_host.cc +++ b/chrome/browser/chromeos/login/base_login_display_host.cc @@ -292,7 +292,8 @@ void BaseLoginDisplayHost::ShutdownDisplayHost(bool post_quit_task) { } void BaseLoginDisplayHost::StartAnimation() { - if (ash::Shell::GetInstance()->GetContainer( + if (ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_DesktopBackgroundContainer)-> children().empty()) { // If there is no background window, don't perform any animation on the @@ -319,7 +320,8 @@ void BaseLoginDisplayHost::StartAnimation() { // Background animation. if (do_background_animation) { ui::Layer* background_layer = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_DesktopBackgroundContainer)-> layer(); @@ -350,8 +352,9 @@ void BaseLoginDisplayHost::StartAnimation() { // Browser windows layer opacity and transform animation. if (do_browser_transform_animation || do_browser_opacity_animation) { ui::Layer* default_container_layer = - ash::Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_DefaultContainer)->layer(); + ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), + ash::internal::kShellWindowId_DefaultContainer)->layer(); ui::LayerAnimationElement::AnimatableProperties browser_pause_properties; diff --git a/chrome/browser/chromeos/login/lock_window_aura.cc b/chrome/browser/chromeos/login/lock_window_aura.cc index 05da9c3..90b4115 100644 --- a/chrome/browser/chromeos/login/lock_window_aura.cc +++ b/chrome/browser/chromeos/login/lock_window_aura.cc @@ -42,10 +42,10 @@ void LockWindowAura::Init() { views::Widget::InitParams params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); params.show_state = ui::SHOW_STATE_FULLSCREEN; - // TODO(flackr): Use a property to specify this container rather than - // depending on shell implementation. + // TODO(oshima): move the lock screen harness to ash. params.parent = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_LockScreenContainer); views::Widget::Init(params); ash::SetWindowVisibilityAnimationTransition(GetNativeView(), diff --git a/chrome/browser/chromeos/login/simple_web_view_dialog.cc b/chrome/browser/chromeos/login/simple_web_view_dialog.cc index 085e978..601791a 100644 --- a/chrome/browser/chromeos/login/simple_web_view_dialog.cc +++ b/chrome/browser/chromeos/login/simple_web_view_dialog.cc @@ -296,7 +296,8 @@ void SimpleWebViewDialog::ShowPageInfo(content::WebContents* web_contents, true, this); page_info_bubble->set_parent_window( - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_LockSystemModalContainer)); CreateViewsBubble(page_info_bubble); page_info_bubble->Show(); diff --git a/chrome/browser/chromeos/login/webui_login_display_host.cc b/chrome/browser/chromeos/login/webui_login_display_host.cc index a51ef3f..ce3943b 100644 --- a/chrome/browser/chromeos/login/webui_login_display_host.cc +++ b/chrome/browser/chromeos/login/webui_login_display_host.cc @@ -153,7 +153,8 @@ void WebUILoginDisplayHost::LoadURL(const GURL& url) { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableNewOobe)) params.transparent = true; params.parent = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_LockScreenContainer); login_window_ = new views::Widget; diff --git a/chrome/browser/chromeos/status/data_promo_notification.cc b/chrome/browser/chromeos/status/data_promo_notification.cc index b2cf615..2c90d0b 100644 --- a/chrome/browser/chromeos/status/data_promo_notification.cc +++ b/chrome/browser/chromeos/status/data_promo_notification.cc @@ -209,7 +209,8 @@ void DataPromoNotification::ShowOptionalMobileDataPromoNotification( links); mobile_data_bubble_->set_link_listener(listener); mobile_data_bubble_->set_parent_window( - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_SettingBubbleContainer)); views::BubbleDelegateView::CreateBubble(mobile_data_bubble_); mobile_data_bubble_->Show(); diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc index c5118c7..dcf5190 100644 --- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc +++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc @@ -967,7 +967,8 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, } virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE { - return ash::Shell::GetInstance()->GetContainer( + return ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), GetUserLoginStatus() == ash::user::LOGGED_IN_NONE ? ash::internal::kShellWindowId_LockSystemModalContainer : ash::internal::kShellWindowId_SystemModalContainer); diff --git a/chrome/browser/pepper_gtalk_message_filter.cc b/chrome/browser/pepper_gtalk_message_filter.cc index 83d0e58..95a5dba 100644 --- a/chrome/browser/pepper_gtalk_message_filter.cc +++ b/chrome/browser/pepper_gtalk_message_filter.cc @@ -48,7 +48,8 @@ void PepperGtalkMessageFilter::OnTalkGetPermission(uint32 plugin_dispatcher_id, const string16 message = l10n_util::GetStringUTF16( IDS_GTALK_SCREEN_SHARE_DIALOG_MESSAGE); - aura::Window* parent = ash::Shell::GetInstance()->GetContainer( + aura::Window* parent = ash::Shell::GetContainer( + ash::Shell::GetActiveRootWindow(), ash::internal::kShellWindowId_SystemModalContainer); user_response = browser::ShowMessageBox(parent, title, message, browser::MESSAGE_BOX_TYPE_QUESTION) == browser::MESSAGE_BOX_RESULT_YES; diff --git a/chrome/browser/ui/views/ash/screenshot_taker.cc b/chrome/browser/ui/views/ash/screenshot_taker.cc index 308fa907..e7659ec 100644 --- a/chrome/browser/ui/views/ash/screenshot_taker.cc +++ b/chrome/browser/ui/views/ash/screenshot_taker.cc @@ -169,7 +169,8 @@ void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect) { visual_feedback_layer_->SetOpacity(kVisualFeedbackLayerOpacity); visual_feedback_layer_->SetBounds(rect); - ui::Layer* parent = ash::Shell::GetInstance()->GetContainer( + ui::Layer* parent = ash::Shell::GetContainer( + ash::Shell::GetActiveRootWindow(), ash::internal::kShellWindowId_OverlayContainer)->layer(); parent->Add(visual_feedback_layer_.get()); visual_feedback_layer_->SetVisible(true); diff --git a/chrome/browser/ui/views/ash/window_positioner_unittest.cc b/chrome/browser/ui/views/ash/window_positioner_unittest.cc index 7fb6070..65ad94e 100644 --- a/chrome/browser/ui/views/ash/window_positioner_unittest.cc +++ b/chrome/browser/ui/views/ash/window_positioner_unittest.cc @@ -121,9 +121,9 @@ WindowPositionerTest::~WindowPositionerTest() { void WindowPositionerTest::SetUp() { AshTestBase::SetUp(); // Create some default dummy windows. - aura::Window* default_container = - ash::Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_DefaultContainer); + aura::Window* default_container = ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), + ash::internal::kShellWindowId_DefaultContainer); window_.reset(aura::test::CreateTestWindowWithId(0, default_container)); window_->SetBounds(gfx::Rect(16, 32, 640, 320)); popup_.reset(aura::test::CreateTestWindowWithId(1, default_container)); diff --git a/chrome/browser/ui/window_sizer_ash_unittest.cc b/chrome/browser/ui/window_sizer_ash_unittest.cc index 2066cd2..92cb5a8 100644 --- a/chrome/browser/ui/window_sizer_ash_unittest.cc +++ b/chrome/browser/ui/window_sizer_ash_unittest.cc @@ -604,7 +604,8 @@ TEST_F(WindowSizerTest, TEST_F(WindowSizerTestWithBrowser, PlaceNewWindowOverOldWindow) { // Create a dummy window. aura::Window* default_container = - ash::Shell::GetInstance()->GetContainer( + ash::Shell::GetContainer( + ash::Shell::GetPrimaryRootWindow(), ash::internal::kShellWindowId_DefaultContainer); scoped_ptr<aura::Window> window( aura::test::CreateTestWindowWithId(0, default_container)); |