Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: ash/display/display_controller.cc

Issue 10828037: ash: Remove wm::GetRootWindowController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/extended_desktop_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/display/display_controller.h" 5 #include "ash/display/display_controller.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/multi_display_manager.h" 8 #include "ash/display/multi_display_manager.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/screen_ash.h" 10 #include "ash/screen_ash.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/wm/property_util.h"
12 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
15 #include "ui/aura/root_window.h" 16 #include "ui/aura/root_window.h"
16 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
17 #include "ui/gfx/display.h" 18 #include "ui/gfx/display.h"
18 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
19 20
20 namespace ash { 21 namespace ash {
21 namespace internal { 22 namespace internal {
22 23
23 DisplayController::DisplayController() 24 DisplayController::DisplayController()
24 : secondary_display_layout_(RIGHT) { 25 : secondary_display_layout_(RIGHT) {
25 aura::Env::GetInstance()->display_manager()->AddObserver(this); 26 aura::Env::GetInstance()->display_manager()->AddObserver(this);
26 } 27 }
27 28
28 DisplayController::~DisplayController() { 29 DisplayController::~DisplayController() {
29 aura::Env::GetInstance()->display_manager()->RemoveObserver(this); 30 aura::Env::GetInstance()->display_manager()->RemoveObserver(this);
30 // Delete all root window controllers, which deletes root window 31 // Delete all root window controllers, which deletes root window
31 // from the last so that the primary root window gets deleted last. 32 // from the last so that the primary root window gets deleted last.
32 for (std::map<int, aura::RootWindow*>::const_reverse_iterator it = 33 for (std::map<int, aura::RootWindow*>::const_reverse_iterator it =
33 root_windows_.rbegin(); it != root_windows_.rend(); ++it) { 34 root_windows_.rbegin(); it != root_windows_.rend(); ++it) {
34 internal::RootWindowController* controller = 35 internal::RootWindowController* controller =
35 wm::GetRootWindowController(it->second); 36 GetRootWindowController(it->second);
36 // RootWindow may not have RootWindowController in non 37 // RootWindow may not have RootWindowController in non
37 // extended desktop mode. 38 // extended desktop mode.
38 if (controller) 39 if (controller)
39 delete controller; 40 delete controller;
40 else 41 else
41 delete it->second; 42 delete it->second;
42 } 43 }
43 } 44 }
44 45
45 void DisplayController::InitPrimaryDisplay() { 46 void DisplayController::InitPrimaryDisplay() {
(...skipping 23 matching lines...) Expand all
69 70
70 aura::RootWindow* DisplayController::GetRootWindowForDisplayId(int id) { 71 aura::RootWindow* DisplayController::GetRootWindowForDisplayId(int id) {
71 return root_windows_[id]; 72 return root_windows_[id];
72 } 73 }
73 74
74 void DisplayController::CloseChildWindows() { 75 void DisplayController::CloseChildWindows() {
75 for (std::map<int, aura::RootWindow*>::const_iterator it = 76 for (std::map<int, aura::RootWindow*>::const_iterator it =
76 root_windows_.begin(); it != root_windows_.end(); ++it) { 77 root_windows_.begin(); it != root_windows_.end(); ++it) {
77 aura::RootWindow* root_window = it->second; 78 aura::RootWindow* root_window = it->second;
78 internal::RootWindowController* controller = 79 internal::RootWindowController* controller =
79 wm::GetRootWindowController(root_window); 80 GetRootWindowController(root_window);
80 if (controller) { 81 if (controller) {
81 controller->CloseChildWindows(); 82 controller->CloseChildWindows();
82 } else { 83 } else {
83 while (!root_window->children().empty()) { 84 while (!root_window->children().empty()) {
84 aura::Window* child = root_window->children()[0]; 85 aura::Window* child = root_window->children()[0];
85 delete child; 86 delete child;
86 } 87 }
87 } 88 }
88 } 89 }
89 } 90 }
90 91
91 std::vector<aura::RootWindow*> DisplayController::GetAllRootWindows() { 92 std::vector<aura::RootWindow*> DisplayController::GetAllRootWindows() {
92 std::vector<aura::RootWindow*> windows; 93 std::vector<aura::RootWindow*> windows;
93 for (std::map<int, aura::RootWindow*>::const_iterator it = 94 for (std::map<int, aura::RootWindow*>::const_iterator it =
94 root_windows_.begin(); it != root_windows_.end(); ++it) { 95 root_windows_.begin(); it != root_windows_.end(); ++it) {
95 DCHECK(it->second); 96 DCHECK(it->second);
96 if (wm::GetRootWindowController(it->second)) 97 if (GetRootWindowController(it->second))
97 windows.push_back(it->second); 98 windows.push_back(it->second);
98 } 99 }
99 return windows; 100 return windows;
100 } 101 }
101 102
102 std::vector<internal::RootWindowController*> 103 std::vector<internal::RootWindowController*>
103 DisplayController::GetAllRootWindowControllers() { 104 DisplayController::GetAllRootWindowControllers() {
104 std::vector<internal::RootWindowController*> controllers; 105 std::vector<internal::RootWindowController*> controllers;
105 for (std::map<int, aura::RootWindow*>::const_iterator it = 106 for (std::map<int, aura::RootWindow*>::const_iterator it =
106 root_windows_.begin(); it != root_windows_.end(); ++it) { 107 root_windows_.begin(); it != root_windows_.end(); ++it) {
107 internal::RootWindowController* controller = 108 internal::RootWindowController* controller =
108 wm::GetRootWindowController(it->second); 109 GetRootWindowController(it->second);
109 if (controller) 110 if (controller)
110 controllers.push_back(controller); 111 controllers.push_back(controller);
111 } 112 }
112 return controllers; 113 return controllers;
113 } 114 }
114 115
115 void DisplayController::SetSecondaryDisplayLayout( 116 void DisplayController::SetSecondaryDisplayLayout(
116 SecondaryDisplayLayout layout) { 117 SecondaryDisplayLayout layout) {
117 secondary_display_layout_ = layout; 118 secondary_display_layout_ = layout;
118 UpdateDisplayBoundsForLayout(); 119 UpdateDisplayBoundsForLayout();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 void DisplayController::OnDisplayRemoved(const gfx::Display& display) { 211 void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
211 aura::RootWindow* root = root_windows_[display.id()]; 212 aura::RootWindow* root = root_windows_[display.id()];
212 DCHECK(root); 213 DCHECK(root);
213 // Primary display should never be removed by DisplayManager. 214 // Primary display should never be removed by DisplayManager.
214 DCHECK(root != Shell::GetPrimaryRootWindow()); 215 DCHECK(root != Shell::GetPrimaryRootWindow());
215 // Display for root window will be deleted when the Primary RootWindow 216 // Display for root window will be deleted when the Primary RootWindow
216 // is deleted by the Shell. 217 // is deleted by the Shell.
217 if (root != Shell::GetPrimaryRootWindow()) { 218 if (root != Shell::GetPrimaryRootWindow()) {
218 root_windows_.erase(display.id()); 219 root_windows_.erase(display.id());
219 internal::RootWindowController* controller = 220 internal::RootWindowController* controller =
220 wm::GetRootWindowController(root); 221 GetRootWindowController(root);
221 if (controller) { 222 if (controller) {
222 controller->MoveWindowsTo(Shell::GetPrimaryRootWindow()); 223 controller->MoveWindowsTo(Shell::GetPrimaryRootWindow());
223 delete controller; 224 delete controller;
224 } else { 225 } else {
225 delete root; 226 delete root;
226 } 227 }
227 } 228 }
228 } 229 }
229 230
230 // static 231 // static
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 break; 281 break;
281 } 282 }
282 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); 283 gfx::Insets insets = secondary_display->GetWorkAreaInsets();
283 secondary_display->set_bounds( 284 secondary_display->set_bounds(
284 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 285 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
285 secondary_display->UpdateWorkAreaFromInsets(insets); 286 secondary_display->UpdateWorkAreaFromInsets(insets);
286 } 287 }
287 288
288 } // namespace internal 289 } // namespace internal
289 } // namespace ash 290 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/extended_desktop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698