Commit b647c5c0 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

Update overview items numbers when adding/removing a window item.

Because of splitscreen, it's now possible to remove an overview window
item to snap in splitscreen, or to add an overview window item from one
of the snapped windows in splitscreen, we should update the overview
items in these two cases. Otherwise in WindowSelector::Shutdown(), the
DCHECK(num_items_ >= remaining_items) might fail and the UMA stat
Ash.WindowSelector.OverviewClosedItems might not record the correct
number.

Bug: 822059
Change-Id: Ic60cd10a8e352bc6ea5c559b1d79f60dee7e81dd
Reviewed-on: https://chromium-review.googlesource.com/963723
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543638}
parent fc657a9f
...@@ -537,6 +537,7 @@ void WindowSelector::AddItem(aura::Window* window) { ...@@ -537,6 +537,7 @@ void WindowSelector::AddItem(aura::Window* window) {
// this will be need to updated. // this will be need to updated.
TabletModeWindowState::UpdateWindowPosition(wm::GetWindowState(window)); TabletModeWindowState::UpdateWindowPosition(wm::GetWindowState(window));
grid->AddItem(window); grid->AddItem(window);
++num_items_;
// Transfer focus from |window| to the text widget, to match the behavior of // Transfer focus from |window| to the text widget, to match the behavior of
// entering overview mode in the beginning. // entering overview mode in the beginning.
...@@ -555,6 +556,7 @@ void WindowSelector::RemoveWindowSelectorItem(WindowSelectorItem* item) { ...@@ -555,6 +556,7 @@ void WindowSelector::RemoveWindowSelectorItem(WindowSelectorItem* item) {
for (std::unique_ptr<WindowGrid>& grid : grid_list_) { for (std::unique_ptr<WindowGrid>& grid : grid_list_) {
if (grid->GetWindowSelectorItemContaining(item->GetWindow())) { if (grid->GetWindowSelectorItemContaining(item->GetWindow())) {
grid->RemoveItem(item); grid->RemoveItem(item);
--num_items_;
if (grid->empty()) if (grid->empty())
OnGridEmpty(grid.get()); OnGridEmpty(grid.get());
break; break;
......
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