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/wm/window_util.h"
8 #include "ash/wm/workspace/workspace_manager.h"
9 #include "ui/aura/client/activation_client.h"
10 #include "ui/aura/client/aura_constants.h"
11 #include "ui/aura/root_window.h"
12 #include "ui/aura/window.h"
17 WorkspaceController::WorkspaceController(aura::Window
* viewport
)
18 : viewport_(viewport
) {
19 aura::RootWindow
* root_window
= viewport
->GetRootWindow();
20 workspace_manager_
.reset(new WorkspaceManager(viewport
));
21 aura::client::GetActivationClient(root_window
)->AddObserver(this);
24 WorkspaceController::~WorkspaceController() {
25 aura::client::GetActivationClient(viewport_
->GetRootWindow())->
29 WorkspaceWindowState
WorkspaceController::GetWindowState() const {
30 return workspace_manager_
->GetWindowState();
33 void WorkspaceController::SetShelf(ShelfLayoutManager
* shelf
) {
34 workspace_manager_
->SetShelf(shelf
);
37 void WorkspaceController::SetActiveWorkspaceByWindow(aura::Window
* window
) {
38 return workspace_manager_
->SetActiveWorkspaceByWindow(window
);
41 aura::Window
* WorkspaceController::GetActiveWorkspaceWindow() {
42 return workspace_manager_
->GetActiveWorkspaceWindow();
45 aura::Window
* WorkspaceController::GetParentForNewWindow(aura::Window
* window
) {
46 return workspace_manager_
->GetParentForNewWindow(window
);
49 void WorkspaceController::DoInitialAnimation() {
50 workspace_manager_
->DoInitialAnimation();
53 void WorkspaceController::OnWindowActivated(aura::Window
* gained_active
,
54 aura::Window
* lost_active
) {
56 gained_active
->GetRootWindow() == viewport_
->GetRootWindow()) {
57 workspace_manager_
->SetActiveWorkspaceByWindow(gained_active
);
61 } // namespace internal