OLD | NEW |
---|---|
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_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 views::Widget::InitParams params; | 142 views::Widget::InitParams params; |
143 params.type = views::Widget::InitParams::TYPE_POPUP; | 143 params.type = views::Widget::InitParams::TYPE_POPUP; |
144 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 144 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
145 params.can_activate = false; | 145 params.can_activate = false; |
146 params.keep_on_top = false; | 146 params.keep_on_top = false; |
147 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 147 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
148 params.parent = parent; | 148 params.parent = parent; |
149 params.accept_events = false; | 149 params.accept_events = false; |
150 set_focus_on_creation(false); | 150 set_focus_on_creation(false); |
151 Init(params); | 151 Init(params); |
152 SetVisibilityChangedAnimationsEnabled(false); | |
152 GetNativeWindow()->SetProperty(internal::kStayInSameRootWindowKey, true); | 153 GetNativeWindow()->SetProperty(internal::kStayInSameRootWindowKey, true); |
153 opaque_background_.SetColor(SK_ColorBLACK); | 154 opaque_background_.SetColor(SK_ColorBLACK); |
154 opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size())); | 155 opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size())); |
155 opaque_background_.SetOpacity(0.0f); | 156 opaque_background_.SetOpacity(0.0f); |
156 GetNativeWindow()->layer()->Add(&opaque_background_); | 157 GetNativeWindow()->layer()->Add(&opaque_background_); |
157 Hide(); | 158 Hide(); |
158 | 159 |
159 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 160 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
160 gfx::ImageSkia shelf_background = | 161 gfx::ImageSkia shelf_background = |
161 *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_BACKGROUND); | 162 *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_BACKGROUND); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 if (is_dragged_window_docked_) | 457 if (is_dragged_window_docked_) |
457 OnDraggedWindowUndocked(); | 458 OnDraggedWindowUndocked(); |
458 DCHECK (!is_dragged_window_docked_); | 459 DCHECK (!is_dragged_window_docked_); |
459 // Stop observing a window unless it is docked container's child in which | 460 // Stop observing a window unless it is docked container's child in which |
460 // case it needs to keep being observed after the drag completes. | 461 // case it needs to keep being observed after the drag completes. |
461 if (dragged_window_->parent() != dock_container_) { | 462 if (dragged_window_->parent() != dock_container_) { |
462 dragged_window_->RemoveObserver(this); | 463 dragged_window_->RemoveObserver(this); |
463 wm::GetWindowState(dragged_window_)->RemoveObserver(this); | 464 wm::GetWindowState(dragged_window_)->RemoveObserver(this); |
464 if (last_active_window_ == dragged_window_) | 465 if (last_active_window_ == dragged_window_) |
465 last_active_window_ = NULL; | 466 last_active_window_ = NULL; |
467 | |
468 views::corewm::SetWindowShowAnimationDuration(dragged_window_, | |
469 base::TimeDelta()); | |
466 } else { | 470 } else { |
467 // A window is no longer dragged and is a child. | 471 // A window is no longer dragged and is a child. |
468 // When a window becomes a child at drag start this is | 472 // When a window becomes a child at drag start this is |
469 // the only opportunity we will have to enforce a window | 473 // the only opportunity we will have to enforce a window |
470 // count limit so do it here. | 474 // count limit so do it here. |
471 MaybeMinimizeChildrenExcept(dragged_window_); | 475 MaybeMinimizeChildrenExcept(dragged_window_); |
476 | |
477 views::corewm::SetWindowShowAnimationDuration(dragged_window_, | |
478 base::TimeDelta::FromMilliseconds(kFadeDurationMs)); | |
472 } | 479 } |
473 dragged_window_ = NULL; | 480 dragged_window_ = NULL; |
474 dragged_bounds_ = gfx::Rect(); | 481 dragged_bounds_ = gfx::Rect(); |
475 Relayout(); | 482 Relayout(); |
476 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 483 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
477 RecordUmaAction(action, source); | 484 RecordUmaAction(action, source); |
478 } | 485 } |
479 | 486 |
480 void DockedWindowLayoutManager::SetShelf(Shelf* shelf) { | 487 void DockedWindowLayoutManager::SetShelf(Shelf* shelf) { |
481 DCHECK(!shelf_); | 488 DCHECK(!shelf_); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 // If this is the first window getting docked - update alignment. | 602 // If this is the first window getting docked - update alignment. |
596 if (alignment_ == DOCKED_ALIGNMENT_NONE) { | 603 if (alignment_ == DOCKED_ALIGNMENT_NONE) { |
597 alignment_ = GetAlignmentOfWindow(child); | 604 alignment_ = GetAlignmentOfWindow(child); |
598 DCHECK(alignment_ != DOCKED_ALIGNMENT_NONE); | 605 DCHECK(alignment_ != DOCKED_ALIGNMENT_NONE); |
599 } | 606 } |
600 MaybeMinimizeChildrenExcept(child); | 607 MaybeMinimizeChildrenExcept(child); |
601 child->AddObserver(this); | 608 child->AddObserver(this); |
602 wm::GetWindowState(child)->AddObserver(this); | 609 wm::GetWindowState(child)->AddObserver(this); |
603 Relayout(); | 610 Relayout(); |
604 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 611 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
612 views::corewm::SetWindowShowAnimationDuration(child, | |
613 base::TimeDelta::FromMilliseconds(kFadeDurationMs)); | |
605 } | 614 } |
606 | 615 |
607 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { | 616 void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { |
608 if (IsPopupOrTransient(child)) | 617 if (IsPopupOrTransient(child)) |
609 return; | 618 return; |
610 // Dragged windows are stopped being observed by FinishDragging and do not | 619 // Dragged windows are stopped being observed by FinishDragging and do not |
611 // change alignment during the drag. They also cannot be set to be the | 620 // change alignment during the drag. They also cannot be set to be the |
612 // |last_active_window_|. | 621 // |last_active_window_|. |
613 if (child == dragged_window_) | 622 if (child == dragged_window_) |
614 return; | 623 return; |
615 // If this is the last window, set alignment and maximize the workspace. | 624 // If this is the last window, set alignment and maximize the workspace. |
616 if (!IsAnyWindowDocked()) { | 625 if (!IsAnyWindowDocked()) { |
617 alignment_ = DOCKED_ALIGNMENT_NONE; | 626 alignment_ = DOCKED_ALIGNMENT_NONE; |
618 UpdateDockedWidth(0); | 627 UpdateDockedWidth(0); |
619 } | 628 } |
620 if (last_active_window_ == child) | 629 if (last_active_window_ == child) |
621 last_active_window_ = NULL; | 630 last_active_window_ = NULL; |
622 child->RemoveObserver(this); | 631 child->RemoveObserver(this); |
623 wm::GetWindowState(child)->RemoveObserver(this); | 632 wm::GetWindowState(child)->RemoveObserver(this); |
624 Relayout(); | 633 Relayout(); |
625 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 634 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
635 views::corewm::SetWindowShowAnimationDuration(child, base::TimeDelta()); | |
626 } | 636 } |
627 | 637 |
628 void DockedWindowLayoutManager::OnChildWindowVisibilityChanged( | 638 void DockedWindowLayoutManager::OnChildWindowVisibilityChanged( |
629 aura::Window* child, | 639 aura::Window* child, |
630 bool visible) { | 640 bool visible) { |
631 if (IsPopupOrTransient(child)) | 641 if (IsPopupOrTransient(child)) |
632 return; | 642 return; |
633 if (visible) | 643 if (visible) |
634 wm::GetWindowState(child)->Restore(); | 644 wm::GetWindowState(child)->Restore(); |
635 Relayout(); | 645 Relayout(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 | 764 |
755 void DockedWindowLayoutManager::OnWindowBoundsChanged( | 765 void DockedWindowLayoutManager::OnWindowBoundsChanged( |
756 aura::Window* window, | 766 aura::Window* window, |
757 const gfx::Rect& old_bounds, | 767 const gfx::Rect& old_bounds, |
758 const gfx::Rect& new_bounds) { | 768 const gfx::Rect& new_bounds) { |
759 // Only relayout if the dragged window would get docked. | 769 // Only relayout if the dragged window would get docked. |
760 if (window == dragged_window_ && is_dragged_window_docked_) | 770 if (window == dragged_window_ && is_dragged_window_docked_) |
761 Relayout(); | 771 Relayout(); |
762 } | 772 } |
763 | 773 |
764 void DockedWindowLayoutManager::OnWindowVisibilityChanging( | |
765 aura::Window* window, bool visible) { | |
766 if (IsPopupOrTransient(window)) | |
767 return; | |
768 int animation_type = views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT; | |
769 if (visible) { | |
770 animation_type = views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DROP; | |
pkotwicz
2013/12/23 01:12:06
WINDOW_VISIBILITY_ANIMATION_TYPE_DROP is the defau
| |
771 views::corewm::SetWindowVisibilityAnimationDuration( | |
772 window, base::TimeDelta::FromMilliseconds(kFadeDurationMs)); | |
773 } else if (wm::GetWindowState(window)->IsMinimized()) { | |
774 animation_type = WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE; | |
775 } | |
776 views::corewm::SetWindowVisibilityAnimationType(window, animation_type); | |
777 } | |
778 | |
779 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) { | 774 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) { |
780 if (dragged_window_ == window) { | 775 if (dragged_window_ == window) { |
781 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN); | 776 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN); |
782 DCHECK(!dragged_window_); | 777 DCHECK(!dragged_window_); |
783 DCHECK (!is_dragged_window_docked_); | 778 DCHECK (!is_dragged_window_docked_); |
784 } | 779 } |
785 if (window == last_active_window_) | 780 if (window == last_active_window_) |
786 last_active_window_ = NULL; | 781 last_active_window_ = NULL; |
787 RecordUmaAction(DOCKED_ACTION_CLOSE, DOCKED_ACTION_SOURCE_UNKNOWN); | 782 RecordUmaAction(DOCKED_ACTION_CLOSE, DOCKED_ACTION_SOURCE_UNKNOWN); |
788 } | 783 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
824 aura::Window::Windows children(dock_container_->children()); | 819 aura::Window::Windows children(dock_container_->children()); |
825 aura::Window::Windows::const_reverse_iterator iter = children.rbegin(); | 820 aura::Window::Windows::const_reverse_iterator iter = children.rbegin(); |
826 while (iter != children.rend()) { | 821 while (iter != children.rend()) { |
827 aura::Window* window(*iter++); | 822 aura::Window* window(*iter++); |
828 if (window == child || !IsUsedByLayout(window)) | 823 if (window == child || !IsUsedByLayout(window)) |
829 continue; | 824 continue; |
830 int room_needed = GetWindowHeightCloseTo(window, 0) + kMinDockGap; | 825 int room_needed = GetWindowHeightCloseTo(window, 0) + kMinDockGap; |
831 if (available_room > room_needed) { | 826 if (available_room > room_needed) { |
832 available_room -= room_needed; | 827 available_room -= room_needed; |
833 } else { | 828 } else { |
834 // Slow down minimizing animations. Lock duration so that it is not | 829 // Slow down the minimize animation. |
835 // overridden by other ScopedLayerAnimationSettings down the stack. | 830 views::corewm::SetWindowHideAnimationDuration( |
836 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 831 window, |
837 settings.SetTransitionDuration( | |
838 base::TimeDelta::FromMilliseconds(kMinimizeDurationMs)); | 832 base::TimeDelta::FromMilliseconds(kMinimizeDurationMs)); |
839 settings.LockTransitionDuration(); | |
840 wm::GetWindowState(window)->Minimize(); | 833 wm::GetWindowState(window)->Minimize(); |
834 views::corewm::SetWindowHideAnimationDuration(window, base::TimeDelta()); | |
841 } | 835 } |
842 } | 836 } |
843 } | 837 } |
844 | 838 |
845 void DockedWindowLayoutManager::MinimizeDockedWindow( | 839 void DockedWindowLayoutManager::MinimizeDockedWindow( |
846 wm::WindowState* window_state) { | 840 wm::WindowState* window_state) { |
847 DCHECK(!IsPopupOrTransient(window_state->window())); | 841 aura::Window* window = window_state->window(); |
848 window_state->window()->Hide(); | 842 DCHECK(!IsPopupOrTransient(window)); |
843 views::corewm::SetWindowVisibilityAnimationType(window, | |
844 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); | |
845 window->Hide(); | |
846 views::corewm::SetWindowVisibilityAnimationType(window, | |
847 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); | |
849 if (window_state->IsActive()) | 848 if (window_state->IsActive()) |
850 window_state->Deactivate(); | 849 window_state->Deactivate(); |
851 RecordUmaAction(DOCKED_ACTION_MINIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); | 850 RecordUmaAction(DOCKED_ACTION_MINIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); |
852 } | 851 } |
853 | 852 |
854 void DockedWindowLayoutManager::RestoreDockedWindow( | 853 void DockedWindowLayoutManager::RestoreDockedWindow( |
855 wm::WindowState* window_state) { | 854 wm::WindowState* window_state) { |
856 aura::Window* window = window_state->window(); | 855 aura::Window* window = window_state->window(); |
857 DCHECK(!IsPopupOrTransient(window)); | 856 DCHECK(!IsPopupOrTransient(window)); |
858 // Always place restored window at the bottom shuffling the other windows up. | 857 // Always place restored window at the bottom shuffling the other windows up. |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1238 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1237 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
1239 const gfx::Rect& keyboard_bounds) { | 1238 const gfx::Rect& keyboard_bounds) { |
1240 // This bounds change will have caused a change to the Shelf which does not | 1239 // This bounds change will have caused a change to the Shelf which does not |
1241 // propagate automatically to this class, so manually recalculate bounds. | 1240 // propagate automatically to this class, so manually recalculate bounds. |
1242 Relayout(); | 1241 Relayout(); |
1243 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1242 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
1244 } | 1243 } |
1245 | 1244 |
1246 } // namespace internal | 1245 } // namespace internal |
1247 } // namespace ash | 1246 } // namespace ash |
OLD | NEW |