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

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
« no previous file with comments | « ash/wm/dock/docked_window_layout_manager.h ('k') | ash/wm/window_animations.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) 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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 if (is_dragged_window_docked_) 507 if (is_dragged_window_docked_)
508 OnDraggedWindowUndocked(); 508 OnDraggedWindowUndocked();
509 DCHECK (!is_dragged_window_docked_); 509 DCHECK (!is_dragged_window_docked_);
510 // Stop observing a window unless it is docked container's child in which 510 // Stop observing a window unless it is docked container's child in which
511 // case it needs to keep being observed after the drag completes. 511 // case it needs to keep being observed after the drag completes.
512 if (dragged_window_->parent() != dock_container_) { 512 if (dragged_window_->parent() != dock_container_) {
513 dragged_window_->RemoveObserver(this); 513 dragged_window_->RemoveObserver(this);
514 wm::GetWindowState(dragged_window_)->RemoveObserver(this); 514 wm::GetWindowState(dragged_window_)->RemoveObserver(this);
515 if (last_active_window_ == dragged_window_) 515 if (last_active_window_ == dragged_window_)
516 last_active_window_ = NULL; 516 last_active_window_ = NULL;
517
518 views::corewm::SetWindowShowAnimationDuration(dragged_window_,
519 base::TimeDelta());
517 } else { 520 } else {
518 // A window is no longer dragged and is a child. 521 // A window is no longer dragged and is a child.
519 // When a window becomes a child at drag start this is 522 // When a window becomes a child at drag start this is
520 // the only opportunity we will have to enforce a window 523 // the only opportunity we will have to enforce a window
521 // count limit so do it here. 524 // count limit so do it here.
522 MaybeMinimizeChildrenExcept(dragged_window_); 525 MaybeMinimizeChildrenExcept(dragged_window_);
526
527 views::corewm::SetWindowShowAnimationDuration(dragged_window_,
528 base::TimeDelta::FromMilliseconds(kFadeDurationMs));
523 } 529 }
524 dragged_window_ = NULL; 530 dragged_window_ = NULL;
525 dragged_bounds_ = gfx::Rect(); 531 dragged_bounds_ = gfx::Rect();
526 Relayout(); 532 Relayout();
527 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 533 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
528 RecordUmaAction(action, source); 534 RecordUmaAction(action, source);
529 } 535 }
530 536
531 void DockedWindowLayoutManager::SetShelf(Shelf* shelf) { 537 void DockedWindowLayoutManager::SetShelf(Shelf* shelf) {
532 DCHECK(!shelf_); 538 DCHECK(!shelf_);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 // change, so the the alignment may not be valid. 657 // change, so the the alignment may not be valid.
652 if (alignment_ == DOCKED_ALIGNMENT_NONE) { 658 if (alignment_ == DOCKED_ALIGNMENT_NONE) {
653 alignment_ = GetAlignmentOfWindow(child); 659 alignment_ = GetAlignmentOfWindow(child);
654 DCHECK(alignment_ != DOCKED_ALIGNMENT_NONE); 660 DCHECK(alignment_ != DOCKED_ALIGNMENT_NONE);
655 } 661 }
656 MaybeMinimizeChildrenExcept(child); 662 MaybeMinimizeChildrenExcept(child);
657 child->AddObserver(this); 663 child->AddObserver(this);
658 wm::GetWindowState(child)->AddObserver(this); 664 wm::GetWindowState(child)->AddObserver(this);
659 Relayout(); 665 Relayout();
660 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 666 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
667 views::corewm::SetWindowShowAnimationDuration(child,
668 base::TimeDelta::FromMilliseconds(kFadeDurationMs));
661 } 669 }
662 670
663 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { 671 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
664 if (IsPopupOrTransient(child)) 672 if (IsPopupOrTransient(child))
665 return; 673 return;
666 // Dragged windows are stopped being observed by FinishDragging and do not 674 // Dragged windows are stopped being observed by FinishDragging and do not
667 // change alignment during the drag. They also cannot be set to be the 675 // change alignment during the drag. They also cannot be set to be the
668 // |last_active_window_|. 676 // |last_active_window_|.
669 if (child == dragged_window_) 677 if (child == dragged_window_)
670 return; 678 return;
671 // If this is the last window, set alignment and maximize the workspace. 679 // If this is the last window, set alignment and maximize the workspace.
672 if (!IsAnyWindowDocked()) { 680 if (!IsAnyWindowDocked()) {
673 alignment_ = DOCKED_ALIGNMENT_NONE; 681 alignment_ = DOCKED_ALIGNMENT_NONE;
674 UpdateDockedWidth(0); 682 UpdateDockedWidth(0);
675 } 683 }
676 if (last_active_window_ == child) 684 if (last_active_window_ == child)
677 last_active_window_ = NULL; 685 last_active_window_ = NULL;
678 child->RemoveObserver(this); 686 child->RemoveObserver(this);
679 wm::GetWindowState(child)->RemoveObserver(this); 687 wm::GetWindowState(child)->RemoveObserver(this);
680 Relayout(); 688 Relayout();
681 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 689 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
690 views::corewm::SetWindowShowAnimationDuration(child, base::TimeDelta());
682 } 691 }
683 692
684 void DockedWindowLayoutManager::OnChildWindowVisibilityChanged( 693 void DockedWindowLayoutManager::OnChildWindowVisibilityChanged(
685 aura::Window* child, 694 aura::Window* child,
686 bool visible) { 695 bool visible) {
687 if (IsPopupOrTransient(child)) 696 if (IsPopupOrTransient(child))
688 return; 697 return;
689 if (visible) 698 if (visible)
690 wm::GetWindowState(child)->Restore(); 699 wm::GetWindowState(child)->Restore();
691 Relayout(); 700 Relayout();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 819
811 void DockedWindowLayoutManager::OnWindowBoundsChanged( 820 void DockedWindowLayoutManager::OnWindowBoundsChanged(
812 aura::Window* window, 821 aura::Window* window,
813 const gfx::Rect& old_bounds, 822 const gfx::Rect& old_bounds,
814 const gfx::Rect& new_bounds) { 823 const gfx::Rect& new_bounds) {
815 // Only relayout if the dragged window would get docked. 824 // Only relayout if the dragged window would get docked.
816 if (window == dragged_window_ && is_dragged_window_docked_) 825 if (window == dragged_window_ && is_dragged_window_docked_)
817 Relayout(); 826 Relayout();
818 } 827 }
819 828
820 void DockedWindowLayoutManager::OnWindowVisibilityChanging(
821 aura::Window* window, bool visible) {
822 if (IsPopupOrTransient(window))
823 return;
824 int animation_type = views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT;
825 if (visible) {
826 animation_type = views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DROP;
827 views::corewm::SetWindowVisibilityAnimationDuration(
828 window, base::TimeDelta::FromMilliseconds(kFadeDurationMs));
829 } else if (wm::GetWindowState(window)->IsMinimized()) {
830 animation_type = WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE;
831 }
832 views::corewm::SetWindowVisibilityAnimationType(window, animation_type);
833 }
834
835 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) { 829 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) {
836 if (dragged_window_ == window) { 830 if (dragged_window_ == window) {
837 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN); 831 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN);
838 DCHECK(!dragged_window_); 832 DCHECK(!dragged_window_);
839 DCHECK (!is_dragged_window_docked_); 833 DCHECK (!is_dragged_window_docked_);
840 } 834 }
841 if (window == last_active_window_) 835 if (window == last_active_window_)
842 last_active_window_ = NULL; 836 last_active_window_ = NULL;
843 RecordUmaAction(DOCKED_ACTION_CLOSE, DOCKED_ACTION_SOURCE_UNKNOWN); 837 RecordUmaAction(DOCKED_ACTION_CLOSE, DOCKED_ACTION_SOURCE_UNKNOWN);
844 } 838 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 while (iter != children.rend()) { 877 while (iter != children.rend()) {
884 aura::Window* window(*iter++); 878 aura::Window* window(*iter++);
885 if (window == child || !IsUsedByLayout(window)) 879 if (window == child || !IsUsedByLayout(window))
886 continue; 880 continue;
887 int room_needed = GetWindowHeightCloseTo(window, 0) + 881 int room_needed = GetWindowHeightCloseTo(window, 0) +
888 (gap_needed ? kMinDockGap : 0); 882 (gap_needed ? kMinDockGap : 0);
889 gap_needed = true; 883 gap_needed = true;
890 if (available_room > room_needed) { 884 if (available_room > room_needed) {
891 available_room -= room_needed; 885 available_room -= room_needed;
892 } else { 886 } else {
893 // Slow down minimizing animations. Lock duration so that it is not 887 // Slow down the minimize animation.
894 // overridden by other ScopedLayerAnimationSettings down the stack. 888 views::corewm::SetWindowHideAnimationDuration(
895 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 889 window,
896 settings.SetTransitionDuration(
897 base::TimeDelta::FromMilliseconds(kMinimizeDurationMs)); 890 base::TimeDelta::FromMilliseconds(kMinimizeDurationMs));
898 settings.LockTransitionDuration();
899 wm::GetWindowState(window)->Minimize(); 891 wm::GetWindowState(window)->Minimize();
892 views::corewm::SetWindowHideAnimationDuration(window, base::TimeDelta());
900 } 893 }
901 } 894 }
902 } 895 }
903 896
904 void DockedWindowLayoutManager::MinimizeDockedWindow( 897 void DockedWindowLayoutManager::MinimizeDockedWindow(
905 wm::WindowState* window_state) { 898 wm::WindowState* window_state) {
906 DCHECK(!IsPopupOrTransient(window_state->window())); 899 aura::Window* window = window_state->window();
907 window_state->window()->Hide(); 900 DCHECK(!IsPopupOrTransient(window));
901 views::corewm::SetWindowVisibilityAnimationType(window,
902 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
903 window->Hide();
904 views::corewm::SetWindowVisibilityAnimationType(window,
905 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
908 if (window_state->IsActive()) 906 if (window_state->IsActive())
909 window_state->Deactivate(); 907 window_state->Deactivate();
910 RecordUmaAction(DOCKED_ACTION_MINIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); 908 RecordUmaAction(DOCKED_ACTION_MINIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN);
911 } 909 }
912 910
913 void DockedWindowLayoutManager::RestoreDockedWindow( 911 void DockedWindowLayoutManager::RestoreDockedWindow(
914 wm::WindowState* window_state) { 912 wm::WindowState* window_state) {
915 aura::Window* window = window_state->window(); 913 aura::Window* window = window_state->window();
916 DCHECK(!IsPopupOrTransient(window)); 914 DCHECK(!IsPopupOrTransient(window));
917 // Always place restored window at the bottom shuffling the other windows up. 915 // Always place restored window at the bottom shuffling the other windows up.
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1297 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1300 const gfx::Rect& keyboard_bounds) { 1298 const gfx::Rect& keyboard_bounds) {
1301 // This bounds change will have caused a change to the Shelf which does not 1299 // This bounds change will have caused a change to the Shelf which does not
1302 // propagate automatically to this class, so manually recalculate bounds. 1300 // propagate automatically to this class, so manually recalculate bounds.
1303 Relayout(); 1301 Relayout();
1304 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1302 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1305 } 1303 }
1306 1304
1307 } // namespace internal 1305 } // namespace internal
1308 } // namespace ash 1306 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/dock/docked_window_layout_manager.h ('k') | ash/wm/window_animations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698