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/display/multi_display_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
| 11 #include "ash/screen_ash.h" |
11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
14 #include "base/string_split.h" | 15 #include "base/string_split.h" |
15 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
17 #include "grit/ash_strings.h" | 18 #include "grit/ash_strings.h" |
18 #include "ui/aura/aura_switches.h" | 19 #include "ui/aura/aura_switches.h" |
19 #include "ui/aura/client/screen_position_client.h" | 20 #include "ui/aura/client/screen_position_client.h" |
| 21 #include "ui/aura/display_util.h" |
20 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
21 #include "ui/aura/root_window.h" | 23 #include "ui/aura/root_window.h" |
22 #include "ui/aura/root_window_host.h" | 24 #include "ui/aura/root_window_host.h" |
23 #include "ui/aura/window_property.h" | 25 #include "ui/aura/window_property.h" |
24 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/gfx/display.h" | 27 #include "ui/gfx/display.h" |
26 #include "ui/gfx/screen.h" | 28 #include "ui/gfx/screen.h" |
27 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
28 #include "ui/gfx/size_conversions.h" | 30 #include "ui/gfx/size_conversions.h" |
29 | 31 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } // namespace | 74 } // namespace |
73 | 75 |
74 using aura::RootWindow; | 76 using aura::RootWindow; |
75 using aura::Window; | 77 using aura::Window; |
76 using std::string; | 78 using std::string; |
77 using std::vector; | 79 using std::vector; |
78 | 80 |
79 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey, | 81 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey, |
80 gfx::Display::kInvalidDisplayID); | 82 gfx::Display::kInvalidDisplayID); |
81 | 83 |
82 MultiDisplayManager::MultiDisplayManager() : | 84 DisplayManager::DisplayManager() : |
83 internal_display_id_(gfx::Display::kInvalidDisplayID), | 85 internal_display_id_(gfx::Display::kInvalidDisplayID), |
84 force_bounds_changed_(false) { | 86 force_bounds_changed_(false) { |
85 Init(); | 87 Init(); |
86 } | 88 } |
87 | 89 |
88 MultiDisplayManager::~MultiDisplayManager() { | 90 DisplayManager::~DisplayManager() { |
89 } | 91 } |
90 | 92 |
91 // static | 93 // static |
92 void MultiDisplayManager::CycleDisplay() { | 94 void DisplayManager::CycleDisplay() { |
93 MultiDisplayManager* manager = static_cast<MultiDisplayManager*>( | 95 Shell::GetInstance()->display_manager()->CycleDisplayImpl(); |
94 aura::Env::GetInstance()->display_manager()); | |
95 manager->CycleDisplayImpl(); | |
96 } | 96 } |
97 | 97 |
98 // static | 98 // static |
99 void MultiDisplayManager::ToggleDisplayScale() { | 99 void DisplayManager::ToggleDisplayScale() { |
100 MultiDisplayManager* manager = static_cast<MultiDisplayManager*>( | 100 Shell::GetInstance()->display_manager()->ScaleDisplayImpl(); |
101 aura::Env::GetInstance()->display_manager()); | |
102 manager->ScaleDisplayImpl(); | |
103 } | 101 } |
104 | 102 |
105 bool MultiDisplayManager::IsActiveDisplay(const gfx::Display& display) const { | 103 bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const { |
106 for (DisplayList::const_iterator iter = displays_.begin(); | 104 for (DisplayList::const_iterator iter = displays_.begin(); |
107 iter != displays_.end(); ++iter) { | 105 iter != displays_.end(); ++iter) { |
108 if ((*iter).id() == display.id()) | 106 if ((*iter).id() == display.id()) |
109 return true; | 107 return true; |
110 } | 108 } |
111 return false; | 109 return false; |
112 } | 110 } |
113 | 111 |
114 bool MultiDisplayManager::HasInternalDisplay() const { | 112 bool DisplayManager::HasInternalDisplay() const { |
115 return internal_display_id_ != gfx::Display::kInvalidDisplayID; | 113 return internal_display_id_ != gfx::Display::kInvalidDisplayID; |
116 } | 114 } |
117 | 115 |
118 bool MultiDisplayManager::IsInternalDisplayId(int64 id) const { | 116 bool DisplayManager::IsInternalDisplayId(int64 id) const { |
119 return internal_display_id_ == id; | 117 return internal_display_id_ == id; |
120 } | 118 } |
121 | 119 |
122 bool MultiDisplayManager::UpdateWorkAreaOfDisplayNearestWindow( | 120 bool DisplayManager::UpdateWorkAreaOfDisplayNearestWindow( |
123 const aura::Window* window, | 121 const aura::Window* window, |
124 const gfx::Insets& insets) { | 122 const gfx::Insets& insets) { |
125 const RootWindow* root = window->GetRootWindow(); | 123 const RootWindow* root = window->GetRootWindow(); |
126 gfx::Display& display = FindDisplayForRootWindow(root); | 124 gfx::Display& display = FindDisplayForRootWindow(root); |
127 gfx::Rect old_work_area = display.work_area(); | 125 gfx::Rect old_work_area = display.work_area(); |
128 display.UpdateWorkAreaFromInsets(insets); | 126 display.UpdateWorkAreaFromInsets(insets); |
129 return old_work_area != display.work_area(); | 127 return old_work_area != display.work_area(); |
130 } | 128 } |
131 | 129 |
132 const gfx::Display& MultiDisplayManager::GetDisplayForId(int64 id) const { | 130 const gfx::Display& DisplayManager::GetDisplayForId(int64 id) const { |
133 return const_cast<MultiDisplayManager*>(this)->FindDisplayForId(id); | 131 return const_cast<DisplayManager*>(this)->FindDisplayForId(id); |
134 } | 132 } |
135 | 133 |
136 const gfx::Display& MultiDisplayManager::FindDisplayContainingPoint( | 134 const gfx::Display& DisplayManager::FindDisplayContainingPoint( |
137 const gfx::Point& point_in_screen) const { | 135 const gfx::Point& point_in_screen) const { |
138 for (DisplayList::const_iterator iter = displays_.begin(); | 136 for (DisplayList::const_iterator iter = displays_.begin(); |
139 iter != displays_.end(); ++iter) { | 137 iter != displays_.end(); ++iter) { |
140 const gfx::Display& display = *iter; | 138 const gfx::Display& display = *iter; |
141 if (display.bounds().Contains(point_in_screen)) | 139 if (display.bounds().Contains(point_in_screen)) |
142 return display; | 140 return display; |
143 } | 141 } |
144 return GetInvalidDisplay(); | 142 return GetInvalidDisplay(); |
145 } | 143 } |
146 | 144 |
147 void MultiDisplayManager::SetOverscanInsets(int64 display_id, | 145 void DisplayManager::SetOverscanInsets(int64 display_id, |
148 const gfx::Insets& insets_in_dip) { | 146 const gfx::Insets& insets_in_dip) { |
149 DisplayList displays = displays_; | 147 DisplayList displays = displays_; |
150 std::map<int64, gfx::Insets>::const_iterator old_overscan = | 148 std::map<int64, gfx::Insets>::const_iterator old_overscan = |
151 overscan_mapping_.find(display_id); | 149 overscan_mapping_.find(display_id); |
152 if (old_overscan != overscan_mapping_.end()) { | 150 if (old_overscan != overscan_mapping_.end()) { |
153 gfx::Insets old_insets = old_overscan->second; | 151 gfx::Insets old_insets = old_overscan->second; |
154 for (DisplayList::iterator iter = displays.begin(); | 152 for (DisplayList::iterator iter = displays.begin(); |
155 iter != displays.end(); ++iter) { | 153 iter != displays.end(); ++iter) { |
156 if (iter->id() == display_id) { | 154 if (iter->id() == display_id) { |
157 // Undo the existing insets before applying the new insets. | 155 // Undo the existing insets before applying the new insets. |
158 gfx::Rect bounds = iter->bounds_in_pixel(); | 156 gfx::Rect bounds = iter->bounds_in_pixel(); |
159 bounds.Inset(old_insets.Scale(-iter->device_scale_factor())); | 157 bounds.Inset(old_insets.Scale(-iter->device_scale_factor())); |
160 iter->SetScaleAndBounds(iter->device_scale_factor(), bounds); | 158 iter->SetScaleAndBounds(iter->device_scale_factor(), bounds); |
161 break; | 159 break; |
162 } | 160 } |
163 } | 161 } |
164 } | 162 } |
165 overscan_mapping_[display_id] = insets_in_dip; | 163 overscan_mapping_[display_id] = insets_in_dip; |
166 OnNativeDisplaysChanged(displays); | 164 OnNativeDisplaysChanged(displays); |
167 } | 165 } |
168 | 166 |
169 gfx::Insets MultiDisplayManager::GetOverscanInsets(int64 display_id) const { | 167 gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const { |
170 std::map<int64, gfx::Insets>::const_iterator it = | 168 std::map<int64, gfx::Insets>::const_iterator it = |
171 overscan_mapping_.find(display_id); | 169 overscan_mapping_.find(display_id); |
172 return (it != overscan_mapping_.end()) ? it->second : gfx::Insets(); | 170 return (it != overscan_mapping_.end()) ? it->second : gfx::Insets(); |
173 } | 171 } |
174 | 172 |
175 void MultiDisplayManager::OnNativeDisplaysChanged( | 173 void DisplayManager::OnNativeDisplaysChanged( |
176 const std::vector<gfx::Display>& updated_displays) { | 174 const std::vector<gfx::Display>& updated_displays) { |
177 if (updated_displays.empty()) { | 175 if (updated_displays.empty()) { |
178 // Don't update the displays when all displays are disconnected. | 176 // Don't update the displays when all displays are disconnected. |
179 // This happens when: | 177 // This happens when: |
180 // - the device is idle and powerd requested to turn off all displays. | 178 // - the device is idle and powerd requested to turn off all displays. |
181 // - the device is suspended. (kernel turns off all displays) | 179 // - the device is suspended. (kernel turns off all displays) |
182 // - the internal display's brightness is set to 0 and no external | 180 // - the internal display's brightness is set to 0 and no external |
183 // display is connected. | 181 // display is connected. |
184 // - the internal display's brightness is 0 and external display is | 182 // - the internal display's brightness is 0 and external display is |
185 // disconnected. | 183 // disconnected. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 282 |
285 displays_ = new_displays; | 283 displays_ = new_displays; |
286 RefreshDisplayNames(); | 284 RefreshDisplayNames(); |
287 | 285 |
288 // Temporarily add displays to be removed because display object | 286 // Temporarily add displays to be removed because display object |
289 // being removed are accessed during shutting down the root. | 287 // being removed are accessed during shutting down the root. |
290 displays_.insert(displays_.end(), removed_displays.begin(), | 288 displays_.insert(displays_.end(), removed_displays.begin(), |
291 removed_displays.end()); | 289 removed_displays.end()); |
292 for (std::vector<size_t>::iterator iter = changed_display_indices.begin(); | 290 for (std::vector<size_t>::iterator iter = changed_display_indices.begin(); |
293 iter != changed_display_indices.end(); ++iter) { | 291 iter != changed_display_indices.end(); ++iter) { |
294 NotifyBoundsChanged(displays_[*iter]); | 292 Shell::GetInstance()->screen()->NotifyBoundsChanged(displays_[*iter]); |
295 } | 293 } |
296 for (std::vector<size_t>::iterator iter = added_display_indices.begin(); | 294 for (std::vector<size_t>::iterator iter = added_display_indices.begin(); |
297 iter != added_display_indices.end(); ++iter) { | 295 iter != added_display_indices.end(); ++iter) { |
298 NotifyDisplayAdded(displays_[*iter]); | 296 Shell::GetInstance()->screen()->NotifyDisplayAdded(displays_[*iter]); |
299 } | 297 } |
300 | |
301 for (DisplayList::const_reverse_iterator iter = removed_displays.rbegin(); | 298 for (DisplayList::const_reverse_iterator iter = removed_displays.rbegin(); |
302 iter != removed_displays.rend(); ++iter) { | 299 iter != removed_displays.rend(); ++iter) { |
303 NotifyDisplayRemoved(displays_.back()); | 300 Shell::GetInstance()->screen()->NotifyDisplayRemoved(displays_.back()); |
304 displays_.pop_back(); | 301 displays_.pop_back(); |
305 } | 302 } |
306 EnsurePointerInDisplays(); | 303 EnsurePointerInDisplays(); |
307 } | 304 } |
308 | 305 |
309 RootWindow* MultiDisplayManager::CreateRootWindowForDisplay( | 306 RootWindow* DisplayManager::CreateRootWindowForDisplay( |
310 const gfx::Display& display) { | 307 const gfx::Display& display) { |
311 | |
312 RootWindow::CreateParams params(display.bounds_in_pixel()); | 308 RootWindow::CreateParams params(display.bounds_in_pixel()); |
313 #if defined(OS_WIN) | 309 #if defined(OS_WIN) |
314 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 310 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
315 params.host = aura::RemoteRootWindowHostWin::Create( | 311 params.host = aura::RemoteRootWindowHostWin::Create( |
316 display.bounds_in_pixel()); | 312 display.bounds_in_pixel()); |
317 } | 313 } |
318 #endif | 314 #endif |
319 aura::RootWindow* root_window = new aura::RootWindow(params); | 315 aura::RootWindow* root_window = new aura::RootWindow(params); |
320 // No need to remove RootWindowObserver because | 316 // No need to remove RootWindowObserver because |
321 // the DisplayManager object outlives RootWindow objects. | 317 // the DisplayManager object outlives RootWindow objects. |
322 root_window->AddRootWindowObserver(this); | 318 root_window->AddRootWindowObserver(this); |
323 root_window->SetProperty(kDisplayIdKey, display.id()); | 319 root_window->SetProperty(kDisplayIdKey, display.id()); |
324 root_window->Init(); | 320 root_window->Init(); |
325 return root_window; | 321 return root_window; |
326 } | 322 } |
327 | 323 |
328 gfx::Display* MultiDisplayManager::GetDisplayAt(size_t index) { | 324 gfx::Display* DisplayManager::GetDisplayAt(size_t index) { |
329 return index < displays_.size() ? &displays_[index] : NULL; | 325 return index < displays_.size() ? &displays_[index] : NULL; |
330 } | 326 } |
331 | 327 |
332 size_t MultiDisplayManager::GetNumDisplays() const { | 328 size_t DisplayManager::GetNumDisplays() const { |
333 return displays_.size(); | 329 return displays_.size(); |
334 } | 330 } |
335 | 331 |
336 const gfx::Display& MultiDisplayManager::GetDisplayNearestWindow( | 332 const gfx::Display& DisplayManager::GetDisplayNearestWindow( |
337 const Window* window) const { | 333 const Window* window) const { |
338 if (!window) | 334 if (!window) |
339 return DisplayController::GetPrimaryDisplay(); | 335 return DisplayController::GetPrimaryDisplay(); |
340 const RootWindow* root = window->GetRootWindow(); | 336 const RootWindow* root = window->GetRootWindow(); |
341 MultiDisplayManager* manager = const_cast<MultiDisplayManager*>(this); | 337 DisplayManager* manager = const_cast<DisplayManager*>(this); |
342 return root ? | 338 return root ? |
343 manager->FindDisplayForRootWindow(root) : | 339 manager->FindDisplayForRootWindow(root) : |
344 DisplayController::GetPrimaryDisplay(); | 340 DisplayController::GetPrimaryDisplay(); |
345 } | 341 } |
346 | 342 |
347 const gfx::Display& MultiDisplayManager::GetDisplayNearestPoint( | 343 const gfx::Display& DisplayManager::GetDisplayNearestPoint( |
348 const gfx::Point& point) const { | 344 const gfx::Point& point) const { |
349 // Fallback to the primary display if there is no root display containing | 345 // Fallback to the primary display if there is no root display containing |
350 // the |point|. | 346 // the |point|. |
351 const gfx::Display& display = FindDisplayContainingPoint(point); | 347 const gfx::Display& display = FindDisplayContainingPoint(point); |
352 return display.is_valid() ? display : DisplayController::GetPrimaryDisplay(); | 348 return display.is_valid() ? display : DisplayController::GetPrimaryDisplay(); |
353 } | 349 } |
354 | 350 |
355 const gfx::Display& MultiDisplayManager::GetDisplayMatching( | 351 const gfx::Display& DisplayManager::GetDisplayMatching( |
356 const gfx::Rect& rect) const { | 352 const gfx::Rect& rect) const { |
357 if (rect.IsEmpty()) | 353 if (rect.IsEmpty()) |
358 return GetDisplayNearestPoint(rect.origin()); | 354 return GetDisplayNearestPoint(rect.origin()); |
359 | 355 |
360 int max = 0; | 356 int max = 0; |
361 const gfx::Display* matching = 0; | 357 const gfx::Display* matching = 0; |
362 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); | 358 for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); |
363 iter != displays_.end(); ++iter) { | 359 iter != displays_.end(); ++iter) { |
364 const gfx::Display& display = *iter; | 360 const gfx::Display& display = *iter; |
365 gfx::Rect intersect = gfx::IntersectRects(display.bounds(), rect); | 361 gfx::Rect intersect = gfx::IntersectRects(display.bounds(), rect); |
366 int area = intersect.width() * intersect.height(); | 362 int area = intersect.width() * intersect.height(); |
367 if (area > max) { | 363 if (area > max) { |
368 max = area; | 364 max = area; |
369 matching = &(*iter); | 365 matching = &(*iter); |
370 } | 366 } |
371 } | 367 } |
372 // Fallback to the primary display if there is no matching display. | 368 // Fallback to the primary display if there is no matching display. |
373 return matching ? *matching : DisplayController::GetPrimaryDisplay(); | 369 return matching ? *matching : DisplayController::GetPrimaryDisplay(); |
374 } | 370 } |
375 | 371 |
376 std::string MultiDisplayManager::GetDisplayNameFor( | 372 std::string DisplayManager::GetDisplayNameFor( |
377 const gfx::Display& display) { | 373 const gfx::Display& display) { |
378 if (!display.is_valid()) | 374 if (!display.is_valid()) |
379 return l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); | 375 return l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); |
380 | 376 |
381 std::map<int64, std::string>::const_iterator iter = | 377 std::map<int64, std::string>::const_iterator iter = |
382 display_names_.find(display.id()); | 378 display_names_.find(display.id()); |
383 if (iter != display_names_.end()) | 379 if (iter != display_names_.end()) |
384 return iter->second; | 380 return iter->second; |
385 | 381 |
386 return base::StringPrintf("Display %d", static_cast<int>(display.id())); | 382 return base::StringPrintf("Display %d", static_cast<int>(display.id())); |
387 } | 383 } |
388 | 384 |
389 void MultiDisplayManager::OnRootWindowResized(const aura::RootWindow* root, | 385 void DisplayManager::OnRootWindowResized(const aura::RootWindow* root, |
390 const gfx::Size& old_size) { | 386 const gfx::Size& old_size) { |
391 if (!use_fullscreen_host_window()) { | 387 if (!aura::UseFullscreenHostWindow()) { |
392 gfx::Display& display = FindDisplayForRootWindow(root); | 388 gfx::Display& display = FindDisplayForRootWindow(root); |
393 if (display.size() != root->GetHostSize()) { | 389 if (display.size() != root->GetHostSize()) { |
394 display.SetSize(root->GetHostSize()); | 390 display.SetSize(root->GetHostSize()); |
395 NotifyBoundsChanged(display); | 391 Shell::GetInstance()->screen()->NotifyBoundsChanged(display); |
396 } | 392 } |
397 } | 393 } |
398 } | 394 } |
399 | 395 |
400 void MultiDisplayManager::Init() { | 396 void DisplayManager::Init() { |
401 #if defined(OS_CHROMEOS) | 397 #if defined(OS_CHROMEOS) |
402 if (base::chromeos::IsRunningOnChromeOS()) { | 398 if (base::chromeos::IsRunningOnChromeOS()) { |
403 std::vector<XID> outputs; | 399 std::vector<XID> outputs; |
404 ui::GetOutputDeviceHandles(&outputs); | 400 ui::GetOutputDeviceHandles(&outputs); |
405 std::vector<std::string> output_names = ui::GetOutputNames(outputs); | 401 std::vector<std::string> output_names = ui::GetOutputNames(outputs); |
406 for (size_t i = 0; i < output_names.size(); ++i) { | 402 for (size_t i = 0; i < output_names.size(); ++i) { |
407 if (chromeos::OutputConfigurator::IsInternalOutputName( | 403 if (chromeos::OutputConfigurator::IsInternalOutputName( |
408 output_names[i])) { | 404 output_names[i])) { |
409 internal_display_id_ = GetDisplayIdForOutput(outputs[i]); | 405 internal_display_id_ = GetDisplayIdForOutput(outputs[i]); |
410 break; | 406 break; |
411 } | 407 } |
412 } | 408 } |
413 } | 409 } |
414 #endif | 410 #endif |
415 | 411 |
416 RefreshDisplayNames(); | 412 RefreshDisplayNames(); |
417 | 413 |
418 #if defined(OS_WIN) | 414 #if defined(OS_WIN) |
419 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | 415 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
420 set_use_fullscreen_host_window(true); | 416 aura::SetUseFullscreenHostWindow(true); |
421 #endif | 417 #endif |
422 // TODO(oshima): Move this logic to DisplayChangeObserver. | 418 // TODO(oshima): Move this logic to DisplayChangeObserver. |
423 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 419 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
424 switches::kAuraHostWindowSize); | 420 switches::kAuraHostWindowSize); |
425 vector<string> parts; | 421 vector<string> parts; |
426 base::SplitString(size_str, ',', &parts); | 422 base::SplitString(size_str, ',', &parts); |
427 for (vector<string>::const_iterator iter = parts.begin(); | 423 for (vector<string>::const_iterator iter = parts.begin(); |
428 iter != parts.end(); ++iter) { | 424 iter != parts.end(); ++iter) { |
429 AddDisplayFromSpec(*iter); | 425 AddDisplayFromSpec(*iter); |
430 } | 426 } |
431 if (displays_.empty()) | 427 if (displays_.empty()) |
432 AddDisplayFromSpec(std::string() /* default */); | 428 AddDisplayFromSpec(std::string() /* default */); |
433 } | 429 } |
434 | 430 |
435 void MultiDisplayManager::CycleDisplayImpl() { | 431 void DisplayManager::CycleDisplayImpl() { |
436 DCHECK(!displays_.empty()); | 432 DCHECK(!displays_.empty()); |
437 std::vector<gfx::Display> new_displays; | 433 std::vector<gfx::Display> new_displays; |
438 new_displays.push_back(DisplayController::GetPrimaryDisplay()); | 434 new_displays.push_back(DisplayController::GetPrimaryDisplay()); |
439 // Add if there is only one display. | 435 // Add if there is only one display. |
440 if (displays_.size() == 1) | 436 if (displays_.size() == 1) |
441 new_displays.push_back(CreateDisplayFromSpec("100+200-500x400")); | 437 new_displays.push_back(aura::CreateDisplayFromSpec("100+200-500x400")); |
442 OnNativeDisplaysChanged(new_displays); | 438 OnNativeDisplaysChanged(new_displays); |
443 } | 439 } |
444 | 440 |
445 void MultiDisplayManager::ScaleDisplayImpl() { | 441 void DisplayManager::ScaleDisplayImpl() { |
446 DCHECK(!displays_.empty()); | 442 DCHECK(!displays_.empty()); |
447 std::vector<gfx::Display> new_displays; | 443 std::vector<gfx::Display> new_displays; |
448 for (DisplayList::const_iterator iter = displays_.begin(); | 444 for (DisplayList::const_iterator iter = displays_.begin(); |
449 iter != displays_.end(); ++iter) { | 445 iter != displays_.end(); ++iter) { |
450 gfx::Display display = *iter; | 446 gfx::Display display = *iter; |
451 float factor = display.device_scale_factor() == 1.0f ? 2.0f : 1.0f; | 447 float factor = display.device_scale_factor() == 1.0f ? 2.0f : 1.0f; |
452 display.SetScaleAndBounds( | 448 display.SetScaleAndBounds( |
453 factor, gfx::Rect(display.bounds_in_pixel().origin(), | 449 factor, gfx::Rect(display.bounds_in_pixel().origin(), |
454 gfx::ToFlooredSize(display.size().Scale(factor)))); | 450 gfx::ToFlooredSize(display.size().Scale(factor)))); |
455 new_displays.push_back(display); | 451 new_displays.push_back(display); |
456 } | 452 } |
457 OnNativeDisplaysChanged(new_displays); | 453 OnNativeDisplaysChanged(new_displays); |
458 } | 454 } |
459 | 455 |
460 gfx::Display& MultiDisplayManager::FindDisplayForRootWindow( | 456 gfx::Display& DisplayManager::FindDisplayForRootWindow( |
461 const aura::RootWindow* root_window) { | 457 const aura::RootWindow* root_window) { |
462 int64 id = root_window->GetProperty(kDisplayIdKey); | 458 int64 id = root_window->GetProperty(kDisplayIdKey); |
463 // if id is |kInvaildDisplayID|, it's being deleted. | 459 // if id is |kInvaildDisplayID|, it's being deleted. |
464 DCHECK(id != gfx::Display::kInvalidDisplayID); | 460 DCHECK(id != gfx::Display::kInvalidDisplayID); |
465 gfx::Display& display = FindDisplayForId(id); | 461 gfx::Display& display = FindDisplayForId(id); |
466 DCHECK(display.is_valid()); | 462 DCHECK(display.is_valid()); |
467 return display; | 463 return display; |
468 } | 464 } |
469 | 465 |
470 gfx::Display& MultiDisplayManager::FindDisplayForId(int64 id) { | 466 gfx::Display& DisplayManager::FindDisplayForId(int64 id) { |
471 for (DisplayList::iterator iter = displays_.begin(); | 467 for (DisplayList::iterator iter = displays_.begin(); |
472 iter != displays_.end(); ++iter) { | 468 iter != displays_.end(); ++iter) { |
473 if ((*iter).id() == id) | 469 if ((*iter).id() == id) |
474 return *iter; | 470 return *iter; |
475 } | 471 } |
476 DLOG(WARNING) << "Could not find display:" << id; | 472 DLOG(WARNING) << "Could not find display:" << id; |
477 return GetInvalidDisplay(); | 473 return GetInvalidDisplay(); |
478 } | 474 } |
479 | 475 |
480 void MultiDisplayManager::AddDisplayFromSpec(const std::string& spec) { | 476 void DisplayManager::AddDisplayFromSpec(const std::string& spec) { |
481 gfx::Display display = CreateDisplayFromSpec(spec); | 477 gfx::Display display = aura::CreateDisplayFromSpec(spec); |
482 | 478 |
483 const gfx::Insets insets = display.GetWorkAreaInsets(); | 479 const gfx::Insets insets = display.GetWorkAreaInsets(); |
484 const gfx::Rect& native_bounds = display.bounds_in_pixel(); | 480 const gfx::Rect& native_bounds = display.bounds_in_pixel(); |
485 display.SetScaleAndBounds(display.device_scale_factor(), native_bounds); | 481 display.SetScaleAndBounds(display.device_scale_factor(), native_bounds); |
486 display.UpdateWorkAreaFromInsets(insets); | 482 display.UpdateWorkAreaFromInsets(insets); |
487 displays_.push_back(display); | 483 displays_.push_back(display); |
488 } | 484 } |
489 | 485 |
490 int64 MultiDisplayManager::SetFirstDisplayAsInternalDisplayForTest() { | 486 int64 DisplayManager::SetFirstDisplayAsInternalDisplayForTest() { |
491 internal_display_id_ = displays_[0].id(); | 487 internal_display_id_ = displays_[0].id(); |
492 internal_display_.reset(new gfx::Display); | 488 internal_display_.reset(new gfx::Display); |
493 *internal_display_ = displays_[0]; | 489 *internal_display_ = displays_[0]; |
494 return internal_display_id_; | 490 return internal_display_id_; |
495 } | 491 } |
496 | 492 |
497 void MultiDisplayManager::EnsurePointerInDisplays() { | 493 void DisplayManager::EnsurePointerInDisplays() { |
498 // Don't try to move the pointer during the boot/startup. | 494 // Don't try to move the pointer during the boot/startup. |
499 if (!Shell::HasInstance()) | 495 if (!Shell::HasInstance()) |
500 return; | 496 return; |
501 gfx::Point location_in_screen = Shell::GetScreen()->GetCursorScreenPoint(); | 497 gfx::Point location_in_screen = Shell::GetScreen()->GetCursorScreenPoint(); |
502 gfx::Point target_location; | 498 gfx::Point target_location; |
503 int64 closest_distance_squared = -1; | 499 int64 closest_distance_squared = -1; |
504 | 500 |
505 for (DisplayList::const_iterator iter = displays_.begin(); | 501 for (DisplayList::const_iterator iter = displays_.begin(); |
506 iter != displays_.end(); ++iter) { | 502 iter != displays_.end(); ++iter) { |
507 const gfx::Rect& display_bounds = iter->bounds(); | 503 const gfx::Rect& display_bounds = iter->bounds(); |
(...skipping 17 matching lines...) Expand all Loading... |
525 } | 521 } |
526 | 522 |
527 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); | 523 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
528 aura::client::ScreenPositionClient* client = | 524 aura::client::ScreenPositionClient* client = |
529 aura::client::GetScreenPositionClient(root_window); | 525 aura::client::GetScreenPositionClient(root_window); |
530 client->ConvertPointFromScreen(root_window, &target_location); | 526 client->ConvertPointFromScreen(root_window, &target_location); |
531 | 527 |
532 root_window->MoveCursorTo(target_location); | 528 root_window->MoveCursorTo(target_location); |
533 } | 529 } |
534 | 530 |
535 void MultiDisplayManager::RefreshDisplayNames() { | 531 void DisplayManager::RefreshDisplayNames() { |
536 display_names_.clear(); | 532 display_names_.clear(); |
537 | 533 |
538 #if defined(OS_CHROMEOS) | 534 #if defined(OS_CHROMEOS) |
539 if (!base::chromeos::IsRunningOnChromeOS()) | 535 if (!base::chromeos::IsRunningOnChromeOS()) |
540 return; | 536 return; |
541 #endif | 537 #endif |
542 | 538 |
543 #if defined(USE_X11) | 539 #if defined(USE_X11) |
544 std::vector<XID> outputs; | 540 std::vector<XID> outputs; |
545 if (!ui::GetOutputDeviceHandles(&outputs)) | 541 if (!ui::GetOutputDeviceHandles(&outputs)) |
(...skipping 10 matching lines...) Expand all Loading... |
556 display_names_[id] = | 552 display_names_[id] = |
557 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME); | 553 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME); |
558 } else { | 554 } else { |
559 display_names_[id] = name; | 555 display_names_[id] = name; |
560 } | 556 } |
561 } | 557 } |
562 } | 558 } |
563 #endif | 559 #endif |
564 } | 560 } |
565 | 561 |
566 void MultiDisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const { | 562 void DisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const { |
567 DisplayList::iterator iter_to_update = to_update->begin(); | 563 DisplayList::iterator iter_to_update = to_update->begin(); |
568 DisplayList::const_iterator iter = displays_.begin(); | 564 DisplayList::const_iterator iter = displays_.begin(); |
569 for (; iter != displays_.end() && iter_to_update != to_update->end(); | 565 for (; iter != displays_.end() && iter_to_update != to_update->end(); |
570 ++iter, ++iter_to_update) { | 566 ++iter, ++iter_to_update) { |
571 (*iter_to_update).set_id((*iter).id()); | 567 (*iter_to_update).set_id((*iter).id()); |
572 } | 568 } |
573 } | 569 } |
574 | 570 |
575 } // namespace internal | 571 } // namespace internal |
576 } // namespace ash | 572 } // namespace ash |
OLD | NEW |