| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "ash/common/ash_switches.h" | 16 #include "ash/common/ash_switches.h" |
| 17 #include "ash/common/display/display_info.h" | |
| 18 #include "ash/display/display_util.h" | 17 #include "ash/display/display_util.h" |
| 19 #include "ash/display/extended_mouse_warp_controller.h" | 18 #include "ash/display/extended_mouse_warp_controller.h" |
| 20 #include "ash/display/null_mouse_warp_controller.h" | 19 #include "ash/display/null_mouse_warp_controller.h" |
| 21 #include "ash/display/screen_ash.h" | 20 #include "ash/display/screen_ash.h" |
| 22 #include "ash/display/unified_mouse_warp_controller.h" | 21 #include "ash/display/unified_mouse_warp_controller.h" |
| 23 #include "ash/screen_util.h" | 22 #include "ash/screen_util.h" |
| 24 #include "ash/shell.h" | 23 #include "ash/shell.h" |
| 25 #include "base/auto_reset.h" | 24 #include "base/auto_reset.h" |
| 26 #include "base/command_line.h" | 25 #include "base/command_line.h" |
| 27 #include "base/logging.h" | 26 #include "base/logging.h" |
| 28 #include "base/memory/ptr_util.h" | 27 #include "base/memory/ptr_util.h" |
| 29 #include "base/metrics/histogram.h" | 28 #include "base/metrics/histogram.h" |
| 30 #include "base/run_loop.h" | 29 #include "base/run_loop.h" |
| 31 #include "base/strings/string_number_conversions.h" | 30 #include "base/strings/string_number_conversions.h" |
| 32 #include "base/strings/string_split.h" | 31 #include "base/strings/string_split.h" |
| 33 #include "base/strings/stringprintf.h" | 32 #include "base/strings/stringprintf.h" |
| 34 #include "base/strings/utf_string_conversions.h" | 33 #include "base/strings/utf_string_conversions.h" |
| 35 #include "base/threading/thread_task_runner_handle.h" | 34 #include "base/threading/thread_task_runner_handle.h" |
| 36 #include "grit/ash_strings.h" | 35 #include "grit/ash_strings.h" |
| 37 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 38 #include "ui/display/display.h" | 37 #include "ui/display/display.h" |
| 39 #include "ui/display/display_observer.h" | 38 #include "ui/display/display_observer.h" |
| 39 #include "ui/display/manager/display_info.h" |
| 40 #include "ui/display/manager/display_layout_store.h" | 40 #include "ui/display/manager/display_layout_store.h" |
| 41 #include "ui/display/screen.h" | 41 #include "ui/display/screen.h" |
| 42 #include "ui/gfx/font_render_params.h" | 42 #include "ui/gfx/font_render_params.h" |
| 43 #include "ui/gfx/geometry/rect.h" | 43 #include "ui/gfx/geometry/rect.h" |
| 44 #include "ui/gfx/geometry/size_conversions.h" | 44 #include "ui/gfx/geometry/size_conversions.h" |
| 45 | 45 |
| 46 #if defined(USE_X11) | 46 #if defined(USE_X11) |
| 47 #include "ui/base/x/x11_util.h" // nogncheck | 47 #include "ui/base/x/x11_util.h" // nogncheck |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 #if defined(OS_CHROMEOS) | 50 #if defined(OS_CHROMEOS) |
| 51 #include "base/sys_info.h" | 51 #include "base/sys_info.h" |
| 52 #endif | 52 #endif |
| 53 | 53 |
| 54 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
| 55 #include "base/win/windows_version.h" | 55 #include "base/win/windows_version.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 namespace ash { | 58 namespace ash { |
| 59 typedef std::vector<DisplayInfo> DisplayInfoList; | |
| 60 | 59 |
| 61 namespace { | 60 namespace { |
| 62 | 61 |
| 63 // We need to keep this in order for unittests to tell if | 62 // We need to keep this in order for unittests to tell if |
| 64 // the object in display::Screen::GetScreenByType is for shutdown. | 63 // the object in display::Screen::GetScreenByType is for shutdown. |
| 65 display::Screen* screen_for_shutdown = nullptr; | 64 display::Screen* screen_for_shutdown = nullptr; |
| 66 | 65 |
| 67 // The number of pixels to overlap between the primary and secondary displays, | 66 // The number of pixels to overlap between the primary and secondary displays, |
| 68 // in case that the offset value is too large. | 67 // in case that the offset value is too large. |
| 69 const int kMinimumOverlapForInvalidOffset = 100; | 68 const int kMinimumOverlapForInvalidOffset = 100; |
| 70 | 69 |
| 71 struct DisplaySortFunctor { | 70 struct DisplaySortFunctor { |
| 72 bool operator()(const display::Display& a, const display::Display& b) { | 71 bool operator()(const display::Display& a, const display::Display& b) { |
| 73 return CompareDisplayIds(a.id(), b.id()); | 72 return CompareDisplayIds(a.id(), b.id()); |
| 74 } | 73 } |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 struct DisplayInfoSortFunctor { | 76 struct DisplayInfoSortFunctor { |
| 78 bool operator()(const DisplayInfo& a, const DisplayInfo& b) { | 77 bool operator()(const ui::DisplayInfo& a, const ui::DisplayInfo& b) { |
| 79 return CompareDisplayIds(a.id(), b.id()); | 78 return CompareDisplayIds(a.id(), b.id()); |
| 80 } | 79 } |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 display::Display& GetInvalidDisplay() { | 82 display::Display& GetInvalidDisplay() { |
| 84 static display::Display* invalid_display = new display::Display(); | 83 static display::Display* invalid_display = new display::Display(); |
| 85 return *invalid_display; | 84 return *invalid_display; |
| 86 } | 85 } |
| 87 | 86 |
| 88 DisplayInfo::ManagedDisplayModeList::const_iterator FindDisplayMode( | 87 ui::DisplayInfo::ManagedDisplayModeList::const_iterator FindDisplayMode( |
| 89 const DisplayInfo& info, | 88 const ui::DisplayInfo& info, |
| 90 const scoped_refptr<ManagedDisplayMode>& target_mode) { | 89 const scoped_refptr<ui::ManagedDisplayMode>& target_mode) { |
| 91 const DisplayInfo::ManagedDisplayModeList& modes = info.display_modes(); | 90 const ui::DisplayInfo::ManagedDisplayModeList& modes = info.display_modes(); |
| 92 return std::find_if( | 91 return std::find_if( |
| 93 modes.begin(), modes.end(), | 92 modes.begin(), modes.end(), |
| 94 [target_mode](const scoped_refptr<ManagedDisplayMode>& mode) { | 93 [target_mode](const scoped_refptr<ui::ManagedDisplayMode>& mode) { |
| 95 return target_mode->IsEquivalent(mode); | 94 return target_mode->IsEquivalent(mode); |
| 96 }); | 95 }); |
| 97 } | 96 } |
| 98 | 97 |
| 99 void SetInternalManagedDisplayModeList(DisplayInfo* info) { | 98 void SetInternalManagedDisplayModeList(ui::DisplayInfo* info) { |
| 100 scoped_refptr<ManagedDisplayMode> native_mode = new ManagedDisplayMode( | 99 scoped_refptr<ui::ManagedDisplayMode> native_mode = |
| 101 info->bounds_in_native().size(), 0.0 /* refresh_rate */, | 100 new ui::ManagedDisplayMode(info->bounds_in_native().size(), |
| 102 false /* interlaced */, false /* native_mode */, 1.0 /* ui_scale */, | 101 0.0 /* refresh_rate */, false /* interlaced */, |
| 103 info->device_scale_factor()); | 102 false /* native_mode */, 1.0 /* ui_scale */, |
| 103 info->device_scale_factor()); |
| 104 info->SetManagedDisplayModes( | 104 info->SetManagedDisplayModes( |
| 105 CreateInternalManagedDisplayModeList(native_mode)); | 105 CreateInternalManagedDisplayModeList(native_mode)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void MaybeInitInternalDisplay(DisplayInfo* info) { | 108 void MaybeInitInternalDisplay(ui::DisplayInfo* info) { |
| 109 int64_t id = info->id(); | 109 int64_t id = info->id(); |
| 110 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 110 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 111 if (command_line->HasSwitch(switches::kAshUseFirstDisplayAsInternal)) { | 111 if (command_line->HasSwitch(switches::kAshUseFirstDisplayAsInternal)) { |
| 112 display::Display::SetInternalDisplayId(id); | 112 display::Display::SetInternalDisplayId(id); |
| 113 SetInternalManagedDisplayModeList(info); | 113 SetInternalManagedDisplayModeList(info); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 gfx::Size GetMaxNativeSize(const DisplayInfo& info) { | 117 gfx::Size GetMaxNativeSize(const ui::DisplayInfo& info) { |
| 118 gfx::Size size; | 118 gfx::Size size; |
| 119 for (auto& mode : info.display_modes()) { | 119 for (auto& mode : info.display_modes()) { |
| 120 if (mode->size().GetArea() > size.GetArea()) | 120 if (mode->size().GetArea() > size.GetArea()) |
| 121 size = mode->size(); | 121 size = mode->size(); |
| 122 } | 122 } |
| 123 return size; | 123 return size; |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace | 126 } // namespace |
| 127 | 127 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 bool DisplayManager::InitFromCommandLine() { | 168 bool DisplayManager::InitFromCommandLine() { |
| 169 DisplayInfoList info_list; | 169 DisplayInfoList info_list; |
| 170 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 170 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 171 if (!command_line->HasSwitch(switches::kAshHostWindowBounds)) | 171 if (!command_line->HasSwitch(switches::kAshHostWindowBounds)) |
| 172 return false; | 172 return false; |
| 173 const string size_str = | 173 const string size_str = |
| 174 command_line->GetSwitchValueASCII(switches::kAshHostWindowBounds); | 174 command_line->GetSwitchValueASCII(switches::kAshHostWindowBounds); |
| 175 for (const std::string& part : base::SplitString( | 175 for (const std::string& part : base::SplitString( |
| 176 size_str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { | 176 size_str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
| 177 info_list.push_back(DisplayInfo::CreateFromSpec(part)); | 177 info_list.push_back(ui::DisplayInfo::CreateFromSpec(part)); |
| 178 info_list.back().set_native(true); | 178 info_list.back().set_native(true); |
| 179 } | 179 } |
| 180 MaybeInitInternalDisplay(&info_list[0]); | 180 MaybeInitInternalDisplay(&info_list[0]); |
| 181 if (info_list.size() > 1 && | 181 if (info_list.size() > 1 && |
| 182 command_line->HasSwitch(switches::kAshEnableSoftwareMirroring)) { | 182 command_line->HasSwitch(switches::kAshEnableSoftwareMirroring)) { |
| 183 SetMultiDisplayMode(MIRRORING); | 183 SetMultiDisplayMode(MIRRORING); |
| 184 } | 184 } |
| 185 OnNativeDisplaysChanged(info_list); | 185 OnNativeDisplaysChanged(info_list); |
| 186 return true; | 186 return true; |
| 187 } | 187 } |
| 188 | 188 |
| 189 void DisplayManager::InitDefaultDisplay() { | 189 void DisplayManager::InitDefaultDisplay() { |
| 190 DisplayInfoList info_list; | 190 DisplayInfoList info_list; |
| 191 info_list.push_back(DisplayInfo::CreateFromSpec(std::string())); | 191 info_list.push_back(ui::DisplayInfo::CreateFromSpec(std::string())); |
| 192 info_list.back().set_native(true); | 192 info_list.back().set_native(true); |
| 193 MaybeInitInternalDisplay(&info_list[0]); | 193 MaybeInitInternalDisplay(&info_list[0]); |
| 194 OnNativeDisplaysChanged(info_list); | 194 OnNativeDisplaysChanged(info_list); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void DisplayManager::RefreshFontParams() { | 197 void DisplayManager::RefreshFontParams() { |
| 198 #if defined(OS_CHROMEOS) | 198 #if defined(OS_CHROMEOS) |
| 199 // Use the largest device scale factor among currently active displays. Non | 199 // Use the largest device scale factor among currently active displays. Non |
| 200 // internal display may have bigger scale factor in case the external display | 200 // internal display may have bigger scale factor in case the external display |
| 201 // is an 4K display. | 201 // is an 4K display. |
| 202 float largest_device_scale_factor = 1.0f; | 202 float largest_device_scale_factor = 1.0f; |
| 203 for (const display::Display& display : active_display_list_) { | 203 for (const display::Display& display : active_display_list_) { |
| 204 const ash::DisplayInfo& info = display_info_[display.id()]; | 204 const ui::DisplayInfo& info = display_info_[display.id()]; |
| 205 largest_device_scale_factor = std::max( | 205 largest_device_scale_factor = std::max( |
| 206 largest_device_scale_factor, info.GetEffectiveDeviceScaleFactor()); | 206 largest_device_scale_factor, info.GetEffectiveDeviceScaleFactor()); |
| 207 } | 207 } |
| 208 gfx::SetFontRenderParamsDeviceScaleFactor(largest_device_scale_factor); | 208 gfx::SetFontRenderParamsDeviceScaleFactor(largest_device_scale_factor); |
| 209 #endif // OS_CHROMEOS | 209 #endif // OS_CHROMEOS |
| 210 } | 210 } |
| 211 | 211 |
| 212 const display::DisplayLayout& DisplayManager::GetCurrentDisplayLayout() const { | 212 const display::DisplayLayout& DisplayManager::GetCurrentDisplayLayout() const { |
| 213 DCHECK_LE(2U, num_connected_displays()); | 213 DCHECK_LE(2U, num_connected_displays()); |
| 214 if (num_connected_displays() > 1) { | 214 if (num_connected_displays() > 1) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 *display, display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 298 *display, display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
| 299 } | 299 } |
| 300 return workarea_changed; | 300 return workarea_changed; |
| 301 } | 301 } |
| 302 | 302 |
| 303 void DisplayManager::SetOverscanInsets(int64_t display_id, | 303 void DisplayManager::SetOverscanInsets(int64_t display_id, |
| 304 const gfx::Insets& insets_in_dip) { | 304 const gfx::Insets& insets_in_dip) { |
| 305 bool update = false; | 305 bool update = false; |
| 306 DisplayInfoList display_info_list; | 306 DisplayInfoList display_info_list; |
| 307 for (const auto& display : active_display_list_) { | 307 for (const auto& display : active_display_list_) { |
| 308 DisplayInfo info = GetDisplayInfo(display.id()); | 308 ui::DisplayInfo info = GetDisplayInfo(display.id()); |
| 309 if (info.id() == display_id) { | 309 if (info.id() == display_id) { |
| 310 if (insets_in_dip.IsEmpty()) { | 310 if (insets_in_dip.IsEmpty()) { |
| 311 info.set_clear_overscan_insets(true); | 311 info.set_clear_overscan_insets(true); |
| 312 } else { | 312 } else { |
| 313 info.set_clear_overscan_insets(false); | 313 info.set_clear_overscan_insets(false); |
| 314 info.SetOverscanInsets(insets_in_dip); | 314 info.SetOverscanInsets(insets_in_dip); |
| 315 } | 315 } |
| 316 update = true; | 316 update = true; |
| 317 } | 317 } |
| 318 display_info_list.push_back(info); | 318 display_info_list.push_back(info); |
| 319 } | 319 } |
| 320 if (update) { | 320 if (update) { |
| 321 AddMirrorDisplayInfoIfAny(&display_info_list); | 321 AddMirrorDisplayInfoIfAny(&display_info_list); |
| 322 UpdateDisplaysWith(display_info_list); | 322 UpdateDisplaysWith(display_info_list); |
| 323 } else { | 323 } else { |
| 324 display_info_[display_id].SetOverscanInsets(insets_in_dip); | 324 display_info_[display_id].SetOverscanInsets(insets_in_dip); |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 | 327 |
| 328 void DisplayManager::SetDisplayRotation( | 328 void DisplayManager::SetDisplayRotation( |
| 329 int64_t display_id, | 329 int64_t display_id, |
| 330 display::Display::Rotation rotation, | 330 display::Display::Rotation rotation, |
| 331 display::Display::RotationSource source) { | 331 display::Display::RotationSource source) { |
| 332 if (IsInUnifiedMode()) | 332 if (IsInUnifiedMode()) |
| 333 return; | 333 return; |
| 334 | 334 |
| 335 DisplayInfoList display_info_list; | 335 DisplayInfoList display_info_list; |
| 336 bool is_active = false; | 336 bool is_active = false; |
| 337 for (const auto& display : active_display_list_) { | 337 for (const auto& display : active_display_list_) { |
| 338 DisplayInfo info = GetDisplayInfo(display.id()); | 338 ui::DisplayInfo info = GetDisplayInfo(display.id()); |
| 339 if (info.id() == display_id) { | 339 if (info.id() == display_id) { |
| 340 if (info.GetRotation(source) == rotation && | 340 if (info.GetRotation(source) == rotation && |
| 341 info.GetActiveRotation() == rotation) { | 341 info.GetActiveRotation() == rotation) { |
| 342 return; | 342 return; |
| 343 } | 343 } |
| 344 info.SetRotation(rotation, source); | 344 info.SetRotation(rotation, source); |
| 345 is_active = true; | 345 is_active = true; |
| 346 } | 346 } |
| 347 display_info_list.push_back(info); | 347 display_info_list.push_back(info); |
| 348 } | 348 } |
| 349 if (is_active) { | 349 if (is_active) { |
| 350 AddMirrorDisplayInfoIfAny(&display_info_list); | 350 AddMirrorDisplayInfoIfAny(&display_info_list); |
| 351 UpdateDisplaysWith(display_info_list); | 351 UpdateDisplaysWith(display_info_list); |
| 352 } else if (display_info_.find(display_id) != display_info_.end()) { | 352 } else if (display_info_.find(display_id) != display_info_.end()) { |
| 353 // Inactive displays can reactivate, ensure they have been updated. | 353 // Inactive displays can reactivate, ensure they have been updated. |
| 354 display_info_[display_id].SetRotation(rotation, source); | 354 display_info_[display_id].SetRotation(rotation, source); |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 | 357 |
| 358 bool DisplayManager::SetDisplayMode( | 358 bool DisplayManager::SetDisplayMode( |
| 359 int64_t display_id, | 359 int64_t display_id, |
| 360 const scoped_refptr<ManagedDisplayMode>& display_mode) { | 360 const scoped_refptr<ui::ManagedDisplayMode>& display_mode) { |
| 361 bool change_ui_scale = GetDisplayIdForUIScaling() == display_id; | 361 bool change_ui_scale = GetDisplayIdForUIScaling() == display_id; |
| 362 | 362 |
| 363 DisplayInfoList display_info_list; | 363 DisplayInfoList display_info_list; |
| 364 bool display_property_changed = false; | 364 bool display_property_changed = false; |
| 365 bool resolution_changed = false; | 365 bool resolution_changed = false; |
| 366 for (const auto& display : active_display_list_) { | 366 for (const auto& display : active_display_list_) { |
| 367 DisplayInfo info = GetDisplayInfo(display.id()); | 367 ui::DisplayInfo info = GetDisplayInfo(display.id()); |
| 368 if (info.id() == display_id) { | 368 if (info.id() == display_id) { |
| 369 auto iter = FindDisplayMode(info, display_mode); | 369 auto iter = FindDisplayMode(info, display_mode); |
| 370 if (iter == info.display_modes().end()) { | 370 if (iter == info.display_modes().end()) { |
| 371 LOG(WARNING) << "Unsupported display mode was requested:" | 371 LOG(WARNING) << "Unsupported display mode was requested:" |
| 372 << "size=" << display_mode->size().ToString() | 372 << "size=" << display_mode->size().ToString() |
| 373 << ", ui scale=" << display_mode->ui_scale() | 373 << ", ui scale=" << display_mode->ui_scale() |
| 374 << ", scale factor=" | 374 << ", scale factor=" |
| 375 << display_mode->device_scale_factor(); | 375 << display_mode->device_scale_factor(); |
| 376 return false; | 376 return false; |
| 377 } | 377 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 409 |
| 410 void DisplayManager::RegisterDisplayProperty( | 410 void DisplayManager::RegisterDisplayProperty( |
| 411 int64_t display_id, | 411 int64_t display_id, |
| 412 display::Display::Rotation rotation, | 412 display::Display::Rotation rotation, |
| 413 float ui_scale, | 413 float ui_scale, |
| 414 const gfx::Insets* overscan_insets, | 414 const gfx::Insets* overscan_insets, |
| 415 const gfx::Size& resolution_in_pixels, | 415 const gfx::Size& resolution_in_pixels, |
| 416 float device_scale_factor, | 416 float device_scale_factor, |
| 417 ui::ColorCalibrationProfile color_profile) { | 417 ui::ColorCalibrationProfile color_profile) { |
| 418 if (display_info_.find(display_id) == display_info_.end()) | 418 if (display_info_.find(display_id) == display_info_.end()) |
| 419 display_info_[display_id] = DisplayInfo(display_id, std::string(), false); | 419 display_info_[display_id] = |
| 420 ui::DisplayInfo(display_id, std::string(), false); |
| 420 | 421 |
| 421 // Do not allow rotation in unified desktop mode. | 422 // Do not allow rotation in unified desktop mode. |
| 422 if (display_id == kUnifiedDisplayId) | 423 if (display_id == kUnifiedDisplayId) |
| 423 rotation = display::Display::ROTATE_0; | 424 rotation = display::Display::ROTATE_0; |
| 424 | 425 |
| 425 display_info_[display_id].SetRotation(rotation, | 426 display_info_[display_id].SetRotation(rotation, |
| 426 display::Display::ROTATION_SOURCE_USER); | 427 display::Display::ROTATION_SOURCE_USER); |
| 427 display_info_[display_id].SetRotation( | 428 display_info_[display_id].SetRotation( |
| 428 rotation, display::Display::ROTATION_SOURCE_ACTIVE); | 429 rotation, display::Display::ROTATION_SOURCE_ACTIVE); |
| 429 display_info_[display_id].SetColorProfile(color_profile); | 430 display_info_[display_id].SetColorProfile(color_profile); |
| 430 // Just in case the preference file was corrupted. | 431 // Just in case the preference file was corrupted. |
| 431 // TODO(mukai): register |display_modes_| here as well, so the lookup for the | 432 // TODO(mukai): register |display_modes_| here as well, so the lookup for the |
| 432 // default mode in GetActiveModeForDisplayId() gets much simpler. | 433 // default mode in GetActiveModeForDisplayId() gets much simpler. |
| 433 if (0.5f <= ui_scale && ui_scale <= 2.0f) | 434 if (0.5f <= ui_scale && ui_scale <= 2.0f) |
| 434 display_info_[display_id].set_configured_ui_scale(ui_scale); | 435 display_info_[display_id].set_configured_ui_scale(ui_scale); |
| 435 if (overscan_insets) | 436 if (overscan_insets) |
| 436 display_info_[display_id].SetOverscanInsets(*overscan_insets); | 437 display_info_[display_id].SetOverscanInsets(*overscan_insets); |
| 437 if (!resolution_in_pixels.IsEmpty()) { | 438 if (!resolution_in_pixels.IsEmpty()) { |
| 438 DCHECK(!display::Display::IsInternalDisplayId(display_id)); | 439 DCHECK(!display::Display::IsInternalDisplayId(display_id)); |
| 439 // Default refresh rate, until OnNativeDisplaysChanged() updates us with the | 440 // Default refresh rate, until OnNativeDisplaysChanged() updates us with the |
| 440 // actual display info, is 60 Hz. | 441 // actual display info, is 60 Hz. |
| 441 scoped_refptr<ManagedDisplayMode> mode = new ManagedDisplayMode( | 442 scoped_refptr<ui::ManagedDisplayMode> mode = new ui::ManagedDisplayMode( |
| 442 resolution_in_pixels, 60.0f, false, false, 1.0, device_scale_factor); | 443 resolution_in_pixels, 60.0f, false, false, 1.0, device_scale_factor); |
| 443 display_modes_[display_id] = mode; | 444 display_modes_[display_id] = mode; |
| 444 } | 445 } |
| 445 } | 446 } |
| 446 | 447 |
| 447 scoped_refptr<ManagedDisplayMode> DisplayManager::GetActiveModeForDisplayId( | 448 scoped_refptr<ui::ManagedDisplayMode> DisplayManager::GetActiveModeForDisplayId( |
| 448 int64_t display_id) const { | 449 int64_t display_id) const { |
| 449 scoped_refptr<ManagedDisplayMode> selected_mode( | 450 scoped_refptr<ui::ManagedDisplayMode> selected_mode( |
| 450 GetSelectedModeForDisplayId(display_id)); | 451 GetSelectedModeForDisplayId(display_id)); |
| 451 if (selected_mode) | 452 if (selected_mode) |
| 452 return selected_mode; | 453 return selected_mode; |
| 453 | 454 |
| 454 // If 'selected' mode is empty, it should return the default mode. This means | 455 // If 'selected' mode is empty, it should return the default mode. This means |
| 455 // the native mode for the external display. Unfortunately this is not true | 456 // the native mode for the external display. Unfortunately this is not true |
| 456 // for the internal display because restoring UI-scale doesn't register the | 457 // for the internal display because restoring UI-scale doesn't register the |
| 457 // restored mode to |display_mode_|, so it needs to look up the mode whose | 458 // restored mode to |display_mode_|, so it needs to look up the mode whose |
| 458 // UI-scale value matches. See the TODO in RegisterDisplayProperty(). | 459 // UI-scale value matches. See the TODO in RegisterDisplayProperty(). |
| 459 const DisplayInfo& info = GetDisplayInfo(display_id); | 460 const ui::DisplayInfo& info = GetDisplayInfo(display_id); |
| 460 | 461 |
| 461 for (auto& mode : info.display_modes()) { | 462 for (auto& mode : info.display_modes()) { |
| 462 if (GetDisplayIdForUIScaling() == display_id) { | 463 if (GetDisplayIdForUIScaling() == display_id) { |
| 463 if (info.configured_ui_scale() == mode->ui_scale()) | 464 if (info.configured_ui_scale() == mode->ui_scale()) |
| 464 return mode.get(); | 465 return mode.get(); |
| 465 } else if (mode->native()) { | 466 } else if (mode->native()) { |
| 466 return mode.get(); | 467 return mode.get(); |
| 467 } | 468 } |
| 468 } | 469 } |
| 469 return selected_mode; | 470 return selected_mode; |
| 470 } | 471 } |
| 471 | 472 |
| 472 void DisplayManager::RegisterDisplayRotationProperties( | 473 void DisplayManager::RegisterDisplayRotationProperties( |
| 473 bool rotation_lock, | 474 bool rotation_lock, |
| 474 display::Display::Rotation rotation) { | 475 display::Display::Rotation rotation) { |
| 475 if (delegate_) | 476 if (delegate_) |
| 476 delegate_->PreDisplayConfigurationChange(false); | 477 delegate_->PreDisplayConfigurationChange(false); |
| 477 registered_internal_display_rotation_lock_ = rotation_lock; | 478 registered_internal_display_rotation_lock_ = rotation_lock; |
| 478 registered_internal_display_rotation_ = rotation; | 479 registered_internal_display_rotation_ = rotation; |
| 479 if (delegate_) | 480 if (delegate_) |
| 480 delegate_->PostDisplayConfigurationChange(); | 481 delegate_->PostDisplayConfigurationChange(); |
| 481 } | 482 } |
| 482 | 483 |
| 483 scoped_refptr<ManagedDisplayMode> DisplayManager::GetSelectedModeForDisplayId( | 484 scoped_refptr<ui::ManagedDisplayMode> |
| 484 int64_t id) const { | 485 DisplayManager::GetSelectedModeForDisplayId(int64_t id) const { |
| 485 std::map<int64_t, scoped_refptr<ManagedDisplayMode>>::const_iterator iter = | 486 std::map<int64_t, scoped_refptr<ui::ManagedDisplayMode>>::const_iterator |
| 486 display_modes_.find(id); | 487 iter = display_modes_.find(id); |
| 487 if (iter == display_modes_.end()) | 488 if (iter == display_modes_.end()) |
| 488 return scoped_refptr<ManagedDisplayMode>(); | 489 return scoped_refptr<ui::ManagedDisplayMode>(); |
| 489 return iter->second; | 490 return iter->second; |
| 490 } | 491 } |
| 491 | 492 |
| 492 bool DisplayManager::IsDisplayUIScalingEnabled() const { | 493 bool DisplayManager::IsDisplayUIScalingEnabled() const { |
| 493 return GetDisplayIdForUIScaling() != display::Display::kInvalidDisplayID; | 494 return GetDisplayIdForUIScaling() != display::Display::kInvalidDisplayID; |
| 494 } | 495 } |
| 495 | 496 |
| 496 gfx::Insets DisplayManager::GetOverscanInsets(int64_t display_id) const { | 497 gfx::Insets DisplayManager::GetOverscanInsets(int64_t display_id) const { |
| 497 std::map<int64_t, DisplayInfo>::const_iterator it = | 498 std::map<int64_t, ui::DisplayInfo>::const_iterator it = |
| 498 display_info_.find(display_id); | 499 display_info_.find(display_id); |
| 499 return (it != display_info_.end()) ? it->second.overscan_insets_in_dip() | 500 return (it != display_info_.end()) ? it->second.overscan_insets_in_dip() |
| 500 : gfx::Insets(); | 501 : gfx::Insets(); |
| 501 } | 502 } |
| 502 | 503 |
| 503 void DisplayManager::SetColorCalibrationProfile( | 504 void DisplayManager::SetColorCalibrationProfile( |
| 504 int64_t display_id, | 505 int64_t display_id, |
| 505 ui::ColorCalibrationProfile profile) { | 506 ui::ColorCalibrationProfile profile) { |
| 506 #if defined(OS_CHROMEOS) | 507 #if defined(OS_CHROMEOS) |
| 507 if (!display_info_[display_id].IsColorProfileAvailable(profile)) | 508 if (!display_info_[display_id].IsColorProfileAvailable(profile)) |
| 508 return; | 509 return; |
| 509 | 510 |
| 510 if (delegate_) | 511 if (delegate_) |
| 511 delegate_->PreDisplayConfigurationChange(false); | 512 delegate_->PreDisplayConfigurationChange(false); |
| 512 // Just sets color profile if it's not running on ChromeOS (like tests). | 513 // Just sets color profile if it's not running on ChromeOS (like tests). |
| 513 if (!base::SysInfo::IsRunningOnChromeOS() || | 514 if (!base::SysInfo::IsRunningOnChromeOS() || |
| 514 Shell::GetInstance()->display_configurator()->SetColorCalibrationProfile( | 515 Shell::GetInstance()->display_configurator()->SetColorCalibrationProfile( |
| 515 display_id, profile)) { | 516 display_id, profile)) { |
| 516 display_info_[display_id].SetColorProfile(profile); | 517 display_info_[display_id].SetColorProfile(profile); |
| 517 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Display.ColorProfile", profile, | 518 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Display.ColorProfile", profile, |
| 518 ui::NUM_COLOR_PROFILES); | 519 ui::NUM_COLOR_PROFILES); |
| 519 } | 520 } |
| 520 if (delegate_) | 521 if (delegate_) |
| 521 delegate_->PostDisplayConfigurationChange(); | 522 delegate_->PostDisplayConfigurationChange(); |
| 522 #endif | 523 #endif |
| 523 } | 524 } |
| 524 | 525 |
| 525 void DisplayManager::OnNativeDisplaysChanged( | 526 void DisplayManager::OnNativeDisplaysChanged( |
| 526 const std::vector<DisplayInfo>& updated_displays) { | 527 const DisplayInfoList& updated_displays) { |
| 527 if (updated_displays.empty()) { | 528 if (updated_displays.empty()) { |
| 528 VLOG(1) << "OnNativeDisplaysChanged(0): # of current displays=" | 529 VLOG(1) << "OnNativeDisplaysChanged(0): # of current displays=" |
| 529 << active_display_list_.size(); | 530 << active_display_list_.size(); |
| 530 // If the device is booted without display, or chrome is started | 531 // If the device is booted without display, or chrome is started |
| 531 // without --ash-host-window-bounds on linux desktop, use the | 532 // without --ash-host-window-bounds on linux desktop, use the |
| 532 // default display. | 533 // default display. |
| 533 if (active_display_list_.empty()) { | 534 if (active_display_list_.empty()) { |
| 534 std::vector<DisplayInfo> init_displays; | 535 DisplayInfoList init_displays; |
| 535 init_displays.push_back(DisplayInfo::CreateFromSpec(std::string())); | 536 init_displays.push_back(ui::DisplayInfo::CreateFromSpec(std::string())); |
| 536 MaybeInitInternalDisplay(&init_displays[0]); | 537 MaybeInitInternalDisplay(&init_displays[0]); |
| 537 OnNativeDisplaysChanged(init_displays); | 538 OnNativeDisplaysChanged(init_displays); |
| 538 } else { | 539 } else { |
| 539 // Otherwise don't update the displays when all displays are disconnected. | 540 // Otherwise don't update the displays when all displays are disconnected. |
| 540 // This happens when: | 541 // This happens when: |
| 541 // - the device is idle and powerd requested to turn off all displays. | 542 // - the device is idle and powerd requested to turn off all displays. |
| 542 // - the device is suspended. (kernel turns off all displays) | 543 // - the device is suspended. (kernel turns off all displays) |
| 543 // - the internal display's brightness is set to 0 and no external | 544 // - the internal display's brightness is set to 0 and no external |
| 544 // display is connected. | 545 // display is connected. |
| 545 // - the internal display's brightness is 0 and external display is | 546 // - the internal display's brightness is 0 and external display is |
| (...skipping 27 matching lines...) Expand all Loading... |
| 573 // Mirrored monitors have the same origins. | 574 // Mirrored monitors have the same origins. |
| 574 gfx::Point origin = iter->bounds_in_native().origin(); | 575 gfx::Point origin = iter->bounds_in_native().origin(); |
| 575 if (origins.find(origin) != origins.end()) { | 576 if (origins.find(origin) != origins.end()) { |
| 576 InsertAndUpdateDisplayInfo(*iter); | 577 InsertAndUpdateDisplayInfo(*iter); |
| 577 mirroring_display_id_ = iter->id(); | 578 mirroring_display_id_ = iter->id(); |
| 578 } else { | 579 } else { |
| 579 origins.insert(origin); | 580 origins.insert(origin); |
| 580 new_display_info_list.push_back(*iter); | 581 new_display_info_list.push_back(*iter); |
| 581 } | 582 } |
| 582 | 583 |
| 583 scoped_refptr<ManagedDisplayMode> new_mode(new ManagedDisplayMode( | 584 scoped_refptr<ui::ManagedDisplayMode> new_mode(new ui::ManagedDisplayMode( |
| 584 iter->bounds_in_native().size(), 0.0 /* refresh rate */, | 585 iter->bounds_in_native().size(), 0.0 /* refresh rate */, |
| 585 false /* interlaced */, false /* native */, iter->configured_ui_scale(), | 586 false /* interlaced */, false /* native */, iter->configured_ui_scale(), |
| 586 iter->device_scale_factor())); | 587 iter->device_scale_factor())); |
| 587 const DisplayInfo::ManagedDisplayModeList& display_modes = | 588 const ui::DisplayInfo::ManagedDisplayModeList& display_modes = |
| 588 iter->display_modes(); | 589 iter->display_modes(); |
| 589 // This is empty the displays are initialized from InitFromCommandLine. | 590 // This is empty the displays are initialized from InitFromCommandLine. |
| 590 if (display_modes.empty()) | 591 if (display_modes.empty()) |
| 591 continue; | 592 continue; |
| 592 auto display_modes_iter = FindDisplayMode(*iter, new_mode); | 593 auto display_modes_iter = FindDisplayMode(*iter, new_mode); |
| 593 // Update the actual resolution selected as the resolution request may fail. | 594 // Update the actual resolution selected as the resolution request may fail. |
| 594 if (display_modes_iter == display_modes.end()) | 595 if (display_modes_iter == display_modes.end()) |
| 595 display_modes_.erase(iter->id()); | 596 display_modes_.erase(iter->id()); |
| 596 else if (display_modes_.find(iter->id()) != display_modes_.end()) | 597 else if (display_modes_.find(iter->id()) != display_modes_.end()) |
| 597 display_modes_[iter->id()] = *display_modes_iter; | 598 display_modes_[iter->id()] = *display_modes_iter; |
| 598 } | 599 } |
| 599 if (display::Display::HasInternalDisplay() && !internal_display_connected) { | 600 if (display::Display::HasInternalDisplay() && !internal_display_connected) { |
| 600 if (display_info_.find(display::Display::InternalDisplayId()) == | 601 if (display_info_.find(display::Display::InternalDisplayId()) == |
| 601 display_info_.end()) { | 602 display_info_.end()) { |
| 602 // Create a dummy internal display if the chrome restarted | 603 // Create a dummy internal display if the chrome restarted |
| 603 // in docked mode. | 604 // in docked mode. |
| 604 DisplayInfo internal_display_info( | 605 ui::DisplayInfo internal_display_info( |
| 605 display::Display::InternalDisplayId(), | 606 display::Display::InternalDisplayId(), |
| 606 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME), | 607 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME), |
| 607 false /*Internal display must not have overscan */); | 608 false /*Internal display must not have overscan */); |
| 608 internal_display_info.SetBounds(gfx::Rect(0, 0, 800, 600)); | 609 internal_display_info.SetBounds(gfx::Rect(0, 0, 800, 600)); |
| 609 display_info_[display::Display::InternalDisplayId()] = | 610 display_info_[display::Display::InternalDisplayId()] = |
| 610 internal_display_info; | 611 internal_display_info; |
| 611 } else { | 612 } else { |
| 612 // Internal display is no longer active. Reset its rotation to user | 613 // Internal display is no longer active. Reset its rotation to user |
| 613 // preference, so that it is restored when the internal display becomes | 614 // preference, so that it is restored when the internal display becomes |
| 614 // active again. | 615 // active again. |
| 615 display::Display::Rotation user_rotation = | 616 display::Display::Rotation user_rotation = |
| 616 display_info_[display::Display::InternalDisplayId()].GetRotation( | 617 display_info_[display::Display::InternalDisplayId()].GetRotation( |
| 617 display::Display::ROTATION_SOURCE_USER); | 618 display::Display::ROTATION_SOURCE_USER); |
| 618 display_info_[display::Display::InternalDisplayId()].SetRotation( | 619 display_info_[display::Display::InternalDisplayId()].SetRotation( |
| 619 user_rotation, display::Display::ROTATION_SOURCE_USER); | 620 user_rotation, display::Display::ROTATION_SOURCE_USER); |
| 620 } | 621 } |
| 621 } | 622 } |
| 622 | 623 |
| 623 #if defined(OS_CHROMEOS) | 624 #if defined(OS_CHROMEOS) |
| 624 if (!base::SysInfo::IsRunningOnChromeOS() && | 625 if (!base::SysInfo::IsRunningOnChromeOS() && |
| 625 new_display_info_list.size() > 1) { | 626 new_display_info_list.size() > 1) { |
| 626 display::DisplayIdList list = GenerateDisplayIdList( | 627 display::DisplayIdList list = GenerateDisplayIdList( |
| 627 new_display_info_list.begin(), new_display_info_list.end(), | 628 new_display_info_list.begin(), new_display_info_list.end(), |
| 628 [](const DisplayInfo& info) { return info.id(); }); | 629 [](const ui::DisplayInfo& info) { return info.id(); }); |
| 629 | 630 |
| 630 const display::DisplayLayout& layout = | 631 const display::DisplayLayout& layout = |
| 631 layout_store_->GetRegisteredDisplayLayout(list); | 632 layout_store_->GetRegisteredDisplayLayout(list); |
| 632 // Mirror mode is set by DisplayConfigurator on the device. | 633 // Mirror mode is set by DisplayConfigurator on the device. |
| 633 // Emulate it when running on linux desktop. | 634 // Emulate it when running on linux desktop. |
| 634 if (layout.mirrored) | 635 if (layout.mirrored) |
| 635 SetMultiDisplayMode(MIRRORING); | 636 SetMultiDisplayMode(MIRRORING); |
| 636 } | 637 } |
| 637 #endif | 638 #endif |
| 638 | 639 |
| 639 UpdateDisplaysWith(new_display_info_list); | 640 UpdateDisplaysWith(new_display_info_list); |
| 640 } | 641 } |
| 641 | 642 |
| 642 void DisplayManager::UpdateDisplays() { | 643 void DisplayManager::UpdateDisplays() { |
| 643 DisplayInfoList display_info_list; | 644 DisplayInfoList display_info_list; |
| 644 for (const auto& display : active_display_list_) | 645 for (const auto& display : active_display_list_) |
| 645 display_info_list.push_back(GetDisplayInfo(display.id())); | 646 display_info_list.push_back(GetDisplayInfo(display.id())); |
| 646 AddMirrorDisplayInfoIfAny(&display_info_list); | 647 AddMirrorDisplayInfoIfAny(&display_info_list); |
| 647 UpdateDisplaysWith(display_info_list); | 648 UpdateDisplaysWith(display_info_list); |
| 648 } | 649 } |
| 649 | 650 |
| 650 void DisplayManager::UpdateDisplaysWith( | 651 void DisplayManager::UpdateDisplaysWith( |
| 651 const std::vector<DisplayInfo>& updated_display_info_list) { | 652 const DisplayInfoList& updated_display_info_list) { |
| 652 #if defined(OS_WIN) | 653 #if defined(OS_WIN) |
| 653 DCHECK_EQ(1u, updated_display_info_list.size()) | 654 DCHECK_EQ(1u, updated_display_info_list.size()) |
| 654 << ": Multiple display test does not work on Windows bots. Please " | 655 << ": Multiple display test does not work on Windows bots. Please " |
| 655 "skip (don't disable) the test using SupportsMultipleDisplays()"; | 656 "skip (don't disable) the test using SupportsMultipleDisplays()"; |
| 656 #endif | 657 #endif |
| 657 | 658 |
| 658 DisplayInfoList new_display_info_list = updated_display_info_list; | 659 DisplayInfoList new_display_info_list = updated_display_info_list; |
| 659 std::sort(active_display_list_.begin(), active_display_list_.end(), | 660 std::sort(active_display_list_.begin(), active_display_list_.end(), |
| 660 DisplaySortFunctor()); | 661 DisplaySortFunctor()); |
| 661 std::sort(new_display_info_list.begin(), new_display_info_list.end(), | 662 std::sort(new_display_info_list.begin(), new_display_info_list.end(), |
| 662 DisplayInfoSortFunctor()); | 663 DisplayInfoSortFunctor()); |
| 663 | 664 |
| 664 if (new_display_info_list.size() > 1) { | 665 if (new_display_info_list.size() > 1) { |
| 665 display::DisplayIdList list = GenerateDisplayIdList( | 666 display::DisplayIdList list = GenerateDisplayIdList( |
| 666 new_display_info_list.begin(), new_display_info_list.end(), | 667 new_display_info_list.begin(), new_display_info_list.end(), |
| 667 [](const DisplayInfo& info) { return info.id(); }); | 668 [](const ui::DisplayInfo& info) { return info.id(); }); |
| 668 const display::DisplayLayout& layout = | 669 const display::DisplayLayout& layout = |
| 669 layout_store_->GetRegisteredDisplayLayout(list); | 670 layout_store_->GetRegisteredDisplayLayout(list); |
| 670 current_default_multi_display_mode_ = | 671 current_default_multi_display_mode_ = |
| 671 (layout.default_unified && unified_desktop_enabled_) ? UNIFIED | 672 (layout.default_unified && unified_desktop_enabled_) ? UNIFIED |
| 672 : EXTENDED; | 673 : EXTENDED; |
| 673 } | 674 } |
| 674 | 675 |
| 675 if (multi_display_mode_ != MIRRORING) | 676 if (multi_display_mode_ != MIRRORING) |
| 676 multi_display_mode_ = current_default_multi_display_mode_; | 677 multi_display_mode_ = current_default_multi_display_mode_; |
| 677 | 678 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 700 CreateDisplayFromDisplayInfoById(new_info_iter->id())); | 701 CreateDisplayFromDisplayInfoById(new_info_iter->id())); |
| 701 ++new_info_iter; | 702 ++new_info_iter; |
| 702 } else if (new_info_iter == new_display_info_list.end()) { | 703 } else if (new_info_iter == new_display_info_list.end()) { |
| 703 // more displays in current list. | 704 // more displays in current list. |
| 704 removed_displays.push_back(*curr_iter); | 705 removed_displays.push_back(*curr_iter); |
| 705 ++curr_iter; | 706 ++curr_iter; |
| 706 } else if (curr_iter->id() == new_info_iter->id()) { | 707 } else if (curr_iter->id() == new_info_iter->id()) { |
| 707 const display::Display& current_display = *curr_iter; | 708 const display::Display& current_display = *curr_iter; |
| 708 // Copy the info because |InsertAndUpdateDisplayInfo| updates the | 709 // Copy the info because |InsertAndUpdateDisplayInfo| updates the |
| 709 // instance. | 710 // instance. |
| 710 const DisplayInfo current_display_info = | 711 const ui::DisplayInfo current_display_info = |
| 711 GetDisplayInfo(current_display.id()); | 712 GetDisplayInfo(current_display.id()); |
| 712 InsertAndUpdateDisplayInfo(*new_info_iter); | 713 InsertAndUpdateDisplayInfo(*new_info_iter); |
| 713 display::Display new_display = | 714 display::Display new_display = |
| 714 CreateDisplayFromDisplayInfoById(new_info_iter->id()); | 715 CreateDisplayFromDisplayInfoById(new_info_iter->id()); |
| 715 const DisplayInfo& new_display_info = GetDisplayInfo(new_display.id()); | 716 const ui::DisplayInfo& new_display_info = |
| 717 GetDisplayInfo(new_display.id()); |
| 716 | 718 |
| 717 uint32_t metrics = display::DisplayObserver::DISPLAY_METRIC_NONE; | 719 uint32_t metrics = display::DisplayObserver::DISPLAY_METRIC_NONE; |
| 718 | 720 |
| 719 // At that point the new Display objects we have are not entirely updated, | 721 // At that point the new Display objects we have are not entirely updated, |
| 720 // they are missing the translation related to the Display disposition in | 722 // they are missing the translation related to the Display disposition in |
| 721 // the layout. | 723 // the layout. |
| 722 // Using display.bounds() and display.work_area() would fail most of the | 724 // Using display.bounds() and display.work_area() would fail most of the |
| 723 // time. | 725 // time. |
| 724 if (force_bounds_changed_ || (current_display_info.bounds_in_native() != | 726 if (force_bounds_changed_ || (current_display_info.bounds_in_native() != |
| 725 new_display_info.bounds_in_native()) || | 727 new_display_info.bounds_in_native()) || |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 // info in hardware mirroring comes from DisplayConfigurator. | 893 // info in hardware mirroring comes from DisplayConfigurator. |
| 892 if (!IsInMirrorMode()) | 894 if (!IsInMirrorMode()) |
| 893 ReconfigureDisplays(); | 895 ReconfigureDisplays(); |
| 894 } | 896 } |
| 895 | 897 |
| 896 bool DisplayManager::IsInUnifiedMode() const { | 898 bool DisplayManager::IsInUnifiedMode() const { |
| 897 return multi_display_mode_ == UNIFIED && | 899 return multi_display_mode_ == UNIFIED && |
| 898 !software_mirroring_display_list_.empty(); | 900 !software_mirroring_display_list_.empty(); |
| 899 } | 901 } |
| 900 | 902 |
| 901 const DisplayInfo& DisplayManager::GetDisplayInfo(int64_t display_id) const { | 903 const ui::DisplayInfo& DisplayManager::GetDisplayInfo( |
| 904 int64_t display_id) const { |
| 902 DCHECK_NE(display::Display::kInvalidDisplayID, display_id); | 905 DCHECK_NE(display::Display::kInvalidDisplayID, display_id); |
| 903 | 906 |
| 904 std::map<int64_t, DisplayInfo>::const_iterator iter = | 907 std::map<int64_t, ui::DisplayInfo>::const_iterator iter = |
| 905 display_info_.find(display_id); | 908 display_info_.find(display_id); |
| 906 CHECK(iter != display_info_.end()) << display_id; | 909 CHECK(iter != display_info_.end()) << display_id; |
| 907 return iter->second; | 910 return iter->second; |
| 908 } | 911 } |
| 909 | 912 |
| 910 const display::Display DisplayManager::GetMirroringDisplayById( | 913 const display::Display DisplayManager::GetMirroringDisplayById( |
| 911 int64_t display_id) const { | 914 int64_t display_id) const { |
| 912 auto iter = std::find_if(software_mirroring_display_list_.begin(), | 915 auto iter = std::find_if(software_mirroring_display_list_.begin(), |
| 913 software_mirroring_display_list_.end(), | 916 software_mirroring_display_list_.end(), |
| 914 [display_id](const display::Display& display) { | 917 [display_id](const display::Display& display) { |
| 915 return display.id() == display_id; | 918 return display.id() == display_id; |
| 916 }); | 919 }); |
| 917 return iter == software_mirroring_display_list_.end() ? display::Display() | 920 return iter == software_mirroring_display_list_.end() ? display::Display() |
| 918 : *iter; | 921 : *iter; |
| 919 } | 922 } |
| 920 | 923 |
| 921 std::string DisplayManager::GetDisplayNameForId(int64_t id) { | 924 std::string DisplayManager::GetDisplayNameForId(int64_t id) { |
| 922 if (id == display::Display::kInvalidDisplayID) | 925 if (id == display::Display::kInvalidDisplayID) |
| 923 return l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); | 926 return l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); |
| 924 | 927 |
| 925 std::map<int64_t, DisplayInfo>::const_iterator iter = display_info_.find(id); | 928 std::map<int64_t, ui::DisplayInfo>::const_iterator iter = |
| 929 display_info_.find(id); |
| 926 if (iter != display_info_.end() && !iter->second.name().empty()) | 930 if (iter != display_info_.end() && !iter->second.name().empty()) |
| 927 return iter->second.name(); | 931 return iter->second.name(); |
| 928 | 932 |
| 929 return base::StringPrintf("Display %d", static_cast<int>(id)); | 933 return base::StringPrintf("Display %d", static_cast<int>(id)); |
| 930 } | 934 } |
| 931 | 935 |
| 932 int64_t DisplayManager::GetDisplayIdForUIScaling() const { | 936 int64_t DisplayManager::GetDisplayIdForUIScaling() const { |
| 933 // UI Scaling is effective on internal display. | 937 // UI Scaling is effective on internal display. |
| 934 return display::Display::HasInternalDisplay() | 938 return display::Display::HasInternalDisplay() |
| 935 ? display::Display::InternalDisplayId() | 939 ? display::Display::InternalDisplayId() |
| (...skipping 14 matching lines...) Expand all Loading... |
| 950 return; | 954 return; |
| 951 } | 955 } |
| 952 #endif | 956 #endif |
| 953 multi_display_mode_ = | 957 multi_display_mode_ = |
| 954 mirror ? MIRRORING : current_default_multi_display_mode_; | 958 mirror ? MIRRORING : current_default_multi_display_mode_; |
| 955 ReconfigureDisplays(); | 959 ReconfigureDisplays(); |
| 956 } | 960 } |
| 957 | 961 |
| 958 void DisplayManager::AddRemoveDisplay() { | 962 void DisplayManager::AddRemoveDisplay() { |
| 959 DCHECK(!active_display_list_.empty()); | 963 DCHECK(!active_display_list_.empty()); |
| 960 std::vector<DisplayInfo> new_display_info_list; | 964 DisplayInfoList new_display_info_list; |
| 961 const DisplayInfo& first_display = | 965 const ui::DisplayInfo& first_display = |
| 962 IsInUnifiedMode() | 966 IsInUnifiedMode() |
| 963 ? GetDisplayInfo(software_mirroring_display_list_[0].id()) | 967 ? GetDisplayInfo(software_mirroring_display_list_[0].id()) |
| 964 : GetDisplayInfo(active_display_list_[0].id()); | 968 : GetDisplayInfo(active_display_list_[0].id()); |
| 965 new_display_info_list.push_back(first_display); | 969 new_display_info_list.push_back(first_display); |
| 966 // Add if there is only one display connected. | 970 // Add if there is only one display connected. |
| 967 if (num_connected_displays() == 1) { | 971 if (num_connected_displays() == 1) { |
| 968 const int kVerticalOffsetPx = 100; | 972 const int kVerticalOffsetPx = 100; |
| 969 // Layout the 2nd display below the primary as with the real device. | 973 // Layout the 2nd display below the primary as with the real device. |
| 970 gfx::Rect host_bounds = first_display.bounds_in_native(); | 974 gfx::Rect host_bounds = first_display.bounds_in_native(); |
| 971 new_display_info_list.push_back( | 975 new_display_info_list.push_back( |
| 972 DisplayInfo::CreateFromSpec(base::StringPrintf( | 976 ui::DisplayInfo::CreateFromSpec(base::StringPrintf( |
| 973 "%d+%d-600x%d", host_bounds.x(), | 977 "%d+%d-600x%d", host_bounds.x(), |
| 974 host_bounds.bottom() + kVerticalOffsetPx, host_bounds.height()))); | 978 host_bounds.bottom() + kVerticalOffsetPx, host_bounds.height()))); |
| 975 } | 979 } |
| 976 num_connected_displays_ = new_display_info_list.size(); | 980 num_connected_displays_ = new_display_info_list.size(); |
| 977 mirroring_display_id_ = display::Display::kInvalidDisplayID; | 981 mirroring_display_id_ = display::Display::kInvalidDisplayID; |
| 978 software_mirroring_display_list_.clear(); | 982 software_mirroring_display_list_.clear(); |
| 979 UpdateDisplaysWith(new_display_info_list); | 983 UpdateDisplaysWith(new_display_info_list); |
| 980 } | 984 } |
| 981 | 985 |
| 982 void DisplayManager::ToggleDisplayScaleFactor() { | 986 void DisplayManager::ToggleDisplayScaleFactor() { |
| 983 DCHECK(!active_display_list_.empty()); | 987 DCHECK(!active_display_list_.empty()); |
| 984 std::vector<DisplayInfo> new_display_info_list; | 988 DisplayInfoList new_display_info_list; |
| 985 for (display::DisplayList::const_iterator iter = active_display_list_.begin(); | 989 for (display::DisplayList::const_iterator iter = active_display_list_.begin(); |
| 986 iter != active_display_list_.end(); ++iter) { | 990 iter != active_display_list_.end(); ++iter) { |
| 987 DisplayInfo display_info = GetDisplayInfo(iter->id()); | 991 ui::DisplayInfo display_info = GetDisplayInfo(iter->id()); |
| 988 display_info.set_device_scale_factor( | 992 display_info.set_device_scale_factor( |
| 989 display_info.device_scale_factor() == 1.0f ? 2.0f : 1.0f); | 993 display_info.device_scale_factor() == 1.0f ? 2.0f : 1.0f); |
| 990 new_display_info_list.push_back(display_info); | 994 new_display_info_list.push_back(display_info); |
| 991 } | 995 } |
| 992 AddMirrorDisplayInfoIfAny(&new_display_info_list); | 996 AddMirrorDisplayInfoIfAny(&new_display_info_list); |
| 993 UpdateDisplaysWith(new_display_info_list); | 997 UpdateDisplaysWith(new_display_info_list); |
| 994 } | 998 } |
| 995 | 999 |
| 996 #if defined(OS_CHROMEOS) | 1000 #if defined(OS_CHROMEOS) |
| 997 void DisplayManager::SetSoftwareMirroring(bool enabled) { | 1001 void DisplayManager::SetSoftwareMirroring(bool enabled) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 void DisplayManager::CreateScreenForShutdown() const { | 1078 void DisplayManager::CreateScreenForShutdown() const { |
| 1075 delete screen_for_shutdown; | 1079 delete screen_for_shutdown; |
| 1076 screen_for_shutdown = screen_->CloneForShutdown(); | 1080 screen_for_shutdown = screen_->CloneForShutdown(); |
| 1077 display::Screen::SetScreenInstance(screen_for_shutdown); | 1081 display::Screen::SetScreenInstance(screen_for_shutdown); |
| 1078 } | 1082 } |
| 1079 | 1083 |
| 1080 void DisplayManager::UpdateInternalManagedDisplayModeListForTest() { | 1084 void DisplayManager::UpdateInternalManagedDisplayModeListForTest() { |
| 1081 if (!display::Display::HasInternalDisplay() || | 1085 if (!display::Display::HasInternalDisplay() || |
| 1082 display_info_.count(display::Display::InternalDisplayId()) == 0) | 1086 display_info_.count(display::Display::InternalDisplayId()) == 0) |
| 1083 return; | 1087 return; |
| 1084 DisplayInfo* info = &display_info_[display::Display::InternalDisplayId()]; | 1088 ui::DisplayInfo* info = &display_info_[display::Display::InternalDisplayId()]; |
| 1085 SetInternalManagedDisplayModeList(info); | 1089 SetInternalManagedDisplayModeList(info); |
| 1086 } | 1090 } |
| 1087 | 1091 |
| 1088 void DisplayManager::CreateSoftwareMirroringDisplayInfo( | 1092 void DisplayManager::CreateSoftwareMirroringDisplayInfo( |
| 1089 DisplayInfoList* display_info_list) { | 1093 DisplayInfoList* display_info_list) { |
| 1090 // Use the internal display or 1st as the mirror source, then scale | 1094 // Use the internal display or 1st as the mirror source, then scale |
| 1091 // the root window so that it matches the external display's | 1095 // the root window so that it matches the external display's |
| 1092 // resolution. This is necessary in order for scaling to work while | 1096 // resolution. This is necessary in order for scaling to work while |
| 1093 // mirrored. | 1097 // mirrored. |
| 1094 switch (multi_display_mode_) { | 1098 switch (multi_display_mode_) { |
| 1095 case MIRRORING: { | 1099 case MIRRORING: { |
| 1096 if (display_info_list->size() != 2) | 1100 if (display_info_list->size() != 2) |
| 1097 return; | 1101 return; |
| 1098 bool zero_is_source = | 1102 bool zero_is_source = |
| 1099 first_display_id_ == (*display_info_list)[0].id() || | 1103 first_display_id_ == (*display_info_list)[0].id() || |
| 1100 display::Display::IsInternalDisplayId((*display_info_list)[0].id()); | 1104 display::Display::IsInternalDisplayId((*display_info_list)[0].id()); |
| 1101 DCHECK_EQ(MIRRORING, multi_display_mode_); | 1105 DCHECK_EQ(MIRRORING, multi_display_mode_); |
| 1102 mirroring_display_id_ = (*display_info_list)[zero_is_source ? 1 : 0].id(); | 1106 mirroring_display_id_ = (*display_info_list)[zero_is_source ? 1 : 0].id(); |
| 1103 | 1107 |
| 1104 int64_t display_id = mirroring_display_id_; | 1108 int64_t display_id = mirroring_display_id_; |
| 1105 auto iter = | 1109 auto iter = |
| 1106 std::find_if(display_info_list->begin(), display_info_list->end(), | 1110 std::find_if(display_info_list->begin(), display_info_list->end(), |
| 1107 [display_id](const DisplayInfo& info) { | 1111 [display_id](const ui::DisplayInfo& info) { |
| 1108 return info.id() == display_id; | 1112 return info.id() == display_id; |
| 1109 }); | 1113 }); |
| 1110 DCHECK(iter != display_info_list->end()); | 1114 DCHECK(iter != display_info_list->end()); |
| 1111 | 1115 |
| 1112 DisplayInfo info = *iter; | 1116 ui::DisplayInfo info = *iter; |
| 1113 info.SetOverscanInsets(gfx::Insets()); | 1117 info.SetOverscanInsets(gfx::Insets()); |
| 1114 InsertAndUpdateDisplayInfo(info); | 1118 InsertAndUpdateDisplayInfo(info); |
| 1115 software_mirroring_display_list_.push_back( | 1119 software_mirroring_display_list_.push_back( |
| 1116 CreateMirroringDisplayFromDisplayInfoById(mirroring_display_id_, | 1120 CreateMirroringDisplayFromDisplayInfoById(mirroring_display_id_, |
| 1117 gfx::Point(), 1.0f)); | 1121 gfx::Point(), 1.0f)); |
| 1118 display_info_list->erase(iter); | 1122 display_info_list->erase(iter); |
| 1119 break; | 1123 break; |
| 1120 } | 1124 } |
| 1121 case UNIFIED: { | 1125 case UNIFIED: { |
| 1122 if (display_info_list->size() == 1) | 1126 if (display_info_list->size() == 1) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1133 float default_device_scale_factor = 1.0f; | 1137 float default_device_scale_factor = 1.0f; |
| 1134 for (auto& info : *display_info_list) { | 1138 for (auto& info : *display_info_list) { |
| 1135 max_height = std::max(max_height, info.size_in_pixel().height()); | 1139 max_height = std::max(max_height, info.size_in_pixel().height()); |
| 1136 if (!default_height || | 1140 if (!default_height || |
| 1137 display::Display::IsInternalDisplayId(info.id())) { | 1141 display::Display::IsInternalDisplayId(info.id())) { |
| 1138 default_height = info.size_in_pixel().height(); | 1142 default_height = info.size_in_pixel().height(); |
| 1139 default_device_scale_factor = info.device_scale_factor(); | 1143 default_device_scale_factor = info.device_scale_factor(); |
| 1140 } | 1144 } |
| 1141 } | 1145 } |
| 1142 | 1146 |
| 1143 DisplayInfo::ManagedDisplayModeList display_mode_list; | 1147 ui::DisplayInfo::ManagedDisplayModeList display_mode_list; |
| 1144 std::set<std::pair<float, float>> dsf_scale_list; | 1148 std::set<std::pair<float, float>> dsf_scale_list; |
| 1145 | 1149 |
| 1146 // 2nd Pass. Compute the unified display size. | 1150 // 2nd Pass. Compute the unified display size. |
| 1147 for (auto& info : *display_info_list) { | 1151 for (auto& info : *display_info_list) { |
| 1148 InsertAndUpdateDisplayInfo(info); | 1152 InsertAndUpdateDisplayInfo(info); |
| 1149 gfx::Point origin(unified_bounds.right(), 0); | 1153 gfx::Point origin(unified_bounds.right(), 0); |
| 1150 float scale = | 1154 float scale = |
| 1151 info.size_in_pixel().height() / static_cast<float>(max_height); | 1155 info.size_in_pixel().height() / static_cast<float>(max_height); |
| 1152 // The display is scaled to fit the unified desktop size. | 1156 // The display is scaled to fit the unified desktop size. |
| 1153 display::Display display = CreateMirroringDisplayFromDisplayInfoById( | 1157 display::Display display = CreateMirroringDisplayFromDisplayInfoById( |
| 1154 info.id(), origin, 1.0f / scale); | 1158 info.id(), origin, 1.0f / scale); |
| 1155 unified_bounds.Union(display.bounds()); | 1159 unified_bounds.Union(display.bounds()); |
| 1156 | 1160 |
| 1157 dsf_scale_list.insert( | 1161 dsf_scale_list.insert( |
| 1158 std::make_pair(info.device_scale_factor(), scale)); | 1162 std::make_pair(info.device_scale_factor(), scale)); |
| 1159 } | 1163 } |
| 1160 | 1164 |
| 1161 DisplayInfo info(kUnifiedDisplayId, "Unified Desktop", false); | 1165 ui::DisplayInfo info(kUnifiedDisplayId, "Unified Desktop", false); |
| 1162 | 1166 |
| 1163 scoped_refptr<ManagedDisplayMode> native_mode(new ManagedDisplayMode( | 1167 scoped_refptr<ui::ManagedDisplayMode> native_mode( |
| 1164 unified_bounds.size(), 60.0f, false, true, 1.0, 1.0)); | 1168 new ui::ManagedDisplayMode(unified_bounds.size(), 60.0f, false, true, |
| 1165 DisplayInfo::ManagedDisplayModeList modes = | 1169 1.0, 1.0)); |
| 1170 ui::DisplayInfo::ManagedDisplayModeList modes = |
| 1166 CreateUnifiedManagedDisplayModeList(native_mode, dsf_scale_list); | 1171 CreateUnifiedManagedDisplayModeList(native_mode, dsf_scale_list); |
| 1167 | 1172 |
| 1168 // Find the default mode. | 1173 // Find the default mode. |
| 1169 auto iter = std::find_if( | 1174 auto iter = std::find_if( |
| 1170 modes.begin(), modes.end(), | 1175 modes.begin(), modes.end(), |
| 1171 [default_height, default_device_scale_factor]( | 1176 [default_height, default_device_scale_factor]( |
| 1172 const scoped_refptr<ManagedDisplayMode>& mode) { | 1177 const scoped_refptr<ui::ManagedDisplayMode>& mode) { |
| 1173 return mode->size().height() == default_height && | 1178 return mode->size().height() == default_height && |
| 1174 mode->device_scale_factor() == default_device_scale_factor; | 1179 mode->device_scale_factor() == default_device_scale_factor; |
| 1175 }); | 1180 }); |
| 1176 | 1181 |
| 1177 scoped_refptr<ManagedDisplayMode> dm(*iter); | 1182 scoped_refptr<ui::ManagedDisplayMode> dm(*iter); |
| 1178 *iter = make_scoped_refptr(new ManagedDisplayMode( | 1183 *iter = make_scoped_refptr(new ui::ManagedDisplayMode( |
| 1179 dm->size(), dm->refresh_rate(), dm->is_interlaced(), | 1184 dm->size(), dm->refresh_rate(), dm->is_interlaced(), |
| 1180 true /* native */, dm->ui_scale(), dm->device_scale_factor())); | 1185 true /* native */, dm->ui_scale(), dm->device_scale_factor())); |
| 1181 | 1186 |
| 1182 info.SetManagedDisplayModes(modes); | 1187 info.SetManagedDisplayModes(modes); |
| 1183 info.set_device_scale_factor(dm->device_scale_factor()); | 1188 info.set_device_scale_factor(dm->device_scale_factor()); |
| 1184 info.SetBounds(gfx::Rect(dm->size())); | 1189 info.SetBounds(gfx::Rect(dm->size())); |
| 1185 | 1190 |
| 1186 // Forget the configured resolution if the original unified | 1191 // Forget the configured resolution if the original unified |
| 1187 // desktop resolution has changed. | 1192 // desktop resolution has changed. |
| 1188 if (display_info_.count(kUnifiedDisplayId) != 0 && | 1193 if (display_info_.count(kUnifiedDisplayId) != 0 && |
| 1189 GetMaxNativeSize(display_info_[kUnifiedDisplayId]) != | 1194 GetMaxNativeSize(display_info_[kUnifiedDisplayId]) != |
| 1190 unified_bounds.size()) { | 1195 unified_bounds.size()) { |
| 1191 display_modes_.erase(kUnifiedDisplayId); | 1196 display_modes_.erase(kUnifiedDisplayId); |
| 1192 } | 1197 } |
| 1193 | 1198 |
| 1194 // 3rd Pass. Set the selected mode, then recompute the mirroring | 1199 // 3rd Pass. Set the selected mode, then recompute the mirroring |
| 1195 // display size. | 1200 // display size. |
| 1196 scoped_refptr<ManagedDisplayMode> mode = | 1201 scoped_refptr<ui::ManagedDisplayMode> mode = |
| 1197 GetSelectedModeForDisplayId(kUnifiedDisplayId); | 1202 GetSelectedModeForDisplayId(kUnifiedDisplayId); |
| 1198 if (mode && FindDisplayMode(info, mode) != info.display_modes().end()) { | 1203 if (mode && FindDisplayMode(info, mode) != info.display_modes().end()) { |
| 1199 info.set_device_scale_factor(mode->device_scale_factor()); | 1204 info.set_device_scale_factor(mode->device_scale_factor()); |
| 1200 info.SetBounds(gfx::Rect(mode->size())); | 1205 info.SetBounds(gfx::Rect(mode->size())); |
| 1201 } else { | 1206 } else { |
| 1202 display_modes_.erase(kUnifiedDisplayId); | 1207 display_modes_.erase(kUnifiedDisplayId); |
| 1203 } | 1208 } |
| 1204 | 1209 |
| 1205 int unified_display_height = info.size_in_pixel().height(); | 1210 int unified_display_height = info.size_in_pixel().height(); |
| 1206 gfx::Point origin; | 1211 gfx::Point origin; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1231 if (iter != active_display_list_.end()) | 1236 if (iter != active_display_list_.end()) |
| 1232 return &(*iter); | 1237 return &(*iter); |
| 1233 // TODO(oshima): This happens when windows in unified desktop have | 1238 // TODO(oshima): This happens when windows in unified desktop have |
| 1234 // been moved to a normal window. Fix this. | 1239 // been moved to a normal window. Fix this. |
| 1235 if (id != kUnifiedDisplayId) | 1240 if (id != kUnifiedDisplayId) |
| 1236 DLOG(WARNING) << "Could not find display:" << id; | 1241 DLOG(WARNING) << "Could not find display:" << id; |
| 1237 return nullptr; | 1242 return nullptr; |
| 1238 } | 1243 } |
| 1239 | 1244 |
| 1240 void DisplayManager::AddMirrorDisplayInfoIfAny( | 1245 void DisplayManager::AddMirrorDisplayInfoIfAny( |
| 1241 std::vector<DisplayInfo>* display_info_list) { | 1246 DisplayInfoList* display_info_list) { |
| 1242 if (software_mirroring_enabled() && IsInMirrorMode()) { | 1247 if (software_mirroring_enabled() && IsInMirrorMode()) { |
| 1243 display_info_list->push_back(GetDisplayInfo(mirroring_display_id_)); | 1248 display_info_list->push_back(GetDisplayInfo(mirroring_display_id_)); |
| 1244 software_mirroring_display_list_.clear(); | 1249 software_mirroring_display_list_.clear(); |
| 1245 } | 1250 } |
| 1246 } | 1251 } |
| 1247 | 1252 |
| 1248 void DisplayManager::InsertAndUpdateDisplayInfo(const DisplayInfo& new_info) { | 1253 void DisplayManager::InsertAndUpdateDisplayInfo( |
| 1249 std::map<int64_t, DisplayInfo>::iterator info = | 1254 const ui::DisplayInfo& new_info) { |
| 1255 std::map<int64_t, ui::DisplayInfo>::iterator info = |
| 1250 display_info_.find(new_info.id()); | 1256 display_info_.find(new_info.id()); |
| 1251 if (info != display_info_.end()) { | 1257 if (info != display_info_.end()) { |
| 1252 info->second.Copy(new_info); | 1258 info->second.Copy(new_info); |
| 1253 } else { | 1259 } else { |
| 1254 display_info_[new_info.id()] = new_info; | 1260 display_info_[new_info.id()] = new_info; |
| 1255 display_info_[new_info.id()].set_native(false); | 1261 display_info_[new_info.id()].set_native(false); |
| 1256 // FHD with 1.25 DSF behaves differently from other configuration. | 1262 // FHD with 1.25 DSF behaves differently from other configuration. |
| 1257 // It uses 1.25 DSF only when UI-Scale is set to 0.8. | 1263 // It uses 1.25 DSF only when UI-Scale is set to 0.8. |
| 1258 // For new users, use the UI-scale to 0.8 so that it will use DSF=1.25 | 1264 // For new users, use the UI-scale to 0.8 so that it will use DSF=1.25 |
| 1259 // internally. | 1265 // internally. |
| 1260 if (display::Display::IsInternalDisplayId(new_info.id()) && | 1266 if (display::Display::IsInternalDisplayId(new_info.id()) && |
| 1261 new_info.bounds_in_native().height() == 1080 && | 1267 new_info.bounds_in_native().height() == 1080 && |
| 1262 new_info.device_scale_factor() == 1.25f) { | 1268 new_info.device_scale_factor() == 1.25f) { |
| 1263 display_info_[new_info.id()].set_configured_ui_scale(0.8f); | 1269 display_info_[new_info.id()].set_configured_ui_scale(0.8f); |
| 1264 } | 1270 } |
| 1265 } | 1271 } |
| 1266 display_info_[new_info.id()].UpdateDisplaySize(); | 1272 display_info_[new_info.id()].UpdateDisplaySize(); |
| 1267 OnDisplayInfoUpdated(display_info_[new_info.id()]); | 1273 OnDisplayInfoUpdated(display_info_[new_info.id()]); |
| 1268 } | 1274 } |
| 1269 | 1275 |
| 1270 void DisplayManager::OnDisplayInfoUpdated(const DisplayInfo& display_info) { | 1276 void DisplayManager::OnDisplayInfoUpdated(const ui::DisplayInfo& display_info) { |
| 1271 #if defined(OS_CHROMEOS) | 1277 #if defined(OS_CHROMEOS) |
| 1272 ui::ColorCalibrationProfile color_profile = display_info.color_profile(); | 1278 ui::ColorCalibrationProfile color_profile = display_info.color_profile(); |
| 1273 if (color_profile != ui::COLOR_PROFILE_STANDARD) { | 1279 if (color_profile != ui::COLOR_PROFILE_STANDARD) { |
| 1274 Shell::GetInstance()->display_configurator()->SetColorCalibrationProfile( | 1280 Shell::GetInstance()->display_configurator()->SetColorCalibrationProfile( |
| 1275 display_info.id(), color_profile); | 1281 display_info.id(), color_profile); |
| 1276 } | 1282 } |
| 1277 #endif | 1283 #endif |
| 1278 } | 1284 } |
| 1279 | 1285 |
| 1280 display::Display DisplayManager::CreateDisplayFromDisplayInfoById(int64_t id) { | 1286 display::Display DisplayManager::CreateDisplayFromDisplayInfoById(int64_t id) { |
| 1281 DCHECK(display_info_.find(id) != display_info_.end()) << "id=" << id; | 1287 DCHECK(display_info_.find(id) != display_info_.end()) << "id=" << id; |
| 1282 const DisplayInfo& display_info = display_info_[id]; | 1288 const ui::DisplayInfo& display_info = display_info_[id]; |
| 1283 | 1289 |
| 1284 display::Display new_display(display_info.id()); | 1290 display::Display new_display(display_info.id()); |
| 1285 gfx::Rect bounds_in_native(display_info.size_in_pixel()); | 1291 gfx::Rect bounds_in_native(display_info.size_in_pixel()); |
| 1286 float device_scale_factor = display_info.GetEffectiveDeviceScaleFactor(); | 1292 float device_scale_factor = display_info.GetEffectiveDeviceScaleFactor(); |
| 1287 | 1293 |
| 1288 // Simply set the origin to (0,0). The primary display's origin is | 1294 // Simply set the origin to (0,0). The primary display's origin is |
| 1289 // always (0,0) and the bounds of non-primary display(s) will be updated | 1295 // always (0,0) and the bounds of non-primary display(s) will be updated |
| 1290 // in |UpdateNonPrimaryDisplayBoundsForLayout| called in |UpdateDisplay|. | 1296 // in |UpdateNonPrimaryDisplayBoundsForLayout| called in |UpdateDisplay|. |
| 1291 new_display.SetScaleAndBounds(device_scale_factor, | 1297 new_display.SetScaleAndBounds(device_scale_factor, |
| 1292 gfx::Rect(bounds_in_native.size())); | 1298 gfx::Rect(bounds_in_native.size())); |
| 1293 new_display.set_rotation(display_info.GetActiveRotation()); | 1299 new_display.set_rotation(display_info.GetActiveRotation()); |
| 1294 new_display.set_touch_support(display_info.touch_support()); | 1300 new_display.set_touch_support(display_info.touch_support()); |
| 1295 new_display.set_maximum_cursor_size(display_info.maximum_cursor_size()); | 1301 new_display.set_maximum_cursor_size(display_info.maximum_cursor_size()); |
| 1296 return new_display; | 1302 return new_display; |
| 1297 } | 1303 } |
| 1298 | 1304 |
| 1299 display::Display DisplayManager::CreateMirroringDisplayFromDisplayInfoById( | 1305 display::Display DisplayManager::CreateMirroringDisplayFromDisplayInfoById( |
| 1300 int64_t id, | 1306 int64_t id, |
| 1301 const gfx::Point& origin, | 1307 const gfx::Point& origin, |
| 1302 float scale) { | 1308 float scale) { |
| 1303 DCHECK(display_info_.find(id) != display_info_.end()) << "id=" << id; | 1309 DCHECK(display_info_.find(id) != display_info_.end()) << "id=" << id; |
| 1304 const DisplayInfo& display_info = display_info_[id]; | 1310 const ui::DisplayInfo& display_info = display_info_[id]; |
| 1305 | 1311 |
| 1306 display::Display new_display(display_info.id()); | 1312 display::Display new_display(display_info.id()); |
| 1307 new_display.SetScaleAndBounds( | 1313 new_display.SetScaleAndBounds( |
| 1308 1.0f, gfx::Rect(origin, gfx::ScaleToFlooredSize( | 1314 1.0f, gfx::Rect(origin, gfx::ScaleToFlooredSize( |
| 1309 display_info.size_in_pixel(), scale))); | 1315 display_info.size_in_pixel(), scale))); |
| 1310 new_display.set_touch_support(display_info.touch_support()); | 1316 new_display.set_touch_support(display_info.touch_support()); |
| 1311 new_display.set_maximum_cursor_size(display_info.maximum_cursor_size()); | 1317 new_display.set_maximum_cursor_size(display_info.maximum_cursor_size()); |
| 1312 return new_display; | 1318 return new_display; |
| 1313 } | 1319 } |
| 1314 | 1320 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 layout.ApplyToDisplayList(display_list, updated_ids, | 1361 layout.ApplyToDisplayList(display_list, updated_ids, |
| 1356 kMinimumOverlapForInvalidOffset); | 1362 kMinimumOverlapForInvalidOffset); |
| 1357 } | 1363 } |
| 1358 | 1364 |
| 1359 void DisplayManager::RunPendingTasksForTest() { | 1365 void DisplayManager::RunPendingTasksForTest() { |
| 1360 if (!software_mirroring_display_list_.empty()) | 1366 if (!software_mirroring_display_list_.empty()) |
| 1361 base::RunLoop().RunUntilIdle(); | 1367 base::RunLoop().RunUntilIdle(); |
| 1362 } | 1368 } |
| 1363 | 1369 |
| 1364 } // namespace ash | 1370 } // namespace ash |
| OLD | NEW |