Mailbox support for texture layers.
[chromium-blink-merge.git] / ash / wm / workspace_controller.cc
blob3ca70d6749c4a02a4f5a72acda85f5c754225048
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/wm/workspace_controller.h"
7 #include "ash/ash_switches.h"
8 #include "ash/wm/window_util.h"
9 #include "ash/wm/workspace/workspace_cycler.h"
10 #include "ash/wm/workspace/workspace_manager.h"
11 #include "base/command_line.h"
12 #include "ui/aura/client/activation_client.h"
13 #include "ui/aura/client/aura_constants.h"
14 #include "ui/aura/root_window.h"
15 #include "ui/aura/window.h"
17 namespace ash {
18 namespace internal {
20 WorkspaceController::WorkspaceController(aura::Window* viewport)
21 : viewport_(viewport),
22 workspace_cycler_(NULL) {
23 aura::RootWindow* root_window = viewport->GetRootWindow();
24 workspace_manager_.reset(new WorkspaceManager(viewport));
25 if (CommandLine::ForCurrentProcess()->HasSwitch(
26 switches::kAshEnableWorkspaceScrubbing)) {
27 workspace_cycler_.reset(new WorkspaceCycler(workspace_manager_.get()));
29 aura::client::GetActivationClient(root_window)->AddObserver(this);
32 WorkspaceController::~WorkspaceController() {
33 aura::client::GetActivationClient(viewport_->GetRootWindow())->
34 RemoveObserver(this);
37 WorkspaceWindowState WorkspaceController::GetWindowState() const {
38 return workspace_manager_->GetWindowState();
41 void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) {
42 workspace_manager_->SetShelf(shelf);
45 void WorkspaceController::SetActiveWorkspaceByWindow(aura::Window* window) {
46 return workspace_manager_->SetActiveWorkspaceByWindow(window);
49 aura::Window* WorkspaceController::GetParentForNewWindow(aura::Window* window) {
50 return workspace_manager_->GetParentForNewWindow(window);
54 void WorkspaceController::DoInitialAnimation() {
55 workspace_manager_->DoInitialAnimation();
58 void WorkspaceController::OnWindowActivated(aura::Window* gained_active,
59 aura::Window* lost_active) {
60 if (!gained_active ||
61 gained_active->GetRootWindow() == viewport_->GetRootWindow()) {
62 workspace_manager_->SetActiveWorkspaceByWindow(gained_active);
66 } // namespace internal
67 } // namespace ash