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

Side by Side Diff: ash/wm/dock/docked_window_layout_manager.cc

Issue 105673008: Remove unneeded ScopedLayerAnimationSettings::LockTransitionDuration() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/dock/docked_window_layout_manager.h" 5 #include "ash/wm/dock/docked_window_layout_manager.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shelf/shelf.h" 9 #include "ash/shelf/shelf.h"
10 #include "ash/shelf/shelf_constants.h" 10 #include "ash/shelf/shelf_constants.h"
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 if (is_dragged_window_docked_) 487 if (is_dragged_window_docked_)
488 OnDraggedWindowUndocked(); 488 OnDraggedWindowUndocked();
489 DCHECK (!is_dragged_window_docked_); 489 DCHECK (!is_dragged_window_docked_);
490 // Stop observing a window unless it is docked container's child in which 490 // Stop observing a window unless it is docked container's child in which
491 // case it needs to keep being observed after the drag completes. 491 // case it needs to keep being observed after the drag completes.
492 if (dragged_window_->parent() != dock_container_) { 492 if (dragged_window_->parent() != dock_container_) {
493 dragged_window_->RemoveObserver(this); 493 dragged_window_->RemoveObserver(this);
494 wm::GetWindowState(dragged_window_)->RemoveObserver(this); 494 wm::GetWindowState(dragged_window_)->RemoveObserver(this);
495 if (last_active_window_ == dragged_window_) 495 if (last_active_window_ == dragged_window_)
496 last_active_window_ = NULL; 496 last_active_window_ = NULL;
497
498 views::corewm::SetWindowShowAnimationDuration(dragged_window_,
499 base::TimeDelta());
497 } else { 500 } else {
498 // A window is no longer dragged and is a child. 501 // A window is no longer dragged and is a child.
499 // When a window becomes a child at drag start this is 502 // When a window becomes a child at drag start this is
500 // the only opportunity we will have to enforce a window 503 // the only opportunity we will have to enforce a window
501 // count limit so do it here. 504 // count limit so do it here.
502 MaybeMinimizeChildrenExcept(dragged_window_); 505 MaybeMinimizeChildrenExcept(dragged_window_);
506
507 views::corewm::SetWindowShowAnimationDuration(dragged_window_,
508 base::TimeDelta::FromMilliseconds(kFadeDurationMs));
503 } 509 }
504 dragged_window_ = NULL; 510 dragged_window_ = NULL;
505 dragged_bounds_ = gfx::Rect(); 511 dragged_bounds_ = gfx::Rect();
506 Relayout(); 512 Relayout();
507 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 513 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
508 RecordUmaAction(action, source); 514 RecordUmaAction(action, source);
509 } 515 }
510 516
511 void DockedWindowLayoutManager::SetShelf(Shelf* shelf) { 517 void DockedWindowLayoutManager::SetShelf(Shelf* shelf) {
512 DCHECK(!shelf_); 518 DCHECK(!shelf_);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // If this is the first window getting docked - update alignment. 632 // If this is the first window getting docked - update alignment.
627 if (alignment_ == DOCKED_ALIGNMENT_NONE) { 633 if (alignment_ == DOCKED_ALIGNMENT_NONE) {
628 alignment_ = GetAlignmentOfWindow(child); 634 alignment_ = GetAlignmentOfWindow(child);
629 DCHECK(alignment_ != DOCKED_ALIGNMENT_NONE); 635 DCHECK(alignment_ != DOCKED_ALIGNMENT_NONE);
630 } 636 }
631 MaybeMinimizeChildrenExcept(child); 637 MaybeMinimizeChildrenExcept(child);
632 child->AddObserver(this); 638 child->AddObserver(this);
633 wm::GetWindowState(child)->AddObserver(this); 639 wm::GetWindowState(child)->AddObserver(this);
634 Relayout(); 640 Relayout();
635 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 641 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
642 views::corewm::SetWindowShowAnimationDuration(child,
643 base::TimeDelta::FromMilliseconds(kFadeDurationMs));
636 } 644 }
637 645
638 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { 646 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
639 if (IsPopupOrTransient(child)) 647 if (IsPopupOrTransient(child))
640 return; 648 return;
641 // Dragged windows are stopped being observed by FinishDragging and do not 649 // Dragged windows are stopped being observed by FinishDragging and do not
642 // change alignment during the drag. They also cannot be set to be the 650 // change alignment during the drag. They also cannot be set to be the
643 // |last_active_window_|. 651 // |last_active_window_|.
644 if (child == dragged_window_) 652 if (child == dragged_window_)
645 return; 653 return;
646 // If this is the last window, set alignment and maximize the workspace. 654 // If this is the last window, set alignment and maximize the workspace.
647 if (!IsAnyWindowDocked()) { 655 if (!IsAnyWindowDocked()) {
648 alignment_ = DOCKED_ALIGNMENT_NONE; 656 alignment_ = DOCKED_ALIGNMENT_NONE;
649 UpdateDockedWidth(0); 657 UpdateDockedWidth(0);
650 } 658 }
651 if (last_active_window_ == child) 659 if (last_active_window_ == child)
652 last_active_window_ = NULL; 660 last_active_window_ = NULL;
653 child->RemoveObserver(this); 661 child->RemoveObserver(this);
654 wm::GetWindowState(child)->RemoveObserver(this); 662 wm::GetWindowState(child)->RemoveObserver(this);
655 Relayout(); 663 Relayout();
656 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 664 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
665 views::corewm::SetWindowShowAnimationDuration(child, base::TimeDelta());
657 } 666 }
658 667
659 void DockedWindowLayoutManager::OnChildWindowVisibilityChanged( 668 void DockedWindowLayoutManager::OnChildWindowVisibilityChanged(
660 aura::Window* child, 669 aura::Window* child,
661 bool visible) { 670 bool visible) {
662 if (IsPopupOrTransient(child)) 671 if (IsPopupOrTransient(child))
663 return; 672 return;
664 if (visible) 673 if (visible)
665 wm::GetWindowState(child)->Restore(); 674 wm::GetWindowState(child)->Restore();
666 Relayout(); 675 Relayout();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 794
786 void DockedWindowLayoutManager::OnWindowBoundsChanged( 795 void DockedWindowLayoutManager::OnWindowBoundsChanged(
787 aura::Window* window, 796 aura::Window* window,
788 const gfx::Rect& old_bounds, 797 const gfx::Rect& old_bounds,
789 const gfx::Rect& new_bounds) { 798 const gfx::Rect& new_bounds) {
790 // Only relayout if the dragged window would get docked. 799 // Only relayout if the dragged window would get docked.
791 if (window == dragged_window_ && is_dragged_window_docked_) 800 if (window == dragged_window_ && is_dragged_window_docked_)
792 Relayout(); 801 Relayout();
793 } 802 }
794 803
795 void DockedWindowLayoutManager::OnWindowVisibilityChanging(
796 aura::Window* window, bool visible) {
797 if (IsPopupOrTransient(window))
798 return;
799 int animation_type = views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT;
800 if (visible) {
801 animation_type = views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DROP;
802 views::corewm::SetWindowVisibilityAnimationDuration(
803 window, base::TimeDelta::FromMilliseconds(kFadeDurationMs));
804 } else if (wm::GetWindowState(window)->IsMinimized()) {
805 animation_type = WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE;
806 }
807 views::corewm::SetWindowVisibilityAnimationType(window, animation_type);
808 }
809
810 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) { 804 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) {
811 if (dragged_window_ == window) { 805 if (dragged_window_ == window) {
812 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN); 806 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN);
813 DCHECK(!dragged_window_); 807 DCHECK(!dragged_window_);
814 DCHECK (!is_dragged_window_docked_); 808 DCHECK (!is_dragged_window_docked_);
815 } 809 }
816 if (window == last_active_window_) 810 if (window == last_active_window_)
817 last_active_window_ = NULL; 811 last_active_window_ = NULL;
818 RecordUmaAction(DOCKED_ACTION_CLOSE, DOCKED_ACTION_SOURCE_UNKNOWN); 812 RecordUmaAction(DOCKED_ACTION_CLOSE, DOCKED_ACTION_SOURCE_UNKNOWN);
819 } 813 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 aura::Window::Windows children(dock_container_->children()); 849 aura::Window::Windows children(dock_container_->children());
856 aura::Window::Windows::const_reverse_iterator iter = children.rbegin(); 850 aura::Window::Windows::const_reverse_iterator iter = children.rbegin();
857 while (iter != children.rend()) { 851 while (iter != children.rend()) {
858 aura::Window* window(*iter++); 852 aura::Window* window(*iter++);
859 if (window == child || !IsUsedByLayout(window)) 853 if (window == child || !IsUsedByLayout(window))
860 continue; 854 continue;
861 int room_needed = GetWindowHeightCloseTo(window, 0) + kMinDockGap; 855 int room_needed = GetWindowHeightCloseTo(window, 0) + kMinDockGap;
862 if (available_room > room_needed) { 856 if (available_room > room_needed) {
863 available_room -= room_needed; 857 available_room -= room_needed;
864 } else { 858 } else {
865 // Slow down minimizing animations. Lock duration so that it is not 859 // Slow down the minimize animation.
866 // overridden by other ScopedLayerAnimationSettings down the stack. 860 views::corewm::SetWindowHideAnimationDuration(
867 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 861 window,
868 settings.SetTransitionDuration(
869 base::TimeDelta::FromMilliseconds(kMinimizeDurationMs)); 862 base::TimeDelta::FromMilliseconds(kMinimizeDurationMs));
870 settings.LockTransitionDuration();
871 wm::GetWindowState(window)->Minimize(); 863 wm::GetWindowState(window)->Minimize();
864 views::corewm::SetWindowHideAnimationDuration(window, base::TimeDelta());
872 } 865 }
873 } 866 }
874 } 867 }
875 868
876 void DockedWindowLayoutManager::MinimizeDockedWindow( 869 void DockedWindowLayoutManager::MinimizeDockedWindow(
877 wm::WindowState* window_state) { 870 wm::WindowState* window_state) {
878 DCHECK(!IsPopupOrTransient(window_state->window())); 871 aura::Window* window = window_state->window();
879 window_state->window()->Hide(); 872 DCHECK(!IsPopupOrTransient(window));
873 views::corewm::SetWindowVisibilityAnimationType(window,
874 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
875 window->Hide();
876 views::corewm::SetWindowVisibilityAnimationType(window,
877 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
880 if (window_state->IsActive()) 878 if (window_state->IsActive())
881 window_state->Deactivate(); 879 window_state->Deactivate();
882 RecordUmaAction(DOCKED_ACTION_MINIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); 880 RecordUmaAction(DOCKED_ACTION_MINIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN);
883 } 881 }
884 882
885 void DockedWindowLayoutManager::RestoreDockedWindow( 883 void DockedWindowLayoutManager::RestoreDockedWindow(
886 wm::WindowState* window_state) { 884 wm::WindowState* window_state) {
887 aura::Window* window = window_state->window(); 885 aura::Window* window = window_state->window();
888 DCHECK(!IsPopupOrTransient(window)); 886 DCHECK(!IsPopupOrTransient(window));
889 // Always place restored window at the bottom shuffling the other windows up. 887 // Always place restored window at the bottom shuffling the other windows up.
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1267 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1270 const gfx::Rect& keyboard_bounds) { 1268 const gfx::Rect& keyboard_bounds) {
1271 // This bounds change will have caused a change to the Shelf which does not 1269 // This bounds change will have caused a change to the Shelf which does not
1272 // propagate automatically to this class, so manually recalculate bounds. 1270 // propagate automatically to this class, so manually recalculate bounds.
1273 Relayout(); 1271 Relayout();
1274 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1272 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1275 } 1273 }
1276 1274
1277 } // namespace internal 1275 } // namespace internal
1278 } // namespace ash 1276 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698