OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/desktop_background/desktop_background_widget_controller.h" | 9 #include "ash/desktop_background/desktop_background_widget_controller.h" |
10 #include "ash/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
| 11 #include "ash/display/multi_display_manager.h" |
11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
12 #include "ash/shell_factory.h" | 13 #include "ash/shell_factory.h" |
13 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
14 #include "ash/wm/base_layout_manager.h" | 15 #include "ash/wm/base_layout_manager.h" |
15 #include "ash/wm/event_client_impl.h" | 16 #include "ash/wm/event_client_impl.h" |
16 #include "ash/wm/property_util.h" | 17 #include "ash/wm/property_util.h" |
17 #include "ash/wm/root_window_layout_manager.h" | 18 #include "ash/wm/root_window_layout_manager.h" |
18 #include "ash/wm/screen_dimmer.h" | 19 #include "ash/wm/screen_dimmer.h" |
19 #include "ash/wm/system_modal_container_layout_manager.h" | 20 #include "ash/wm/system_modal_container_layout_manager.h" |
20 #include "ash/wm/toplevel_window_event_handler.h" | 21 #include "ash/wm/toplevel_window_event_handler.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 289 |
289 RootWindowController::RootWindowController(aura::RootWindow* root_window) | 290 RootWindowController::RootWindowController(aura::RootWindow* root_window) |
290 : root_window_(root_window) { | 291 : root_window_(root_window) { |
291 SetRootWindowController(root_window, this); | 292 SetRootWindowController(root_window, this); |
292 | 293 |
293 event_client_.reset(new internal::EventClientImpl(root_window)); | 294 event_client_.reset(new internal::EventClientImpl(root_window)); |
294 screen_dimmer_.reset(new internal::ScreenDimmer(root_window)); | 295 screen_dimmer_.reset(new internal::ScreenDimmer(root_window)); |
295 } | 296 } |
296 | 297 |
297 RootWindowController::~RootWindowController() { | 298 RootWindowController::~RootWindowController() { |
| 299 Shutdown(); |
| 300 root_window_.reset(); |
| 301 } |
| 302 |
| 303 void RootWindowController::Shutdown() { |
| 304 CloseChildWindows(); |
298 if (Shell::GetActiveRootWindow() == root_window_.get()) { | 305 if (Shell::GetActiveRootWindow() == root_window_.get()) { |
299 Shell::GetInstance()->set_active_root_window( | 306 Shell::GetInstance()->set_active_root_window( |
300 Shell::GetPrimaryRootWindow() == root_window_.get() ? | 307 Shell::GetPrimaryRootWindow() == root_window_.get() ? |
301 NULL : Shell::GetPrimaryRootWindow()); | 308 NULL : Shell::GetPrimaryRootWindow()); |
302 } | 309 } |
303 SetRootWindowController(root_window_.get(), NULL); | 310 SetRootWindowController(root_window_.get(), NULL); |
304 event_client_.reset(); | 311 event_client_.reset(); |
305 screen_dimmer_.reset(); | 312 screen_dimmer_.reset(); |
306 workspace_controller_.reset(); | 313 workspace_controller_.reset(); |
307 root_window_.reset(); | 314 // Forget with the display ID so that display lookup |
| 315 // ends up with invalid display. |
| 316 root_window_->ClearProperty(kDisplayIdKey); |
| 317 // And this root window should no longer process events. |
| 318 root_window_->PrepareForShutdown(); |
308 } | 319 } |
309 | 320 |
310 aura::Window* RootWindowController::GetContainer(int container_id) { | 321 aura::Window* RootWindowController::GetContainer(int container_id) { |
311 return root_window_->GetChildById(container_id); | 322 return root_window_->GetChildById(container_id); |
312 } | 323 } |
313 | 324 |
314 void RootWindowController::InitLayoutManagers() { | 325 void RootWindowController::InitLayoutManagers() { |
315 root_window_layout_ = | 326 root_window_layout_ = |
316 new internal::RootWindowLayoutManager(root_window_.get()); | 327 new internal::RootWindowLayoutManager(root_window_.get()); |
317 root_window_->SetLayoutManager(root_window_layout_); | 328 root_window_->SetLayoutManager(root_window_layout_); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 // Restore focused or active window if it's still alive. | 385 // Restore focused or active window if it's still alive. |
375 if (focused && tracker.Contains(focused) && dst->Contains(focused)) { | 386 if (focused && tracker.Contains(focused) && dst->Contains(focused)) { |
376 dst->GetFocusManager()->SetFocusedWindow(focused, NULL); | 387 dst->GetFocusManager()->SetFocusedWindow(focused, NULL); |
377 } else if (active && tracker.Contains(active) && dst->Contains(active)) { | 388 } else if (active && tracker.Contains(active) && dst->Contains(active)) { |
378 activation_client->ActivateWindow(active); | 389 activation_client->ActivateWindow(active); |
379 } | 390 } |
380 } | 391 } |
381 | 392 |
382 } // namespace internal | 393 } // namespace internal |
383 } // namespace ash | 394 } // namespace ash |
OLD | NEW |