| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/overview/scoped_transform_overview_window.h" | 5 #include "ash/wm/overview/scoped_transform_overview_window.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 11 #include "ash/wm/overview/scoped_overview_animation_settings.h" | 11 #include "ash/wm/overview/scoped_overview_animation_settings.h" |
| 12 #include "ash/wm/overview/scoped_overview_animation_settings_factory.h" | |
| 13 #include "ash/wm/overview/window_selector_item.h" | 12 #include "ash/wm/overview/window_selector_item.h" |
| 14 #include "ash/wm/window_mirror_view.h" | 13 #include "ash/wm/window_mirror_view.h" |
| 15 #include "ash/wm/window_state.h" | 14 #include "ash/wm/window_state.h" |
| 16 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
| 17 #include "ash/wm_window.h" | 16 #include "ash/wm_window.h" |
| 18 #include "base/macros.h" | 17 #include "base/macros.h" |
| 19 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 20 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
| 22 #include "ui/aura/client/aura_constants.h" | 21 #include "ui/aura/client/aura_constants.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 38 | 37 |
| 39 // Delay closing window to allow it to shrink and fade out. | 38 // Delay closing window to allow it to shrink and fade out. |
| 40 const int kCloseWindowDelayInMilliseconds = 150; | 39 const int kCloseWindowDelayInMilliseconds = 150; |
| 41 | 40 |
| 42 aura::Window* GetTransientRoot(aura::Window* window) { | 41 aura::Window* GetTransientRoot(aura::Window* window) { |
| 43 while (window && ::wm::GetTransientParent(window)) | 42 while (window && ::wm::GetTransientParent(window)) |
| 44 window = ::wm::GetTransientParent(window); | 43 window = ::wm::GetTransientParent(window); |
| 45 return window; | 44 return window; |
| 46 } | 45 } |
| 47 | 46 |
| 48 std::unique_ptr<ScopedOverviewAnimationSettings> | |
| 49 CreateScopedOverviewAnimationSettings(OverviewAnimationType animation_type, | |
| 50 aura::Window* window) { | |
| 51 return ScopedOverviewAnimationSettingsFactory::Get() | |
| 52 ->CreateOverviewAnimationSettings(animation_type, window); | |
| 53 } | |
| 54 | |
| 55 // An iterator class that traverses an aura::Window and all of its transient | 47 // An iterator class that traverses an aura::Window and all of its transient |
| 56 // descendants. | 48 // descendants. |
| 57 class TransientDescendantIterator { | 49 class TransientDescendantIterator { |
| 58 public: | 50 public: |
| 59 // Creates an empty iterator. | 51 // Creates an empty iterator. |
| 60 TransientDescendantIterator(); | 52 TransientDescendantIterator(); |
| 61 | 53 |
| 62 // Copy constructor required for iterator purposes. | 54 // Copy constructor required for iterator purposes. |
| 63 TransientDescendantIterator(const TransientDescendantIterator& other) = | 55 TransientDescendantIterator(const TransientDescendantIterator& other) = |
| 64 default; | 56 default; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 if (minimized_widget_) { | 182 if (minimized_widget_) { |
| 191 // TODO(oshima): Use unminimize animation instead of hiding animation. | 183 // TODO(oshima): Use unminimize animation instead of hiding animation. |
| 192 minimized_widget_->CloseNow(); | 184 minimized_widget_->CloseNow(); |
| 193 minimized_widget_.reset(); | 185 minimized_widget_.reset(); |
| 194 return; | 186 return; |
| 195 } | 187 } |
| 196 ScopedAnimationSettings animation_settings_list; | 188 ScopedAnimationSettings animation_settings_list; |
| 197 BeginScopedAnimation(OverviewAnimationType::OVERVIEW_ANIMATION_RESTORE_WINDOW, | 189 BeginScopedAnimation(OverviewAnimationType::OVERVIEW_ANIMATION_RESTORE_WINDOW, |
| 198 &animation_settings_list); | 190 &animation_settings_list); |
| 199 SetTransform(window()->GetRootWindow(), original_transform_); | 191 SetTransform(window()->GetRootWindow(), original_transform_); |
| 200 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = | 192 ScopedOverviewAnimationSettings animation_settings( |
| 201 CreateScopedOverviewAnimationSettings( | 193 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS, |
| 202 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS, | 194 window_); |
| 203 window_); | |
| 204 wm::GetWindowState(window_)->set_ignored_by_shelf(ignored_by_shelf_); | 195 wm::GetWindowState(window_)->set_ignored_by_shelf(ignored_by_shelf_); |
| 205 SetOpacity(original_opacity_); | 196 SetOpacity(original_opacity_); |
| 206 } | 197 } |
| 207 | 198 |
| 208 void ScopedTransformOverviewWindow::BeginScopedAnimation( | 199 void ScopedTransformOverviewWindow::BeginScopedAnimation( |
| 209 OverviewAnimationType animation_type, | 200 OverviewAnimationType animation_type, |
| 210 ScopedAnimationSettings* animation_settings) { | 201 ScopedAnimationSettings* animation_settings) { |
| 211 for (auto* window : GetTransientTreeIterator(GetOverviewWindow())) { | 202 for (auto* window : GetTransientTreeIterator(GetOverviewWindow())) { |
| 212 animation_settings->push_back( | 203 animation_settings->push_back( |
| 213 CreateScopedOverviewAnimationSettings(animation_type, window)); | 204 base::MakeUnique<ScopedOverviewAnimationSettings>(animation_type, |
| 205 window)); |
| 214 } | 206 } |
| 215 } | 207 } |
| 216 | 208 |
| 217 bool ScopedTransformOverviewWindow::Contains(const aura::Window* target) const { | 209 bool ScopedTransformOverviewWindow::Contains(const aura::Window* target) const { |
| 218 for (auto* window : GetTransientTreeIterator(window_)) { | 210 for (auto* window : GetTransientTreeIterator(window_)) { |
| 219 if (window->Contains(target)) | 211 if (window->Contains(target)) |
| 220 return true; | 212 return true; |
| 221 } | 213 } |
| 222 aura::Window* mirror = GetOverviewWindowForMinimizedState(); | 214 aura::Window* mirror = GetOverviewWindowForMinimizedState(); |
| 223 return mirror && mirror->Contains(target); | 215 return mirror && mirror->Contains(target); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 // In unit tests, the content view can have empty size. | 498 // In unit tests, the content view can have empty size. |
| 507 if (!preferred.IsEmpty()) { | 499 if (!preferred.IsEmpty()) { |
| 508 int inset = bounds.height() - preferred.height(); | 500 int inset = bounds.height() - preferred.height(); |
| 509 bounds.Inset(0, 0, 0, inset); | 501 bounds.Inset(0, 0, 0, inset); |
| 510 } | 502 } |
| 511 minimized_widget_->SetBounds(bounds); | 503 minimized_widget_->SetBounds(bounds); |
| 512 minimized_widget_->Show(); | 504 minimized_widget_->Show(); |
| 513 } | 505 } |
| 514 | 506 |
| 515 } // namespace ash | 507 } // namespace ash |
| OLD | NEW |