summaryrefslogtreecommitdiffstats
path: root/ash/root_window_controller.cc
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 /ash/root_window_controller.cc
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
Diffstat (limited to 'ash/root_window_controller.cc')
-rw-r--r--ash/root_window_controller.cc218
1 files changed, 218 insertions, 0 deletions
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