Commit 5e63a09e authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

wm: Fix transparent zone under window mirror/preview views.

This happens for mirrors because we only scale by x for both x and y
dimensions, so some windows (ones with insets) that don't scale the same
way on the two axes end up having a transparent zone underneath.

Also, for WindowPreviewView the view is shifted after the above is fixed.
It's because the top inset is used in calculations, but is already taken
care of in WindowMirrorView.

Test: manual
Bug: 962893
Change-Id: Idd2e4676be10de0306aefc7fb112db3a01d9bf1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1647138
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666593}
parent 8cf45904
......@@ -77,11 +77,13 @@ void WindowMirrorView::Layout() {
gfx::Transform transform;
gfx::Rect client_area_bounds = GetClientAreaBounds();
// Scale down if necessary.
// Scale if necessary.
if (size() != source_->bounds().size()) {
const float scale =
const float scale_x =
width() / static_cast<float>(client_area_bounds.width());
transform.Scale(scale, scale);
const float scale_y =
height() / static_cast<float>(client_area_bounds.height());
transform.Scale(scale_x, scale_y);
}
// Reposition such that the client area is the only part visible.
transform.Translate(-client_area_bounds.x(), -client_area_bounds.y());
......
......@@ -73,12 +73,11 @@ void WindowPreviewView::Layout() {
local_bounds.height() / union_rect.height());
for (auto entry : mirror_views_) {
const gfx::Rect bounds = entry.first->GetBoundsInScreen();
const int top_inset = entry.first->GetProperty(aura::client::kTopViewInset);
gfx::Rect mirror_bounds;
mirror_bounds.set_x(
gfx::ToRoundedInt((bounds.x() - union_origin.x()) * scale.x()));
mirror_bounds.set_y(gfx::ToRoundedInt(
(bounds.y() + top_inset - union_origin.y()) * scale.y()));
mirror_bounds.set_y(
gfx::ToRoundedInt((bounds.y() - union_origin.y()) * scale.y()));
mirror_bounds.set_width(gfx::ToRoundedInt(bounds.width() * scale.x()));
mirror_bounds.set_height(gfx::ToRoundedInt(bounds.height() * scale.y()));
entry.second->SetBoundsRect(mirror_bounds);
......@@ -130,14 +129,10 @@ void WindowPreviewView::RemoveWindow(aura::Window* window) {
}
gfx::RectF WindowPreviewView::GetUnionRect() const {
gfx::RectF bounds;
for (auto entry : mirror_views_) {
gfx::RectF entry_bounds(entry.first->GetBoundsInScreen());
entry_bounds.Inset(0, entry.first->GetProperty(aura::client::kTopViewInset),
0, 0);
bounds.Union(entry_bounds);
}
return bounds;
gfx::Rect bounds;
for (auto entry : mirror_views_)
bounds.Union(entry.first->GetBoundsInScreen());
return gfx::RectF(bounds);
}
} // namespace wm
......
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