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

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

Issue 10675011: Rename the remaining usage of Monitor to Display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync 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 | « ash/display/display_controller.h ('k') | ash/display/mouse_cursor_event_filter.h » ('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/monitor/monitor_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/monitor/multi_monitor_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/shell.h" 10 #include "ash/shell.h"
11 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "ui/aura/env.h" 13 #include "ui/aura/env.h"
14 #include "ui/aura/root_window.h" 14 #include "ui/aura/root_window.h"
15 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
16 #include "ui/gfx/display.h" 16 #include "ui/gfx/display.h"
17 #include "ui/gfx/screen.h" 17 #include "ui/gfx/screen.h"
18 18
19 namespace ash { 19 namespace ash {
20 namespace internal { 20 namespace internal {
21 namespace { 21 namespace {
22 // True if the extended desktop mode is enabled. 22 // True if the extended desktop mode is enabled.
23 bool extended_desktop_enabled = false; 23 bool extended_desktop_enabled = false;
24 24
25 // True if the virtual screen coordinates is enabled. 25 // True if the virtual screen coordinates is enabled.
26 bool virtual_screen_coordinates_enabled = false; 26 bool virtual_screen_coordinates_enabled = false;
27 } 27 }
28 28
29 MonitorController::MonitorController() 29 DisplayController::DisplayController()
30 : secondary_display_layout_(RIGHT) { 30 : secondary_display_layout_(RIGHT) {
31 aura::Env::GetInstance()->monitor_manager()->AddObserver(this); 31 aura::Env::GetInstance()->display_manager()->AddObserver(this);
32 } 32 }
33 33
34 MonitorController::~MonitorController() { 34 DisplayController::~DisplayController() {
35 aura::Env::GetInstance()->monitor_manager()->RemoveObserver(this); 35 aura::Env::GetInstance()->display_manager()->RemoveObserver(this);
36 // Delete all root window controllers, which deletes root window 36 // Delete all root window controllers, which deletes root window
37 // from the last so that the primary root window gets deleted last. 37 // from the last so that the primary root window gets deleted last.
38 for (std::map<int, aura::RootWindow*>::const_reverse_iterator it = 38 for (std::map<int, aura::RootWindow*>::const_reverse_iterator it =
39 root_windows_.rbegin(); it != root_windows_.rend(); ++it) { 39 root_windows_.rbegin(); it != root_windows_.rend(); ++it) {
40 internal::RootWindowController* controller = 40 internal::RootWindowController* controller =
41 wm::GetRootWindowController(it->second); 41 wm::GetRootWindowController(it->second);
42 // RootWindow may not have RootWindowController in non 42 // RootWindow may not have RootWindowController in non
43 // extended desktop mode. 43 // extended desktop mode.
44 if (controller) 44 if (controller)
45 delete controller; 45 delete controller;
46 else 46 else
47 delete it->second; 47 delete it->second;
48 } 48 }
49 } 49 }
50 50
51 void MonitorController::InitPrimaryDisplay() { 51 void DisplayController::InitPrimaryDisplay() {
52 aura::MonitorManager* monitor_manager = 52 aura::DisplayManager* display_manager =
53 aura::Env::GetInstance()->monitor_manager(); 53 aura::Env::GetInstance()->display_manager();
54 const gfx::Display& display = monitor_manager->GetDisplayAt(0); 54 const gfx::Display& display = display_manager->GetDisplayAt(0);
55 DCHECK_EQ(0, display.id()); 55 DCHECK_EQ(0, display.id());
56 aura::RootWindow* root = AddRootWindowForDisplay(display); 56 aura::RootWindow* root = AddRootWindowForDisplay(display);
57 root->SetHostBounds(display.bounds_in_pixel()); 57 root->SetHostBounds(display.bounds_in_pixel());
58 } 58 }
59 59
60 void MonitorController::InitSecondaryDisplays() { 60 void DisplayController::InitSecondaryDisplays() {
61 aura::MonitorManager* monitor_manager = 61 aura::DisplayManager* display_manager =
62 aura::Env::GetInstance()->monitor_manager(); 62 aura::Env::GetInstance()->display_manager();
63 for (size_t i = 1; i < monitor_manager->GetNumDisplays(); ++i) { 63 for (size_t i = 1; i < display_manager->GetNumDisplays(); ++i) {
64 const gfx::Display& display = monitor_manager->GetDisplayAt(i); 64 const gfx::Display& display = display_manager->GetDisplayAt(i);
65 aura::RootWindow* root = AddRootWindowForDisplay(display); 65 aura::RootWindow* root = AddRootWindowForDisplay(display);
66 Shell::GetInstance()->InitRootWindowForSecondaryMonitor(root); 66 Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root);
67 } 67 }
68 } 68 }
69 69
70 aura::RootWindow* MonitorController::GetPrimaryRootWindow() { 70 aura::RootWindow* DisplayController::GetPrimaryRootWindow() {
71 DCHECK(!root_windows_.empty()); 71 DCHECK(!root_windows_.empty());
72 return root_windows_[0]; 72 return root_windows_[0];
73 } 73 }
74 74
75 void MonitorController::CloseChildWindows() { 75 void DisplayController::CloseChildWindows() {
76 for (std::map<int, aura::RootWindow*>::const_iterator it = 76 for (std::map<int, aura::RootWindow*>::const_iterator it =
77 root_windows_.begin(); it != root_windows_.end(); ++it) { 77 root_windows_.begin(); it != root_windows_.end(); ++it) {
78 aura::RootWindow* root_window = it->second; 78 aura::RootWindow* root_window = it->second;
79 internal::RootWindowController* controller = 79 internal::RootWindowController* controller =
80 wm::GetRootWindowController(root_window); 80 wm::GetRootWindowController(root_window);
81 if (controller) { 81 if (controller) {
82 controller->CloseChildWindows(); 82 controller->CloseChildWindows();
83 } else { 83 } else {
84 while (!root_window->children().empty()) { 84 while (!root_window->children().empty()) {
85 aura::Window* child = root_window->children()[0]; 85 aura::Window* child = root_window->children()[0];
86 delete child; 86 delete child;
87 } 87 }
88 } 88 }
89 } 89 }
90 } 90 }
91 91
92 std::vector<aura::RootWindow*> MonitorController::GetAllRootWindows() { 92 std::vector<aura::RootWindow*> DisplayController::GetAllRootWindows() {
93 std::vector<aura::RootWindow*> windows; 93 std::vector<aura::RootWindow*> windows;
94 for (std::map<int, aura::RootWindow*>::const_iterator it = 94 for (std::map<int, aura::RootWindow*>::const_iterator it =
95 root_windows_.begin(); it != root_windows_.end(); ++it) { 95 root_windows_.begin(); it != root_windows_.end(); ++it) {
96 DCHECK(it->second); 96 DCHECK(it->second);
97 if (wm::GetRootWindowController(it->second)) 97 if (wm::GetRootWindowController(it->second))
98 windows.push_back(it->second); 98 windows.push_back(it->second);
99 } 99 }
100 return windows; 100 return windows;
101 } 101 }
102 102
103 std::vector<internal::RootWindowController*> 103 std::vector<internal::RootWindowController*>
104 MonitorController::GetAllRootWindowControllers() { 104 DisplayController::GetAllRootWindowControllers() {
105 std::vector<internal::RootWindowController*> controllers; 105 std::vector<internal::RootWindowController*> controllers;
106 for (std::map<int, aura::RootWindow*>::const_iterator it = 106 for (std::map<int, aura::RootWindow*>::const_iterator it =
107 root_windows_.begin(); it != root_windows_.end(); ++it) { 107 root_windows_.begin(); it != root_windows_.end(); ++it) {
108 internal::RootWindowController* controller = 108 internal::RootWindowController* controller =
109 wm::GetRootWindowController(it->second); 109 wm::GetRootWindowController(it->second);
110 if (controller) 110 if (controller)
111 controllers.push_back(controller); 111 controllers.push_back(controller);
112 } 112 }
113 return controllers; 113 return controllers;
114 } 114 }
115 115
116 void MonitorController::SetSecondaryDisplayLayout( 116 void DisplayController::SetSecondaryDisplayLayout(
117 SecondaryDisplayLayout layout) { 117 SecondaryDisplayLayout layout) {
118 secondary_display_layout_ = layout; 118 secondary_display_layout_ = layout;
119 } 119 }
120 120
121 bool MonitorController::WarpMouseCursorIfNecessary( 121 bool DisplayController::WarpMouseCursorIfNecessary(
122 aura::Window* current_root, 122 aura::Window* current_root,
123 const gfx::Point& location_in_root) { 123 const gfx::Point& location_in_root) {
124 if (root_windows_.size() < 2) 124 if (root_windows_.size() < 2)
125 return false; 125 return false;
126 // Only 1 external display is supported in extended desktop mode. 126 // Only 1 external display is supported in extended desktop mode.
127 DCHECK_EQ(2U, root_windows_.size()); 127 DCHECK_EQ(2U, root_windows_.size());
128 128
129 bool in_primary = current_root == root_windows_[0]; 129 bool in_primary = current_root == root_windows_[0];
130 130
131 std::map<int, aura::RootWindow*>::iterator iter = root_windows_.begin(); 131 std::map<int, aura::RootWindow*>::iterator iter = root_windows_.begin();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 alternate_root = NULL; 182 alternate_root = NULL;
183 } 183 }
184 if (alternate_root) { 184 if (alternate_root) {
185 DCHECK_NE(alternate_root, current_root); 185 DCHECK_NE(alternate_root, current_root);
186 alternate_root->MoveCursorTo(alternate_point); 186 alternate_root->MoveCursorTo(alternate_point);
187 return true; 187 return true;
188 } 188 }
189 return false; 189 return false;
190 } 190 }
191 191
192 void MonitorController::OnDisplayBoundsChanged(const gfx::Display& display) { 192 void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) {
193 root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel()); 193 root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel());
194 } 194 }
195 195
196 void MonitorController::OnDisplayAdded(const gfx::Display& display) { 196 void DisplayController::OnDisplayAdded(const gfx::Display& display) {
197 if (root_windows_.empty()) { 197 if (root_windows_.empty()) {
198 DCHECK_EQ(0, display.id()); 198 DCHECK_EQ(0, display.id());
199 root_windows_[display.id()] = Shell::GetPrimaryRootWindow(); 199 root_windows_[display.id()] = Shell::GetPrimaryRootWindow();
200 Shell::GetPrimaryRootWindow()->SetHostBounds(display.bounds_in_pixel()); 200 Shell::GetPrimaryRootWindow()->SetHostBounds(display.bounds_in_pixel());
201 return; 201 return;
202 } 202 }
203 aura::RootWindow* root = AddRootWindowForDisplay(display); 203 aura::RootWindow* root = AddRootWindowForDisplay(display);
204 Shell::GetInstance()->InitRootWindowForSecondaryMonitor(root); 204 Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root);
205 } 205 }
206 206
207 void MonitorController::OnDisplayRemoved(const gfx::Display& display) { 207 void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
208 aura::RootWindow* root = root_windows_[display.id()]; 208 aura::RootWindow* root = root_windows_[display.id()];
209 DCHECK(root); 209 DCHECK(root);
210 // Primary monitor should never be removed by MonitorManager. 210 // Primary display should never be removed by DisplayManager.
211 DCHECK(root != Shell::GetPrimaryRootWindow()); 211 DCHECK(root != Shell::GetPrimaryRootWindow());
212 // Monitor for root window will be deleted when the Primary RootWindow 212 // Display for root window will be deleted when the Primary RootWindow
213 // is deleted by the Shell. 213 // is deleted by the Shell.
214 if (root != Shell::GetPrimaryRootWindow()) { 214 if (root != Shell::GetPrimaryRootWindow()) {
215 root_windows_.erase(display.id()); 215 root_windows_.erase(display.id());
216 internal::RootWindowController* controller = 216 internal::RootWindowController* controller =
217 wm::GetRootWindowController(root); 217 wm::GetRootWindowController(root);
218 if (controller) { 218 if (controller) {
219 controller->MoveWindowsTo(Shell::GetPrimaryRootWindow()); 219 controller->MoveWindowsTo(Shell::GetPrimaryRootWindow());
220 delete controller; 220 delete controller;
221 } else { 221 } else {
222 delete root; 222 delete root;
223 } 223 }
224 } 224 }
225 } 225 }
226 226
227 // static 227 // static
228 bool MonitorController::IsExtendedDesktopEnabled(){ 228 bool DisplayController::IsExtendedDesktopEnabled(){
229 return extended_desktop_enabled || 229 return extended_desktop_enabled ||
230 CommandLine::ForCurrentProcess()->HasSwitch( 230 CommandLine::ForCurrentProcess()->HasSwitch(
231 switches::kAshExtendedDesktop); 231 switches::kAshExtendedDesktop);
232 } 232 }
233 233
234 // static 234 // static
235 void MonitorController::SetExtendedDesktopEnabled(bool enabled) { 235 void DisplayController::SetExtendedDesktopEnabled(bool enabled) {
236 extended_desktop_enabled = enabled; 236 extended_desktop_enabled = enabled;
237 } 237 }
238 238
239 // static 239 // static
240 bool MonitorController::IsVirtualScreenCoordinatesEnabled() { 240 bool DisplayController::IsVirtualScreenCoordinatesEnabled() {
241 return virtual_screen_coordinates_enabled || 241 return virtual_screen_coordinates_enabled ||
242 CommandLine::ForCurrentProcess()->HasSwitch( 242 CommandLine::ForCurrentProcess()->HasSwitch(
243 switches::kAshVirtualScreenCoordinates); 243 switches::kAshVirtualScreenCoordinates);
244 } 244 }
245 245
246 // static 246 // static
247 void MonitorController::SetVirtualScreenCoordinatesEnabled(bool enabled) { 247 void DisplayController::SetVirtualScreenCoordinatesEnabled(bool enabled) {
248 virtual_screen_coordinates_enabled = enabled; 248 virtual_screen_coordinates_enabled = enabled;
249 } 249 }
250 250
251 aura::RootWindow* MonitorController::AddRootWindowForDisplay( 251 aura::RootWindow* DisplayController::AddRootWindowForDisplay(
252 const gfx::Display& display) { 252 const gfx::Display& display) {
253 aura::RootWindow* root = aura::Env::GetInstance()->monitor_manager()-> 253 aura::RootWindow* root = aura::Env::GetInstance()->display_manager()->
254 CreateRootWindowForMonitor(display); 254 CreateRootWindowForDisplay(display);
255 root_windows_[display.id()] = root; 255 root_windows_[display.id()] = root;
256 // Confine the cursor within the window if 256 // Confine the cursor within the window if
257 // 1) Extended desktop is enabled or 257 // 1) Extended desktop is enabled or
258 // 2) the display is primary monitor and the host window 258 // 2) the display is primary display and the host window
259 // is set to be fullscreen (this is old behavior). 259 // is set to be fullscreen (this is old behavior).
260 if (IsExtendedDesktopEnabled() || 260 if (IsExtendedDesktopEnabled() ||
261 (aura::MonitorManager::use_fullscreen_host_window() && 261 (aura::DisplayManager::use_fullscreen_host_window() &&
262 display.id() == 0)) { 262 display.id() == 0)) {
263 root->ConfineCursorToWindow(); 263 root->ConfineCursorToWindow();
264 } 264 }
265 return root; 265 return root;
266 } 266 }
267 267
268 } // namespace internal 268 } // namespace internal
269 } // namespace ash 269 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_controller.h ('k') | ash/display/mouse_cursor_event_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698