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_filter.h" | 21 #include "ash/wm/toplevel_window_event_filter.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 287 |
287 RootWindowController::RootWindowController(aura::RootWindow* root_window) | 288 RootWindowController::RootWindowController(aura::RootWindow* root_window) |
288 : root_window_(root_window) { | 289 : root_window_(root_window) { |
289 SetRootWindowController(root_window, this); | 290 SetRootWindowController(root_window, this); |
290 | 291 |
291 event_client_.reset(new internal::EventClientImpl(root_window)); | 292 event_client_.reset(new internal::EventClientImpl(root_window)); |
292 screen_dimmer_.reset(new internal::ScreenDimmer(root_window)); | 293 screen_dimmer_.reset(new internal::ScreenDimmer(root_window)); |
293 } | 294 } |
294 | 295 |
295 RootWindowController::~RootWindowController() { | 296 RootWindowController::~RootWindowController() { |
| 297 Shutdown(); |
| 298 root_window_.reset(); |
| 299 } |
| 300 |
| 301 void RootWindowController::Shutdown() { |
| 302 CloseChildWindows(); |
296 if (Shell::GetActiveRootWindow() == root_window_.get()) { | 303 if (Shell::GetActiveRootWindow() == root_window_.get()) { |
297 Shell::GetInstance()->set_active_root_window( | 304 Shell::GetInstance()->set_active_root_window( |
298 Shell::GetPrimaryRootWindow() == root_window_.get() ? | 305 Shell::GetPrimaryRootWindow() == root_window_.get() ? |
299 NULL : Shell::GetPrimaryRootWindow()); | 306 NULL : Shell::GetPrimaryRootWindow()); |
300 } | 307 } |
301 SetRootWindowController(root_window_.get(), NULL); | 308 SetRootWindowController(root_window_.get(), NULL); |
302 event_client_.reset(); | 309 event_client_.reset(); |
303 screen_dimmer_.reset(); | 310 screen_dimmer_.reset(); |
304 workspace_controller_.reset(); | 311 workspace_controller_.reset(); |
305 root_window_.reset(); | 312 // Forget with the display ID so that display lookup |
| 313 // ends up with invalid display. |
| 314 root_window_->ClearProperty(kDisplayIdKey); |
| 315 // And this root window should no longer process events. |
| 316 root_window_->StopListeningEvents(); |
306 } | 317 } |
307 | 318 |
308 aura::Window* RootWindowController::GetContainer(int container_id) { | 319 aura::Window* RootWindowController::GetContainer(int container_id) { |
309 return root_window_->GetChildById(container_id); | 320 return root_window_->GetChildById(container_id); |
310 } | 321 } |
311 | 322 |
312 void RootWindowController::InitLayoutManagers() { | 323 void RootWindowController::InitLayoutManagers() { |
313 root_window_layout_ = | 324 root_window_layout_ = |
314 new internal::RootWindowLayoutManager(root_window_.get()); | 325 new internal::RootWindowLayoutManager(root_window_.get()); |
315 root_window_->SetLayoutManager(root_window_layout_); | 326 root_window_->SetLayoutManager(root_window_layout_); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // Restore focused or active window if it's still alive. | 383 // Restore focused or active window if it's still alive. |
373 if (focused && tracker.Contains(focused) && dst->Contains(focused)) { | 384 if (focused && tracker.Contains(focused) && dst->Contains(focused)) { |
374 dst->GetFocusManager()->SetFocusedWindow(focused, NULL); | 385 dst->GetFocusManager()->SetFocusedWindow(focused, NULL); |
375 } else if (active && tracker.Contains(active) && dst->Contains(active)) { | 386 } else if (active && tracker.Contains(active) && dst->Contains(active)) { |
376 activation_client->ActivateWindow(active); | 387 activation_client->ActivateWindow(active); |
377 } | 388 } |
378 } | 389 } |
379 | 390 |
380 } // namespace internal | 391 } // namespace internal |
381 } // namespace ash | 392 } // namespace ash |
OLD | NEW |