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

Side by Side Diff: ash/wm/workspace/workspace_manager.cc

Issue 11293014: Renames Workspace*2 -> Workspace*. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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/workspace_manager.h ('k') | ash/wm/workspace/workspace_manager2.h » ('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/workspace_manager2.h" 5 #include "ash/wm/workspace/workspace_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/shell_window_ids.h" 13 #include "ash/shell_window_ids.h"
14 #include "ash/wm/base_layout_manager.h" 14 #include "ash/wm/base_layout_manager.h"
15 #include "ash/wm/property_util.h" 15 #include "ash/wm/property_util.h"
16 #include "ash/wm/shelf_layout_manager.h" 16 #include "ash/wm/shelf_layout_manager.h"
17 #include "ash/wm/window_animations.h" 17 #include "ash/wm/window_animations.h"
18 #include "ash/wm/window_properties.h" 18 #include "ash/wm/window_properties.h"
19 #include "ash/wm/window_util.h" 19 #include "ash/wm/window_util.h"
20 #include "ash/wm/workspace/auto_window_management.h" 20 #include "ash/wm/workspace/auto_window_management.h"
21 #include "ash/wm/workspace/desktop_background_fade_controller.h" 21 #include "ash/wm/workspace/desktop_background_fade_controller.h"
22 #include "ash/wm/workspace/workspace_animations.h" 22 #include "ash/wm/workspace/workspace_animations.h"
23 #include "ash/wm/workspace/workspace_layout_manager2.h" 23 #include "ash/wm/workspace/workspace_layout_manager.h"
24 #include "ash/wm/workspace/workspace2.h" 24 #include "ash/wm/workspace/workspace.h"
25 #include "base/auto_reset.h" 25 #include "base/auto_reset.h"
26 #include "base/command_line.h" 26 #include "base/command_line.h"
27 #include "base/logging.h" 27 #include "base/logging.h"
28 #include "base/stl_util.h" 28 #include "base/stl_util.h"
29 #include "ui/aura/client/aura_constants.h" 29 #include "ui/aura/client/aura_constants.h"
30 #include "ui/aura/root_window.h" 30 #include "ui/aura/root_window.h"
31 #include "ui/aura/window.h" 31 #include "ui/aura/window.h"
32 #include "ui/aura/window_property.h" 32 #include "ui/aura/window_property.h"
33 #include "ui/base/ui_base_types.h" 33 #include "ui/base/ui_base_types.h"
34 #include "ui/compositor/layer.h" 34 #include "ui/compositor/layer.h"
35 #include "ui/compositor/layer_animator.h" 35 #include "ui/compositor/layer_animator.h"
36 #include "ui/compositor/scoped_layer_animation_settings.h" 36 #include "ui/compositor/scoped_layer_animation_settings.h"
37 #include "ui/views/widget/widget.h" 37 #include "ui/views/widget/widget.h"
38 38
39 DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::Workspace2*); 39 DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::Workspace*);
40 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ASH_EXPORT, ui::WindowShowState); 40 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ASH_EXPORT, ui::WindowShowState);
41 41
42 using aura::Window; 42 using aura::Window;
43 43
44 namespace ash { 44 namespace ash {
45 namespace internal { 45 namespace internal {
46 46
47 DEFINE_WINDOW_PROPERTY_KEY(Workspace2*, kWorkspaceKey, NULL); 47 DEFINE_WINDOW_PROPERTY_KEY(Workspace*, kWorkspaceKey, NULL);
48 48
49 namespace { 49 namespace {
50 50
51 // Duration for fading out the desktop background when maximizing. 51 // Duration for fading out the desktop background when maximizing.
52 const int kCrossFadeSwitchTimeMS = 700; 52 const int kCrossFadeSwitchTimeMS = 700;
53 53
54 // Amount of time to pause before animating anything. Only used during initial 54 // Amount of time to pause before animating anything. Only used during initial
55 // animation (when logging in). 55 // animation (when logging in).
56 const int kInitialPauseTimeMS = 750; 56 const int kInitialPauseTimeMS = 750;
57 57
58 // Changes the parent of |window| and all its transient children to 58 // Changes the parent of |window| and all its transient children to
59 // |new_parent|. If |stack_beneach| is non-NULL all the windows are stacked 59 // |new_parent|. If |stack_beneach| is non-NULL all the windows are stacked
60 // beneath it. 60 // beneath it.
61 void ReparentWindow(Window* window, 61 void ReparentWindow(Window* window,
62 Window* new_parent, 62 Window* new_parent,
63 Window* stack_beneath) { 63 Window* stack_beneath) {
64 window->SetParent(new_parent); 64 window->SetParent(new_parent);
65 if (stack_beneath) 65 if (stack_beneath)
66 new_parent->StackChildBelow(window, stack_beneath); 66 new_parent->StackChildBelow(window, stack_beneath);
67 for (size_t i = 0; i < window->transient_children().size(); ++i) 67 for (size_t i = 0; i < window->transient_children().size(); ++i)
68 ReparentWindow(window->transient_children()[i], new_parent, stack_beneath); 68 ReparentWindow(window->transient_children()[i], new_parent, stack_beneath);
69 } 69 }
70 70
71 } // namespace 71 } // namespace
72 72
73 // Workspace ------------------------------------------------------------------- 73 // Workspace -------------------------------------------------------------------
74 74
75 // LayoutManager installed on the parent window of all the Workspace window (eg 75 // LayoutManager installed on the parent window of all the Workspace window (eg
76 // |WorkspaceManager2::contents_view_|). 76 // |WorkspaceManager::contents_view_|).
77 class WorkspaceManager2::LayoutManagerImpl : public BaseLayoutManager { 77 class WorkspaceManager::LayoutManagerImpl : public BaseLayoutManager {
78 public: 78 public:
79 explicit LayoutManagerImpl(WorkspaceManager2* workspace_manager) 79 explicit LayoutManagerImpl(WorkspaceManager* workspace_manager)
80 : BaseLayoutManager(workspace_manager->contents_view_->GetRootWindow()), 80 : BaseLayoutManager(workspace_manager->contents_view_->GetRootWindow()),
81 workspace_manager_(workspace_manager) { 81 workspace_manager_(workspace_manager) {
82 } 82 }
83 virtual ~LayoutManagerImpl() {} 83 virtual ~LayoutManagerImpl() {}
84 84
85 // Overridden from BaseWorkspaceLayoutManager: 85 // Overridden from BaseWorkspaceLayoutManager:
86 virtual void OnWindowResized() OVERRIDE { 86 virtual void OnWindowResized() OVERRIDE {
87 for (size_t i = 0; i < window()->children().size(); ++i) 87 for (size_t i = 0; i < window()->children().size(); ++i)
88 window()->children()[i]->SetBounds(gfx::Rect(window()->bounds().size())); 88 window()->children()[i]->SetBounds(gfx::Rect(window()->bounds().size()));
89 } 89 }
90 virtual void OnWindowAddedToLayout(Window* child) OVERRIDE { 90 virtual void OnWindowAddedToLayout(Window* child) OVERRIDE {
91 // Only workspaces should be added as children. 91 // Only workspaces should be added as children.
92 DCHECK((child->id() == kShellWindowId_WorkspaceContainer) || 92 DCHECK((child->id() == kShellWindowId_WorkspaceContainer) ||
93 workspace_manager_->creating_fade_); 93 workspace_manager_->creating_fade_);
94 child->SetBounds(gfx::Rect(window()->bounds().size())); 94 child->SetBounds(gfx::Rect(window()->bounds().size()));
95 } 95 }
96 96
97 private: 97 private:
98 aura::Window* window() { return workspace_manager_->contents_view_; } 98 aura::Window* window() { return workspace_manager_->contents_view_; }
99 99
100 WorkspaceManager2* workspace_manager_; 100 WorkspaceManager* workspace_manager_;
101 101
102 DISALLOW_COPY_AND_ASSIGN(LayoutManagerImpl); 102 DISALLOW_COPY_AND_ASSIGN(LayoutManagerImpl);
103 }; 103 };
104 104
105 // WorkspaceManager2 ----------------------------------------------------------- 105 // WorkspaceManager -----------------------------------------------------------
106 106
107 WorkspaceManager2::WorkspaceManager2(Window* contents_view) 107 WorkspaceManager::WorkspaceManager(Window* contents_view)
108 : contents_view_(contents_view), 108 : contents_view_(contents_view),
109 active_workspace_(NULL), 109 active_workspace_(NULL),
110 shelf_(NULL), 110 shelf_(NULL),
111 in_move_(false), 111 in_move_(false),
112 ALLOW_THIS_IN_INITIALIZER_LIST( 112 ALLOW_THIS_IN_INITIALIZER_LIST(
113 clear_unminimizing_workspace_factory_(this)), 113 clear_unminimizing_workspace_factory_(this)),
114 unminimizing_workspace_(NULL), 114 unminimizing_workspace_(NULL),
115 app_terminating_(false), 115 app_terminating_(false),
116 creating_fade_(false) { 116 creating_fade_(false) {
117 // Clobber any existing event filter. 117 // Clobber any existing event filter.
118 contents_view->SetEventFilter(NULL); 118 contents_view->SetEventFilter(NULL);
119 // |contents_view| takes ownership of LayoutManagerImpl. 119 // |contents_view| takes ownership of LayoutManagerImpl.
120 contents_view->SetLayoutManager(new LayoutManagerImpl(this)); 120 contents_view->SetLayoutManager(new LayoutManagerImpl(this));
121 active_workspace_ = CreateWorkspace(false); 121 active_workspace_ = CreateWorkspace(false);
122 workspaces_.push_back(active_workspace_); 122 workspaces_.push_back(active_workspace_);
123 active_workspace_->window()->Show(); 123 active_workspace_->window()->Show();
124 Shell::GetInstance()->AddShellObserver(this); 124 Shell::GetInstance()->AddShellObserver(this);
125 } 125 }
126 126
127 WorkspaceManager2::~WorkspaceManager2() { 127 WorkspaceManager::~WorkspaceManager() {
128 Shell::GetInstance()->RemoveShellObserver(this); 128 Shell::GetInstance()->RemoveShellObserver(this);
129 // Release the windows, they'll be destroyed when |contents_view_| is 129 // Release the windows, they'll be destroyed when |contents_view_| is
130 // destroyed. 130 // destroyed.
131 std::for_each(workspaces_.begin(), workspaces_.end(), 131 std::for_each(workspaces_.begin(), workspaces_.end(),
132 std::mem_fun(&Workspace2::ReleaseWindow)); 132 std::mem_fun(&Workspace::ReleaseWindow));
133 std::for_each(pending_workspaces_.begin(), pending_workspaces_.end(), 133 std::for_each(pending_workspaces_.begin(), pending_workspaces_.end(),
134 std::mem_fun(&Workspace2::ReleaseWindow)); 134 std::mem_fun(&Workspace::ReleaseWindow));
135 std::for_each(to_delete_.begin(), to_delete_.end(), 135 std::for_each(to_delete_.begin(), to_delete_.end(),
136 std::mem_fun(&Workspace2::ReleaseWindow)); 136 std::mem_fun(&Workspace::ReleaseWindow));
137 STLDeleteElements(&workspaces_); 137 STLDeleteElements(&workspaces_);
138 STLDeleteElements(&pending_workspaces_); 138 STLDeleteElements(&pending_workspaces_);
139 STLDeleteElements(&to_delete_); 139 STLDeleteElements(&to_delete_);
140 } 140 }
141 141
142 // static 142 // static
143 bool WorkspaceManager2::IsMaximized(Window* window) { 143 bool WorkspaceManager::IsMaximized(Window* window) {
144 return IsMaximizedState(window->GetProperty(aura::client::kShowStateKey)); 144 return IsMaximizedState(window->GetProperty(aura::client::kShowStateKey));
145 } 145 }
146 146
147 // static 147 // static
148 bool WorkspaceManager2::IsMaximizedState(ui::WindowShowState state) { 148 bool WorkspaceManager::IsMaximizedState(ui::WindowShowState state) {
149 return state == ui::SHOW_STATE_MAXIMIZED || 149 return state == ui::SHOW_STATE_MAXIMIZED ||
150 state == ui::SHOW_STATE_FULLSCREEN; 150 state == ui::SHOW_STATE_FULLSCREEN;
151 } 151 }
152 152
153 // static 153 // static
154 bool WorkspaceManager2::WillRestoreMaximized(Window* window) { 154 bool WorkspaceManager::WillRestoreMaximized(Window* window) {
155 return wm::IsWindowMinimized(window) && 155 return wm::IsWindowMinimized(window) &&
156 IsMaximizedState(window->GetProperty(internal::kRestoreShowStateKey)); 156 IsMaximizedState(window->GetProperty(internal::kRestoreShowStateKey));
157 } 157 }
158 158
159 WorkspaceWindowState WorkspaceManager2::GetWindowState() const { 159 WorkspaceWindowState WorkspaceManager::GetWindowState() const {
160 if (!shelf_) 160 if (!shelf_)
161 return WORKSPACE_WINDOW_STATE_DEFAULT; 161 return WORKSPACE_WINDOW_STATE_DEFAULT;
162 162
163 const bool is_active_maximized = active_workspace_->is_maximized(); 163 const bool is_active_maximized = active_workspace_->is_maximized();
164 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); 164 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds());
165 const Window::Windows& windows(active_workspace_->window()->children()); 165 const Window::Windows& windows(active_workspace_->window()->children());
166 bool window_overlaps_launcher = false; 166 bool window_overlaps_launcher = false;
167 bool has_maximized_window = false; 167 bool has_maximized_window = false;
168 for (Window::Windows::const_iterator i = windows.begin(); 168 for (Window::Windows::const_iterator i = windows.begin();
169 i != windows.end(); ++i) { 169 i != windows.end(); ++i) {
(...skipping 19 matching lines...) Expand all
189 window_overlaps_launcher = true; 189 window_overlaps_launcher = true;
190 } 190 }
191 if (has_maximized_window) 191 if (has_maximized_window)
192 return WORKSPACE_WINDOW_STATE_MAXIMIZED; 192 return WORKSPACE_WINDOW_STATE_MAXIMIZED;
193 193
194 return window_overlaps_launcher ? 194 return window_overlaps_launcher ?
195 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF : 195 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF :
196 WORKSPACE_WINDOW_STATE_DEFAULT; 196 WORKSPACE_WINDOW_STATE_DEFAULT;
197 } 197 }
198 198
199 void WorkspaceManager2::SetShelf(ShelfLayoutManager* shelf) { 199 void WorkspaceManager::SetShelf(ShelfLayoutManager* shelf) {
200 shelf_ = shelf; 200 shelf_ = shelf;
201 } 201 }
202 202
203 void WorkspaceManager2::SetActiveWorkspaceByWindow(Window* window) { 203 void WorkspaceManager::SetActiveWorkspaceByWindow(Window* window) {
204 Workspace2* workspace = FindBy(window); 204 Workspace* workspace = FindBy(window);
205 if (!workspace) 205 if (!workspace)
206 return; 206 return;
207 207
208 if (workspace != active_workspace_) { 208 if (workspace != active_workspace_) {
209 // A window is being made active. In the following cases we reparent to 209 // A window is being made active. In the following cases we reparent to
210 // the active desktop: 210 // the active desktop:
211 // . The window is not tracked by workspace code. This is used for tab 211 // . The window is not tracked by workspace code. This is used for tab
212 // dragging. Since tab dragging needs to happen in the active workspace we 212 // dragging. Since tab dragging needs to happen in the active workspace we
213 // have to reparent the window (otherwise the window you dragged the tab 213 // have to reparent the window (otherwise the window you dragged the tab
214 // out of would disappear since the workspace changed). Since this case is 214 // out of would disappear since the workspace changed). Since this case is
(...skipping 15 matching lines...) Expand all
230 base::TimeDelta()); 230 base::TimeDelta());
231 } 231 }
232 } 232 }
233 if (workspace->is_maximized() && IsMaximized(window)) { 233 if (workspace->is_maximized() && IsMaximized(window)) {
234 // Clicking on the maximized window in a maximized workspace. Force all 234 // Clicking on the maximized window in a maximized workspace. Force all
235 // other windows to drop to the desktop. 235 // other windows to drop to the desktop.
236 MoveChildrenToDesktop(workspace->window(), NULL); 236 MoveChildrenToDesktop(workspace->window(), NULL);
237 } 237 }
238 } 238 }
239 239
240 Window* WorkspaceManager2::GetParentForNewWindow(Window* window) { 240 Window* WorkspaceManager::GetParentForNewWindow(Window* window) {
241 // Try to put windows with transient parents in the same workspace as their 241 // Try to put windows with transient parents in the same workspace as their
242 // transient parent. 242 // transient parent.
243 if (window->transient_parent() && !IsMaximized(window)) { 243 if (window->transient_parent() && !IsMaximized(window)) {
244 Workspace2* workspace = FindBy(window->transient_parent()); 244 Workspace* workspace = FindBy(window->transient_parent());
245 if (workspace) 245 if (workspace)
246 return workspace->window(); 246 return workspace->window();
247 // Fall through to normal logic. 247 // Fall through to normal logic.
248 } 248 }
249 249
250 if (!GetTrackedByWorkspace(window)) 250 if (!GetTrackedByWorkspace(window))
251 return active_workspace_->window(); 251 return active_workspace_->window();
252 252
253 if (IsMaximized(window)) { 253 if (IsMaximized(window)) {
254 // Wait for the window to be made active before showing the workspace. 254 // Wait for the window to be made active before showing the workspace.
255 Workspace2* workspace = CreateWorkspace(true); 255 Workspace* workspace = CreateWorkspace(true);
256 pending_workspaces_.insert(workspace); 256 pending_workspaces_.insert(workspace);
257 return workspace->window(); 257 return workspace->window();
258 } 258 }
259 259
260 if (!GetTrackedByWorkspace(window) || GetPersistsAcrossAllWorkspaces(window)) 260 if (!GetTrackedByWorkspace(window) || GetPersistsAcrossAllWorkspaces(window))
261 return active_workspace_->window(); 261 return active_workspace_->window();
262 262
263 return desktop_workspace()->window(); 263 return desktop_workspace()->window();
264 } 264 }
265 265
266 void WorkspaceManager2::DoInitialAnimation() { 266 void WorkspaceManager::DoInitialAnimation() {
267 if (active_workspace_->is_maximized()) { 267 if (active_workspace_->is_maximized()) {
268 RootWindowController* root_controller = GetRootWindowController( 268 RootWindowController* root_controller = GetRootWindowController(
269 contents_view_->GetRootWindow()); 269 contents_view_->GetRootWindow());
270 if (root_controller) { 270 if (root_controller) {
271 aura::Window* background = root_controller->GetContainer( 271 aura::Window* background = root_controller->GetContainer(
272 kShellWindowId_DesktopBackgroundContainer); 272 kShellWindowId_DesktopBackgroundContainer);
273 background->Show(); 273 background->Show();
274 ShowOrHideDesktopBackground(background, SWITCH_INITIAL, 274 ShowOrHideDesktopBackground(background, SWITCH_INITIAL,
275 base::TimeDelta(), false); 275 base::TimeDelta(), false);
276 } 276 }
277 } 277 }
278 ShowWorkspace(active_workspace_, active_workspace_, SWITCH_INITIAL); 278 ShowWorkspace(active_workspace_, active_workspace_, SWITCH_INITIAL);
279 } 279 }
280 280
281 void WorkspaceManager2::OnAppTerminating() { 281 void WorkspaceManager::OnAppTerminating() {
282 app_terminating_ = true; 282 app_terminating_ = true;
283 } 283 }
284 284
285 void WorkspaceManager2::UpdateShelfVisibility() { 285 void WorkspaceManager::UpdateShelfVisibility() {
286 if (shelf_) 286 if (shelf_)
287 shelf_->UpdateVisibilityState(); 287 shelf_->UpdateVisibilityState();
288 } 288 }
289 289
290 Workspace2* WorkspaceManager2::FindBy(Window* window) const { 290 Workspace* WorkspaceManager::FindBy(Window* window) const {
291 while (window) { 291 while (window) {
292 Workspace2* workspace = window->GetProperty(kWorkspaceKey); 292 Workspace* workspace = window->GetProperty(kWorkspaceKey);
293 if (workspace) 293 if (workspace)
294 return workspace; 294 return workspace;
295 window = window->parent(); 295 window = window->parent();
296 } 296 }
297 return NULL; 297 return NULL;
298 } 298 }
299 299
300 void WorkspaceManager2::SetActiveWorkspace(Workspace2* workspace, 300 void WorkspaceManager::SetActiveWorkspace(Workspace* workspace,
301 SwitchReason reason, 301 SwitchReason reason,
302 base::TimeDelta duration) { 302 base::TimeDelta duration) {
303 DCHECK(workspace); 303 DCHECK(workspace);
304 if (active_workspace_ == workspace) 304 if (active_workspace_ == workspace)
305 return; 305 return;
306 306
307 pending_workspaces_.erase(workspace); 307 pending_workspaces_.erase(workspace);
308 308
309 // Adjust the z-order. No need to adjust the z-order for the desktop since 309 // Adjust the z-order. No need to adjust the z-order for the desktop since
310 // it always stays at the bottom. 310 // it always stays at the bottom.
311 if (workspace != desktop_workspace() && 311 if (workspace != desktop_workspace() &&
312 FindWorkspace(workspace) == workspaces_.end()) { 312 FindWorkspace(workspace) == workspaces_.end()) {
313 contents_view_->StackChildAbove(workspace->window(), 313 contents_view_->StackChildAbove(workspace->window(),
314 workspaces_.back()->window()); 314 workspaces_.back()->window());
315 workspaces_.push_back(workspace); 315 workspaces_.push_back(workspace);
316 } 316 }
317 317
318 Workspace2* last_active = active_workspace_; 318 Workspace* last_active = active_workspace_;
319 active_workspace_ = workspace; 319 active_workspace_ = workspace;
320 320
321 // The display work-area may have changed while |workspace| was not the active 321 // The display work-area may have changed while |workspace| was not the active
322 // workspace. Give it a chance to adjust its state for the new work-area. 322 // workspace. Give it a chance to adjust its state for the new work-area.
323 active_workspace_->workspace_layout_manager()-> 323 active_workspace_->workspace_layout_manager()->
324 OnDisplayWorkAreaInsetsChanged(); 324 OnDisplayWorkAreaInsetsChanged();
325 325
326 const bool is_unminimizing_maximized_window = 326 const bool is_unminimizing_maximized_window =
327 unminimizing_workspace_ && unminimizing_workspace_ == active_workspace_ && 327 unminimizing_workspace_ && unminimizing_workspace_ == active_workspace_ &&
328 active_workspace_->is_maximized(); 328 active_workspace_->is_maximized();
(...skipping 21 matching lines...) Expand all
350 aura::Window* background = root_controller->GetContainer( 350 aura::Window* background = root_controller->GetContainer(
351 kShellWindowId_DesktopBackgroundContainer); 351 kShellWindowId_DesktopBackgroundContainer);
352 if (last_active == desktop_workspace()) { 352 if (last_active == desktop_workspace()) {
353 ShowOrHideDesktopBackground(background, reason, duration, false); 353 ShowOrHideDesktopBackground(background, reason, duration, false);
354 } else if (active_workspace_ == desktop_workspace() && !app_terminating_) { 354 } else if (active_workspace_ == desktop_workspace() && !app_terminating_) {
355 ShowOrHideDesktopBackground(background, reason, duration, true); 355 ShowOrHideDesktopBackground(background, reason, duration, true);
356 } 356 }
357 } 357 }
358 } 358 }
359 359
360 WorkspaceManager2::Workspaces::iterator 360 WorkspaceManager::Workspaces::iterator
361 WorkspaceManager2::FindWorkspace(Workspace2* workspace) { 361 WorkspaceManager::FindWorkspace(Workspace* workspace) {
362 return std::find(workspaces_.begin(), workspaces_.end(), workspace); 362 return std::find(workspaces_.begin(), workspaces_.end(), workspace);
363 } 363 }
364 364
365 Workspace2* WorkspaceManager2::CreateWorkspace(bool maximized) { 365 Workspace* WorkspaceManager::CreateWorkspace(bool maximized) {
366 return new Workspace2(this, contents_view_, maximized); 366 return new Workspace(this, contents_view_, maximized);
367 } 367 }
368 368
369 void WorkspaceManager2::MoveWorkspaceToPendingOrDelete( 369 void WorkspaceManager::MoveWorkspaceToPendingOrDelete(
370 Workspace2* workspace, 370 Workspace* workspace,
371 Window* stack_beneath, 371 Window* stack_beneath,
372 SwitchReason reason) { 372 SwitchReason reason) {
373 // We're all ready moving windows. 373 // We're all ready moving windows.
374 if (in_move_) 374 if (in_move_)
375 return; 375 return;
376 376
377 DCHECK_NE(desktop_workspace(), workspace); 377 DCHECK_NE(desktop_workspace(), workspace);
378 378
379 if (workspace == active_workspace_) 379 if (workspace == active_workspace_)
380 SelectNextWorkspace(reason); 380 SelectNextWorkspace(reason);
(...skipping 11 matching lines...) Expand all
392 if (workspace->window()->children().empty()) { 392 if (workspace->window()->children().empty()) {
393 if (workspace == unminimizing_workspace_) 393 if (workspace == unminimizing_workspace_)
394 unminimizing_workspace_ = NULL; 394 unminimizing_workspace_ = NULL;
395 pending_workspaces_.erase(workspace); 395 pending_workspaces_.erase(workspace);
396 ScheduleDelete(workspace); 396 ScheduleDelete(workspace);
397 } else { 397 } else {
398 pending_workspaces_.insert(workspace); 398 pending_workspaces_.insert(workspace);
399 } 399 }
400 } 400 }
401 401
402 void WorkspaceManager2::MoveChildrenToDesktop(aura::Window* window, 402 void WorkspaceManager::MoveChildrenToDesktop(aura::Window* window,
403 aura::Window* stack_beneath) { 403 aura::Window* stack_beneath) {
404 // Build the list of windows to move. Exclude maximized/fullscreen and windows 404 // Build the list of windows to move. Exclude maximized/fullscreen and windows
405 // with transient parents. 405 // with transient parents.
406 Window::Windows to_move; 406 Window::Windows to_move;
407 for (size_t i = 0; i < window->children().size(); ++i) { 407 for (size_t i = 0; i < window->children().size(); ++i) {
408 Window* child = window->children()[i]; 408 Window* child = window->children()[i];
409 if (!child->transient_parent() && !IsMaximized(child) && 409 if (!child->transient_parent() && !IsMaximized(child) &&
410 !WillRestoreMaximized(child)) { 410 !WillRestoreMaximized(child)) {
411 to_move.push_back(child); 411 to_move.push_back(child);
412 } 412 }
413 } 413 }
414 // Move the windows, but make sure the window is still a child of |window| 414 // Move the windows, but make sure the window is still a child of |window|
415 // (moving may cascade and cause other windows to move). 415 // (moving may cascade and cause other windows to move).
416 for (size_t i = 0; i < to_move.size(); ++i) { 416 for (size_t i = 0; i < to_move.size(); ++i) {
417 if (std::find(window->children().begin(), window->children().end(), 417 if (std::find(window->children().begin(), window->children().end(),
418 to_move[i]) != window->children().end()) { 418 to_move[i]) != window->children().end()) {
419 ReparentWindow(to_move[i], desktop_workspace()->window(), 419 ReparentWindow(to_move[i], desktop_workspace()->window(),
420 stack_beneath); 420 stack_beneath);
421 } 421 }
422 } 422 }
423 } 423 }
424 424
425 void WorkspaceManager2::SelectNextWorkspace(SwitchReason reason) { 425 void WorkspaceManager::SelectNextWorkspace(SwitchReason reason) {
426 DCHECK_NE(active_workspace_, desktop_workspace()); 426 DCHECK_NE(active_workspace_, desktop_workspace());
427 427
428 Workspaces::const_iterator workspace_i(FindWorkspace(active_workspace_)); 428 Workspaces::const_iterator workspace_i(FindWorkspace(active_workspace_));
429 Workspaces::const_iterator next_workspace_i(workspace_i + 1); 429 Workspaces::const_iterator next_workspace_i(workspace_i + 1);
430 if (next_workspace_i != workspaces_.end()) 430 if (next_workspace_i != workspaces_.end())
431 SetActiveWorkspace(*next_workspace_i, reason, base::TimeDelta()); 431 SetActiveWorkspace(*next_workspace_i, reason, base::TimeDelta());
432 else 432 else
433 SetActiveWorkspace(*(workspace_i - 1), reason, base::TimeDelta()); 433 SetActiveWorkspace(*(workspace_i - 1), reason, base::TimeDelta());
434 } 434 }
435 435
436 void WorkspaceManager2::ScheduleDelete(Workspace2* workspace) { 436 void WorkspaceManager::ScheduleDelete(Workspace* workspace) {
437 to_delete_.insert(workspace); 437 to_delete_.insert(workspace);
438 delete_timer_.Stop(); 438 delete_timer_.Stop();
439 delete_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), this, 439 delete_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), this,
440 &WorkspaceManager2::ProcessDeletion); 440 &WorkspaceManager::ProcessDeletion);
441 } 441 }
442 442
443 void WorkspaceManager2::SetUnminimizingWorkspace(Workspace2* workspace) { 443 void WorkspaceManager::SetUnminimizingWorkspace(Workspace* workspace) {
444 // The normal sequence of unminimizing a window is: Show() the window, which 444 // The normal sequence of unminimizing a window is: Show() the window, which
445 // triggers changing the kShowStateKey to NORMAL and lastly the window is made 445 // triggers changing the kShowStateKey to NORMAL and lastly the window is made
446 // active. This means at the time the window is unminimized we don't know if 446 // active. This means at the time the window is unminimized we don't know if
447 // the workspace it is in is going to become active. To track this 447 // the workspace it is in is going to become active. To track this
448 // |unminimizing_workspace_| is set at the time we unminimize and a task is 448 // |unminimizing_workspace_| is set at the time we unminimize and a task is
449 // schedule to reset it. This way when we get the activate we know we're in 449 // schedule to reset it. This way when we get the activate we know we're in
450 // the process unminimizing and can do the right animation. 450 // the process unminimizing and can do the right animation.
451 unminimizing_workspace_ = workspace; 451 unminimizing_workspace_ = workspace;
452 if (unminimizing_workspace_) { 452 if (unminimizing_workspace_) {
453 MessageLoop::current()->PostTask( 453 MessageLoop::current()->PostTask(
454 FROM_HERE, 454 FROM_HERE,
455 base::Bind(&WorkspaceManager2::SetUnminimizingWorkspace, 455 base::Bind(&WorkspaceManager::SetUnminimizingWorkspace,
456 clear_unminimizing_workspace_factory_.GetWeakPtr(), 456 clear_unminimizing_workspace_factory_.GetWeakPtr(),
457 static_cast<Workspace2*>(NULL))); 457 static_cast<Workspace*>(NULL)));
458 } 458 }
459 } 459 }
460 460
461 void WorkspaceManager2::FadeDesktop(aura::Window* window, 461 void WorkspaceManager::FadeDesktop(aura::Window* window,
462 base::TimeDelta duration) { 462 base::TimeDelta duration) {
463 if (CommandLine::ForCurrentProcess()->HasSwitch( 463 if (CommandLine::ForCurrentProcess()->HasSwitch(
464 ash::switches::kAshWindowAnimationsDisabled) || 464 ash::switches::kAshWindowAnimationsDisabled) ||
465 ui::LayerAnimator::disable_animations_for_test()) 465 ui::LayerAnimator::disable_animations_for_test())
466 return; 466 return;
467 467
468 AutoReset<bool> reseter(&creating_fade_, true); 468 AutoReset<bool> reseter(&creating_fade_, true);
469 DesktopBackgroundFadeController::Direction direction; 469 DesktopBackgroundFadeController::Direction direction;
470 aura::Window* parent = NULL; 470 aura::Window* parent = NULL;
471 aura::Window* stack_above = NULL; 471 aura::Window* stack_above = NULL;
472 if (active_workspace_ == desktop_workspace()) { 472 if (active_workspace_ == desktop_workspace()) {
473 direction = DesktopBackgroundFadeController::FADE_IN; 473 direction = DesktopBackgroundFadeController::FADE_IN;
474 parent = desktop_workspace()->window(); 474 parent = desktop_workspace()->window();
475 stack_above = window; 475 stack_above = window;
476 } else { 476 } else {
477 direction = DesktopBackgroundFadeController::FADE_OUT; 477 direction = DesktopBackgroundFadeController::FADE_OUT;
478 parent = contents_view_; 478 parent = contents_view_;
479 stack_above = desktop_workspace()->window(); 479 stack_above = desktop_workspace()->window();
480 DCHECK_EQ(kCrossFadeSwitchTimeMS, (int)duration.InMilliseconds()); 480 DCHECK_EQ(kCrossFadeSwitchTimeMS, (int)duration.InMilliseconds());
481 duration = base::TimeDelta::FromMilliseconds(kCrossFadeSwitchTimeMS); 481 duration = base::TimeDelta::FromMilliseconds(kCrossFadeSwitchTimeMS);
482 } 482 }
483 desktop_fade_controller_.reset( 483 desktop_fade_controller_.reset(
484 new DesktopBackgroundFadeController( 484 new DesktopBackgroundFadeController(
485 parent, stack_above, duration, direction)); 485 parent, stack_above, duration, direction));
486 } 486 }
487 487
488 void WorkspaceManager2::ShowOrHideDesktopBackground( 488 void WorkspaceManager::ShowOrHideDesktopBackground(
489 aura::Window* window, 489 aura::Window* window,
490 SwitchReason reason, 490 SwitchReason reason,
491 base::TimeDelta duration, 491 base::TimeDelta duration,
492 bool show) const { 492 bool show) const {
493 WorkspaceAnimationDetails details; 493 WorkspaceAnimationDetails details;
494 details.animate = true; 494 details.animate = true;
495 details.direction = show ? WORKSPACE_ANIMATE_UP : WORKSPACE_ANIMATE_DOWN; 495 details.direction = show ? WORKSPACE_ANIMATE_UP : WORKSPACE_ANIMATE_DOWN;
496 details.animate_scale = reason != SWITCH_MAXIMIZED_OR_RESTORED; 496 details.animate_scale = reason != SWITCH_MAXIMIZED_OR_RESTORED;
497 details.duration = duration; 497 details.duration = duration;
498 if (reason == SWITCH_INITIAL) 498 if (reason == SWITCH_INITIAL)
499 details.pause_time_ms = kInitialPauseTimeMS; 499 details.pause_time_ms = kInitialPauseTimeMS;
500 if (show) 500 if (show)
501 ash::internal::ShowWorkspace(window, details); 501 ash::internal::ShowWorkspace(window, details);
502 else 502 else
503 ash::internal::HideWorkspace(window, details); 503 ash::internal::HideWorkspace(window, details);
504 } 504 }
505 505
506 void WorkspaceManager2::ShowWorkspace( 506 void WorkspaceManager::ShowWorkspace(
507 Workspace2* workspace, 507 Workspace* workspace,
508 Workspace2* last_active, 508 Workspace* last_active,
509 SwitchReason reason) const { 509 SwitchReason reason) const {
510 WorkspaceAnimationDetails details; 510 WorkspaceAnimationDetails details;
511 details.direction = 511 details.direction =
512 (last_active == desktop_workspace() || reason == SWITCH_INITIAL) ? 512 (last_active == desktop_workspace() || reason == SWITCH_INITIAL) ?
513 WORKSPACE_ANIMATE_DOWN : WORKSPACE_ANIMATE_UP; 513 WORKSPACE_ANIMATE_DOWN : WORKSPACE_ANIMATE_UP;
514 514
515 switch (reason) { 515 switch (reason) {
516 case SWITCH_WINDOW_MADE_ACTIVE: 516 case SWITCH_WINDOW_MADE_ACTIVE:
517 case SWITCH_TRACKED_BY_WORKSPACE_CHANGED: 517 case SWITCH_TRACKED_BY_WORKSPACE_CHANGED:
518 case SWITCH_WINDOW_REMOVED: 518 case SWITCH_WINDOW_REMOVED:
519 case SWITCH_VISIBILITY_CHANGED: 519 case SWITCH_VISIBILITY_CHANGED:
520 case SWITCH_MINIMIZED: 520 case SWITCH_MINIMIZED:
521 details.animate = details.animate_scale = true; 521 details.animate = details.animate_scale = true;
522 details.animate_opacity = last_active == desktop_workspace(); 522 details.animate_opacity = last_active == desktop_workspace();
523 break; 523 break;
524 524
525 case SWITCH_INITIAL: 525 case SWITCH_INITIAL:
526 details.animate = details.animate_opacity = details.animate_scale = true; 526 details.animate = details.animate_opacity = details.animate_scale = true;
527 details.pause_time_ms = kInitialPauseTimeMS; 527 details.pause_time_ms = kInitialPauseTimeMS;
528 break; 528 break;
529 529
530 // Remaining cases require no animation. 530 // Remaining cases require no animation.
531 default: 531 default:
532 break; 532 break;
533 } 533 }
534 ash::internal::ShowWorkspace(workspace->window(), details); 534 ash::internal::ShowWorkspace(workspace->window(), details);
535 } 535 }
536 536
537 void WorkspaceManager2::HideWorkspace( 537 void WorkspaceManager::HideWorkspace(
538 Workspace2* workspace, 538 Workspace* workspace,
539 SwitchReason reason, 539 SwitchReason reason,
540 bool is_unminimizing_maximized_window) const { 540 bool is_unminimizing_maximized_window) const {
541 WorkspaceAnimationDetails details; 541 WorkspaceAnimationDetails details;
542 details.direction = active_workspace_ == desktop_workspace() ? 542 details.direction = active_workspace_ == desktop_workspace() ?
543 WORKSPACE_ANIMATE_UP : WORKSPACE_ANIMATE_DOWN; 543 WORKSPACE_ANIMATE_UP : WORKSPACE_ANIMATE_DOWN;
544 switch (reason) { 544 switch (reason) {
545 case SWITCH_WINDOW_MADE_ACTIVE: 545 case SWITCH_WINDOW_MADE_ACTIVE:
546 case SWITCH_TRACKED_BY_WORKSPACE_CHANGED: 546 case SWITCH_TRACKED_BY_WORKSPACE_CHANGED:
547 details.animate_opacity = 547 details.animate_opacity =
548 ((active_workspace_ == desktop_workspace() || 548 ((active_workspace_ == desktop_workspace() ||
(...skipping 12 matching lines...) Expand all
561 } 561 }
562 break; 562 break;
563 563
564 // Remaining cases require no animation. 564 // Remaining cases require no animation.
565 default: 565 default:
566 break; 566 break;
567 } 567 }
568 ash::internal::HideWorkspace(workspace->window(), details); 568 ash::internal::HideWorkspace(workspace->window(), details);
569 } 569 }
570 570
571 void WorkspaceManager2::ProcessDeletion() { 571 void WorkspaceManager::ProcessDeletion() {
572 std::set<Workspace2*> to_delete; 572 std::set<Workspace*> to_delete;
573 to_delete.swap(to_delete_); 573 to_delete.swap(to_delete_);
574 for (std::set<Workspace2*>::iterator i = to_delete.begin(); 574 for (std::set<Workspace*>::iterator i = to_delete.begin();
575 i != to_delete.end(); ++i) { 575 i != to_delete.end(); ++i) {
576 Workspace2* workspace = *i; 576 Workspace* workspace = *i;
577 if (workspace->window()->layer()->children().empty()) { 577 if (workspace->window()->layer()->children().empty()) {
578 delete workspace->ReleaseWindow(); 578 delete workspace->ReleaseWindow();
579 delete workspace; 579 delete workspace;
580 } else { 580 } else {
581 to_delete_.insert(workspace); 581 to_delete_.insert(workspace);
582 } 582 }
583 } 583 }
584 if (!to_delete_.empty()) { 584 if (!to_delete_.empty()) {
585 delete_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), this, 585 delete_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), this,
586 &WorkspaceManager2::ProcessDeletion); 586 &WorkspaceManager::ProcessDeletion);
587 } 587 }
588 } 588 }
589 589
590 void WorkspaceManager2::OnWindowAddedToWorkspace(Workspace2* workspace, 590 void WorkspaceManager::OnWindowAddedToWorkspace(Workspace* workspace,
591 Window* child) { 591 Window* child) {
592 child->SetProperty(kWorkspaceKey, workspace); 592 child->SetProperty(kWorkspaceKey, workspace);
593 // Do nothing (other than updating shelf visibility) as the right parent was 593 // Do nothing (other than updating shelf visibility) as the right parent was
594 // chosen by way of GetParentForNewWindow() or we explicitly moved the window 594 // chosen by way of GetParentForNewWindow() or we explicitly moved the window
595 // to the workspace. 595 // to the workspace.
596 if (workspace == active_workspace_) 596 if (workspace == active_workspace_)
597 UpdateShelfVisibility(); 597 UpdateShelfVisibility();
598 598
599 RearrangeVisibleWindowOnShow(child); 599 RearrangeVisibleWindowOnShow(child);
600 } 600 }
601 601
602 void WorkspaceManager2::OnWillRemoveWindowFromWorkspace(Workspace2* workspace, 602 void WorkspaceManager::OnWillRemoveWindowFromWorkspace(Workspace* workspace,
603 Window* child) { 603 Window* child) {
604 if (child->TargetVisibility()) 604 if (child->TargetVisibility())
605 RearrangeVisibleWindowOnHideOrRemove(child); 605 RearrangeVisibleWindowOnHideOrRemove(child);
606 child->ClearProperty(kWorkspaceKey); 606 child->ClearProperty(kWorkspaceKey);
607 } 607 }
608 608
609 void WorkspaceManager2::OnWindowRemovedFromWorkspace(Workspace2* workspace, 609 void WorkspaceManager::OnWindowRemovedFromWorkspace(Workspace* workspace,
610 Window* child) { 610 Window* child) {
611 if (workspace->ShouldMoveToPending()) 611 if (workspace->ShouldMoveToPending())
612 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_WINDOW_REMOVED); 612 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_WINDOW_REMOVED);
613 } 613 }
614 614
615 void WorkspaceManager2::OnWorkspaceChildWindowVisibilityChanged( 615 void WorkspaceManager::OnWorkspaceChildWindowVisibilityChanged(
616 Workspace2* workspace, 616 Workspace* workspace,
617 Window* child) { 617 Window* child) {
618 if (workspace->ShouldMoveToPending()) { 618 if (workspace->ShouldMoveToPending()) {
619 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_VISIBILITY_CHANGED); 619 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_VISIBILITY_CHANGED);
620 } else { 620 } else {
621 if (child->TargetVisibility()) 621 if (child->TargetVisibility())
622 RearrangeVisibleWindowOnShow(child); 622 RearrangeVisibleWindowOnShow(child);
623 else 623 else
624 RearrangeVisibleWindowOnHideOrRemove(child); 624 RearrangeVisibleWindowOnHideOrRemove(child);
625 if (workspace == active_workspace_) 625 if (workspace == active_workspace_)
626 UpdateShelfVisibility(); 626 UpdateShelfVisibility();
627 } 627 }
628 } 628 }
629 629
630 void WorkspaceManager2::OnWorkspaceWindowChildBoundsChanged( 630 void WorkspaceManager::OnWorkspaceWindowChildBoundsChanged(
631 Workspace2* workspace, 631 Workspace* workspace,
632 Window* child) { 632 Window* child) {
633 if (workspace == active_workspace_) 633 if (workspace == active_workspace_)
634 UpdateShelfVisibility(); 634 UpdateShelfVisibility();
635 } 635 }
636 636
637 void WorkspaceManager2::OnWorkspaceWindowShowStateChanged( 637 void WorkspaceManager::OnWorkspaceWindowShowStateChanged(
638 Workspace2* workspace, 638 Workspace* workspace,
639 Window* child, 639 Window* child,
640 ui::WindowShowState last_show_state, 640 ui::WindowShowState last_show_state,
641 ui::Layer* old_layer) { 641 ui::Layer* old_layer) {
642 // |child| better still be in |workspace| else things have gone wrong. 642 // |child| better still be in |workspace| else things have gone wrong.
643 DCHECK_EQ(workspace, child->GetProperty(kWorkspaceKey)); 643 DCHECK_EQ(workspace, child->GetProperty(kWorkspaceKey));
644 if (wm::IsWindowMinimized(child)) { 644 if (wm::IsWindowMinimized(child)) {
645 if (workspace->ShouldMoveToPending()) 645 if (workspace->ShouldMoveToPending())
646 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_MINIMIZED); 646 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_MINIMIZED);
647 DCHECK(!old_layer); 647 DCHECK(!old_layer);
648 } else { 648 } else {
649 // Set of cases to deal with: 649 // Set of cases to deal with:
650 // . More than one maximized window: move newly maximized window into 650 // . More than one maximized window: move newly maximized window into
651 // own workspace. 651 // own workspace.
652 // . One maximized window and not in a maximized workspace: move window 652 // . One maximized window and not in a maximized workspace: move window
653 // into own workspace. 653 // into own workspace.
654 // . No maximized window and not in desktop: move to desktop and further 654 // . No maximized window and not in desktop: move to desktop and further
655 // any existing windows are stacked beneath |child|. 655 // any existing windows are stacked beneath |child|.
656 const bool is_active = wm::IsActiveWindow(child); 656 const bool is_active = wm::IsActiveWindow(child);
657 Workspace2* new_workspace = NULL; 657 Workspace* new_workspace = NULL;
658 const int max_count = workspace->GetNumMaximizedWindows(); 658 const int max_count = workspace->GetNumMaximizedWindows();
659 base::TimeDelta duration = old_layer && !IsMaximized(child) ? 659 base::TimeDelta duration = old_layer && !IsMaximized(child) ?
660 GetCrossFadeDuration(old_layer->bounds(), child->bounds()) : 660 GetCrossFadeDuration(old_layer->bounds(), child->bounds()) :
661 base::TimeDelta::FromMilliseconds(kCrossFadeSwitchTimeMS); 661 base::TimeDelta::FromMilliseconds(kCrossFadeSwitchTimeMS);
662 if (max_count == 0) { 662 if (max_count == 0) {
663 if (workspace != desktop_workspace()) { 663 if (workspace != desktop_workspace()) {
664 { 664 {
665 AutoReset<bool> setter(&in_move_, true); 665 AutoReset<bool> setter(&in_move_, true);
666 ReparentWindow(child, desktop_workspace()->window(), NULL); 666 ReparentWindow(child, desktop_workspace()->window(), NULL);
667 } 667 }
668 DCHECK(!is_active || old_layer); 668 DCHECK(!is_active || old_layer);
669 new_workspace = desktop_workspace(); 669 new_workspace = desktop_workspace();
670 SetActiveWorkspace(new_workspace, SWITCH_MAXIMIZED_OR_RESTORED, 670 SetActiveWorkspace(new_workspace, SWITCH_MAXIMIZED_OR_RESTORED,
671 duration); 671 duration);
672 MoveWorkspaceToPendingOrDelete(workspace, child, 672 MoveWorkspaceToPendingOrDelete(workspace, child,
673 SWITCH_MAXIMIZED_OR_RESTORED); 673 SWITCH_MAXIMIZED_OR_RESTORED);
674 if (FindWorkspace(workspace) == workspaces_.end()) 674 if (FindWorkspace(workspace) == workspaces_.end())
675 workspace = NULL; 675 workspace = NULL;
676 } 676 }
677 } else if ((max_count == 1 && workspace == desktop_workspace()) || 677 } else if ((max_count == 1 && workspace == desktop_workspace()) ||
678 max_count > 1) { 678 max_count > 1) {
679 new_workspace = CreateWorkspace(true); 679 new_workspace = CreateWorkspace(true);
680 pending_workspaces_.insert(new_workspace); 680 pending_workspaces_.insert(new_workspace);
681 ReparentWindow(child, new_workspace->window(), NULL); 681 ReparentWindow(child, new_workspace->window(), NULL);
682 } 682 }
683 if (is_active && new_workspace) { 683 if (is_active && new_workspace) {
684 // |old_layer| may be NULL if as part of processing 684 // |old_layer| may be NULL if as part of processing
685 // WorkspaceLayoutManager2::OnWindowPropertyChanged() the window is made 685 // WorkspaceLayoutManager::OnWindowPropertyChanged() the window is made
686 // active. 686 // active.
687 if (old_layer) { 687 if (old_layer) {
688 SetActiveWorkspace(new_workspace, SWITCH_MAXIMIZED_OR_RESTORED, 688 SetActiveWorkspace(new_workspace, SWITCH_MAXIMIZED_OR_RESTORED,
689 duration); 689 duration);
690 CrossFadeWindowBetweenWorkspaces(new_workspace->window(), child, 690 CrossFadeWindowBetweenWorkspaces(new_workspace->window(), child,
691 old_layer); 691 old_layer);
692 if (workspace == desktop_workspace() || 692 if (workspace == desktop_workspace() ||
693 new_workspace == desktop_workspace()) { 693 new_workspace == desktop_workspace()) {
694 FadeDesktop(child, duration); 694 FadeDesktop(child, duration);
695 } 695 }
696 } else { 696 } else {
697 SetActiveWorkspace(new_workspace, SWITCH_OTHER, base::TimeDelta()); 697 SetActiveWorkspace(new_workspace, SWITCH_OTHER, base::TimeDelta());
698 } 698 }
699 } else { 699 } else {
700 if (last_show_state == ui::SHOW_STATE_MINIMIZED) 700 if (last_show_state == ui::SHOW_STATE_MINIMIZED)
701 SetUnminimizingWorkspace(new_workspace ? new_workspace : workspace); 701 SetUnminimizingWorkspace(new_workspace ? new_workspace : workspace);
702 DCHECK(!old_layer); 702 DCHECK(!old_layer);
703 } 703 }
704 } 704 }
705 UpdateShelfVisibility(); 705 UpdateShelfVisibility();
706 } 706 }
707 707
708 void WorkspaceManager2::OnTrackedByWorkspaceChanged(Workspace2* workspace, 708 void WorkspaceManager::OnTrackedByWorkspaceChanged(Workspace* workspace,
709 aura::Window* window) { 709 aura::Window* window) {
710 Workspace2* new_workspace = NULL; 710 Workspace* new_workspace = NULL;
711 if (IsMaximized(window)) { 711 if (IsMaximized(window)) {
712 new_workspace = CreateWorkspace(true); 712 new_workspace = CreateWorkspace(true);
713 pending_workspaces_.insert(new_workspace); 713 pending_workspaces_.insert(new_workspace);
714 } else if (workspace->is_maximized()) { 714 } else if (workspace->is_maximized()) {
715 new_workspace = desktop_workspace(); 715 new_workspace = desktop_workspace();
716 } else { 716 } else {
717 return; 717 return;
718 } 718 }
719 // If the window is active we need to make sure the destination Workspace 719 // If the window is active we need to make sure the destination Workspace
720 // window is showing. Otherwise the window will be parented to a hidden window 720 // window is showing. Otherwise the window will be parented to a hidden window
721 // and lose activation. 721 // and lose activation.
722 const bool is_active = wm::IsActiveWindow(window); 722 const bool is_active = wm::IsActiveWindow(window);
723 if (is_active) 723 if (is_active)
724 new_workspace->window()->Show(); 724 new_workspace->window()->Show();
725 ReparentWindow(window, new_workspace->window(), NULL); 725 ReparentWindow(window, new_workspace->window(), NULL);
726 if (is_active) { 726 if (is_active) {
727 SetActiveWorkspace(new_workspace, SWITCH_TRACKED_BY_WORKSPACE_CHANGED, 727 SetActiveWorkspace(new_workspace, SWITCH_TRACKED_BY_WORKSPACE_CHANGED,
728 base::TimeDelta()); 728 base::TimeDelta());
729 } 729 }
730 } 730 }
731 731
732 } // namespace internal 732 } // namespace internal
733 } // namespace ash 733 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_manager.h ('k') | ash/wm/workspace/workspace_manager2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698