Commit 9b5b3507 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Modify header clipping.

If a window is not animated, clipping will happen on first bounds update
and without animation. Windows animated into overview remain unchanged.

See bug for before and after videos [1].

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=1069540#c11

Test: manual
Bug: 1069540
Change-Id: I683b49e87c5fa4fe0bc6d27b2dee31389fbb0d32
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145233
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758231}
parent 49036091
......@@ -281,8 +281,9 @@ gfx::RectF OverviewItem::GetTransformedBounds() const {
void OverviewItem::SetBounds(const gfx::RectF& target_bounds,
OverviewAnimationType animation_type) {
if (in_bounds_update_ ||
!Shell::Get()->overview_controller()->InOverviewSession())
!Shell::Get()->overview_controller()->InOverviewSession()) {
return;
}
// Do not animate if the resulting bounds does not change. The original
// window may change bounds so we still need to call SetItemBounds to update
......@@ -398,6 +399,8 @@ void OverviewItem::SetBounds(const gfx::RectF& target_bounds,
SetItemBounds(inset_bounds, new_animation_type, is_first_update);
UpdateHeaderLayout(is_first_update ? OVERVIEW_ANIMATION_NONE
: new_animation_type);
if (is_first_update && !should_animate_when_entering_)
transform_window_.ClipHeaderIfNeeded(/*animate=*/false);
}
// Shadow is normally set after an animation is finished. In the case of no
......@@ -760,9 +763,7 @@ void OverviewItem::UpdateRoundedCornersAndShadow() {
overview_item_view_->UpdatePreviewRoundedCorners(
should_show_rounded_corners);
} else {
transform_window_.UpdateRoundedCorners(
should_show_rounded_corners,
/*update_clip=*/should_show_rounded_corners);
transform_window_.UpdateRoundedCornersAndClip(should_show_rounded_corners);
}
// In addition, the shadow should be hidden if
......
......@@ -148,11 +148,10 @@ ScopedOverviewTransformWindow::~ScopedOverviewTransformWindow() {
event_targeting_blocker_map_.erase(transient);
}
// No need to update the clip since we're about to restore it to
// `original_clip_rect_`.
UpdateRoundedCorners(/*show=*/false, /*update_clip=*/false);
aura::client::GetTransientWindowClient()->RemoveObserver(this);
// Remove rounded corners and clipping.
UpdateRoundedCornersAndClip(/*show=*/false);
window_->layer()->SetClipRect(original_clip_rect_);
aura::client::GetTransientWindowClient()->RemoveObserver(this);
}
// static
......@@ -396,8 +395,7 @@ void ScopedOverviewTransformWindow::UpdateWindowDimensionsType() {
type_ = GetWindowDimensionsType(window_->bounds().size());
}
void ScopedOverviewTransformWindow::UpdateRoundedCorners(bool show,
bool update_clip) {
void ScopedOverviewTransformWindow::UpdateRoundedCornersAndClip(bool show) {
// Hide the corners if minimized, OverviewItemView will handle showing the
// rounded corners on the UI.
const bool show_corners = show && !IsMinimized();
......@@ -411,21 +409,38 @@ void ScopedOverviewTransformWindow::UpdateRoundedCorners(bool show,
layer->SetRoundedCornerRadius(radii);
layer->SetIsFastRoundedCorner(true);
if (!update_clip || layer->GetAnimator()->is_animating() || IsMinimized())
if (!show || layer->GetAnimator()->is_animating() || IsMinimized())
return;
ClipHeaderIfNeeded(true);
}
void ScopedOverviewTransformWindow::ClipHeaderIfNeeded(bool animate) {
const int top_inset = GetTopInset();
if (!has_aspect_ratio_clipping_ && top_inset > 0) {
gfx::Rect clip_rect(window_->bounds().size());
// We add 1 to the top_inset, because in some cases, the header is not
// clipped fully due to what seems to be a rounding error.
// TODO(afakhry|sammiequon): Investigate a proper fix for this.
clip_rect.Inset(0, top_inset + 1, 0, 0);
ScopedOverviewAnimationSettings settings(
if (top_inset <= 0)
return;
// Clipping a window to preserve aspect ratios will account for the header, so
// no need to clip here.
if (has_aspect_ratio_clipping_)
return;
gfx::Rect clip_rect(window_->bounds().size());
// We add 1 to the top_inset, because in some cases, the header is not
// clipped fully due to what seems to be a rounding error.
// TODO(afakhry|sammiequon): Investigate a proper fix for this.
clip_rect.Inset(0, top_inset + 1, 0, 0);
if (overview_clip_rect_ == clip_rect)
return;
std::unique_ptr<ScopedOverviewAnimationSettings> settings;
if (animate) {
settings = std::make_unique<ScopedOverviewAnimationSettings>(
OVERVIEW_ANIMATION_FRAME_HEADER_CLIP, window_);
layer->SetClipRect(clip_rect);
overview_clip_rect_ = clip_rect;
}
window_->layer()->SetClipRect(clip_rect);
overview_clip_rect_ = clip_rect;
}
void ScopedOverviewTransformWindow::OnTransientChildWindowAdded(
......
......@@ -123,11 +123,14 @@ class ASH_EXPORT ScopedOverviewTransformWindow
// change. Must be called before PositionWindows in OverviewGrid.
void UpdateWindowDimensionsType();
// Updates the rounded corners on the window. Makes the rounded corners if
// |show| is true, otherwise removes it. If |update_clip| is true, it will
// clip the top portion of the window that normally contains the caption (if
// any), otherwise it will skip updating that clip.
void UpdateRoundedCorners(bool show, bool update_clip);
// Updates the rounded corners and clipping on the window. Note that the
// rounded corners can be hidden with |show| set to false, but the clipping
// stays for the duration of overview once applied.
void UpdateRoundedCornersAndClip(bool show);
// Clip the top portion of the window that normally contains the caption (if
// any).
void ClipHeaderIfNeeded(bool animate);
// aura::client::TransientWindowClientObserver:
void OnTransientChildWindowAdded(aura::Window* parent,
......
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