Index: components/mus/example/wm/window_manager_application.cc |
diff --git a/components/mus/example/wm/window_manager_application.cc b/components/mus/example/wm/window_manager_application.cc |
index 2ab82f8fa8bafe2225ee016e228a3d9b463c7ba5..175397e79bc78d766cf9a77c87acb79cb7196a01 100644 |
--- a/components/mus/example/wm/window_manager_application.cc |
+++ b/components/mus/example/wm/window_manager_application.cc |
@@ -43,13 +43,11 @@ bool WindowManagerApplication::ConfigureIncomingConnection( |
void WindowManagerApplication::OnEmbed(mus::Window* root) { |
root_ = root; |
+ root_->AddObserver(this); |
CreateContainers(); |
layout_.reset( |
new WindowLayout(GetWindowForContainer(Container::USER_WINDOWS))); |
- host_->EnableWindowDraggingForChildren( |
- GetWindowForContainer(Container::USER_WINDOWS)->id()); |
- |
window_manager_.reset(new WindowManagerImpl(this)); |
for (auto request : requests_) |
window_manager_binding_.AddBinding(window_manager_.get(), request->Pass()); |
@@ -73,6 +71,15 @@ void WindowManagerApplication::Create( |
} |
} |
+void WindowManagerApplication::OnWindowDestroyed(mus::Window* window) { |
+ DCHECK_EQ(window, root_); |
+ root_->RemoveObserver(this); |
+ // Delete the |window_manager_| here so that WindowManager doesn't have to |
+ // worry about the possibility of |root_| being null. |
+ window_manager_.reset(); |
+ root_ = nullptr; |
+} |
+ |
void WindowManagerApplication::CreateContainers() { |
for (uint16_t container = |
static_cast<uint16_t>(Container::ALL_USER_BACKGROUND); |