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

Side by Side Diff: ash/wm/workspace_controller.cc

Issue 9113045: Reworks the workspace code. Here's the new heuristics: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged and all that good stuff. Created 8 years, 11 months 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 | « ash/wm/workspace_controller.h ('k') | ash/wm/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) 2012 The Chromium Authors. All rights reserved. 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 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 "ash/wm/workspace_controller.h" 5 #include "ash/wm/workspace_controller.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/launcher/launcher_model.h" 8 #include "ash/launcher/launcher_model.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
11 #include "ash/wm/workspace/workspace.h"
12 #include "ash/wm/workspace/workspace_layout_manager.h" 11 #include "ash/wm/workspace/workspace_layout_manager.h"
13 #include "ash/wm/workspace/workspace_manager.h" 12 #include "ash/wm/workspace/workspace_manager.h"
14 #include "ui/aura/client/activation_client.h" 13 #include "ui/aura/client/activation_client.h"
15 #include "ui/aura/client/aura_constants.h" 14 #include "ui/aura/client/aura_constants.h"
16 #include "ui/aura/root_window.h" 15 #include "ui/aura/root_window.h"
17 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
18 17
19 namespace ash { 18 namespace ash {
20 namespace internal { 19 namespace internal {
21 20
22 WorkspaceController::WorkspaceController(aura::Window* viewport) 21 WorkspaceController::WorkspaceController(aura::Window* viewport)
23 : workspace_manager_(new WorkspaceManager(viewport)), 22 : workspace_manager_(new WorkspaceManager(viewport)),
24 launcher_model_(NULL), 23 launcher_model_(NULL),
25 ignore_move_event_(false) { 24 ignore_move_event_(false) {
26 workspace_manager_->AddObserver(this);
27 aura::RootWindow::GetInstance()->AddRootWindowObserver(this); 25 aura::RootWindow::GetInstance()->AddRootWindowObserver(this);
28 aura::RootWindow::GetInstance()->AddObserver(this); 26 aura::RootWindow::GetInstance()->AddObserver(this);
29 } 27 }
30 28
31 WorkspaceController::~WorkspaceController() { 29 WorkspaceController::~WorkspaceController() {
32 workspace_manager_->RemoveObserver(this);
33 if (launcher_model_) 30 if (launcher_model_)
34 launcher_model_->RemoveObserver(this); 31 launcher_model_->RemoveObserver(this);
35 aura::RootWindow::GetInstance()->RemoveObserver(this); 32 aura::RootWindow::GetInstance()->RemoveObserver(this);
36 aura::RootWindow::GetInstance()->RemoveRootWindowObserver(this); 33 aura::RootWindow::GetInstance()->RemoveRootWindowObserver(this);
37 } 34 }
38 35
39 void WorkspaceController::ToggleOverview() { 36 void WorkspaceController::ToggleOverview() {
40 workspace_manager_->SetOverview(!workspace_manager_->is_overview()); 37 workspace_manager_->SetOverview(!workspace_manager_->is_overview());
41 } 38 }
42 39
43 void WorkspaceController::SetLauncherModel(LauncherModel* launcher_model) { 40 void WorkspaceController::SetLauncherModel(LauncherModel* launcher_model) {
44 DCHECK(!launcher_model_); 41 DCHECK(!launcher_model_);
45 launcher_model_ = launcher_model; 42 launcher_model_ = launcher_model;
46 launcher_model_->AddObserver(this); 43 launcher_model_->AddObserver(this);
47 } 44 }
48 45
49 //////////////////////////////////////////////////////////////////////////////// 46 ////////////////////////////////////////////////////////////////////////////////
50 // WorkspaceController, aura::RootWindowObserver overrides: 47 // WorkspaceController, aura::RootWindowObserver overrides:
51 48
52 void WorkspaceController::OnRootWindowResized(const gfx::Size& new_size) { 49 void WorkspaceController::OnRootWindowResized(const gfx::Size& new_size) {
53 workspace_manager_->SetWorkspaceSize(new_size); 50 workspace_manager_->SetWorkspaceSize(new_size);
54 } 51 }
55 52
56 //////////////////////////////////////////////////////////////////////////////// 53 ////////////////////////////////////////////////////////////////////////////////
57 // WorkspaceController, aura::WindowObserver overrides: 54 // WorkspaceController, aura::WindowObserver overrides:
58 55
59 void WorkspaceController::OnWindowPropertyChanged(aura::Window* window, 56 void WorkspaceController::OnWindowPropertyChanged(aura::Window* window,
60 const char* key, 57 const char* key,
61 void* old) { 58 void* old) {
62 if (key == aura::client::kRootWindowActiveWindow) { 59 if (key == aura::client::kRootWindowActiveWindow)
63 // FindBy handles NULL. 60 workspace_manager_->SetActiveWorkspaceByWindow(GetActiveWindow());
64 Workspace* workspace = workspace_manager_->FindBy(GetActiveWindow());
65 if (workspace)
66 workspace->Activate();
67 }
68 } 61 }
69 62
70 //////////////////////////////////////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////////////////
71 // WorkspaceController, ash::internal::WorkspaceObserver overrides:
72
73 void WorkspaceController::WindowMoved(WorkspaceManager* manager,
74 aura::Window* source,
75 aura::Window* target) {
76 if (ignore_move_event_ || !launcher_model_)
77 return;
78 // TODO: there is no longer a 1-1 mapping between the launcher and windows;
79 // decide how we want to handle it.
80 NOTIMPLEMENTED();
81 }
82
83 void WorkspaceController::ActiveWorkspaceChanged(WorkspaceManager* manager,
84 Workspace* old) {
85 // TODO(oshima): Update Launcher and Status area state when the active
86 // workspace's fullscreen state changes.
87 //NOTIMPLEMENTED();
88 }
89
90 ////////////////////////////////////////////////////////////////////////////////
91 // WorkspaceController, ash::LauncherModelObserver overrides: 64 // WorkspaceController, ash::LauncherModelObserver overrides:
92 65
93 void WorkspaceController::LauncherItemAdded(int index) { 66 void WorkspaceController::LauncherItemAdded(int index) {
94 } 67 }
95 68
96 void WorkspaceController::LauncherItemRemoved(int index) { 69 void WorkspaceController::LauncherItemRemoved(int index) {
97 } 70 }
98 71
99 void WorkspaceController::LauncherItemMoved(int start_index, int target_index) { 72 void WorkspaceController::LauncherItemMoved(int start_index, int target_index) {
100 if (ignore_move_event_) 73 if (ignore_move_event_)
101 return; 74 return;
102 // TODO: there is no longer a 1-1 mapping between the launcher and windows; 75 // TODO: there is no longer a 1-1 mapping between the launcher and windows;
103 // decide how we want to handle it. 76 // decide how we want to handle it.
104 DCHECK(launcher_model_); 77 DCHECK(launcher_model_);
105 NOTIMPLEMENTED(); 78 NOTIMPLEMENTED();
106 } 79 }
107 80
108 void WorkspaceController::LauncherItemChanged( 81 void WorkspaceController::LauncherItemChanged(
109 int index, 82 int index,
110 const ash::LauncherItem& old_item) { 83 const ash::LauncherItem& old_item) {
111 } 84 }
112 85
113 } // namespace internal 86 } // namespace internal
114 } // namespace ash 87 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace_controller.h ('k') | ash/wm/workspace_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698