| Index: ash/wm/overview/window_selector.cc
|
| diff --git a/ash/wm/overview/window_selector.cc b/ash/wm/overview/window_selector.cc
|
| index 76eb46a10de22b2b98d4e610d1ea44844cbcd665..0a63e8f8265829e03a8ec472e7d46841ac6a1894 100644
|
| --- a/ash/wm/overview/window_selector.cc
|
| +++ b/ash/wm/overview/window_selector.cc
|
| @@ -92,7 +92,7 @@ struct WindowSelectorItemTargetComparator
|
| }
|
|
|
| bool operator()(WindowSelectorItem* window) const {
|
| - return window->Contains(target);
|
| + return window->GetWindow() == target;
|
| }
|
|
|
| const aura::Window* target;
|
| @@ -217,8 +217,7 @@ views::Widget* CreateTextFilter(views::TextfieldController* controller,
|
| const int WindowSelector::kTextFilterBottomEdge =
|
| kTextFilterDistanceFromTop + kTextFilterHeight;
|
|
|
| -WindowSelector::WindowSelector(const WindowList& windows,
|
| - WindowSelectorDelegate* delegate)
|
| +WindowSelector::WindowSelector(WindowSelectorDelegate* delegate)
|
| : delegate_(delegate),
|
| restore_focus_window_(aura::client::GetFocusClient(
|
| Shell::GetPrimaryRootWindow())->GetFocusedWindow()),
|
| @@ -229,11 +228,19 @@ WindowSelector::WindowSelector(const WindowList& windows,
|
| num_items_(0),
|
| showing_selection_widget_(false),
|
| text_filter_string_length_(0),
|
| - num_times_textfield_cleared_(0) {
|
| + num_times_textfield_cleared_(0),
|
| + restoring_minimized_windows_(false) {
|
| DCHECK(delegate_);
|
| - Shell* shell = Shell::GetInstance();
|
| - shell->OnOverviewModeStarting();
|
| +}
|
|
|
| +WindowSelector::~WindowSelector() {
|
| + RemoveAllObservers();
|
| +}
|
| +
|
| +// NOTE: The work done in Init() is not done in the constructor because it may
|
| +// cause other, unrelated classes, (ie PanelLayoutManager) to make indirect
|
| +// calls to restoring_minimized_windows() on a partially constructed object.
|
| +void WindowSelector::Init(const WindowList& windows) {
|
| if (restore_focus_window_)
|
| restore_focus_window_->AddObserver(this);
|
|
|
| @@ -262,20 +269,33 @@ WindowSelector::WindowSelector(const WindowList& windows,
|
| grid_list_.push_back(grid.release());
|
| }
|
|
|
| - // Do not call PrepareForOverview until all items are added to window_list_ as
|
| - // we don't want to cause any window updates until all windows in overview
|
| - // are observed. See http://crbug.com/384495.
|
| - for (ScopedVector<WindowGrid>::iterator iter = grid_list_.begin();
|
| - iter != grid_list_.end(); ++iter) {
|
| - (*iter)->PrepareForOverview();
|
| - (*iter)->PositionWindows(true);
|
| + {
|
| + // The calls to WindowGrid::PrepareForOverview() and CreateTextFilter(...)
|
| + // requires some LayoutManagers (ie PanelLayoutManager) to perform layouts
|
| + // so that windows are correctly visible and properly animated in overview
|
| + // mode. Otherwise these layouts should be suppressed during overview mode
|
| + // so they don't conflict with overview mode animations. The
|
| + // |restoring_minimized_windows_| flag enables the PanelLayoutManager to
|
| + // make this decision.
|
| + base::AutoReset<bool> auto_restoring_minimized_windows(
|
| + &restoring_minimized_windows_, true);
|
| +
|
| + // Do not call PrepareForOverview until all items are added to window_list_
|
| + // as we don't want to cause any window updates until all windows in
|
| + // overview are observed. See http://crbug.com/384495.
|
| + for (WindowGrid* window_grid : grid_list_) {
|
| + window_grid->PrepareForOverview();
|
| + window_grid->PositionWindows(true);
|
| + }
|
| +
|
| + text_filter_widget_.reset(
|
| + CreateTextFilter(this, Shell::GetPrimaryRootWindow()));
|
| }
|
|
|
| DCHECK(!grid_list_.empty());
|
| UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_);
|
|
|
| - text_filter_widget_.reset(
|
| - CreateTextFilter(this, Shell::GetPrimaryRootWindow()));
|
| + Shell* shell = Shell::GetInstance();
|
|
|
| shell->activation_client()->AddObserver(this);
|
|
|
| @@ -289,15 +309,12 @@ WindowSelector::WindowSelector(const WindowList& windows,
|
| UpdateShelfVisibility();
|
| }
|
|
|
| -WindowSelector::~WindowSelector() {
|
| - Shell* shell = Shell::GetInstance();
|
| -
|
| +// NOTE: The work done in Shutdown() is not done in the destructor because it
|
| +// may cause other, unrelated classes, (ie PanelLayoutManager) to make indirect
|
| +// calls to restoring_minimized_windows() on a partially destructed object.
|
| +void WindowSelector::Shutdown() {
|
| ResetFocusRestoreWindow(true);
|
| - for (std::set<aura::Window*>::iterator iter = observed_windows_.begin();
|
| - iter != observed_windows_.end(); ++iter) {
|
| - (*iter)->RemoveObserver(this);
|
| - }
|
| - shell->activation_client()->RemoveObserver(this);
|
| + RemoveAllObservers();
|
|
|
| aura::Window::Windows root_windows = Shell::GetAllRootWindows();
|
| for (aura::Window::Windows::const_iterator iter = root_windows.begin();
|
| @@ -319,12 +336,11 @@ WindowSelector::~WindowSelector() {
|
| (*iter)->Show();
|
| }
|
|
|
| - shell->GetScreen()->RemoveObserver(this);
|
| -
|
| size_t remaining_items = 0;
|
| - for (ScopedVector<WindowGrid>::iterator iter = grid_list_.begin();
|
| - iter != grid_list_.end(); iter++) {
|
| - remaining_items += (*iter)->size();
|
| + for (WindowGrid* window_grid : grid_list_) {
|
| + for (WindowSelectorItem* window_selector_item : window_grid->window_list())
|
| + window_selector_item->RestoreWindow();
|
| + remaining_items += window_grid->size();
|
| }
|
|
|
| DCHECK(num_items_ >= remaining_items);
|
| @@ -347,15 +363,22 @@ WindowSelector::~WindowSelector() {
|
| remaining_items);
|
| }
|
|
|
| - // TODO(flackr): Change this to OnOverviewModeEnded and move it to when
|
| - // everything is done.
|
| - shell->OnOverviewModeEnding();
|
| -
|
| // Clearing the window list resets the ignored_by_shelf flag on the windows.
|
| grid_list_.clear();
|
| UpdateShelfVisibility();
|
| }
|
|
|
| +void WindowSelector::RemoveAllObservers() {
|
| + Shell* shell = Shell::GetInstance();
|
| + for (aura::Window* window : observed_windows_)
|
| + window->RemoveObserver(this);
|
| +
|
| + shell->activation_client()->RemoveObserver(this);
|
| + shell->GetScreen()->RemoveObserver(this);
|
| + if (restore_focus_window_)
|
| + restore_focus_window_->RemoveObserver(this);
|
| +}
|
| +
|
| void WindowSelector::CancelSelection() {
|
| delegate_->OnSelectionEnded();
|
| }
|
| @@ -409,7 +432,7 @@ bool WindowSelector::HandleKeyEvent(views::Textfield* sender,
|
| Shell::GetInstance()->metrics()->RecordUserMetricsAction(
|
| UMA_WINDOW_OVERVIEW_ENTER_KEY);
|
| wm::GetWindowState(grid_list_[selected_grid_index_]->
|
| - SelectedWindow()->SelectionWindow())->Activate();
|
| + SelectedWindow()->GetWindow())->Activate();
|
| break;
|
| default:
|
| // Not a key we are interested in, allow the textfield to handle it.
|
| @@ -474,7 +497,7 @@ void WindowSelector::OnWindowActivated(aura::Window* gained_active,
|
| WindowSelectorItemTargetComparator(gained_active));
|
|
|
| if (iter != windows.end())
|
| - (*iter)->RestoreWindowOnExit(gained_active);
|
| + (*iter)->ShowWindowOnExit();
|
|
|
| // Don't restore focus on exit if a window was just activated.
|
| ResetFocusRestoreWindow(false);
|
|
|