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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 if (window != window_ && window->GetType() != ui::wm::WINDOW_TYPE_NORMAL && | 336 if (window != window_ && window->GetType() != ui::wm::WINDOW_TYPE_NORMAL && |
337 window->GetType() != ui::wm::WINDOW_TYPE_PANEL) { | 337 window->GetType() != ui::wm::WINDOW_TYPE_PANEL) { |
338 continue; | 338 continue; |
339 } | 339 } |
340 bounds.Union( | 340 bounds.Union( |
341 window->GetParent()->ConvertRectToScreen(window->GetTargetBounds())); | 341 window->GetParent()->ConvertRectToScreen(window->GetTargetBounds())); |
342 } | 342 } |
343 return bounds; | 343 return bounds; |
344 } | 344 } |
345 | 345 |
346 gfx::Rect ScopedTransformOverviewWindow::GetTransformedBounds( | |
347 bool hide_header) const { | |
348 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); | |
349 int top_inset = hide_header ? GetTopInset() : 0; | |
tdanderson
2016/07/29 20:20:02
nit: const
varkha
2016/07/29 20:45:12
Done.
| |
350 gfx::Rect bounds; | |
351 for (auto* window : GetTransientTreeIterator(window_)) { | |
352 // Ignore other window types when computing bounding box of window | |
353 // selector target item. | |
354 if (window != window_ && | |
355 (!material || (window->GetType() != ui::wm::WINDOW_TYPE_NORMAL && | |
356 window->GetType() != ui::wm::WINDOW_TYPE_PANEL))) { | |
357 continue; | |
358 } | |
359 gfx::RectF window_bounds(window->GetTargetBounds()); | |
360 gfx::Transform new_transform = | |
361 TransformAboutPivot(gfx::Point(window_bounds.x(), window_bounds.y()), | |
362 window->GetTargetTransform()); | |
363 new_transform.TransformRect(&window_bounds); | |
364 | |
365 // With Material Design the preview title is shown above the preview window. | |
366 // Hide the window header for apps or browser windows with no tabs (web | |
367 // apps) to avoid showing both the window header and the preview title. | |
368 if (material && top_inset > 0) { | |
369 gfx::RectF header_bounds(window_bounds); | |
370 header_bounds.set_height(top_inset); | |
371 new_transform.TransformRect(&header_bounds); | |
372 window_bounds.Inset(0, gfx::ToCeiledInt(header_bounds.height()), 0, 0); | |
373 } | |
374 bounds.Union(window->GetParent()->ConvertRectToScreen( | |
375 ToEnclosingRect(window_bounds))); | |
376 } | |
377 return bounds; | |
378 } | |
379 | |
380 int ScopedTransformOverviewWindow::GetTopInset() const { | |
381 for (auto* window : GetTransientTreeIterator(window_)) { | |
382 // Ignore other window types when computing bounding box of window | |
383 // selector target item. | |
tdanderson
2016/07/29 20:20:02
Did you mean to have this comment here? I think so
varkha
2016/07/29 20:45:12
Done.
| |
384 if (window == window_ || (window->GetType() != ui::wm::WINDOW_TYPE_NORMAL && | |
tdanderson
2016/07/29 20:20:02
Perhaps restructure as this instead:
for (...) {
varkha
2016/07/29 20:45:12
Done.
| |
385 window->GetType() != ui::wm::WINDOW_TYPE_PANEL)) { | |
386 continue; | |
387 } | |
388 return 0; | |
389 } | |
390 return window_->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET); | |
391 } | |
392 | |
346 void ScopedTransformOverviewWindow::ShowWindowIfMinimized() { | 393 void ScopedTransformOverviewWindow::ShowWindowIfMinimized() { |
347 if ((original_visibility_ == ORIGINALLY_MINIMIZED && | 394 if ((original_visibility_ == ORIGINALLY_MINIMIZED && |
348 window_->GetShowState() == ui::SHOW_STATE_MINIMIZED) || | 395 window_->GetShowState() == ui::SHOW_STATE_MINIMIZED) || |
349 (original_visibility_ == ORIGINALLY_DOCKED_MINIMIZED && | 396 (original_visibility_ == ORIGINALLY_DOCKED_MINIMIZED && |
350 window_->GetWindowState()->GetStateType() == | 397 window_->GetWindowState()->GetStateType() == |
351 wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED)) { | 398 wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED)) { |
352 window_->Show(); | 399 window_->Show(); |
353 } | 400 } |
354 } | 401 } |
355 | 402 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 mask_->layer()->SetFillsBoundsOpaquely(false); | 479 mask_->layer()->SetFillsBoundsOpaquely(false); |
433 window()->GetLayer()->SetMaskLayer(mask_->layer()); | 480 window()->GetLayer()->SetMaskLayer(mask_->layer()); |
434 } | 481 } |
435 if (!determined_original_window_shape_) { | 482 if (!determined_original_window_shape_) { |
436 determined_original_window_shape_ = true; | 483 determined_original_window_shape_ = true; |
437 SkRegion* window_shape = window()->GetLayer()->alpha_shape(); | 484 SkRegion* window_shape = window()->GetLayer()->alpha_shape(); |
438 if (!original_window_shape_ && window_shape) | 485 if (!original_window_shape_ && window_shape) |
439 original_window_shape_.reset(new SkRegion(*window_shape)); | 486 original_window_shape_.reset(new SkRegion(*window_shape)); |
440 } | 487 } |
441 gfx::Rect bounds(GetTargetBoundsInScreen().size()); | 488 gfx::Rect bounds(GetTargetBoundsInScreen().size()); |
442 const int inset = | 489 const int inset = (use_mask || use_shape) ? GetTopInset() : 0; |
443 (use_mask || use_shape) | |
444 ? window()->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET) | |
445 : 0; | |
446 if (mask_) { | 490 if (mask_) { |
447 // Mask layer is used both to hide the window header and to use rounded | 491 // Mask layer is used both to hide the window header and to use rounded |
448 // corners. Its layout needs to be update when setting a transform. | 492 // corners. Its layout needs to be update when setting a transform. |
449 mask_->layer()->SetBounds(bounds); | 493 mask_->layer()->SetBounds(bounds); |
450 mask_->set_inset(inset); | 494 mask_->set_inset(inset); |
451 mask_->set_radius(radius); | 495 mask_->set_radius(radius); |
452 window()->GetLayer()->SchedulePaint(bounds); | 496 window()->GetLayer()->SchedulePaint(bounds); |
453 } else if (inset > 0) { | 497 } else if (inset > 0) { |
454 // Alpha shape is only used to to hide the window header and only when | 498 // Alpha shape is only used to to hide the window header and only when |
455 // not using a mask layer. | 499 // not using a mask layer. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 if (parent_window) | 551 if (parent_window) |
508 parent_window->CloseWidget(); | 552 parent_window->CloseWidget(); |
509 } | 553 } |
510 | 554 |
511 // static | 555 // static |
512 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() { | 556 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() { |
513 immediate_close_for_tests = true; | 557 immediate_close_for_tests = true; |
514 } | 558 } |
515 | 559 |
516 } // namespace ash | 560 } // namespace ash |
OLD | NEW |