| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura_shell/workspace_controller.h" | 5 #include "ui/aura_shell/workspace_controller.h" |
| 6 | 6 |
| 7 #include "ui/aura/client/aura_constants.h" | |
| 8 #include "ui/aura/root_window.h" | 7 #include "ui/aura/root_window.h" |
| 9 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 10 #include "ui/aura_shell/default_container_layout_manager.h" | 9 #include "ui/aura_shell/default_container_layout_manager.h" |
| 11 #include "ui/aura_shell/launcher/launcher.h" | 10 #include "ui/aura_shell/launcher/launcher.h" |
| 12 #include "ui/aura_shell/launcher/launcher_model.h" | 11 #include "ui/aura_shell/launcher/launcher_model.h" |
| 13 #include "ui/aura_shell/shell.h" | 12 #include "ui/aura_shell/shell.h" |
| 14 #include "ui/aura_shell/window_util.h" | |
| 15 #include "ui/aura_shell/workspace/workspace.h" | 13 #include "ui/aura_shell/workspace/workspace.h" |
| 16 #include "ui/aura_shell/workspace/workspace_manager.h" | 14 #include "ui/aura_shell/workspace/workspace_manager.h" |
| 17 | 15 |
| 18 namespace aura_shell { | 16 namespace aura_shell { |
| 19 namespace internal { | 17 namespace internal { |
| 20 | 18 |
| 21 WorkspaceController::WorkspaceController(aura::Window* viewport) | 19 WorkspaceController::WorkspaceController(aura::Window* viewport) |
| 22 : workspace_manager_(new WorkspaceManager(viewport)), | 20 : workspace_manager_(new WorkspaceManager(viewport)), |
| 23 launcher_model_(NULL), | 21 launcher_model_(NULL), |
| 24 ignore_move_event_(false) { | 22 ignore_move_event_(false) { |
| 25 workspace_manager_->AddObserver(this); | 23 workspace_manager_->AddObserver(this); |
| 26 aura::RootWindow::GetInstance()->AddRootWindowObserver(this); | |
| 27 aura::RootWindow::GetInstance()->AddObserver(this); | 24 aura::RootWindow::GetInstance()->AddObserver(this); |
| 28 } | 25 } |
| 29 | 26 |
| 30 WorkspaceController::~WorkspaceController() { | 27 WorkspaceController::~WorkspaceController() { |
| 31 workspace_manager_->RemoveObserver(this); | 28 workspace_manager_->RemoveObserver(this); |
| 32 if (launcher_model_) | 29 if (launcher_model_) |
| 33 launcher_model_->RemoveObserver(this); | 30 launcher_model_->RemoveObserver(this); |
| 34 aura::RootWindow::GetInstance()->RemoveObserver(this); | 31 aura::RootWindow::GetInstance()->RemoveObserver(this); |
| 35 aura::RootWindow::GetInstance()->RemoveRootWindowObserver(this); | |
| 36 } | 32 } |
| 37 | 33 |
| 38 void WorkspaceController::ToggleOverview() { | 34 void WorkspaceController::ToggleOverview() { |
| 39 workspace_manager_->SetOverview(!workspace_manager_->is_overview()); | 35 workspace_manager_->SetOverview(!workspace_manager_->is_overview()); |
| 40 } | 36 } |
| 41 | 37 |
| 42 void WorkspaceController::SetLauncherModel(LauncherModel* launcher_model) { | 38 void WorkspaceController::SetLauncherModel(LauncherModel* launcher_model) { |
| 43 DCHECK(!launcher_model_); | 39 DCHECK(!launcher_model_); |
| 44 launcher_model_ = launcher_model; | 40 launcher_model_ = launcher_model; |
| 45 launcher_model_->AddObserver(this); | 41 launcher_model_->AddObserver(this); |
| 46 } | 42 } |
| 47 | 43 |
| 48 //////////////////////////////////////////////////////////////////////////////// | 44 //////////////////////////////////////////////////////////////////////////////// |
| 49 // WorkspaceController, aura::RootWindowObserver overrides: | 45 // WorkspaceController, aura::RootWindowObserver overrides: |
| 50 | 46 |
| 51 void WorkspaceController::OnRootWindowResized(const gfx::Size& new_size) { | 47 void WorkspaceController::OnRootWindowResized(const gfx::Size& new_size) { |
| 52 workspace_manager_->SetWorkspaceSize(new_size); | 48 workspace_manager_->SetWorkspaceSize(new_size); |
| 53 } | 49 } |
| 54 | 50 |
| 55 //////////////////////////////////////////////////////////////////////////////// | 51 void WorkspaceController::OnActiveWindowChanged(aura::Window* active) { |
| 56 // WorkspaceController, aura::WindowObserver overrides: | 52 // FindBy handles NULL. |
| 57 | 53 Workspace* workspace = workspace_manager_->FindBy(active); |
| 58 void WorkspaceController::OnWindowPropertyChanged(aura::Window* window, | 54 if (workspace) |
| 59 const char* key, | 55 workspace->Activate(); |
| 60 void* old) { | |
| 61 if (key == aura::kRootWindowActiveWindow) { | |
| 62 // FindBy handles NULL. | |
| 63 Workspace* workspace = workspace_manager_->FindBy(GetActiveWindow()); | |
| 64 if (workspace) | |
| 65 workspace->Activate(); | |
| 66 } | |
| 67 } | 56 } |
| 68 | 57 |
| 69 //////////////////////////////////////////////////////////////////////////////// | 58 //////////////////////////////////////////////////////////////////////////////// |
| 70 // WorkspaceController, aura_shell::internal::WorkspaceObserver overrides: | 59 // WorkspaceController, aura_shell::internal::WorkspaceObserver overrides: |
| 71 | 60 |
| 72 void WorkspaceController::WindowMoved(WorkspaceManager* manager, | 61 void WorkspaceController::WindowMoved(WorkspaceManager* manager, |
| 73 aura::Window* source, | 62 aura::Window* source, |
| 74 aura::Window* target) { | 63 aura::Window* target) { |
| 75 if (ignore_move_event_ || !launcher_model_) | 64 if (ignore_move_event_ || !launcher_model_) |
| 76 return; | 65 return; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 ignore_move_event_ = true; | 106 ignore_move_event_ = true; |
| 118 workspace_manager_->RotateWindows(start, target); | 107 workspace_manager_->RotateWindows(start, target); |
| 119 ignore_move_event_ = false; | 108 ignore_move_event_ = false; |
| 120 } | 109 } |
| 121 | 110 |
| 122 void WorkspaceController::LauncherItemImagesChanged(int index) { | 111 void WorkspaceController::LauncherItemImagesChanged(int index) { |
| 123 } | 112 } |
| 124 | 113 |
| 125 } // namespace internal | 114 } // namespace internal |
| 126 } // namespace aura_shell | 115 } // namespace aura_shell |
| OLD | NEW |