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/display_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 return; | 314 return; |
315 } | 315 } |
316 info.set_ui_scale(ui_scale); | 316 info.set_ui_scale(ui_scale); |
317 } | 317 } |
318 display_info_list.push_back(info); | 318 display_info_list.push_back(info); |
319 } | 319 } |
320 AddMirrorDisplayInfoIfAny(&display_info_list); | 320 AddMirrorDisplayInfoIfAny(&display_info_list); |
321 UpdateDisplays(display_info_list); | 321 UpdateDisplays(display_info_list); |
322 } | 322 } |
323 | 323 |
| 324 void DisplayManager::SetDisplayResolution(int64 display_id, |
| 325 const gfx::Size& resolution) { |
| 326 DCHECK_NE(gfx::Display::InternalDisplayId(), display_id); |
| 327 if (gfx::Display::InternalDisplayId() == display_id) |
| 328 return; |
| 329 resolutions_[display_id] = resolution; |
| 330 #if defined(OS_CHROMEOS) && defined(USE_X11) |
| 331 if (base::chromeos::IsRunningOnChromeOS()) |
| 332 Shell::GetInstance()->output_configurator()->ScheduleConfigureOutputs(); |
| 333 #endif |
| 334 } |
| 335 |
324 void DisplayManager::RegisterDisplayProperty( | 336 void DisplayManager::RegisterDisplayProperty( |
325 int64 display_id, | 337 int64 display_id, |
326 gfx::Display::Rotation rotation, | 338 gfx::Display::Rotation rotation, |
327 float ui_scale, | 339 float ui_scale, |
328 const gfx::Insets* overscan_insets) { | 340 const gfx::Insets* overscan_insets, |
| 341 const gfx::Size& resolution_in_pixels) { |
329 if (display_info_.find(display_id) == display_info_.end()) { | 342 if (display_info_.find(display_id) == display_info_.end()) { |
330 display_info_[display_id] = | 343 display_info_[display_id] = |
331 DisplayInfo(display_id, std::string(""), false); | 344 DisplayInfo(display_id, std::string(""), false); |
332 } | 345 } |
333 | 346 |
334 display_info_[display_id].set_rotation(rotation); | 347 display_info_[display_id].set_rotation(rotation); |
335 // Just in case the preference file was corrupted. | 348 // Just in case the preference file was corrupted. |
336 if (0.5f <= ui_scale && ui_scale <= 2.0f) | 349 if (0.5f <= ui_scale && ui_scale <= 2.0f) |
337 display_info_[display_id].set_ui_scale(ui_scale); | 350 display_info_[display_id].set_ui_scale(ui_scale); |
338 if (overscan_insets) | 351 if (overscan_insets) |
339 display_info_[display_id].SetOverscanInsets(*overscan_insets); | 352 display_info_[display_id].SetOverscanInsets(*overscan_insets); |
| 353 if (!resolution_in_pixels.IsEmpty()) |
| 354 resolutions_[display_id] = resolution_in_pixels; |
| 355 } |
| 356 |
| 357 bool DisplayManager::GetSelectedResolutionForDisplayId( |
| 358 int64 id, |
| 359 gfx::Size* resolution_out) const { |
| 360 std::map<int64, gfx::Size>::const_iterator iter = |
| 361 resolutions_.find(id); |
| 362 if (iter == resolutions_.end()) |
| 363 return false; |
| 364 *resolution_out = iter->second; |
| 365 return true; |
340 } | 366 } |
341 | 367 |
342 bool DisplayManager::IsDisplayRotationEnabled() const { | 368 bool DisplayManager::IsDisplayRotationEnabled() const { |
343 static bool enabled = !CommandLine::ForCurrentProcess()-> | 369 static bool enabled = !CommandLine::ForCurrentProcess()-> |
344 HasSwitch(switches::kAshDisableDisplayRotation); | 370 HasSwitch(switches::kAshDisableDisplayRotation); |
345 return enabled; | 371 return enabled; |
346 } | 372 } |
347 | 373 |
348 bool DisplayManager::IsDisplayUIScalingEnabled() const { | 374 bool DisplayManager::IsDisplayUIScalingEnabled() const { |
349 static bool enabled = !CommandLine::ForCurrentProcess()-> | 375 static bool enabled = !CommandLine::ForCurrentProcess()-> |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 break; | 904 break; |
879 } | 905 } |
880 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); | 906 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); |
881 secondary_display->set_bounds( | 907 secondary_display->set_bounds( |
882 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 908 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
883 secondary_display->UpdateWorkAreaFromInsets(insets); | 909 secondary_display->UpdateWorkAreaFromInsets(insets); |
884 } | 910 } |
885 | 911 |
886 } // namespace internal | 912 } // namespace internal |
887 } // namespace ash | 913 } // namespace ash |
OLD | NEW |