Commit 03dd856b authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

overview: Correct for changes to the |kTopViewInset| window property.

The |kTopViewInset| window property can change during overview.
Particularly, the Settings window behaves that way if overview starts
during transition to tablet mode as another window carries over from
clamshell snapped state to tablet split view. Now, when the
|kTopViewInset| window property changes, consistent with existing
behavior for bounds changes, the visual appearance of overview shall
generally be corrected at the expense of interrupting animation effects.
The one exception is if the |kTopViewInset| window property changes
while overview is being prepared. In this case, still consistent with
existing behavior for bounds changes, nothing shall be done, because
when the overview preparation has been completed, overview will look
right anyway.

Test: ash_unittests OverviewSessionTest.TopViewInsetChangeDuringOverview
Bug: 932816
Change-Id: I482d5ce5c24ff40ccc28e898ae3668f6831b71bd
Reviewed-on: https://chromium-review.googlesource.com/c/1495444
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636633}
parent c9e45be2
...@@ -919,6 +919,16 @@ void OverviewGrid::OnWindowBoundsChanged(aura::Window* window, ...@@ -919,6 +919,16 @@ void OverviewGrid::OnWindowBoundsChanged(aura::Window* window,
PositionWindows(false); PositionWindows(false);
} }
void OverviewGrid::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
if (prepared_for_overview_ && key == aura::client::kTopViewInset &&
window->GetProperty(aura::client::kTopViewInset) !=
static_cast<int>(old)) {
PositionWindows(/*animate=*/false);
}
}
void OverviewGrid::OnPostWindowStateTypeChange( void OverviewGrid::OnPostWindowStateTypeChange(
wm::WindowState* window_state, wm::WindowState* window_state,
mojom::WindowStateType old_type) { mojom::WindowStateType old_type) {
......
...@@ -139,11 +139,15 @@ class ASH_EXPORT OverviewGrid : public aura::WindowObserver, ...@@ -139,11 +139,15 @@ class ASH_EXPORT OverviewGrid : public aura::WindowObserver,
// aura::WindowObserver: // aura::WindowObserver:
void OnWindowDestroying(aura::Window* window) override; void OnWindowDestroying(aura::Window* window) override;
// TODO(flackr): Handle window bounds changed in OverviewItem. // TODO(flackr): Handle window bounds changed in OverviewItem. See also
// OnWindowPropertyChanged() below.
void OnWindowBoundsChanged(aura::Window* window, void OnWindowBoundsChanged(aura::Window* window,
const gfx::Rect& old_bounds, const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds, const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) override; ui::PropertyChangeReason reason) override;
void OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) override;
// wm::WindowStateObserver: // wm::WindowStateObserver:
void OnPostWindowStateTypeChange(wm::WindowState* window_state, void OnPostWindowStateTypeChange(wm::WindowState* window_state,
......
...@@ -874,6 +874,19 @@ TEST_F(OverviewSessionTest, BoundsChangeDuringOverview) { ...@@ -874,6 +874,19 @@ TEST_F(OverviewSessionTest, BoundsChangeDuringOverview) {
ToggleOverview(); ToggleOverview();
} }
// Tests that a change to the |kTopViewInset| window property during overview is
// corrected for.
TEST_F(OverviewSessionTest, TopViewInsetChangeDuringOverview) {
std::unique_ptr<aura::Window> window = CreateTestWindow(gfx::Rect(400, 400));
window->SetProperty(aura::client::kTopViewInset, 32);
ToggleOverview();
gfx::Rect overview_bounds = GetTransformedTargetBounds(window.get());
window->SetProperty(aura::client::kTopViewInset, 0);
gfx::Rect new_overview_bounds = GetTransformedTargetBounds(window.get());
EXPECT_NE(overview_bounds, new_overview_bounds);
ToggleOverview();
}
// Tests that a newly created window aborts overview. // Tests that a newly created window aborts overview.
TEST_F(OverviewSessionTest, NewWindowCancelsOverview) { TEST_F(OverviewSessionTest, NewWindowCancelsOverview) {
std::unique_ptr<aura::Window> window1(CreateTestWindow()); std::unique_ptr<aura::Window> window1(CreateTestWindow());
......
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