OLD | NEW |
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_manager2.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
13 #include "ash/wm/base_layout_manager.h" | 13 #include "ash/wm/base_layout_manager.h" |
14 #include "ash/wm/property_util.h" | 14 #include "ash/wm/property_util.h" |
15 #include "ash/wm/shelf_layout_manager.h" | 15 #include "ash/wm/shelf_layout_manager.h" |
16 #include "ash/wm/window_animations.h" | 16 #include "ash/wm/window_animations.h" |
17 #include "ash/wm/window_properties.h" | 17 #include "ash/wm/window_properties.h" |
18 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
19 #include "ash/wm/workspace/system_background_controller.h" | |
20 #include "ash/wm/workspace/workspace_layout_manager2.h" | 19 #include "ash/wm/workspace/workspace_layout_manager2.h" |
21 #include "ash/wm/workspace/workspace2.h" | 20 #include "ash/wm/workspace/workspace2.h" |
22 #include "base/auto_reset.h" | 21 #include "base/auto_reset.h" |
23 #include "base/command_line.h" | 22 #include "base/command_line.h" |
24 #include "base/logging.h" | 23 #include "base/logging.h" |
25 #include "base/stl_util.h" | 24 #include "base/stl_util.h" |
26 #include "base/stringprintf.h" | 25 #include "base/stringprintf.h" |
27 #include "ui/aura/client/aura_constants.h" | 26 #include "ui/aura/client/aura_constants.h" |
28 #include "ui/aura/root_window.h" | 27 #include "ui/aura/root_window.h" |
29 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 // won't see the animation. | 323 // won't see the animation. |
325 contents_view_->StackChildAtTop(active_workspace_->window()); | 324 contents_view_->StackChildAtTop(active_workspace_->window()); |
326 } else if (active_workspace_->is_maximized() && last_active->is_maximized()) { | 325 } else if (active_workspace_->is_maximized() && last_active->is_maximized()) { |
327 // When switching between maximized windows we need the last active | 326 // When switching between maximized windows we need the last active |
328 // workspace on top of the new, otherwise the animations won't look | 327 // workspace on top of the new, otherwise the animations won't look |
329 // right. Since only one workspace is visible at a time stacking order of | 328 // right. Since only one workspace is visible at a time stacking order of |
330 // the workspace windows ultimately doesn't matter. | 329 // the workspace windows ultimately doesn't matter. |
331 contents_view_->StackChildAtTop(last_active->window()); | 330 contents_view_->StackChildAtTop(last_active->window()); |
332 } | 331 } |
333 | 332 |
334 destroy_background_timer_.Stop(); | |
335 if (active_workspace_ == desktop_workspace()) { | |
336 base::TimeDelta delay(GetSystemBackgroundDestroyDuration()); | |
337 if (ui::LayerAnimator::slow_animation_mode()) | |
338 delay *= ui::LayerAnimator::slow_animation_scale_factor(); | |
339 // Delay an extra 100ms to make sure everything settles down before | |
340 // destroying the background. | |
341 delay += base::TimeDelta::FromMilliseconds(100); | |
342 destroy_background_timer_.Start( | |
343 FROM_HERE, delay, this, &WorkspaceManager2::DestroySystemBackground); | |
344 } else if (!background_controller_.get()) { | |
345 background_controller_.reset(new SystemBackgroundController( | |
346 contents_view_->GetRootWindow())); | |
347 } | |
348 | |
349 UpdateShelfVisibility(); | 333 UpdateShelfVisibility(); |
350 | 334 |
351 if (animate_type != ANIMATE_NONE) { | 335 if (animate_type != ANIMATE_NONE) { |
352 AnimateBetweenWorkspaces( | 336 AnimateBetweenWorkspaces( |
353 last_active->window(), | 337 last_active->window(), |
354 WorkspaceType(last_active), | 338 WorkspaceType(last_active), |
355 (animate_type == ANIMATE_OLD_AND_NEW), | 339 (animate_type == ANIMATE_OLD_AND_NEW), |
356 workspace->window(), | 340 workspace->window(), |
357 WorkspaceType(workspace), | 341 WorkspaceType(workspace), |
358 is_unminimizing_maximized_window); | 342 is_unminimizing_maximized_window); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 SetActiveWorkspace(*(workspace_i - 1), animate_type); | 433 SetActiveWorkspace(*(workspace_i - 1), animate_type); |
450 } | 434 } |
451 | 435 |
452 void WorkspaceManager2::ScheduleDelete(Workspace2* workspace) { | 436 void WorkspaceManager2::ScheduleDelete(Workspace2* workspace) { |
453 to_delete_.insert(workspace); | 437 to_delete_.insert(workspace); |
454 delete_timer_.Stop(); | 438 delete_timer_.Stop(); |
455 delete_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), this, | 439 delete_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), this, |
456 &WorkspaceManager2::ProcessDeletion); | 440 &WorkspaceManager2::ProcessDeletion); |
457 } | 441 } |
458 | 442 |
459 void WorkspaceManager2::DestroySystemBackground() { | |
460 background_controller_.reset(); | |
461 } | |
462 | |
463 void WorkspaceManager2::SetUnminimizingWorkspace(Workspace2* workspace) { | 443 void WorkspaceManager2::SetUnminimizingWorkspace(Workspace2* workspace) { |
464 // 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 |
465 // 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 |
466 // 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 |
467 // 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 |
468 // |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 |
469 // 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 |
470 // the process unminimizing and can do the right animation. | 450 // the process unminimizing and can do the right animation. |
471 unminimizing_workspace_ = workspace; | 451 unminimizing_workspace_ = workspace; |
472 if (unminimizing_workspace_) { | 452 if (unminimizing_workspace_) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 const bool is_active = wm::IsActiveWindow(window); | 595 const bool is_active = wm::IsActiveWindow(window); |
616 if (is_active) | 596 if (is_active) |
617 new_workspace->window()->Show(); | 597 new_workspace->window()->Show(); |
618 ReparentWindow(window, new_workspace->window(), NULL); | 598 ReparentWindow(window, new_workspace->window(), NULL); |
619 if (is_active) | 599 if (is_active) |
620 SetActiveWorkspace(new_workspace, ANIMATE_OLD_AND_NEW); | 600 SetActiveWorkspace(new_workspace, ANIMATE_OLD_AND_NEW); |
621 } | 601 } |
622 | 602 |
623 } // namespace internal | 603 } // namespace internal |
624 } // namespace ash | 604 } // namespace ash |
OLD | NEW |