Commit 60172c24 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Edge extension should take rotation/overscan into account

Bug: 843354, b/141898654
Test: covered by unittest
Change-Id: Ib92013f3e0721c054c94981d93a8b2167076fa8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1911100Reviewed-by: default avatarMalay Keshav <malaykeshav@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715089}
parent eb461c9c
...@@ -104,30 +104,26 @@ gfx::Rect GetDisplayBoundsWithShelf(aura::Window* window) { ...@@ -104,30 +104,26 @@ gfx::Rect GetDisplayBoundsWithShelf(aura::Window* window) {
gfx::Rect SnapBoundsToDisplayEdge(const gfx::Rect& bounds, gfx::Rect SnapBoundsToDisplayEdge(const gfx::Rect& bounds,
const aura::Window* window) { const aura::Window* window) {
const aura::WindowTreeHost* host = window->GetHost(); display::Display display =
if (!host) display::Screen::GetScreen()->GetDisplayNearestWindow(
return bounds; const_cast<aura::Window*>(window));
const float dsf = host->device_scale_factor(); const float dsf = display.device_scale_factor();
const gfx::Rect display_bounds_in_pixel = host->GetBoundsInPixels(); const gfx::Size display_size_in_pixel = display.GetSizeInPixel();
const gfx::Rect display_bounds_in_dip = window->GetRootWindow()->bounds(); const gfx::Size scaled_size_in_pixel =
const gfx::Rect bounds_in_pixel = gfx::ScaleToEnclosedRect(bounds, dsf); gfx::ScaleToFlooredSize(display.size(), dsf);
// Adjusts |bounds| such that the scaled enclosed bounds are atleast as big as // Adjusts |bounds| such that the scaled enclosed bounds are atleast as big as
// the scaled enclosing unadjusted bounds. // the scaled enclosing unadjusted bounds.
gfx::Rect snapped_bounds = bounds; gfx::Rect snapped_bounds = bounds;
if ((display_bounds_in_dip.width() == bounds.width() && if (scaled_size_in_pixel.width() < display_size_in_pixel.width() &&
bounds_in_pixel.width() != display_bounds_in_pixel.width()) || display.bounds().right() == bounds.right()) {
(bounds.right() == display_bounds_in_dip.width() &&
bounds_in_pixel.right() != display_bounds_in_pixel.width())) {
snapped_bounds.Inset(0, 0, -1, 0); snapped_bounds.Inset(0, 0, -1, 0);
DCHECK_GE(gfx::ScaleToEnclosedRect(snapped_bounds, dsf).right(), DCHECK_GE(gfx::ScaleToEnclosedRect(snapped_bounds, dsf).right(),
gfx::ScaleToEnclosingRect(bounds, dsf).right()); gfx::ScaleToEnclosingRect(bounds, dsf).right());
} }
if ((display_bounds_in_dip.height() == bounds.height() && if (scaled_size_in_pixel.height() < display_size_in_pixel.height() &&
bounds_in_pixel.height() != display_bounds_in_pixel.height()) || display.bounds().bottom() == bounds.bottom()) {
(bounds.bottom() == display_bounds_in_dip.height() &&
bounds_in_pixel.bottom() != display_bounds_in_pixel.height())) {
snapped_bounds.Inset(0, 0, 0, -1); snapped_bounds.Inset(0, 0, 0, -1);
DCHECK_GE(gfx::ScaleToEnclosedRect(snapped_bounds, dsf).bottom(), DCHECK_GE(gfx::ScaleToEnclosedRect(snapped_bounds, dsf).bottom(),
gfx::ScaleToEnclosingRect(bounds, dsf).bottom()); gfx::ScaleToEnclosingRect(bounds, dsf).bottom());
......
...@@ -223,6 +223,13 @@ TEST_F(ScreenUtilTest, SnapBoundsToDisplayEdge) { ...@@ -223,6 +223,13 @@ TEST_F(ScreenUtilTest, SnapBoundsToDisplayEdge) {
bounds = gfx::Rect(0, 552, 800, 48); bounds = gfx::Rect(0, 552, 800, 48);
snapped_bounds = screen_util::SnapBoundsToDisplayEdge(bounds, window); snapped_bounds = screen_util::SnapBoundsToDisplayEdge(bounds, window);
EXPECT_EQ(snapped_bounds, gfx::Rect(0, 552, 800, 48)); EXPECT_EQ(snapped_bounds, gfx::Rect(0, 552, 800, 48));
UpdateDisplay("2400x1800*1.8/r");
EXPECT_EQ(gfx::Size(1000, 1333),
display::Screen::GetScreen()->GetPrimaryDisplay().size());
bounds = gfx::Rect(950, 0, 50, 1333);
snapped_bounds = screen_util::SnapBoundsToDisplayEdge(bounds, window);
EXPECT_EQ(snapped_bounds, gfx::Rect(950, 0, 50, 1334));
} }
// Tests that making a window fullscreen while the Docked Magnifier is enabled // Tests that making a window fullscreen while the Docked Magnifier is enabled
......
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