Commit 97b6e560 authored by Min Chen's avatar Min Chen Committed by Commit Bot

Put the new selector item as the first one in overview grid.

Bug: 872052
Test: SplitViewTabDraggingTest.ShowNewWindowItemWhenDragStarts
Change-Id: Ib7a563d350fb5d789495518b414f7a319bc9063b
Reviewed-on: https://chromium-review.googlesource.com/1168592
Commit-Queue: Min Chen <minch@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581969}
parent 2719d34c
......@@ -478,9 +478,10 @@ void WindowGrid::AddItem(aura::Window* window, bool reposition, bool animate) {
window_observer_.Add(window);
window_state_observer_.Add(wm::GetWindowState(window));
window_list_.push_back(
window_list_.insert(
window_list_.begin(),
std::make_unique<WindowSelectorItem>(window, window_selector_, this));
window_list_.back()->PrepareForOverview();
window_list_.front()->PrepareForOverview();
if (reposition)
PositionWindows(animate);
......
......@@ -2216,7 +2216,8 @@ TEST_F(SplitViewTabDraggingTest, ShowNewWindowItemWhenDragStarts) {
EXPECT_EQ(split_view_controller()->state(),
SplitViewController::RIGHT_SNAPPED);
// Test that the new window item widget shows up.
// Test that the new window item widget shows up as the first one of the
// windows in the grid.
WindowSelector* window_selector =
Shell::Get()->window_selector_controller()->window_selector();
WindowGrid* current_grid =
......@@ -2230,6 +2231,7 @@ TEST_F(SplitViewTabDraggingTest, ShowNewWindowItemWhenDragStarts) {
current_grid->GetWindowSelectorItemContaining(
new_selector_widget->GetNativeWindow());
ASSERT_TRUE(new_selector_item);
EXPECT_EQ(new_selector_item, current_grid->window_list().front().get());
const gfx::Rect new_selector_bounds = new_selector_item->target_bounds();
DragWindowTo(resizer.get(), new_selector_bounds.CenterPoint());
CompleteDrag(std::move(resizer));
......@@ -2237,8 +2239,12 @@ TEST_F(SplitViewTabDraggingTest, ShowNewWindowItemWhenDragStarts) {
EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting());
EXPECT_EQ(split_view_controller()->state(),
SplitViewController::RIGHT_SNAPPED);
// Test that the dragged window has been added to the overview mode.
// Test that the dragged window has been added to the overview mode, and it is
// added at the front of the grid.
EXPECT_EQ(current_grid->window_list().size(), 2u);
WindowSelectorItem* first_selector_item =
current_grid->GetWindowSelectorItemContaining(window1.get());
EXPECT_EQ(first_selector_item, current_grid->window_list().front().get());
EXPECT_TRUE(window_selector->IsWindowInOverview(window1.get()));
EXPECT_TRUE(window_selector->IsWindowInOverview(window3.get()));
// Test that the new window item widget has been destroyed.
......
......@@ -50,11 +50,12 @@ gfx::Rect GetNewSelectorItemBounds(aura::Window* dragged_window) {
if (!window_grid || window_grid->empty())
return gfx::Rect();
WindowSelectorItem* last_item = window_grid->window_list().back().get();
if (!window_grid->IsNewSelectorItemWindow(last_item->GetWindow()))
WindowSelectorItem* new_selector_item =
window_grid->window_list().front().get();
if (!window_grid->IsNewSelectorItemWindow(new_selector_item->GetWindow()))
return gfx::Rect();
return last_item->target_bounds();
return new_selector_item->target_bounds();
}
// Set |transform| to |window| and its transient child windows. |transform| is
......
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