| Index: ash/common/wm/maximize_mode/maximize_mode_window_manager.cc
|
| diff --git a/ash/common/wm/maximize_mode/maximize_mode_window_manager.cc b/ash/common/wm/maximize_mode/maximize_mode_window_manager.cc
|
| index f393fd618fcb21b47bc23e0a4e6077ff62ca883b..a0ab320385c971f8a7a1f077b2ce397352703ee6 100644
|
| --- a/ash/common/wm/maximize_mode/maximize_mode_window_manager.cc
|
| +++ b/ash/common/wm/maximize_mode/maximize_mode_window_manager.cc
|
| @@ -42,7 +42,9 @@ MaximizeModeWindowManager::~MaximizeModeWindowManager() {
|
| // transforming windows which are currently in
|
| // overview: http://crbug.com/366605
|
| CancelOverview();
|
| -
|
| + for (auto* window : added_windows_)
|
| + window->RemoveObserver(this);
|
| + added_windows_.clear();
|
| WmShell::Get()->RemoveShellObserver(this);
|
| display::Screen::GetScreen()->RemoveObserver(this);
|
| EnableBackdropBehindTopWindowOnEachDisplay(false);
|
| @@ -98,6 +100,10 @@ void MaximizeModeWindowManager::OnWindowDestroying(WmWindow* window) {
|
| // container window can be removed on display destruction.
|
| window->RemoveObserver(this);
|
| observed_container_windows_.erase(window);
|
| + } else if (ContainsValue(added_windows_, window)) {
|
| + // Added window was destroyed before being shown.
|
| + added_windows_.erase(window);
|
| + window->RemoveObserver(this);
|
| } else {
|
| // If a known window gets destroyed we need to remove all knowledge about
|
| // it.
|
| @@ -111,6 +117,16 @@ void MaximizeModeWindowManager::OnWindowTreeChanged(
|
| // A window can get removed and then re-added by a drag and drop operation.
|
| if (params.new_parent && IsContainerWindow(params.new_parent) &&
|
| !ContainsKey(window_state_map_, params.target)) {
|
| + // Don't register the window if the window is invisible. Instead,
|
| + // wait until it becomes visible because the client may update the
|
| + // flag to control if the window should be added.
|
| + if (!params.target->IsVisible()) {
|
| + if (!ContainsValue(added_windows_, params.target)) {
|
| + added_windows_.insert(params.target);
|
| + params.target->AddObserver(this);
|
| + }
|
| + return;
|
| + }
|
| MaximizeAndTrackWindow(params.target);
|
| // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got
|
| // already sent and we have to notify our state again.
|
| @@ -140,6 +156,26 @@ void MaximizeModeWindowManager::OnWindowBoundsChanged(
|
| pair.second->UpdateWindowPosition(pair.first->GetWindowState());
|
| }
|
|
|
| +void MaximizeModeWindowManager::OnWindowVisibilityChanging(WmWindow* window,
|
| + bool visible) {
|
| + // Skip if it's already managed.
|
| + if (ContainsKey(window_state_map_, window))
|
| + return;
|
| +
|
| + if (IsContainerWindow(window->GetParent()) &&
|
| + ContainsValue(added_windows_, window) && visible) {
|
| + added_windows_.erase(window);
|
| + window->RemoveObserver(this);
|
| + MaximizeAndTrackWindow(window);
|
| + // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got
|
| + // already sent and we have to notify our state again.
|
| + if (ContainsKey(window_state_map_, window)) {
|
| + wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
|
| + window->GetWindowState()->OnWMEvent(&event);
|
| + }
|
| + }
|
| +}
|
| +
|
| void MaximizeModeWindowManager::OnDisplayAdded(
|
| const display::Display& display) {
|
| DisplayConfigurationChanged();
|
|
|