Chromium Code Reviews| 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 "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/wm/overview/scoped_window_copy.h" | 9 #include "ash/wm/overview/scoped_window_copy.h" |
| 10 #include "ash/wm/overview/window_selector_item.h" | 10 #include "ash/wm/overview/window_selector_item.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 | 90 |
| 91 const int ScopedTransformOverviewWindow::kTransitionMilliseconds = 200; | 91 const int ScopedTransformOverviewWindow::kTransitionMilliseconds = 200; |
| 92 | 92 |
| 93 ScopedTransformOverviewWindow::ScopedTransformOverviewWindow( | 93 ScopedTransformOverviewWindow::ScopedTransformOverviewWindow( |
| 94 aura::Window* window) | 94 aura::Window* window) |
| 95 : window_(window), | 95 : window_(window), |
| 96 minimized_(window->GetProperty(aura::client::kShowStateKey) == | 96 minimized_(window->GetProperty(aura::client::kShowStateKey) == |
| 97 ui::SHOW_STATE_MINIMIZED), | 97 ui::SHOW_STATE_MINIMIZED), |
| 98 ignored_by_shelf_(ash::wm::GetWindowState(window)->ignored_by_shelf()), | 98 ignored_by_shelf_(ash::wm::GetWindowState(window)->ignored_by_shelf()), |
| 99 overview_started_(false), | 99 overview_started_(false), |
| 100 original_transform_(window->layer()->GetTargetTransform()) { | 100 original_transform_(window->layer()->GetTargetTransform()), |
| 101 opacity_(window->layer()->opacity()) { | |
|
flackr
2014/06/26 17:33:07
Use GetTargetOpacity so that if instantiated durin
Nina
2014/06/27 15:20:38
Done.
| |
| 101 } | 102 } |
| 102 | 103 |
| 103 ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() { | 104 ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() { |
| 104 if (window_) { | 105 if (window_) { |
| 105 WindowSelectorAnimationSettings animation_settings(window_); | 106 WindowSelectorAnimationSettings animation_settings(window_); |
| 106 gfx::Transform transform; | 107 gfx::Transform transform; |
| 107 SetTransformOnWindowAndTransientChildren(original_transform_, true); | 108 SetTransformOnWindowAndTransientChildren(original_transform_, true); |
| 108 if (minimized_ && window_->GetProperty(aura::client::kShowStateKey) != | 109 if (minimized_ && window_->GetProperty(aura::client::kShowStateKey) != |
| 109 ui::SHOW_STATE_MINIMIZED) { | 110 ui::SHOW_STATE_MINIMIZED) { |
| 110 // Setting opacity 0 and visible false ensures that the property change | 111 // Setting opacity 0 and visible false ensures that the property change |
| 111 // to SHOW_STATE_MINIMIZED will not animate the window from its original | 112 // to SHOW_STATE_MINIMIZED will not animate the window from its original |
| 112 // bounds to the minimized position. | 113 // bounds to the minimized position. |
| 113 // Hiding the window needs to be done before the target opacity is 0, | 114 // Hiding the window needs to be done before the target opacity is 0, |
| 114 // otherwise the layer's visibility will not be updated | 115 // otherwise the layer's visibility will not be updated |
| 115 // (See VisibilityController::UpdateLayerVisibility). | 116 // (See VisibilityController::UpdateLayerVisibility). |
| 116 window_->Hide(); | 117 window_->Hide(); |
| 117 window_->layer()->SetOpacity(0); | 118 window_->layer()->SetOpacity(0); |
| 118 window_->SetProperty(aura::client::kShowStateKey, | 119 window_->SetProperty(aura::client::kShowStateKey, |
| 119 ui::SHOW_STATE_MINIMIZED); | 120 ui::SHOW_STATE_MINIMIZED); |
| 120 } | 121 } |
| 121 ash::wm::GetWindowState(window_)->set_ignored_by_shelf(ignored_by_shelf_); | 122 ash::wm::GetWindowState(window_)->set_ignored_by_shelf(ignored_by_shelf_); |
| 123 window_->layer()->SetOpacity(opacity_); | |
| 122 } | 124 } |
| 123 } | 125 } |
| 124 | 126 |
| 125 bool ScopedTransformOverviewWindow::Contains(const aura::Window* target) const { | 127 bool ScopedTransformOverviewWindow::Contains(const aura::Window* target) const { |
| 126 for (ScopedVector<ScopedWindowCopy>::const_iterator iter = | 128 for (ScopedVector<ScopedWindowCopy>::const_iterator iter = |
| 127 window_copies_.begin(); iter != window_copies_.end(); ++iter) { | 129 window_copies_.begin(); iter != window_copies_.end(); ++iter) { |
| 128 if ((*iter)->GetWindow()->Contains(target)) | 130 if ((*iter)->GetWindow()->Contains(target)) |
| 129 return true; | 131 return true; |
| 130 } | 132 } |
| 131 aura::Window* window = window_; | 133 aura::Window* window = window_; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 150 | 152 |
| 151 void ScopedTransformOverviewWindow::RestoreWindow() { | 153 void ScopedTransformOverviewWindow::RestoreWindow() { |
| 152 if (minimized_ && window_->GetProperty(aura::client::kShowStateKey) == | 154 if (minimized_ && window_->GetProperty(aura::client::kShowStateKey) == |
| 153 ui::SHOW_STATE_MINIMIZED) { | 155 ui::SHOW_STATE_MINIMIZED) { |
| 154 window_->Show(); | 156 window_->Show(); |
| 155 } | 157 } |
| 156 } | 158 } |
| 157 | 159 |
| 158 void ScopedTransformOverviewWindow::RestoreWindowOnExit() { | 160 void ScopedTransformOverviewWindow::RestoreWindowOnExit() { |
| 159 minimized_ = false; | 161 minimized_ = false; |
| 160 original_transform_ = gfx::Transform(); | 162 original_transform_ = gfx::Transform(); |
|
flackr
2014/06/26 17:33:07
Probably should set opacity_ = 1.0f here so that t
Nina
2014/06/27 15:20:38
Wow this was a really serious bug, since minimized
| |
| 161 } | 163 } |
| 162 | 164 |
| 163 void ScopedTransformOverviewWindow::OnWindowDestroyed() { | 165 void ScopedTransformOverviewWindow::OnWindowDestroyed() { |
| 164 window_ = NULL; | 166 window_ = NULL; |
| 165 } | 167 } |
| 166 | 168 |
| 167 gfx::Rect ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( | 169 gfx::Rect ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( |
| 168 const gfx::Rect& rect, | 170 const gfx::Rect& rect, |
| 169 const gfx::Rect& bounds) { | 171 const gfx::Rect& bounds) { |
| 170 DCHECK(!rect.IsEmpty()); | 172 DCHECK(!rect.IsEmpty()); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 } | 264 } |
| 263 | 265 |
| 264 void ScopedTransformOverviewWindow::PrepareForOverview() { | 266 void ScopedTransformOverviewWindow::PrepareForOverview() { |
| 265 DCHECK(!overview_started_); | 267 DCHECK(!overview_started_); |
| 266 overview_started_ = true; | 268 overview_started_ = true; |
| 267 ash::wm::GetWindowState(window_)->set_ignored_by_shelf(true); | 269 ash::wm::GetWindowState(window_)->set_ignored_by_shelf(true); |
| 268 RestoreWindow(); | 270 RestoreWindow(); |
| 269 } | 271 } |
| 270 | 272 |
| 271 } // namespace ash | 273 } // namespace ash |
| OLD | NEW |