Chromium Code Reviews| Index: mash/wm/window_manager.cc |
| diff --git a/mash/wm/window_manager.cc b/mash/wm/window_manager.cc |
| index fcaaea2077287b8768dbf08dc58fdb689daf93b2..f8adfab67deb41c11e9d2cca36ddfe6d28c056a4 100644 |
| --- a/mash/wm/window_manager.cc |
| +++ b/mash/wm/window_manager.cc |
| @@ -44,11 +44,17 @@ void WindowManager::Initialize(RootWindowController* root_controller, |
| DCHECK(root_controller); |
| DCHECK(!root_controller_); |
| root_controller_ = root_controller; |
| - // The children of the root are considered containers. |
| - for (auto container : root_controller_->root()->children()) { |
| + |
| + // Observe all the containers and their child windows. |
|
sky
2016/04/22 15:23:42
Why do you need to observer the child windows?
sky
2016/04/22 15:25:40
Never mind this comment, I just saw your comments
sadrul
2016/04/22 16:06:05
Done (introduced a DisconnectedAppHandler). Change
|
| + int count = static_cast<int>(mojom::Container::COUNT); |
| + for (int id = 1; id < count; ++id) { |
|
sky
2016/04/22 15:23:42
1 -> ROOT + 1 ?
sadrul
2016/04/22 16:06:06
Done.
|
| + mus::Window* container = root_controller_->GetWindowForContainer( |
| + static_cast<mojom::Container>(id)); |
| container->AddObserver(this); |
| - for (auto child : container->children()) |
| - child->AddObserver(this); |
| + for (auto child : container->children()) { |
| + if (!root_controller_->WindowIsContainer(child)) |
| + child->AddObserver(this); |
| + } |
| } |
| // The insets are roughly what is needed by CustomFrameView. The expectation |
| @@ -111,7 +117,10 @@ mus::Window* WindowManager::NewTopLevelWindow( |
| window->SetBounds(CalculateDefaultBounds(window)); |
| mojom::Container container = GetRequestedContainer(window); |
| - root_controller_->GetWindowForContainer(container)->AddChild(window); |
| + mus::Window* container_window = |
| + root_controller_->GetWindowForContainer(container); |
| + DCHECK(root_controller_->WindowIsContainer(container_window)); |
| + container_window->AddChild(window); |
| if (provide_non_client_frame) { |
| NonClientFrameController::Create(root_controller_->GetConnector(), window, |
| @@ -125,9 +134,12 @@ mus::Window* WindowManager::NewTopLevelWindow( |
| void WindowManager::OnTreeChanging(const TreeChangeParams& params) { |
| DCHECK(root_controller_); |
| - if (root_controller_->WindowIsContainer(params.old_parent)) |
| + if (params.old_parent == params.receiver && |
| + root_controller_->WindowIsContainer(params.old_parent)) |
| params.target->RemoveObserver(this); |
| - else if (root_controller_->WindowIsContainer(params.new_parent)) |
| + |
| + if (params.new_parent == params.receiver && |
| + root_controller_->WindowIsContainer(params.new_parent)) |
| params.target->AddObserver(this); |
| } |