Commit 92d3c167 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Fix stacking order for new UI.

New UI bypasses some animations when in tablet mode. Old UI relied on
animation ended to stack windows properly. After this patch lands, the
enable new overview UI patch should be able to reland safely.

Test: ash_unittests WindowSelectorTest.OverviewWidgetStackingOrder
Bug: 821999, 822049
Change-Id: I4028b9c045b0bfc93207d2d0bc6343e634eb6c89
Reviewed-on: https://chromium-review.googlesource.com/963693Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543567}
parent 866f56d1
...@@ -448,11 +448,8 @@ class WindowSelectorItem::RoundedContainerView ...@@ -448,11 +448,8 @@ class WindowSelectorItem::RoundedContainerView
// during the initial animation. Once the initial fade-in completes and the // during the initial animation. Once the initial fade-in completes and the
// overview header is fully exposed update stacking to keep the label above // overview header is fully exposed update stacking to keep the label above
// the item which prevents input events from reaching the window. // the item which prevents input events from reaching the window.
aura::Window* widget_window = GetWidget()->GetNativeWindow(); if (item_)
aura::Window* stacking_window = item_->RestackItemWidget();
item_ ? item_->GetWindowForStacking() : nullptr;
if (widget_window && stacking_window)
widget_window->parent()->StackChildAbove(widget_window, stacking_window);
} }
void AnimationProgressed(const gfx::Animation* animation) override { void AnimationProgressed(const gfx::Animation* animation) override {
...@@ -753,6 +750,14 @@ void WindowSelectorItem::Shutdown() { ...@@ -753,6 +750,14 @@ void WindowSelectorItem::Shutdown() {
void WindowSelectorItem::PrepareForOverview() { void WindowSelectorItem::PrepareForOverview() {
transform_window_.PrepareForOverview(); transform_window_.PrepareForOverview();
RestackItemWidget();
// The minimized widget was unavailable up to this point, but if a window
// is minimized, |item_widget_| should stack on top of it, unless the
// animation is in progress and will take care of that.
if (!background_view_->should_animate() &&
wm::GetWindowState(GetWindow())->IsMinimized()) {
RestackItemWidget();
}
UpdateHeaderLayout(HeaderFadeInMode::kEnter, UpdateHeaderLayout(HeaderFadeInMode::kEnter,
OverviewAnimationType::OVERVIEW_ANIMATION_NONE); OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
} }
...@@ -898,6 +903,12 @@ void WindowSelectorItem::SetDimmed(bool dimmed) { ...@@ -898,6 +903,12 @@ void WindowSelectorItem::SetDimmed(bool dimmed) {
SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f);
} }
void WindowSelectorItem::RestackItemWidget() {
aura::Window* widget_window = item_widget_->GetNativeWindow();
widget_window->parent()->StackChildAbove(widget_window,
GetWindowForStacking());
}
void WindowSelectorItem::ButtonPressed(views::Button* sender, void WindowSelectorItem::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
if (sender == close_button_) { if (sender == close_button_) {
......
...@@ -165,6 +165,12 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener, ...@@ -165,6 +165,12 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
const gfx::Rect& target_bounds() const { return target_bounds_; } const gfx::Rect& target_bounds() const { return target_bounds_; }
// Stacks the |item_widget_| in the correct place. |item_widget_| may be
// initially stacked in the wrong place due to animation or if it is a
// minimized window, the overview minimized widget is not available on
// |item_widget_|'s creation.
void RestackItemWidget();
// views::ButtonListener: // views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
......
...@@ -2591,9 +2591,11 @@ TEST_F(WindowSelectorTest, WindowItemTitleCloseVisibilityOnDrag) { ...@@ -2591,9 +2591,11 @@ TEST_F(WindowSelectorTest, WindowItemTitleCloseVisibilityOnDrag) {
EXPECT_EQ(1.f, item2->GetCloseButtonOpacityForTesting()); EXPECT_EQ(1.f, item2->GetCloseButtonOpacityForTesting());
} }
// http://crbug.com/822049
// Tests that overview widgets are stacked in the correct order. // Tests that overview widgets are stacked in the correct order.
TEST_F(WindowSelectorTest, DISABLED_OverviewWidgetStackingOrder) { TEST_F(WindowSelectorTest, OverviewWidgetStackingOrder) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kAshEnableNewOverviewUi);
// Helper function to get the index of |child|, give its parent window // Helper function to get the index of |child|, give its parent window
// |parent|. Given the same |parent|, the children with higher index will be // |parent|. Given the same |parent|, the children with higher index will be
// stacked above (but not neccessarily directly) the children with lower // stacked above (but not neccessarily directly) the children with lower
...@@ -2663,6 +2665,8 @@ TEST_F(WindowSelectorTest, DISABLED_OverviewWidgetStackingOrder) { ...@@ -2663,6 +2665,8 @@ TEST_F(WindowSelectorTest, DISABLED_OverviewWidgetStackingOrder) {
index_of(window.get(), parent)); index_of(window.get(), parent));
EXPECT_GT(index_of(widget2->GetNativeWindow(), parent), EXPECT_GT(index_of(widget2->GetNativeWindow(), parent),
index_of(min_widget2->GetNativeWindow(), parent)); index_of(min_widget2->GetNativeWindow(), parent));
EXPECT_GT(index_of(widget3->GetNativeWindow(), parent),
index_of(window3.get(), parent));
// Drag the first window. Verify that it's item widget is not stacked above // Drag the first window. Verify that it's item widget is not stacked above
// the other two. // the other two.
......
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