summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-13 09:34:56 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-13 09:34:56 +0000
commitd90b839ad378031602d5dbdf846c58994d451403 (patch)
tree013c72c390c7a7e4e9cb76f03a6c9eb29c7d68a2
parent7bc8299dccc300184e850e1a76db110a85234db1 (diff)
downloadchromium_src-d90b839ad378031602d5dbdf846c58994d451403.zip
chromium_src-d90b839ad378031602d5dbdf846c58994d451403.tar.gz
chromium_src-d90b839ad378031602d5dbdf846c58994d451403.tar.bz2
Reland r141871.
Add RootWindowController that keeps per root window state. Cleanup Shell::Init(). Separated initialization that are specific to shell, root window and primary display. I also did small cleanup in detor. I'll do more cleanups when I have a chance. BUG=123160 TEST=no functional change. all tests should pass. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=141871 Review URL: https://chromiumcodereview.appspot.com/10546024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141881 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/accelerators/accelerator_controller.cc11
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/launcher/launcher_context_menu.cc15
-rw-r--r--ash/root_window_controller.cc218
-rw-r--r--ash/root_window_controller.h84
-rw-r--r--ash/shell.cc329
-rw-r--r--ash/shell.h38
-rw-r--r--ash/system/status_area_widget.cc7
-rw-r--r--ash/tooltips/tooltip_controller.cc1
-rw-r--r--ash/wm/app_list_controller.cc4
-rw-r--r--ash/wm/property_util.cc11
-rw-r--r--ash/wm/property_util.h11
-rw-r--r--ash/wm/screen_dimmer.h2
-rw-r--r--ash/wm/screen_dimmer_unittest.cc3
-rw-r--r--ash/wm/system_gesture_event_filter.cc7
-rw-r--r--ash/wm/window_properties.cc4
-rw-r--r--ash/wm/window_properties.h4
-rw-r--r--ash/wm/window_util.cc5
-rw-r--r--ash/wm/window_util.h6
-rw-r--r--chrome/browser/chromeos/power/screen_dimming_observer.cc3
20 files changed, 480 insertions, 285 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index ae314fb..0bd5ece 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -15,6 +15,7 @@
#include "ash/launcher/launcher_model.h"
#include "ash/monitor/monitor_controller.h"
#include "ash/monitor/multi_monitor_manager.h"
+#include "ash/root_window_controller.h"
#include "ash/screenshot_delegate.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
@@ -112,9 +113,9 @@ bool HandleShowTaskManager() {
// Rotates the default window container.
bool HandleRotateWindows() {
- aura::Window* target = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
+ aura::Window* target =
+ Shell::GetPrimaryRootWindowController()->GetContainer(
+ internal::kShellWindowId_DefaultContainer);
scoped_ptr<ui::LayerAnimationSequence> screen_rotation(
new ui::LayerAnimationSequence(new ui::ScreenRotation(360)));
target->layer()->GetAnimator()->StartAnimation(
@@ -191,8 +192,8 @@ void PrintWindowHierarchy(aura::Window* window, int indent) {
bool HandlePrintWindowHierarchy() {
DLOG(INFO) << "Window hierarchy:";
aura::Window* container =
- Shell::GetContainer(Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
+ Shell::GetPrimaryRootWindowController()->GetContainer(
+ internal::kShellWindowId_DefaultContainer);
PrintWindowHierarchy(container, 0);
return true;
}
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 5897fce..67907da 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -101,6 +101,8 @@
'monitor/multi_monitor_manager.h',
'monitor/secondary_monitor_view.cc',
'monitor/secondary_monitor_view.h',
+ 'root_window_controller.cc',
+ 'root_window_controller.h',
'screen_ash.cc',
'screen_ash.h',
'screensaver/screensaver_view.cc',
diff --git a/ash/launcher/launcher_context_menu.cc b/ash/launcher/launcher_context_menu.cc
index 7b586ba..cb92a3b 100644
--- a/ash/launcher/launcher_context_menu.cc
+++ b/ash/launcher/launcher_context_menu.cc
@@ -4,6 +4,7 @@
#include "ash/launcher/launcher_context_menu.h"
+#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/wm/shelf_auto_hide_behavior.h"
#include "grit/ash_strings.h"
@@ -24,21 +25,21 @@ LauncherContextMenu::~LauncherContextMenu() {
// static
bool LauncherContextMenu::IsAutoHideMenuHideChecked() {
- ash::Shell* shell = ash::Shell::GetInstance();
+ internal::RootWindowController* controller =
+ Shell::GetPrimaryRootWindowController();
ash::ShelfAutoHideBehavior auto_hide_behavior =
- shell->GetShelfAutoHideBehavior();
- return (shell->IsInMaximizedMode() &&
+ Shell::GetInstance()->GetShelfAutoHideBehavior();
+ return (controller->IsInMaximizedMode() &&
(auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT ||
auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS)) ||
- (!shell->IsInMaximizedMode() &&
+ (!controller->IsInMaximizedMode() &&
auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
}
// static
ShelfAutoHideBehavior LauncherContextMenu::GetToggledAutoHideBehavior() {
- ash::Shell* shell = ash::Shell::GetInstance();
ash::ShelfAutoHideBehavior auto_hide_behavior;
- if (shell->IsInMaximizedMode()) {
+ if (Shell::GetPrimaryRootWindowController()->IsInMaximizedMode()) {
if (IsAutoHideMenuHideChecked())
auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
else
@@ -53,7 +54,7 @@ ShelfAutoHideBehavior LauncherContextMenu::GetToggledAutoHideBehavior() {
// static
int LauncherContextMenu::GetAutoHideResourceStringId() {
- return ash::Shell::GetInstance()->IsInMaximizedMode() ?
+ return Shell::GetPrimaryRootWindowController()->IsInMaximizedMode() ?
IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_MAXIMIZED :
IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_NOT_MAXIMIZED;
}
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
new file mode 100644
index 0000000..0938beb
--- /dev/null
+++ b/ash/root_window_controller.cc
@@ -0,0 +1,218 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/root_window_controller.h"
+
+#include "ash/shell.h"
+#include "ash/shell_factory.h"
+#include "ash/shell_window_ids.h"
+#include "ash/wm/base_layout_manager.h"
+#include "ash/wm/event_client_impl.h"
+#include "ash/wm/property_util.h"
+#include "ash/wm/root_window_layout_manager.h"
+#include "ash/wm/screen_dimmer.h"
+#include "ash/wm/system_modal_container_layout_manager.h"
+#include "ash/wm/toplevel_window_event_filter.h"
+#include "ash/wm/visibility_controller.h"
+#include "ash/wm/workspace/workspace_manager.h"
+#include "ash/wm/workspace_controller.h"
+#include "ui/aura/client/tooltip_client.h"
+#include "ui/aura/root_window.h"
+
+namespace ash {
+namespace {
+
+// Creates a new window for use as a container.
+aura::Window* CreateContainer(int window_id,
+ const char* name,
+ aura::Window* parent) {
+ aura::Window* container = new aura::Window(NULL);
+ container->set_id(window_id);
+ container->SetName(name);
+ container->Init(ui::LAYER_NOT_DRAWN);
+ parent->AddChild(container);
+ if (window_id != internal::kShellWindowId_UnparentedControlContainer)
+ container->Show();
+ return container;
+}
+
+// Creates each of the special window containers that holds windows of various
+// types in the shell UI.
+void CreateContainersInRootWindow(aura::RootWindow* root_window) {
+ // These containers are just used by PowerButtonController to animate groups
+ // of containers simultaneously without messing up the current transformations
+ // on those containers. These are direct children of the root window; all of
+ // the other containers are their children.
+ aura::Window* non_lock_screen_containers = CreateContainer(
+ internal::kShellWindowId_NonLockScreenContainersContainer,
+ "NonLockScreenContainersContainer",
+ root_window);
+ aura::Window* lock_screen_containers = CreateContainer(
+ internal::kShellWindowId_LockScreenContainersContainer,
+ "LockScreenContainersContainer",
+ root_window);
+ aura::Window* lock_screen_related_containers = CreateContainer(
+ internal::kShellWindowId_LockScreenRelatedContainersContainer,
+ "LockScreenRelatedContainersContainer",
+ root_window);
+
+ CreateContainer(internal::kShellWindowId_UnparentedControlContainer,
+ "UnparentedControlContainer",
+ non_lock_screen_containers);
+
+ aura::Window* desktop_background_containers = CreateContainer(
+ internal::kShellWindowId_DesktopBackgroundContainer,
+ "DesktopBackgroundContainer",
+ non_lock_screen_containers);
+ SetChildWindowVisibilityChangesAnimated(desktop_background_containers);
+
+ aura::Window* default_container = CreateContainer(
+ internal::kShellWindowId_DefaultContainer,
+ "DefaultContainer",
+ non_lock_screen_containers);
+ default_container->SetEventFilter(
+ new ToplevelWindowEventFilter(default_container));
+ SetChildWindowVisibilityChangesAnimated(default_container);
+
+ aura::Window* always_on_top_container = CreateContainer(
+ internal::kShellWindowId_AlwaysOnTopContainer,
+ "AlwaysOnTopContainer",
+ non_lock_screen_containers);
+ always_on_top_container->SetEventFilter(
+ new ToplevelWindowEventFilter(always_on_top_container));
+ SetChildWindowVisibilityChangesAnimated(always_on_top_container);
+
+ CreateContainer(internal::kShellWindowId_PanelContainer,
+ "PanelContainer",
+ non_lock_screen_containers);
+
+ CreateContainer(internal::kShellWindowId_LauncherContainer,
+ "LauncherContainer",
+ non_lock_screen_containers);
+
+ CreateContainer(internal::kShellWindowId_AppListContainer,
+ "AppListContainer",
+ non_lock_screen_containers);
+
+ aura::Window* modal_container = CreateContainer(
+ internal::kShellWindowId_SystemModalContainer,
+ "SystemModalContainer",
+ non_lock_screen_containers);
+ modal_container->SetEventFilter(
+ new ToplevelWindowEventFilter(modal_container));
+ modal_container->SetLayoutManager(
+ new internal::SystemModalContainerLayoutManager(modal_container));
+ SetChildWindowVisibilityChangesAnimated(modal_container);
+
+ // TODO(beng): Figure out if we can make this use
+ // SystemModalContainerEventFilter instead of stops_event_propagation.
+ aura::Window* lock_container = CreateContainer(
+ internal::kShellWindowId_LockScreenContainer,
+ "LockScreenContainer",
+ lock_screen_containers);
+ lock_container->SetLayoutManager(
+ new internal::BaseLayoutManager(root_window));
+ // TODO(beng): stopsevents
+
+ aura::Window* lock_modal_container = CreateContainer(
+ internal::kShellWindowId_LockSystemModalContainer,
+ "LockSystemModalContainer",
+ lock_screen_containers);
+ lock_modal_container->SetEventFilter(
+ new ToplevelWindowEventFilter(lock_modal_container));
+ lock_modal_container->SetLayoutManager(
+ new internal::SystemModalContainerLayoutManager(lock_modal_container));
+ SetChildWindowVisibilityChangesAnimated(lock_modal_container);
+
+ CreateContainer(internal::kShellWindowId_StatusContainer,
+ "StatusContainer",
+ lock_screen_related_containers);
+
+ aura::Window* settings_bubble_container = CreateContainer(
+ internal::kShellWindowId_SettingBubbleContainer,
+ "SettingBubbleContainer",
+ lock_screen_related_containers);
+ SetChildWindowVisibilityChangesAnimated(settings_bubble_container);
+
+ aura::Window* menu_container = CreateContainer(
+ internal::kShellWindowId_MenuContainer,
+ "MenuContainer",
+ lock_screen_related_containers);
+ SetChildWindowVisibilityChangesAnimated(menu_container);
+
+ aura::Window* drag_drop_container = CreateContainer(
+ internal::kShellWindowId_DragImageAndTooltipContainer,
+ "DragImageAndTooltipContainer",
+ lock_screen_related_containers);
+ SetChildWindowVisibilityChangesAnimated(drag_drop_container);
+
+ CreateContainer(internal::kShellWindowId_OverlayContainer,
+ "OverlayContainer",
+ lock_screen_related_containers);
+}
+
+} // namespace
+
+namespace internal {
+
+RootWindowController::RootWindowController(aura::RootWindow* root_window)
+ : root_window_(root_window) {
+ SetRootWindowController(root_window, this);
+
+ event_client_.reset(new internal::EventClientImpl(root_window));
+ screen_dimmer_.reset(new internal::ScreenDimmer(root_window));
+}
+
+RootWindowController::~RootWindowController() {
+ SetRootWindowController(root_window_.get(), NULL);
+ event_client_.reset();
+ screen_dimmer_.reset();
+ workspace_controller_.reset();
+ root_window_.reset();
+}
+
+aura::Window* RootWindowController::GetContainer(int container_id) {
+ return root_window_->GetChildById(container_id);
+}
+
+void RootWindowController::InitLayoutManagers() {
+ root_window_layout_ =
+ new internal::RootWindowLayoutManager(root_window_.get());
+ root_window_->SetLayoutManager(root_window_layout_);
+
+ aura::Window* default_container =
+ GetContainer(internal::kShellWindowId_DefaultContainer);
+ // Workspace manager has its own layout managers.
+ workspace_controller_.reset(
+ new internal::WorkspaceController(default_container));
+
+ aura::Window* always_on_top_container =
+ GetContainer(internal::kShellWindowId_AlwaysOnTopContainer);
+ always_on_top_container->SetLayoutManager(
+ new internal::BaseLayoutManager(
+ always_on_top_container->GetRootWindow()));
+}
+
+void RootWindowController::CreateContainers() {
+ CreateContainersInRootWindow(root_window_.get());
+}
+
+void RootWindowController::CloseChildWindows() {
+ // Close background widget first as it depends on tooltip.
+ root_window_layout_->SetBackgroundWidget(NULL);
+ workspace_controller_.reset();
+ aura::client::SetTooltipClient(root_window_.get(), NULL);
+
+ while (!root_window_->children().empty()) {
+ aura::Window* child = root_window_->children()[0];
+ delete child;
+ }
+}
+
+bool RootWindowController::IsInMaximizedMode() const {
+ return workspace_controller_->workspace_manager()->IsInMaximizedMode();
+}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h
new file mode 100644
index 0000000..66cf105
--- /dev/null
+++ b/ash/root_window_controller.h
@@ -0,0 +1,84 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_ROOT_WINDOW_CONTROLLER_H_
+#define ASH_ROOT_WINDOW_CONTROLLER_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+
+class SkBitmap;
+
+namespace aura {
+class EventFilter;
+class RootWindow;
+class Window;
+namespace shared {
+class InputMethodEventFilter;
+class RootWindowEventFilter;
+} // namespace shared
+} // namespace aura
+
+namespace ash {
+namespace internal {
+
+class EventClientImpl;
+class RootWindowLayoutManager;
+class ScreenDimmer;
+class WorkspaceController;
+
+// This class maintains the per root window state for ash. This class
+// owns the root window and other dependent objects that should be
+// deleted upon the deletion of the root window. The RootWindowController
+// for particular root window is stored as a property and can be obtained
+// using |GetRootWindowController(aura::RootWindow*)| function.
+class RootWindowController {
+ public:
+ explicit RootWindowController(aura::RootWindow* root_window);
+ ~RootWindowController();
+
+ aura::RootWindow* root_window() {
+ return root_window_.get();
+ }
+
+ internal::RootWindowLayoutManager* root_window_layout() {
+ return root_window_layout_;
+ }
+
+ internal::WorkspaceController* workspace_controller() {
+ return workspace_controller_.get();
+ }
+
+ internal::ScreenDimmer* screen_dimmer() {
+ return screen_dimmer_.get();
+ }
+
+ aura::Window* GetContainer(int container_id);
+
+ void CreateContainers();
+ void InitLayoutManagers();
+
+ // Deletes all child windows and performs necessary cleanup.
+ void CloseChildWindows();
+
+ // Returns true if the workspace has a maximized or fullscreen window.
+ bool IsInMaximizedMode() const;
+
+ private:
+ scoped_ptr<aura::RootWindow> root_window_;
+ internal::RootWindowLayoutManager* root_window_layout_;
+
+ // An event filter that pre-handles all key events to send them to an IME.
+ scoped_ptr<internal::EventClientImpl> event_client_;
+ scoped_ptr<internal::ScreenDimmer> screen_dimmer_;
+ scoped_ptr<internal::WorkspaceController> workspace_controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(RootWindowController);
+};
+
+} // namespace internal
+} // ash
+
+#endif // ASH_ROOT_WINDOW_CONTROLLER_H_
diff --git a/ash/shell.cc b/ash/shell.cc
index 63062980..3070679 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -20,6 +20,7 @@
#include "ash/monitor/monitor_controller.h"
#include "ash/monitor/multi_monitor_manager.h"
#include "ash/monitor/secondary_monitor_view.h"
+#include "ash/root_window_controller.h"
#include "ash/screen_ash.h"
#include "ash/shell_context_menu.h"
#include "ash/shell_delegate.h"
@@ -106,135 +107,6 @@ namespace {
using aura::Window;
using views::Widget;
-// Creates a new window for use as a container.
-aura::Window* CreateContainer(int window_id,
- const char* name,
- aura::Window* parent) {
- aura::Window* container = new aura::Window(NULL);
- container->set_id(window_id);
- container->SetName(name);
- container->Init(ui::LAYER_NOT_DRAWN);
- parent->AddChild(container);
- if (window_id != internal::kShellWindowId_UnparentedControlContainer)
- container->Show();
- return container;
-}
-
-// Creates each of the special window containers that holds windows of various
-// types in the shell UI.
-void CreateSpecialContainers(aura::RootWindow* root_window) {
- // These containers are just used by PowerButtonController to animate groups
- // of containers simultaneously without messing up the current transformations
- // on those containers. These are direct children of the root window; all of
- // the other containers are their children.
- aura::Window* non_lock_screen_containers = CreateContainer(
- internal::kShellWindowId_NonLockScreenContainersContainer,
- "NonLockScreenContainersContainer",
- root_window);
- aura::Window* lock_screen_containers = CreateContainer(
- internal::kShellWindowId_LockScreenContainersContainer,
- "LockScreenContainersContainer",
- root_window);
- aura::Window* lock_screen_related_containers = CreateContainer(
- internal::kShellWindowId_LockScreenRelatedContainersContainer,
- "LockScreenRelatedContainersContainer",
- root_window);
-
- CreateContainer(internal::kShellWindowId_UnparentedControlContainer,
- "UnparentedControlContainer",
- non_lock_screen_containers);
-
- aura::Window* desktop_background_containers = CreateContainer(
- internal::kShellWindowId_DesktopBackgroundContainer,
- "DesktopBackgroundContainer",
- non_lock_screen_containers);
- SetChildWindowVisibilityChangesAnimated(desktop_background_containers);
-
- aura::Window* default_container = CreateContainer(
- internal::kShellWindowId_DefaultContainer,
- "DefaultContainer",
- non_lock_screen_containers);
- default_container->SetEventFilter(
- new ToplevelWindowEventFilter(default_container));
- SetChildWindowVisibilityChangesAnimated(default_container);
-
- aura::Window* always_on_top_container = CreateContainer(
- internal::kShellWindowId_AlwaysOnTopContainer,
- "AlwaysOnTopContainer",
- non_lock_screen_containers);
- always_on_top_container->SetEventFilter(
- new ToplevelWindowEventFilter(always_on_top_container));
- SetChildWindowVisibilityChangesAnimated(always_on_top_container);
-
- CreateContainer(internal::kShellWindowId_PanelContainer,
- "PanelContainer",
- non_lock_screen_containers);
-
- CreateContainer(internal::kShellWindowId_LauncherContainer,
- "LauncherContainer",
- non_lock_screen_containers);
-
- CreateContainer(internal::kShellWindowId_AppListContainer,
- "AppListContainer",
- non_lock_screen_containers);
-
- aura::Window* modal_container = CreateContainer(
- internal::kShellWindowId_SystemModalContainer,
- "SystemModalContainer",
- non_lock_screen_containers);
- modal_container->SetEventFilter(
- new ToplevelWindowEventFilter(modal_container));
- modal_container->SetLayoutManager(
- new internal::SystemModalContainerLayoutManager(modal_container));
- SetChildWindowVisibilityChangesAnimated(modal_container);
-
- // TODO(beng): Figure out if we can make this use
- // SystemModalContainerEventFilter instead of stops_event_propagation.
- aura::Window* lock_container = CreateContainer(
- internal::kShellWindowId_LockScreenContainer,
- "LockScreenContainer",
- lock_screen_containers);
- lock_container->SetLayoutManager(
- new internal::BaseLayoutManager(root_window));
- // TODO(beng): stopsevents
-
- aura::Window* lock_modal_container = CreateContainer(
- internal::kShellWindowId_LockSystemModalContainer,
- "LockSystemModalContainer",
- lock_screen_containers);
- lock_modal_container->SetEventFilter(
- new ToplevelWindowEventFilter(lock_modal_container));
- lock_modal_container->SetLayoutManager(
- new internal::SystemModalContainerLayoutManager(lock_modal_container));
- SetChildWindowVisibilityChangesAnimated(lock_modal_container);
-
- CreateContainer(internal::kShellWindowId_StatusContainer,
- "StatusContainer",
- lock_screen_related_containers);
-
- aura::Window* settings_bubble_container = CreateContainer(
- internal::kShellWindowId_SettingBubbleContainer,
- "SettingBubbleContainer",
- lock_screen_related_containers);
- SetChildWindowVisibilityChangesAnimated(settings_bubble_container);
-
- aura::Window* menu_container = CreateContainer(
- internal::kShellWindowId_MenuContainer,
- "MenuContainer",
- lock_screen_related_containers);
- SetChildWindowVisibilityChangesAnimated(menu_container);
-
- aura::Window* drag_drop_container = CreateContainer(
- internal::kShellWindowId_DragImageAndTooltipContainer,
- "DragImageAndTooltipContainer",
- lock_screen_related_containers);
- SetChildWindowVisibilityChangesAnimated(drag_drop_container);
-
- CreateContainer(internal::kShellWindowId_OverlayContainer,
- "OverlayContainer",
- lock_screen_related_containers);
-}
-
// This dummy class is used for shell unit tests. We dont have chrome delegate
// in these tests.
class DummyUserWallpaperDelegate : public UserWallpaperDelegate {
@@ -272,7 +144,7 @@ bool Shell::initially_hide_cursor_ = false;
Shell::TestApi::TestApi(Shell* shell) : shell_(shell) {}
internal::RootWindowLayoutManager* Shell::TestApi::root_window_layout() {
- return shell_->root_window_layout_;
+ return shell_->GetPrimaryRootWindowController()->root_window_layout();
}
aura::shared::InputMethodEventFilter*
@@ -286,15 +158,14 @@ internal::SystemGestureEventFilter*
}
internal::WorkspaceController* Shell::TestApi::workspace_controller() {
- return shell_->workspace_controller_.get();
+ return shell_->GetPrimaryRootWindowController()->workspace_controller();
}
////////////////////////////////////////////////////////////////////////////////
// Shell, public:
Shell::Shell(ShellDelegate* delegate)
- : root_window_(aura::MonitorManager::CreateRootWindowForPrimaryMonitor()),
- screen_(new ScreenAsh),
+ : screen_(new ScreenAsh),
env_filter_(NULL),
delegate_(delegate),
#if defined(OS_CHROMEOS)
@@ -302,7 +173,6 @@ Shell::Shell(ShellDelegate* delegate)
#endif // defined(OS_CHROMEOS)
shelf_(NULL),
panel_layout_manager_(NULL),
- root_window_layout_(NULL),
status_area_widget_(NULL),
browser_context_(NULL) {
gfx::Screen::SetInstance(screen_);
@@ -333,20 +203,8 @@ Shell::~Shell() {
if (touch_observer_hud_.get())
RemoveEnvEventFilter(touch_observer_hud_.get());
- // Close background widget now so that the focus manager of the
- // widget gets deleted in the final message loop run.
- root_window_layout_->SetBackgroundWidget(NULL);
-
- aura::RootWindow* root_window = GetPrimaryRootWindow();
-
// TooltipController is deleted with the Shell so removing its references.
RemoveEnvEventFilter(tooltip_controller_.get());
- aura::client::SetTooltipClient(root_window, NULL);
- tooltip_controller_.reset();
-
- // Make sure we delete WorkspaceController before launcher is
- // deleted as it has a reference to launcher model.
- workspace_controller_.reset();
// The status area needs to be shut down before the windows are destroyed.
status_area_widget_->Shutdown();
@@ -360,35 +218,26 @@ Shell::~Shell() {
// Destroy secondary monitor's widgets before all the windows are destroyed.
monitor_controller_.reset();
- // Delete containers now so that child windows does not access
- // observers when they are destructed.
- while (!root_window->children().empty()) {
- aura::Window* child = root_window->children()[0];
- delete child;
- }
+ root_window_controller_->CloseChildWindows();
// These need a valid Shell instance to clean up properly, so explicitly
// delete them before invalidating the instance.
// Alphabetical.
drag_drop_controller_.reset();
- event_client_.reset();
magnification_controller_.reset();
monitor_controller_.reset();
power_button_controller_.reset();
resize_shadow_controller_.reset();
- screen_dimmer_.reset();
shadow_controller_.reset();
tooltip_controller_.reset();
window_cycle_controller_.reset();
- aura::client::SetCaptureClient(root_window, NULL);
capture_controller_.reset();
- aura::client::SetDispatcherClient(root_window, NULL);
nested_dispatcher_controller_.reset();
- aura::client::SetUserActionClient(root_window, NULL);
user_action_client_.reset();
- aura::client::SetVisibilityClient(root_window, NULL);
visibility_controller_.reset();
+ root_window_controller_.reset();
+
// Launcher widget has a InputMethodBridge that references to
// input_method_filter_'s input_method_. So explicitly release launcher_
// before input_method_filter_. And this needs to be after we delete all
@@ -398,7 +247,6 @@ Shell::~Shell() {
// Delete the activation controller after other controllers and launcher
// because they might have registered ActivationChangeObserver.
- aura::client::SetActivationClient(root_window, NULL);
activation_controller_.reset();
DCHECK(instance_ == this);
@@ -440,8 +288,13 @@ void Shell::DeleteInstance() {
}
// static
+internal::RootWindowController* Shell::GetPrimaryRootWindowController() {
+ return GetInstance()->root_window_controller_.get();
+}
+
+// static
aura::RootWindow* Shell::GetPrimaryRootWindow() {
- return GetInstance()->root_window_.get();
+ return GetPrimaryRootWindowController()->root_window();
}
// static
@@ -481,17 +334,14 @@ void Shell::Init() {
aura::Env::GetInstance()->SetEventFilter(env_filter_);
aura::Env::GetInstance()->cursor_manager()->set_delegate(this);
-
- aura::RootWindow* root_window = GetPrimaryRootWindow();
+ aura::RootWindow* root_window =
+ aura::MonitorManager::CreateRootWindowForPrimaryMonitor();
active_root_window_ = root_window;
focus_manager_.reset(new aura::FocusManager);
- root_window_->set_focus_manager(focus_manager_.get());
#if !defined(OS_MACOSX)
nested_dispatcher_controller_.reset(new NestedDispatcherController);
- aura::client::SetDispatcherClient(root_window,
- nested_dispatcher_controller_.get());
accelerator_controller_.reset(new AcceleratorController);
#endif
shell_context_menu_.reset(new internal::ShellContextMenu);
@@ -512,7 +362,6 @@ void Shell::Init() {
DCHECK_EQ(3U, GetEnvEventFilterCount());
input_method_filter_.reset(new aura::shared::InputMethodEventFilter());
- input_method_filter_->SetInputMethodPropertyInRootWindow(root_window);
AddEnvEventFilter(input_method_filter_.get());
#if !defined(OS_MACOSX)
@@ -526,18 +375,10 @@ void Shell::Init() {
slow_animation_filter_.reset(new internal::SlowAnimationEventFilter);
AddEnvEventFilter(slow_animation_filter_.get());
- root_window->SetCursor(ui::kCursorPointer);
- if (initially_hide_cursor_)
- aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
-
activation_controller_.reset(
new internal::ActivationController(focus_manager_.get()));
- aura::client::SetActivationClient(root_window, activation_controller_.get());
capture_controller_.reset(new internal::CaptureController);
- aura::client::SetCaptureClient(root_window, capture_controller_.get());
-
- CreateSpecialContainers(root_window);
CommandLine* command_line = CommandLine::ForCurrentProcess();
@@ -546,17 +387,40 @@ void Shell::Init() {
AddEnvEventFilter(touch_observer_hud_.get());
}
+ root_window_controller_.reset(
+ new internal::RootWindowController(root_window));
+ root_window_controller_->CreateContainers();
+
+ // Create Controllers that may need root window.
+ // TODO(oshima): Move as many controllers before creating
+ // RootWindowController as possible.
stacking_controller_.reset(new internal::StackingController);
+ visibility_controller_.reset(new internal::VisibilityController);
+ drag_drop_controller_.reset(new internal::DragDropController);
+ tooltip_controller_.reset(new internal::TooltipController(
+ drag_drop_controller_.get()));
+ if (delegate_.get())
+ user_action_client_.reset(delegate_->CreateUserActionClient());
+ window_modality_controller_.reset(new internal::WindowModalityController);
+ AddEnvEventFilter(window_modality_controller_.get());
+ AddEnvEventFilter(tooltip_controller_.get());
- root_window_layout_ = new internal::RootWindowLayoutManager(root_window);
- root_window->SetLayoutManager(root_window_layout_);
+ magnification_controller_.reset(new internal::MagnificationController);
+ high_contrast_controller_.reset(new HighContrastController);
+ video_detector_.reset(new VideoDetector);
+ window_cycle_controller_.reset(new WindowCycleController);
+ monitor_controller_.reset(new internal::MonitorController);
- event_client_.reset(new internal::EventClientImpl(root_window));
+ InitRootWindow(root_window);
+ // Initialize Primary RootWindow specific items.
status_area_widget_ = new internal::StatusAreaWidget();
status_area_widget_->CreateTrayViews(delegate_.get());
status_area_widget_->Show();
+ focus_cycler_.reset(new internal::FocusCycler());
+ focus_cycler_->AddWidget(status_area_widget_);
+
// This controller needs to be set before SetupManagedWindowMode.
desktop_background_controller_.reset(new DesktopBackgroundController());
if (delegate_.get())
@@ -564,54 +428,28 @@ void Shell::Init() {
if (!user_wallpaper_delegate_.get())
user_wallpaper_delegate_.reset(new DummyUserWallpaperDelegate());
- if (delegate_.get())
- user_action_client_.reset(delegate_->CreateUserActionClient());
- if (user_action_client_.get())
- aura::client::SetUserActionClient(root_window, user_action_client_.get());
-
- InitLayoutManagers();
+ InitLayoutManagersForPrimaryDisplay(root_window_controller_.get());
if (!command_line->HasSwitch(switches::kAuraNoShadows)) {
resize_shadow_controller_.reset(new internal::ResizeShadowController());
shadow_controller_.reset(new internal::ShadowController());
}
- focus_cycler_.reset(new internal::FocusCycler());
- focus_cycler_->AddWidget(status_area_widget_);
-
if (!delegate_.get() || delegate_->IsUserLoggedIn())
CreateLauncher();
- // Force a layout.
- root_window->layout_manager()->OnWindowResized();
+ // Force Layout
+ root_window_controller_->root_window_layout()->OnWindowResized();
// It needs to be created after OnWindowResized has been called, otherwise the
// widget will not paint when restoring after a browser crash.
user_wallpaper_delegate_->InitializeWallpaper();
- window_modality_controller_.reset(new internal::WindowModalityController);
- AddEnvEventFilter(window_modality_controller_.get());
-
- visibility_controller_.reset(new internal::VisibilityController);
- aura::client::SetVisibilityClient(root_window, visibility_controller_.get());
-
- drag_drop_controller_.reset(new internal::DragDropController);
- aura::client::SetDragDropClient(root_window, drag_drop_controller_.get());
-
- tooltip_controller_.reset(
- new internal::TooltipController(drag_drop_controller_.get()));
- aura::client::SetTooltipClient(root_window, tooltip_controller_.get());
-
- AddEnvEventFilter(tooltip_controller_.get());
-
- magnification_controller_.reset(new internal::MagnificationController);
- high_contrast_controller_.reset(new HighContrastController);
power_button_controller_.reset(new PowerButtonController);
AddShellObserver(power_button_controller_.get());
- video_detector_.reset(new VideoDetector);
- window_cycle_controller_.reset(new WindowCycleController);
- monitor_controller_.reset(new internal::MonitorController);
- screen_dimmer_.reset(new internal::ScreenDimmer(root_window));
+
+ if (initially_hide_cursor_)
+ aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
}
void Shell::AddEnvEventFilter(aura::EventFilter* filter) {
@@ -704,9 +542,9 @@ void Shell::CreateLauncher() {
if (launcher_.get())
return;
- aura::Window* default_container = GetContainer(
- GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
+ aura::Window* default_container =
+ GetPrimaryRootWindowController()->
+ GetContainer(internal::kShellWindowId_DefaultContainer);
launcher_.reset(new Launcher(default_container));
launcher_->SetFocusCycler(focus_cycler_.get());
@@ -748,6 +586,10 @@ ShelfAlignment Shell::GetShelfAlignment() {
return shelf_->alignment();
}
+void Shell::SetDimming(bool should_dim) {
+ GetPrimaryRootWindowController()->screen_dimmer()->SetDimming(should_dim);
+}
+
SystemTrayDelegate* Shell::tray_delegate() {
return status_area_widget_->system_tray_delegate();
}
@@ -757,11 +599,8 @@ SystemTray* Shell::system_tray() {
}
int Shell::GetGridSize() const {
- return workspace_controller_->workspace_manager()->grid_size();
-}
-
-bool Shell::IsInMaximizedMode() const {
- return workspace_controller_->workspace_manager()->IsInMaximizedMode();
+ return GetPrimaryRootWindowController()->workspace_controller()->
+ workspace_manager()->grid_size();
}
void Shell::InitRootWindowForSecondaryMonitor(aura::RootWindow* root) {
@@ -781,41 +620,55 @@ void Shell::InitRootWindowForSecondaryMonitor(aura::RootWindow* root) {
aura::client::SetCaptureClient(root, capture_controller_.get());
}
+void Shell::InitRootWindow(aura::RootWindow* root_window) {
+ DCHECK(activation_controller_.get());
+ DCHECK(visibility_controller_.get());
+ DCHECK(drag_drop_controller_.get());
+ DCHECK(capture_controller_.get());
+
+ root_window->set_focus_manager(focus_manager_.get());
+ input_method_filter_->SetInputMethodPropertyInRootWindow(root_window);
+ aura::client::SetActivationClient(root_window, activation_controller_.get());
+ aura::client::SetVisibilityClient(root_window, visibility_controller_.get());
+ aura::client::SetDragDropClient(root_window, drag_drop_controller_.get());
+ aura::client::SetTooltipClient(root_window, tooltip_controller_.get());
+ aura::client::SetCaptureClient(root_window, capture_controller_.get());
+
+ if (nested_dispatcher_controller_.get()) {
+ aura::client::SetDispatcherClient(root_window,
+ nested_dispatcher_controller_.get());
+ }
+ if (user_action_client_.get())
+ aura::client::SetUserActionClient(root_window, user_action_client_.get());
+
+ root_window->SetCursor(ui::kCursorPointer);
+ root_window_controller_->InitLayoutManagers();
+}
+
////////////////////////////////////////////////////////////////////////////////
// Shell, private:
-void Shell::InitLayoutManagers() {
- DCHECK(root_window_layout_);
+void Shell::InitLayoutManagersForPrimaryDisplay(
+ internal::RootWindowController* controller) {
DCHECK(status_area_widget_);
internal::ShelfLayoutManager* shelf_layout_manager =
new internal::ShelfLayoutManager(status_area_widget_);
- GetContainer(
- GetPrimaryRootWindow(),
- internal::kShellWindowId_LauncherContainer)->
+ controller->GetContainer(internal::kShellWindowId_LauncherContainer)->
SetLayoutManager(shelf_layout_manager);
shelf_ = shelf_layout_manager;
internal::StatusAreaLayoutManager* status_area_layout_manager =
new internal::StatusAreaLayoutManager(shelf_layout_manager);
- GetContainer(GetPrimaryRootWindow(),
- internal::kShellWindowId_StatusContainer)->
+ controller->GetContainer(internal::kShellWindowId_StatusContainer)->
SetLayoutManager(status_area_layout_manager);
- aura::Window* default_container = GetContainer(
- GetPrimaryRootWindow(), internal::kShellWindowId_DefaultContainer);
- // Workspace manager has its own layout managers.
- workspace_controller_.reset(
- new internal::WorkspaceController(default_container));
- workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager);
shelf_layout_manager->set_workspace_manager(
- workspace_controller_->workspace_manager());
+ controller->workspace_controller()->workspace_manager());
- aura::Window* always_on_top_container = GetContainer(
- GetPrimaryRootWindow(), internal::kShellWindowId_AlwaysOnTopContainer);
- always_on_top_container->SetLayoutManager(
- new internal::BaseLayoutManager(
- always_on_top_container->GetRootWindow()));
+ // TODO(oshima): Support multiple displays.
+ controller->workspace_controller()->workspace_manager()->
+ set_shelf(shelf());
// Create Panel layout manager
if (CommandLine::ForCurrentProcess()->
@@ -833,8 +686,8 @@ void Shell::InitLayoutManagers() {
}
void Shell::DisableWorkspaceGridLayout() {
- if (workspace_controller_.get())
- workspace_controller_->workspace_manager()->set_grid_size(0);
+ GetPrimaryRootWindowController()->
+ workspace_controller()->workspace_manager()->set_grid_size(0);
}
void Shell::SetCursor(gfx::NativeCursor cursor) {
diff --git a/ash/shell.h b/ash/shell.h
index c178cbf..daa17f0 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -80,7 +80,6 @@ class ActivationController;
class AppListController;
class CaptureController;
class DragDropController;
-class EventClientImpl;
class FocusCycler;
class KeyRewriterEventFilter;
class MagnificationController;
@@ -88,8 +87,8 @@ class MonitorController;
class PanelLayoutManager;
class PartialScreenshotEventFilter;
class ResizeShadowController;
+class RootWindowController;
class RootWindowLayoutManager;
-class ScreenDimmer;
class ShadowController;
class ShelfLayoutManager;
class ShellContextMenu;
@@ -144,6 +143,9 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
static void DeleteInstance();
+ // Returns the root window controller for the primary root window.
+ static internal::RootWindowController* GetPrimaryRootWindowController();
+
// Gets the primary RootWindow. The primary RootWindow is the one
// that has a launcher.
static aura::RootWindow* GetPrimaryRootWindow();
@@ -170,10 +172,6 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
active_root_window_ = active_root_window;
}
- internal::RootWindowLayoutManager* root_window_layout() const {
- return root_window_layout_;
- }
-
// Adds or removes |filter| from the aura::Env's CompoundEventFilter.
void AddEnvEventFilter(aura::EventFilter* filter);
void RemoveEnvEventFilter(aura::EventFilter* filter);
@@ -283,10 +281,6 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
return magnification_controller_.get();
}
- internal::ScreenDimmer* screen_dimmer() {
- return screen_dimmer_.get();
- }
-
Launcher* launcher() { return launcher_.get(); }
const ScreenAsh* screen() { return screen_; }
@@ -301,6 +295,9 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
void SetShelfAlignment(ShelfAlignment alignment);
ShelfAlignment GetShelfAlignment();
+ // Dims or undims the screen.
+ void SetDimming(bool should_dim);
+
// TODO(sky): don't expose this!
internal::ShelfLayoutManager* shelf() const { return shelf_; }
@@ -315,9 +312,6 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
// Returns the size of the grid.
int GetGridSize() const;
- // Returns true if in maximized or fullscreen mode.
- bool IsInMaximizedMode() const;
-
static void set_initially_hide_cursor(bool hide) {
initially_hide_cursor_ = hide;
}
@@ -348,6 +342,7 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
private:
FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
+ friend class internal::RootWindowController;
typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
@@ -356,8 +351,13 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
void Init();
- // Initializes the layout managers and event filters.
- void InitLayoutManagers();
+ // Initiailze the root window so that it can host browser windows.
+ void InitRootWindow(aura::RootWindow* root);
+
+ // Initializes the layout managers and event filters specific for
+ // primary display.
+ void InitLayoutManagersForPrimaryDisplay(
+ internal::RootWindowController* root_window_controller);
// Disables the workspace grid layout.
void DisableWorkspaceGridLayout();
@@ -372,7 +372,7 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
// when the screen is initially created.
static bool initially_hide_cursor_;
- scoped_ptr<aura::RootWindow> root_window_;
+ scoped_ptr<internal::RootWindowController> root_window_controller_;
ScreenAsh* screen_;
// Active root window. Never become NULL.
@@ -402,7 +402,6 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
scoped_ptr<internal::CaptureController> capture_controller_;
scoped_ptr<internal::WindowModalityController> window_modality_controller_;
scoped_ptr<internal::DragDropController> drag_drop_controller_;
- scoped_ptr<internal::WorkspaceController> workspace_controller_;
scoped_ptr<internal::ResizeShadowController> resize_shadow_controller_;
scoped_ptr<internal::ShadowController> shadow_controller_;
scoped_ptr<internal::TooltipController> tooltip_controller_;
@@ -413,11 +412,9 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
scoped_ptr<VideoDetector> video_detector_;
scoped_ptr<WindowCycleController> window_cycle_controller_;
scoped_ptr<internal::FocusCycler> focus_cycler_;
- scoped_ptr<internal::EventClientImpl> event_client_;
scoped_ptr<internal::MonitorController> monitor_controller_;
scoped_ptr<HighContrastController> high_contrast_controller_;
scoped_ptr<internal::MagnificationController> magnification_controller_;
- scoped_ptr<internal::ScreenDimmer> screen_dimmer_;
scoped_ptr<aura::FocusManager> focus_manager_;
scoped_ptr<aura::client::UserActionClient> user_action_client_;
@@ -462,9 +459,6 @@ class ASH_EXPORT Shell : aura::CursorDelegate {
ObserverList<ShellObserver> observers_;
- // Owned by aura::RootWindow, cached here for type safety.
- internal::RootWindowLayoutManager* root_window_layout_;
-
// Widget containing system tray.
internal::StatusAreaWidget* status_area_widget_;
diff --git a/ash/system/status_area_widget.cc b/ash/system/status_area_widget.cc
index f0ae1d0..9c0a312 100644
--- a/ash/system/status_area_widget.cc
+++ b/ash/system/status_area_widget.cc
@@ -4,6 +4,7 @@
#include "ash/system/status_area_widget.h"
+#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
@@ -285,9 +286,9 @@ StatusAreaWidget::StatusAreaWidget()
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params.delegate = widget_delegate_;
- params.parent = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- ash::internal::kShellWindowId_StatusContainer);
+ params.parent =
+ Shell::GetPrimaryRootWindowController()->GetContainer(
+ ash::internal::kShellWindowId_StatusContainer);
params.transparent = true;
Init(params);
set_focus_on_creation(false);
diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc
index 368603d..23b30a5 100644
--- a/ash/tooltips/tooltip_controller.cc
+++ b/ash/tooltips/tooltip_controller.cc
@@ -104,7 +104,6 @@ class TooltipController::Tooltip {
label_.set_owned_by_client();
widget_.reset(CreateTooltip());
widget_->SetContentsView(&label_);
- widget_->Activate();
}
~Tooltip() {
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc
index d4c51f1..5ffc075 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -5,6 +5,7 @@
#include "ash/wm/app_list_controller.h"
#include "ash/ash_switches.h"
+#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
@@ -85,8 +86,7 @@ void AppListController::SetVisible(bool visible) {
app_list::AppListView* view = new app_list::AppListView(
Shell::GetInstance()->delegate()->CreateAppListViewDelegate());
view->InitAsBubble(
- Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
+ Shell::GetPrimaryRootWindowController()->GetContainer(
kShellWindowId_AppListContainer),
Shell::GetInstance()->launcher()->GetAppListButtonView(),
GetBubbleArrowLocation());
diff --git a/ash/wm/property_util.cc b/ash/wm/property_util.cc
index 50a7bed..a51d298 100644
--- a/ash/wm/property_util.cc
+++ b/ash/wm/property_util.cc
@@ -8,6 +8,7 @@
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.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"
#include "ui/gfx/rect.h"
@@ -72,4 +73,14 @@ void SetDefaultPersistsAcrossAllWorkspaces(bool value) {
g_default_windows_persist_across_all_workspaces = value;
}
+internal::RootWindowController* GetRootWindowController(
+ aura::RootWindow* root_window) {
+ return root_window->GetProperty(internal::kRootWindowControllerKey);
}
+
+void SetRootWindowController(aura::RootWindow* root_window,
+ internal::RootWindowController* controller) {
+ root_window->SetProperty(internal::kRootWindowControllerKey, controller);
+}
+
+} // namespace ash
diff --git a/ash/wm/property_util.h b/ash/wm/property_util.h
index ce0940b..1850269 100644
--- a/ash/wm/property_util.h
+++ b/ash/wm/property_util.h
@@ -9,6 +9,7 @@
#include "ash/ash_export.h"
namespace aura {
+class RootWindow;
class Window;
}
@@ -17,6 +18,9 @@ class Rect;
}
namespace ash {
+namespace internal {
+class RootWindowController;
+}
// Sets the restore bounds property on |window|. Deletes existing bounds value
// if exists.
@@ -61,6 +65,13 @@ ASH_EXPORT bool GetPersistsAcrossAllWorkspaces(aura::Window* window);
// The default is false.
ASH_EXPORT void SetDefaultPersistsAcrossAllWorkspaces(bool value);
+// Sets/Gets the RootWindowController for |root_window|.
+ASH_EXPORT void SetRootWindowController(
+ aura::RootWindow* root_window,
+ internal::RootWindowController* controller);
+ASH_EXPORT internal::RootWindowController* GetRootWindowController(
+ aura::RootWindow* root_window);
+
}
#endif // ASH_WM_PROPERTY_UTIL_H_
diff --git a/ash/wm/screen_dimmer.h b/ash/wm/screen_dimmer.h
index eeedecc..daa60ea0 100644
--- a/ash/wm/screen_dimmer.h
+++ b/ash/wm/screen_dimmer.h
@@ -47,7 +47,7 @@ class ASH_EXPORT ScreenDimmer : public aura::RootWindowObserver {
explicit ScreenDimmer(aura::RootWindow* root_window);
virtual ~ScreenDimmer();
- // Dim or undim the screen.
+ // Dim or undim the root window.
void SetDimming(bool should_dim);
// aura::RootWindowObserver overrides:
diff --git a/ash/wm/screen_dimmer_unittest.cc b/ash/wm/screen_dimmer_unittest.cc
index ecc6cd5..2c40e33 100644
--- a/ash/wm/screen_dimmer_unittest.cc
+++ b/ash/wm/screen_dimmer_unittest.cc
@@ -4,6 +4,7 @@
#include "ash/wm/screen_dimmer.h"
+#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "base/basictypes.h"
@@ -21,7 +22,7 @@ class ScreenDimmerTest : public AshTestBase {
void SetUp() OVERRIDE {
AshTestBase::SetUp();
- dimmer_ = Shell::GetInstance()->screen_dimmer();
+ dimmer_ = Shell::GetPrimaryRootWindowController()->screen_dimmer();
test_api_.reset(new internal::ScreenDimmer::TestApi(dimmer_));
}
diff --git a/ash/wm/system_gesture_event_filter.cc b/ash/wm/system_gesture_event_filter.cc
index 98cbac9..1db677f 100644
--- a/ash/wm/system_gesture_event_filter.cc
+++ b/ash/wm/system_gesture_event_filter.cc
@@ -6,6 +6,7 @@
#include "ash/accelerators/accelerator_controller.h"
#include "ash/launcher/launcher.h"
+#include "ash/root_window_controller.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
@@ -79,9 +80,9 @@ Widget* CreateAffordanceWidget() {
params.transparent = true;
widget->Init(params);
widget->SetOpacity(0xFF);
- widget->GetNativeWindow()->SetParent(ash::Shell::GetContainer(
- ash::Shell::GetPrimaryRootWindow(),
- ash::internal::kShellWindowId_OverlayContainer));
+ widget->GetNativeWindow()->SetParent(
+ ash::Shell::GetPrimaryRootWindowController()->GetContainer(
+ ash::internal::kShellWindowId_OverlayContainer));
ash::SetWindowVisibilityAnimationTransition(widget->GetNativeView(),
ash::ANIMATE_HIDE);
return widget;
diff --git a/ash/wm/window_properties.cc b/ash/wm/window_properties.cc
index 7f15c5b..a312149 100644
--- a/ash/wm/window_properties.cc
+++ b/ash/wm/window_properties.cc
@@ -4,6 +4,7 @@
#include "ash/wm/window_properties.h"
+#include "ash/root_window_controller.h"
#include "ash/wm/always_on_top_controller.h"
#include "ash/wm/shadow_types.h"
#include "ui/aura/window_property.h"
@@ -15,6 +16,7 @@ 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*)
+DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::RootWindowController*);
namespace ash {
namespace internal {
@@ -33,6 +35,8 @@ DEFINE_WINDOW_PROPERTY_KEY(ash::WindowPersistsAcrossAllWorkspacesType,
kWindowPersistsAcrossAllWorkspacesKey,
WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_DEFAULT);
DEFINE_WINDOW_PROPERTY_KEY(bool, kWindowTrackedByWorkspaceKey, true);
+DEFINE_WINDOW_PROPERTY_KEY(RootWindowController*,
+ kRootWindowControllerKey, NULL);
} // namespace internal
} // namespace ash
diff --git a/ash/wm/window_properties.h b/ash/wm/window_properties.h
index 88c1b70..ef99942 100644
--- a/ash/wm/window_properties.h
+++ b/ash/wm/window_properties.h
@@ -18,6 +18,7 @@ class UIControlsAura;
namespace ash {
namespace internal {
class AlwaysOnTopController;
+class RootWindowController;
// Shell-specific window property keys.
@@ -52,6 +53,9 @@ extern const aura::WindowProperty<WindowPersistsAcrossAllWorkspacesType>* const
extern const aura::WindowProperty<bool>* const
kWindowTrackedByWorkspaceKey;
+extern const aura::WindowProperty<RootWindowController*>* const
+ kRootWindowControllerKey;
+
// Alphabetical sort.
} // namespace internal
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
index 5ac2f11..833e02c 100644
--- a/ash/wm/window_util.cc
+++ b/ash/wm/window_util.cc
@@ -99,5 +99,10 @@ void CenterWindow(aura::Window* window) {
window->SetBounds(center);
}
+internal::RootWindowController* GetRootWindowController(
+ aura::RootWindow* root_window) {
+ return root_window->GetProperty(internal::kRootWindowControllerKey);
+}
+
} // namespace wm
} // namespace ash
diff --git a/ash/wm/window_util.h b/ash/wm/window_util.h
index 6cfc907..e0bd718 100644
--- a/ash/wm/window_util.h
+++ b/ash/wm/window_util.h
@@ -9,10 +9,14 @@
#include "ash/ash_export.h"
namespace aura {
+class RootWindow;
class Window;
}
namespace ash {
+namespace internal {
+class RootWindowController;
+}
namespace wm {
// Convenience setters/getters for |aura::client::kRootWindowActiveWindow|.
@@ -21,6 +25,8 @@ ASH_EXPORT void DeactivateWindow(aura::Window* window);
ASH_EXPORT bool IsActiveWindow(aura::Window* window);
ASH_EXPORT aura::Window* GetActiveWindow();
ASH_EXPORT bool CanActivateWindow(aura::Window* window);
+ASH_EXPORT internal::RootWindowController* GetRootWindowController(
+ aura::RootWindow* root_window);
// Retrieves the activatable window for |window|. If |window| is activatable,
// this will just return it, otherwise it will climb the parent/transient parent
diff --git a/chrome/browser/chromeos/power/screen_dimming_observer.cc b/chrome/browser/chromeos/power/screen_dimming_observer.cc
index 7795760..a09204d 100644
--- a/chrome/browser/chromeos/power/screen_dimming_observer.cc
+++ b/chrome/browser/chromeos/power/screen_dimming_observer.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/chromeos/power/screen_dimming_observer.h"
#include "ash/shell.h"
-#include "ash/wm/screen_dimmer.h"
#include "chromeos/dbus/dbus_thread_manager.h"
namespace chromeos {
@@ -19,7 +18,7 @@ ScreenDimmingObserver::~ScreenDimmingObserver() {
}
void ScreenDimmingObserver::ScreenDimmingRequested(ScreenDimmingState state) {
- ash::Shell::GetInstance()->screen_dimmer()->SetDimming(
+ ash::Shell::GetInstance()->SetDimming(
state == PowerManagerClient::Observer::SCREEN_DIMMING_IDLE);
}