Commit b3480b45 authored by Eliot Courtney's avatar Eliot Courtney Committed by Commit Bot

Don't try to modify PIP window size upon work area change.

This handles the case where the client changes the size of the PIP
window after restore-bounds are saved for it. We just want to restore
the position, not the size after, for example, showing and hiding the
virtual keyboard.

Bug: b/129385430
Test: added unit test
Change-Id: If34134a69b4ea9698b302de10c6a1d8371e9ecaf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1547612
Commit-Queue: Eliot Courtney <edcourtney@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#647090}
parent 2dae0c6d
...@@ -278,10 +278,13 @@ gfx::Rect PipPositioner::GetPositionAfterMovementAreaChange( ...@@ -278,10 +278,13 @@ gfx::Rect PipPositioner::GetPositionAfterMovementAreaChange(
// Restore to previous bounds if we have them. This lets us move the PIP // Restore to previous bounds if we have them. This lets us move the PIP
// window back to its original bounds after transient movement area changes, // window back to its original bounds after transient movement area changes,
// like the keyboard popping up and pushing the PIP window up. // like the keyboard popping up and pushing the PIP window up.
const gfx::Rect bounds_in_screen = gfx::Rect bounds_in_screen = window_state->window()->GetBoundsInScreen();
window_state->HasRestoreBounds() // If the client changes the window size, don't try to resize it back for
? window_state->GetRestoreBoundsInScreen() // restore.
: window_state->window()->GetBoundsInScreen(); if (window_state->HasRestoreBounds()) {
bounds_in_screen.set_origin(
window_state->GetRestoreBoundsInScreen().origin());
}
return GetRestingPosition(window_state->GetDisplay(), bounds_in_screen); return GetRestingPosition(window_state->GetDisplay(), bounds_in_screen);
} }
......
...@@ -246,4 +246,30 @@ TEST_F( ...@@ -246,4 +246,30 @@ TEST_F(
EXPECT_EQ(gfx::Rect(408, 292, 100, 100), window->GetBoundsInScreen()); EXPECT_EQ(gfx::Rect(408, 292, 100, 100), window->GetBoundsInScreen());
} }
TEST_F(PipTest, PipRestoreOnWorkAreaChangeDoesNotChangeWindowSize) {
ForceHideShelvesForTest();
UpdateDisplay("400x400");
std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(200, 200, 100, 100)));
wm::WindowState* window_state = wm::GetWindowState(window.get());
const wm::WMEvent enter_pip(wm::WM_EVENT_PIP);
window_state->OnWMEvent(&enter_pip);
window->Show();
// Position the PIP window on the side of the screen where it will be next
// to an edge and therefore in a resting position for the whole test.
const gfx::Rect bounds = gfx::Rect(292, 200, 100, 100);
window->SetBounds(bounds);
// Set the restore bounds to be a different size.
window_state->SetRestoreBoundsInParent(gfx::Rect(342, 250, 50, 100));
EXPECT_TRUE(window_state->HasRestoreBounds());
// Update the work area so that the PIP window should be pushed upward.
UpdateDisplay("400x200");
ForceHideShelvesForTest();
// The PIP window should not change size.
EXPECT_EQ(gfx::Rect(292, 92, 100, 100), window->GetBoundsInScreen());
}
} // namespace ash } // namespace ash
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