Commit 1db2eecd authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Minimized windows should have same size after entering.

Discovered new bug regarding windows with top insets which affects both
minimized windows and unminimzed windows. The current patch does not
make it perfect in the case of windows with top insets (especially if
they are letterboxed), but its a lot closer than before.

Test: added test, manual
Bug: 1041555
Change-Id: I3503ca4a6760517176607c50d1dc6f1a2b9ca376
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001753Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734137}
parent f42aff05
...@@ -763,9 +763,14 @@ void OverviewItem::UpdateRoundedCornersAndShadow() { ...@@ -763,9 +763,14 @@ void OverviewItem::UpdateRoundedCornersAndShadow() {
!disable_mask_ && !is_shutting_down && !disable_mask_ && !is_shutting_down &&
!overview_controller->IsInStartAnimation(); !overview_controller->IsInStartAnimation();
transform_window_.UpdateRoundedCorners( if (transform_window_.IsMinimized()) {
should_show_rounded_corners, overview_item_view_->UpdatePreviewRoundedCorners(
/*update_clip=*/should_show_rounded_corners); should_show_rounded_corners);
} else {
transform_window_.UpdateRoundedCorners(
should_show_rounded_corners,
/*update_clip=*/should_show_rounded_corners);
}
// In addition, the shadow should be hidden if // In addition, the shadow should be hidden if
// 1) this overview item is the drop target window or // 1) this overview item is the drop target window or
...@@ -777,14 +782,15 @@ void OverviewItem::UpdateRoundedCornersAndShadow() { ...@@ -777,14 +782,15 @@ void OverviewItem::UpdateRoundedCornersAndShadow() {
->layer() ->layer()
->GetAnimator() ->GetAnimator()
->is_animating(); ->is_animating();
if (should_show_shadow) {
SetShadowBounds( const gfx::RectF shadow_bounds =
should_show_shadow transform_window_.IsMinimized()
? base::make_optional(transform_window_.GetTransformedBounds()) ? gfx::RectF(
: base::nullopt); overview_item_view_->preview_view()->GetBoundsInScreen())
if (transform_window_.IsMinimized()) { : transform_window_.GetTransformedBounds();
overview_item_view_->UpdatePreviewRoundedCorners( SetShadowBounds(base::make_optional(shadow_bounds));
should_show_rounded_corners); } else {
SetShadowBounds(base::nullopt);
} }
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
#include "ui/views/animation/flood_fill_ink_drop_ripple.h" #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
...@@ -274,6 +275,29 @@ gfx::Rect OverviewItemView::GetHeaderBounds() const { ...@@ -274,6 +275,29 @@ gfx::Rect OverviewItemView::GetHeaderBounds() const {
kHeaderHeightDp); kHeaderHeightDp);
} }
gfx::Size OverviewItemView::GetPreviewViewSize() const {
// The preview should expand to fit the bounds allocated for the content,
// except if it is letterboxed or pillarboxed.
const gfx::SizeF preview_pref_size(preview_view()->GetPreferredSize());
const float aspect_ratio =
preview_pref_size.width() / preview_pref_size.height();
gfx::SizeF target_size(GetContentAreaBounds().size());
ScopedOverviewTransformWindow::GridWindowFillMode fill_mode =
overview_item_->GetWindowDimensionsType();
switch (fill_mode) {
case ScopedOverviewTransformWindow::GridWindowFillMode::kNormal:
break;
case ScopedOverviewTransformWindow::GridWindowFillMode::kLetterBoxed:
target_size.set_height(target_size.width() / aspect_ratio);
break;
case ScopedOverviewTransformWindow::GridWindowFillMode::kPillarBoxed:
target_size.set_width(target_size.height() * aspect_ratio);
break;
}
return gfx::ToRoundedSize(target_size);
}
views::View* OverviewItemView::GetView() { views::View* OverviewItemView::GetView() {
return this; return this;
} }
......
...@@ -64,6 +64,7 @@ class ASH_EXPORT OverviewItemView ...@@ -64,6 +64,7 @@ class ASH_EXPORT OverviewItemView
// WindowMiniView: // WindowMiniView:
int GetMargin() const override; int GetMargin() const override;
gfx::Rect GetHeaderBounds() const override; gfx::Rect GetHeaderBounds() const override;
gfx::Size GetPreviewViewSize() const override;
// OverviewHighlightController::OverviewHighlightableView: // OverviewHighlightController::OverviewHighlightableView:
views::View* GetView() override; views::View* GetView() override;
......
...@@ -155,18 +155,21 @@ WindowMiniView::WindowMiniView(aura::Window* source_window) ...@@ -155,18 +155,21 @@ WindowMiniView::WindowMiniView(aura::Window* source_window)
SetBorder(std::move(border)); SetBorder(std::move(border));
} }
void WindowMiniView::Layout() { gfx::Rect WindowMiniView::GetContentAreaBounds() const {
gfx::Rect bounds = GetContentsBounds(); const int margin = GetMargin();
gfx::Rect bounds(GetLocalBounds());
bounds.Inset(margin, margin);
bounds.Inset(0, kHeaderHeightDp, 0, 0);
return bounds;
}
if (backdrop_view_) { void WindowMiniView::Layout() {
gfx::Rect backdrop_bounds = bounds; const gfx::Rect content_area_bounds = GetContentAreaBounds();
backdrop_bounds.Inset(0, kHeaderHeightDp, 0, 0); if (backdrop_view_)
backdrop_view_->SetBoundsRect(backdrop_bounds); backdrop_view_->SetBoundsRect(content_area_bounds);
}
if (preview_view_) { if (preview_view_) {
gfx::Rect preview_bounds = bounds; gfx::Rect preview_bounds = content_area_bounds;
preview_bounds.Inset(0, kHeaderHeightDp, 0, 0);
preview_bounds.ClampToCenteredSize(GetPreviewViewSize()); preview_bounds.ClampToCenteredSize(GetPreviewViewSize());
preview_view_->SetBoundsRect(preview_bounds); preview_view_->SetBoundsRect(preview_bounds);
} }
......
...@@ -55,6 +55,9 @@ class ASH_EXPORT WindowMiniView : public views::View, ...@@ -55,6 +55,9 @@ class ASH_EXPORT WindowMiniView : public views::View,
WmHighlightItemBorder* border_ptr() { return border_ptr_; } WmHighlightItemBorder* border_ptr() { return border_ptr_; }
// Returns the bounds where the backdrop and preview should go.
gfx::Rect GetContentAreaBounds() const;
// Subclasses can override these functions to provide customization for // Subclasses can override these functions to provide customization for
// margins and layouts of certain elements. // margins and layouts of certain elements.
virtual int GetMargin() const; virtual int GetMargin() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment