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/common/wm/overview/scoped_transform_overview_window.h" | 5 #include "ash/common/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/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 242 } |
243 | 243 |
244 base::Closure ScopedTransformOverviewWindow::OverviewContentMask:: | 244 base::Closure ScopedTransformOverviewWindow::OverviewContentMask:: |
245 PrepareForLayerBoundsChange() { | 245 PrepareForLayerBoundsChange() { |
246 return base::Closure(); | 246 return base::Closure(); |
247 } | 247 } |
248 | 248 |
249 ScopedTransformOverviewWindow::ScopedTransformOverviewWindow(WmWindow* window) | 249 ScopedTransformOverviewWindow::ScopedTransformOverviewWindow(WmWindow* window) |
250 : window_(window), | 250 : window_(window), |
251 determined_original_window_shape_(false), | 251 determined_original_window_shape_(false), |
252 minimized_(window->GetShowState() == ui::SHOW_STATE_MINIMIZED), | 252 original_visibility_( |
| 253 window->GetWindowState()->GetStateType() == |
| 254 wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED |
| 255 ? ORIGINALLY_DOCKED_MINIMIZED |
| 256 : (window->GetShowState() == ui::SHOW_STATE_MINIMIZED |
| 257 ? ORIGINALLY_MINIMIZED |
| 258 : ORIGINALLY_VISIBLE)), |
253 ignored_by_shelf_(window->GetWindowState()->ignored_by_shelf()), | 259 ignored_by_shelf_(window->GetWindowState()->ignored_by_shelf()), |
254 overview_started_(false), | 260 overview_started_(false), |
255 original_transform_(window->GetTargetTransform()), | 261 original_transform_(window->GetTargetTransform()), |
256 original_opacity_(window->GetTargetOpacity()), | 262 original_opacity_(window->GetTargetOpacity()), |
257 weak_ptr_factory_(this) {} | 263 weak_ptr_factory_(this) {} |
258 | 264 |
259 ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() {} | 265 ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() {} |
260 | 266 |
261 void ScopedTransformOverviewWindow::RestoreWindow() { | 267 void ScopedTransformOverviewWindow::RestoreWindow() { |
262 ScopedAnimationSettings animation_settings_list; | 268 ScopedAnimationSettings animation_settings_list; |
263 BeginScopedAnimation(OverviewAnimationType::OVERVIEW_ANIMATION_RESTORE_WINDOW, | 269 BeginScopedAnimation(OverviewAnimationType::OVERVIEW_ANIMATION_RESTORE_WINDOW, |
264 &animation_settings_list); | 270 &animation_settings_list); |
265 SetTransform(window()->GetRootWindow(), original_transform_, 0); | 271 SetTransform(window()->GetRootWindow(), original_transform_, 0); |
266 | 272 |
267 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = | 273 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = |
268 CreateScopedOverviewAnimationSettings( | 274 CreateScopedOverviewAnimationSettings( |
269 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS, | 275 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS, |
270 window_); | 276 window_); |
271 gfx::Transform transform; | 277 gfx::Transform transform; |
272 if (minimized_ && window_->GetShowState() != ui::SHOW_STATE_MINIMIZED) { | 278 if ((original_visibility_ == ORIGINALLY_MINIMIZED && |
| 279 window_->GetShowState() != ui::SHOW_STATE_MINIMIZED) || |
| 280 (original_visibility_ == ORIGINALLY_DOCKED_MINIMIZED && |
| 281 window_->GetWindowState()->GetStateType() != |
| 282 wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED)) { |
273 // Setting opacity 0 and visible false ensures that the property change | 283 // Setting opacity 0 and visible false ensures that the property change |
274 // to SHOW_STATE_MINIMIZED will not animate the window from its original | 284 // to SHOW_STATE_MINIMIZED will not animate the window from its original |
275 // bounds to the minimized position. | 285 // bounds to the minimized position. |
276 // Hiding the window needs to be done before the target opacity is 0, | 286 // Hiding the window needs to be done before the target opacity is 0, |
277 // otherwise the layer's visibility will not be updated | 287 // otherwise the layer's visibility will not be updated |
278 // (See VisibilityController::UpdateLayerVisibility). | 288 // (See VisibilityController::UpdateLayerVisibility). |
279 window_->Hide(); | 289 window_->Hide(); |
280 window_->SetOpacity(0); | 290 window_->SetOpacity(0); |
281 window_->SetShowState(ui::SHOW_STATE_MINIMIZED); | 291 window_->SetShowState(ui::SHOW_STATE_MINIMIZED); |
282 } | 292 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 window->GetType() != ui::wm::WINDOW_TYPE_PANEL) { | 334 window->GetType() != ui::wm::WINDOW_TYPE_PANEL) { |
325 continue; | 335 continue; |
326 } | 336 } |
327 bounds.Union( | 337 bounds.Union( |
328 window->GetParent()->ConvertRectToScreen(window->GetTargetBounds())); | 338 window->GetParent()->ConvertRectToScreen(window->GetTargetBounds())); |
329 } | 339 } |
330 return bounds; | 340 return bounds; |
331 } | 341 } |
332 | 342 |
333 void ScopedTransformOverviewWindow::ShowWindowIfMinimized() { | 343 void ScopedTransformOverviewWindow::ShowWindowIfMinimized() { |
334 if (minimized_ && window_->GetShowState() == ui::SHOW_STATE_MINIMIZED) | 344 if ((original_visibility_ == ORIGINALLY_MINIMIZED && |
| 345 window_->GetShowState() == ui::SHOW_STATE_MINIMIZED) || |
| 346 (original_visibility_ == ORIGINALLY_DOCKED_MINIMIZED && |
| 347 window_->GetWindowState()->GetStateType() == |
| 348 wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED)) { |
335 window_->Show(); | 349 window_->Show(); |
| 350 } |
336 } | 351 } |
337 | 352 |
338 void ScopedTransformOverviewWindow::ShowWindowOnExit() { | 353 void ScopedTransformOverviewWindow::ShowWindowOnExit() { |
339 if (minimized_) { | 354 if (original_visibility_ != ORIGINALLY_VISIBLE) { |
340 minimized_ = false; | 355 original_visibility_ = ORIGINALLY_VISIBLE; |
341 original_transform_ = gfx::Transform(); | 356 original_transform_ = gfx::Transform(); |
342 original_opacity_ = kRestoreWindowOpacity; | 357 original_opacity_ = kRestoreWindowOpacity; |
343 } | 358 } |
344 } | 359 } |
345 | 360 |
346 void ScopedTransformOverviewWindow::OnWindowDestroyed() { | 361 void ScopedTransformOverviewWindow::OnWindowDestroyed() { |
347 window_ = nullptr; | 362 window_ = nullptr; |
348 } | 363 } |
349 | 364 |
350 float ScopedTransformOverviewWindow::GetItemScale(const gfx::Size& source, | 365 float ScopedTransformOverviewWindow::GetItemScale(const gfx::Size& source, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 if (parent_window) | 495 if (parent_window) |
481 parent_window->CloseWidget(); | 496 parent_window->CloseWidget(); |
482 } | 497 } |
483 | 498 |
484 // static | 499 // static |
485 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() { | 500 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() { |
486 immediate_close_for_tests = true; | 501 immediate_close_for_tests = true; |
487 } | 502 } |
488 | 503 |
489 } // namespace ash | 504 } // namespace ash |
OLD | NEW |