Chromium Code Reviews| Index: ash/display/display_manager.cc |
| diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc |
| index 50aabb503ef9db6108ef075ae3b3c4ee3f7b1c7e..2262abf4cd3033846bf392347e8d1fe4bc530f0d 100644 |
| --- a/ash/display/display_manager.cc |
| +++ b/ash/display/display_manager.cc |
| @@ -129,6 +129,20 @@ scoped_refptr<display::ManagedDisplayMode> GetDisplayModeForUIScale( |
| return *iter; |
| } |
| +scoped_refptr<display::ManagedDisplayMode> GetDefaultDisplayMode( |
| + const display::ManagedDisplayInfo& info) { |
| + const auto& modes = info.display_modes(); |
| + auto iter = |
| + std::find_if(modes.begin(), modes.end(), |
| + [](const scoped_refptr<display::ManagedDisplayMode>& mode) { |
| + return mode->is_default(); |
| + }); |
| + |
| + if (iter == modes.end()) |
| + return scoped_refptr<display::ManagedDisplayMode>(); |
| + return *iter; |
| +} |
| + |
| } // namespace |
| using std::string; |
| @@ -1110,6 +1124,16 @@ bool DisplayManager::SetDisplayUIScale(int64_t id, float ui_scale) { |
| return SetDisplayMode(id, mode); |
| } |
| +bool DisplayManager::ResetDisplayToDefaultMode(int64_t display_id) { |
| + if (!IsActiveDisplayId(display_id)) |
|
oshima
2016/10/19 21:04:06
Check internal display as well.
afakhry
2016/10/24 20:21:46
Done.
|
| + return false; |
| + |
| + const display::ManagedDisplayInfo& info = GetDisplayInfo(display_id); |
| + scoped_refptr<display::ManagedDisplayMode> mode = GetDefaultDisplayMode(info); |
| + |
| + return mode ? SetDisplayMode(display_id, mode) : false; |
| +} |
| + |
| void DisplayManager::ResetInternalDisplayZoom() { |
| if (IsInUnifiedMode()) { |
| const display::ManagedDisplayInfo& display_info = |
| @@ -1123,7 +1147,7 @@ void DisplayManager::ResetInternalDisplayZoom() { |
| }); |
| SetDisplayMode(kUnifiedDisplayId, *iter); |
| } else { |
| - SetDisplayUIScale(GetDisplayIdForUIScaling(), 1.0f); |
| + ResetDisplayToDefaultMode(GetDisplayIdForUIScaling()); |
| } |
| } |