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_cycler_animator.h" | 5 #include "ash/wm/workspace/workspace_cycler_animator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "ash/launcher/launcher.h" | 10 #include "ash/launcher/launcher.h" |
11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
12 #include "ash/screen_ash.h" | 12 #include "ash/screen_ash.h" |
13 #include "ash/shell_window_ids.h" | 13 #include "ash/shell_window_ids.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_properties.h" |
16 #include "ash/wm/workspace/colored_window_controller.h" | 17 #include "ash/wm/workspace/colored_window_controller.h" |
17 #include "ash/wm/workspace/workspace.h" | 18 #include "ash/wm/workspace/workspace.h" |
18 #include "ash/wm/workspace/workspace_cycler_configuration.h" | 19 #include "ash/wm/workspace/workspace_cycler_configuration.h" |
19 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "ui/aura/root_window.h" |
20 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
21 #include "ui/base/events/event_utils.h" | 23 #include "ui/base/events/event_utils.h" |
22 #include "ui/compositor/layer_animator.h" | 24 #include "ui/compositor/layer_animator.h" |
23 #include "ui/compositor/scoped_layer_animation_settings.h" | 25 #include "ui/compositor/scoped_layer_animation_settings.h" |
24 #include "ui/gfx/transform_util.h" | 26 #include "ui/gfx/transform_util.h" |
25 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
26 | 28 |
27 typedef ash::WorkspaceCyclerConfiguration Config; | 29 typedef ash::WorkspaceCyclerConfiguration Config; |
28 | 30 |
29 namespace ash { | 31 namespace ash { |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 | 383 |
382 screen_bounds_ = ScreenAsh::GetDisplayBoundsInParent( | 384 screen_bounds_ = ScreenAsh::GetDisplayBoundsInParent( |
383 workspaces_[0]->window()); | 385 workspaces_[0]->window()); |
384 maximized_bounds_ = ScreenAsh::GetMaximizedWindowBoundsInParent( | 386 maximized_bounds_ = ScreenAsh::GetMaximizedWindowBoundsInParent( |
385 workspaces_[0]->window()); | 387 workspaces_[0]->window()); |
386 style_calculator_.reset(new StyleCalculator( | 388 style_calculator_.reset(new StyleCalculator( |
387 screen_bounds_, maximized_bounds_, workspaces_.size())); | 389 screen_bounds_, maximized_bounds_, workspaces_.size())); |
388 } | 390 } |
389 | 391 |
390 void WorkspaceCyclerAnimator::AnimateStartingCycler() { | 392 void WorkspaceCyclerAnimator::AnimateStartingCycler() { |
| 393 // Set kCyclingThroughWorkspaces so that the window frame is painted with the |
| 394 // correct style. |
| 395 workspaces_[0]->window()->GetRootWindow()->SetProperty( |
| 396 ash::internal::kCyclingThroughWorkspacesKey, true); |
| 397 |
391 // Ensure that the workspaces are stacked with respect to their order | 398 // Ensure that the workspaces are stacked with respect to their order |
392 // in |workspaces_|. | 399 // in |workspaces_|. |
393 aura::Window* parent = workspaces_[0]->window()->parent(); | 400 aura::Window* parent = workspaces_[0]->window()->parent(); |
394 DCHECK(parent); | 401 DCHECK(parent); |
395 for (size_t i = 0; i < workspaces_.size() - 1; ++i) { | 402 for (size_t i = 0; i < workspaces_.size() - 1; ++i) { |
396 parent->StackChildAbove(workspaces_[i + 1]->window(), | 403 parent->StackChildAbove(workspaces_[i + 1]->window(), |
397 workspaces_[i]->window()); | 404 workspaces_[i]->window()); |
398 } | 405 } |
399 | 406 |
400 // Set the initial transform and brightness of the workspaces such that they | 407 // Set the initial transform and brightness of the workspaces such that they |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 transform, brightness, visible); | 592 transform, brightness, visible); |
586 } | 593 } |
587 | 594 |
588 // All of the animations started by this method were of zero duration. | 595 // All of the animations started by this method were of zero duration. |
589 // Call the animation callback. | 596 // Call the animation callback. |
590 if (!animator_to_wait_for_selected) | 597 if (!animator_to_wait_for_selected) |
591 OnImplicitAnimationsCompleted(); | 598 OnImplicitAnimationsCompleted(); |
592 } | 599 } |
593 | 600 |
594 void WorkspaceCyclerAnimator::CyclerStopped(size_t visible_workspace_index) { | 601 void WorkspaceCyclerAnimator::CyclerStopped(size_t visible_workspace_index) { |
| 602 aura::Window* root_window = workspaces_[0]->window()->GetRootWindow(); |
| 603 root_window->SetProperty(ash::internal::kCyclingThroughWorkspacesKey, |
| 604 false); |
| 605 |
595 for(size_t i = 0; i < workspaces_.size(); ++i) { | 606 for(size_t i = 0; i < workspaces_.size(); ++i) { |
596 aura::Window* window = workspaces_[i]->window(); | 607 aura::Window* window = workspaces_[i]->window(); |
597 ui::Layer* layer = window->layer(); | 608 ui::Layer* layer = window->layer(); |
598 layer->SetLayerBrightness(0.0f); | 609 layer->SetLayerBrightness(0.0f); |
599 layer->SetTransform(gfx::Transform()); | 610 layer->SetTransform(gfx::Transform()); |
600 | 611 |
601 if (i == visible_workspace_index) | 612 if (i == visible_workspace_index) |
602 window->Show(); | 613 window->Show(); |
603 else | 614 else |
604 window->Hide(); | 615 window->Hide(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 MessageLoopForUI::current()->PostTask( | 728 MessageLoopForUI::current()->PostTask( |
718 FROM_HERE, | 729 FROM_HERE, |
719 base::Bind(&WorkspaceCyclerAnimator::NotifyDelegate, | 730 base::Bind(&WorkspaceCyclerAnimator::NotifyDelegate, |
720 AsWeakPtr(), | 731 AsWeakPtr(), |
721 completed_animation)); | 732 completed_animation)); |
722 } | 733 } |
723 } | 734 } |
724 | 735 |
725 } // namespace internal | 736 } // namespace internal |
726 } // namespace ash | 737 } // namespace ash |
OLD | NEW |