Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: ui/aura_shell/workspace_controller.cc

Issue 8894018: Move the concept of Activation to the Shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura_shell/workspace_controller.h ('k') | ui/aura_shell/workspace_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
7 #include "ui/aura/root_window.h" 8 #include "ui/aura/root_window.h"
8 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
9 #include "ui/aura_shell/default_container_layout_manager.h" 10 #include "ui/aura_shell/default_container_layout_manager.h"
10 #include "ui/aura_shell/launcher/launcher.h" 11 #include "ui/aura_shell/launcher/launcher.h"
11 #include "ui/aura_shell/launcher/launcher_model.h" 12 #include "ui/aura_shell/launcher/launcher_model.h"
12 #include "ui/aura_shell/shell.h" 13 #include "ui/aura_shell/shell.h"
14 #include "ui/aura_shell/window_util.h"
13 #include "ui/aura_shell/workspace/workspace.h" 15 #include "ui/aura_shell/workspace/workspace.h"
14 #include "ui/aura_shell/workspace/workspace_manager.h" 16 #include "ui/aura_shell/workspace/workspace_manager.h"
15 17
16 namespace aura_shell { 18 namespace aura_shell {
17 namespace internal { 19 namespace internal {
18 20
19 WorkspaceController::WorkspaceController(aura::Window* viewport) 21 WorkspaceController::WorkspaceController(aura::Window* viewport)
20 : workspace_manager_(new WorkspaceManager(viewport)), 22 : workspace_manager_(new WorkspaceManager(viewport)),
21 launcher_model_(NULL), 23 launcher_model_(NULL),
22 ignore_move_event_(false) { 24 ignore_move_event_(false) {
23 workspace_manager_->AddObserver(this); 25 workspace_manager_->AddObserver(this);
26 aura::RootWindow::GetInstance()->AddRootWindowObserver(this);
24 aura::RootWindow::GetInstance()->AddObserver(this); 27 aura::RootWindow::GetInstance()->AddObserver(this);
25 } 28 }
26 29
27 WorkspaceController::~WorkspaceController() { 30 WorkspaceController::~WorkspaceController() {
28 workspace_manager_->RemoveObserver(this); 31 workspace_manager_->RemoveObserver(this);
29 if (launcher_model_) 32 if (launcher_model_)
30 launcher_model_->RemoveObserver(this); 33 launcher_model_->RemoveObserver(this);
31 aura::RootWindow::GetInstance()->RemoveObserver(this); 34 aura::RootWindow::GetInstance()->RemoveObserver(this);
35 aura::RootWindow::GetInstance()->RemoveRootWindowObserver(this);
32 } 36 }
33 37
34 void WorkspaceController::ToggleOverview() { 38 void WorkspaceController::ToggleOverview() {
35 workspace_manager_->SetOverview(!workspace_manager_->is_overview()); 39 workspace_manager_->SetOverview(!workspace_manager_->is_overview());
36 } 40 }
37 41
38 void WorkspaceController::SetLauncherModel(LauncherModel* launcher_model) { 42 void WorkspaceController::SetLauncherModel(LauncherModel* launcher_model) {
39 DCHECK(!launcher_model_); 43 DCHECK(!launcher_model_);
40 launcher_model_ = launcher_model; 44 launcher_model_ = launcher_model;
41 launcher_model_->AddObserver(this); 45 launcher_model_->AddObserver(this);
42 } 46 }
43 47
44 //////////////////////////////////////////////////////////////////////////////// 48 ////////////////////////////////////////////////////////////////////////////////
45 // WorkspaceController, aura::RootWindowObserver overrides: 49 // WorkspaceController, aura::RootWindowObserver overrides:
46 50
47 void WorkspaceController::OnRootWindowResized(const gfx::Size& new_size) { 51 void WorkspaceController::OnRootWindowResized(const gfx::Size& new_size) {
48 workspace_manager_->SetWorkspaceSize(new_size); 52 workspace_manager_->SetWorkspaceSize(new_size);
49 } 53 }
50 54
51 void WorkspaceController::OnActiveWindowChanged(aura::Window* active) { 55 ////////////////////////////////////////////////////////////////////////////////
52 // FindBy handles NULL. 56 // WorkspaceController, aura::WindowObserver overrides:
53 Workspace* workspace = workspace_manager_->FindBy(active); 57
54 if (workspace) 58 void WorkspaceController::OnWindowPropertyChanged(aura::Window* window,
55 workspace->Activate(); 59 const char* key,
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 }
56 } 67 }
57 68
58 //////////////////////////////////////////////////////////////////////////////// 69 ////////////////////////////////////////////////////////////////////////////////
59 // WorkspaceController, aura_shell::internal::WorkspaceObserver overrides: 70 // WorkspaceController, aura_shell::internal::WorkspaceObserver overrides:
60 71
61 void WorkspaceController::WindowMoved(WorkspaceManager* manager, 72 void WorkspaceController::WindowMoved(WorkspaceManager* manager,
62 aura::Window* source, 73 aura::Window* source,
63 aura::Window* target) { 74 aura::Window* target) {
64 if (ignore_move_event_ || !launcher_model_) 75 if (ignore_move_event_ || !launcher_model_)
65 return; 76 return;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ignore_move_event_ = true; 117 ignore_move_event_ = true;
107 workspace_manager_->RotateWindows(start, target); 118 workspace_manager_->RotateWindows(start, target);
108 ignore_move_event_ = false; 119 ignore_move_event_ = false;
109 } 120 }
110 121
111 void WorkspaceController::LauncherItemImagesChanged(int index) { 122 void WorkspaceController::LauncherItemImagesChanged(int index) {
112 } 123 }
113 124
114 } // namespace internal 125 } // namespace internal
115 } // namespace aura_shell 126 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/workspace_controller.h ('k') | ui/aura_shell/workspace_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698