Chromium Code Reviews| Index: ash/display/display_manager.cc |
| diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc |
| index ff8d137f18957e9d313ab52af892329886d70898..153f5925bb41a5c864cf9bee1952138e2b88a794 100644 |
| --- a/ash/display/display_manager.cc |
| +++ b/ash/display/display_manager.cc |
| @@ -37,6 +37,7 @@ |
| #include "ui/display/display.h" |
| #include "ui/display/display_observer.h" |
| #include "ui/display/manager/display_layout_store.h" |
| +#include "ui/display/manager/display_manager_utilities.h" |
| #include "ui/display/manager/managed_display_info.h" |
| #include "ui/display/screen.h" |
| #include "ui/gfx/font_render_params.h" |
| @@ -69,14 +70,14 @@ const int kMinimumOverlapForInvalidOffset = 100; |
| struct DisplaySortFunctor { |
| bool operator()(const display::Display& a, const display::Display& b) { |
| - return CompareDisplayIds(a.id(), b.id()); |
| + return ui::CompareDisplayIds(a.id(), b.id()); |
| } |
| }; |
| struct DisplayInfoSortFunctor { |
| bool operator()(const ui::ManagedDisplayInfo& a, |
| const ui::ManagedDisplayInfo& b) { |
| - return CompareDisplayIds(a.id(), b.id()); |
| + return ui::CompareDisplayIds(a.id(), b.id()); |
| } |
| }; |
| @@ -104,7 +105,7 @@ void SetInternalManagedDisplayModeList(ui::ManagedDisplayInfo* info) { |
| false /* native_mode */, 1.0 /* ui_scale */, |
| info->device_scale_factor()); |
| info->SetManagedDisplayModes( |
| - CreateInternalManagedDisplayModeList(native_mode)); |
| + ui::CreateInternalManagedDisplayModeList(native_mode)); |
| } |
| void MaybeInitInternalDisplay(ui::ManagedDisplayInfo* info) { |
| @@ -226,7 +227,7 @@ const display::DisplayLayout& DisplayManager::GetCurrentDisplayLayout() const { |
| display::DisplayIdList DisplayManager::GetCurrentDisplayIdList() const { |
| if (IsInUnifiedMode()) { |
| - return CreateDisplayIdList(software_mirroring_display_list_); |
| + return ui::CreateDisplayIdList(software_mirroring_display_list_); |
| } else if (IsInMirrorMode()) { |
| if (software_mirroring_enabled()) { |
| CHECK_EQ(2u, num_connected_displays()); |
| @@ -235,10 +236,10 @@ display::DisplayIdList DisplayManager::GetCurrentDisplayIdList() const { |
| CHECK_EQ(1u, active_display_list_.size()); |
| } |
| int64_t ids[] = {active_display_list_[0].id(), mirroring_display_id_}; |
| - return ash::GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| + return ui::GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| } else { |
| CHECK_LE(2u, active_display_list_.size()); |
| - return CreateDisplayIdList(active_display_list_); |
| + return ui::CreateDisplayIdList(active_display_list_); |
| } |
| } |
| @@ -283,8 +284,8 @@ const display::Display& DisplayManager::GetDisplayForId(int64_t id) const { |
| const display::Display& DisplayManager::FindDisplayContainingPoint( |
| const gfx::Point& point_in_screen) const { |
| - int index = |
| - FindDisplayIndexContainingPoint(active_display_list_, point_in_screen); |
| + int index = ui::FindDisplayIndexContainingPoint(active_display_list_, |
| + point_in_screen); |
| return index < 0 ? GetInvalidDisplay() : active_display_list_[index]; |
| } |
| @@ -1093,6 +1094,44 @@ void DisplayManager::UpdateInternalManagedDisplayModeListForTest() { |
| SetInternalManagedDisplayModeList(info); |
| } |
| +bool DisplayManager::ZoomInternalDisplay(bool up) { |
| + int64_t display_id = |
| + IsInUnifiedMode() ? kUnifiedDisplayId : GetDisplayIdForUIScaling(); |
| + const ui::ManagedDisplayInfo& display_info = GetDisplayInfo(display_id); |
| + |
| + scoped_refptr<ui::ManagedDisplayMode> mode; |
| + if (IsInUnifiedMode()) { |
| + mode = GetDisplayModeForNextResolution(display_info, up); |
| + } else { |
| + if (!IsActiveDisplayId(display_info.id()) || |
| + !display::Display::IsInternalDisplayId(display_info.id())) { |
| + return false; |
| + } |
| + mode = GetDisplayModeForNextUIScale(display_info, up); |
| + } |
| + |
| + if (!mode) |
| + return false; |
| + return SetDisplayMode(display_id, mode); |
|
oshima
2016/08/26 21:55:59
nit:
return mode ? SetDisplayMode() : false;
rjkroege
2016/08/30 19:11:06
Done.
|
| +} |
| + |
| +void DisplayManager::ResetInternalDisplayZoom() { |
| + if (IsInUnifiedMode()) { |
| + const ui::ManagedDisplayInfo& display_info = |
| + GetDisplayInfo(DisplayManager::kUnifiedDisplayId); |
| + const ui::ManagedDisplayInfo::ManagedDisplayModeList& modes = |
| + display_info.display_modes(); |
| + auto iter = |
| + std::find_if(modes.begin(), modes.end(), |
| + [](const scoped_refptr<ui::ManagedDisplayMode>& mode) { |
| + return mode->native(); |
| + }); |
| + SetDisplayMode(kUnifiedDisplayId, *iter); |
| + } else { |
| + SetDisplayUIScale(GetDisplayIdForUIScaling(), 1.0f); |
| + } |
| +} |
| + |
| void DisplayManager::CreateSoftwareMirroringDisplayInfo( |
| DisplayInfoList* display_info_list) { |
| // Use the internal display or 1st as the mirror source, then scale |
| @@ -1331,7 +1370,7 @@ void DisplayManager::UpdateNonPrimaryDisplayBoundsForLayout( |
| const display::DisplayLayout& layout = |
| layout_store_->GetRegisteredDisplayLayout( |
| - CreateDisplayIdList(*display_list)); |
| + ui::CreateDisplayIdList(*display_list)); |
| // Ignore if a user has a old format (should be extremely rare) |
| // and this will be replaced with DCHECK. |