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 <queue> | 7 #include <queue> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 if (shelf_->shelf_layout_manager()) | 430 if (shelf_->shelf_layout_manager()) |
431 shelf_->shelf_layout_manager()->PrepareForShutdown(); | 431 shelf_->shelf_layout_manager()->PrepareForShutdown(); |
432 | 432 |
433 // Close background widget first as it depends on tooltip. | 433 // Close background widget first as it depends on tooltip. |
434 wallpaper_controller_.reset(); | 434 wallpaper_controller_.reset(); |
435 animating_wallpaper_controller_.reset(); | 435 animating_wallpaper_controller_.reset(); |
436 | 436 |
437 workspace_controller_.reset(); | 437 workspace_controller_.reset(); |
438 aura::client::SetTooltipClient(root_window_.get(), NULL); | 438 aura::client::SetTooltipClient(root_window_.get(), NULL); |
439 | 439 |
440 // Explicitly destroy top level windows. We do this as during part of | 440 // Remove all toplevel windows first. |
441 // destruction such windows may query the RootWindow for state. | |
442 std::queue<aura::Window*> non_toplevel_windows; | 441 std::queue<aura::Window*> non_toplevel_windows; |
443 non_toplevel_windows.push(root_window_.get()); | 442 non_toplevel_windows.push(root_window_.get()); |
444 while (!non_toplevel_windows.empty()) { | 443 while (!non_toplevel_windows.empty()) { |
445 aura::Window* non_toplevel_window = non_toplevel_windows.front(); | 444 aura::Window* non_toplevel_window = non_toplevel_windows.front(); |
446 non_toplevel_windows.pop(); | 445 non_toplevel_windows.pop(); |
447 aura::WindowTracker toplevel_windows; | 446 aura::WindowTracker toplevel_windows; |
448 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) { | 447 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) { |
449 aura::Window* child = non_toplevel_window->children()[i]; | 448 aura::Window* child = non_toplevel_window->children()[i]; |
450 if (!child->owned_by_parent()) | |
451 continue; | |
452 if (child->delegate()) | 449 if (child->delegate()) |
453 toplevel_windows.Add(child); | 450 toplevel_windows.Add(child); |
454 else | 451 else |
455 non_toplevel_windows.push(child); | 452 non_toplevel_windows.push(child); |
456 } | 453 } |
457 while (!toplevel_windows.windows().empty()) | 454 while (!toplevel_windows.windows().empty()) |
458 delete *toplevel_windows.windows().begin(); | 455 delete *toplevel_windows.windows().begin(); |
459 } | 456 } |
460 // And then remove the containers. | 457 // And then remove the containers. |
461 while (!root_window_->children().empty()) { | 458 while (!root_window_->children().empty()) |
462 aura::Window* window = root_window_->children()[0]; | 459 delete root_window_->children()[0]; |
463 if (window->owned_by_parent()) { | |
464 delete window; | |
465 } else { | |
466 root_window_->RemoveChild(window); | |
467 } | |
468 } | |
469 | 460 |
470 shelf_.reset(NULL); | 461 shelf_.reset(NULL); |
471 } | 462 } |
472 | 463 |
473 void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) { | 464 void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) { |
474 // Forget the shelf early so that shelf don't update itself using wrong | 465 // Forget the shelf early so that shelf don't update itself using wrong |
475 // display info. | 466 // display info. |
476 workspace_controller_->SetShelf(NULL); | 467 workspace_controller_->SetShelf(NULL); |
477 ReparentAllWindows(root_window_.get(), dst); | 468 ReparentAllWindows(root_window_.get(), dst); |
478 } | 469 } |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 DisableTouchHudProjection(); | 828 DisableTouchHudProjection(); |
838 } | 829 } |
839 | 830 |
840 RootWindowController* GetRootWindowController( | 831 RootWindowController* GetRootWindowController( |
841 const aura::RootWindow* root_window) { | 832 const aura::RootWindow* root_window) { |
842 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; | 833 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
843 } | 834 } |
844 | 835 |
845 } // namespace internal | 836 } // namespace internal |
846 } // namespace ash | 837 } // namespace ash |
OLD | NEW |