Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2485)

Unified Diff: ash/display/display_manager.cc

Issue 2426103004: Specify a default display UI scale to reset the zoom to (Closed)
Patch Set: Working test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/display/display_manager.h ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_manager.cc
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc
index 50aabb503ef9db6108ef075ae3b3c4ee3f7b1c7e..b117acb0e6fab55b0baabe34a08710366fe4771b 100644
--- a/ash/display/display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -114,16 +114,15 @@ gfx::Size GetMaxNativeSize(const display::ManagedDisplayInfo& info) {
return size;
}
-scoped_refptr<display::ManagedDisplayMode> GetDisplayModeForUIScale(
- const display::ManagedDisplayInfo& info,
- float ui_scale) {
- const display::ManagedDisplayInfo::ManagedDisplayModeList& modes =
- info.display_modes();
- auto iter = std::find_if(
- modes.begin(), modes.end(),
- [ui_scale](const scoped_refptr<display::ManagedDisplayMode>& mode) {
- return mode->ui_scale() == ui_scale;
- });
+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;
@@ -1097,17 +1096,14 @@ bool DisplayManager::ZoomInternalDisplay(bool up) {
return mode ? SetDisplayMode(display_id, mode) : false;
}
-bool DisplayManager::SetDisplayUIScale(int64_t id, float ui_scale) {
- if (!IsActiveDisplayId(id) || !display::Display::IsInternalDisplayId(id)) {
+bool DisplayManager::ResetDisplayToDefaultMode(int64_t id) {
+ if (!IsActiveDisplayId(id) || !display::Display::IsInternalDisplayId(id))
return false;
- }
+
const display::ManagedDisplayInfo& info = GetDisplayInfo(id);
+ scoped_refptr<display::ManagedDisplayMode> mode = GetDefaultDisplayMode(info);
- scoped_refptr<display::ManagedDisplayMode> mode =
- GetDisplayModeForUIScale(info, ui_scale);
- if (!mode)
- return false;
- return SetDisplayMode(id, mode);
+ return mode ? SetDisplayMode(id, mode) : false;
}
void DisplayManager::ResetInternalDisplayZoom() {
@@ -1123,7 +1119,7 @@ void DisplayManager::ResetInternalDisplayZoom() {
});
SetDisplayMode(kUnifiedDisplayId, *iter);
} else {
- SetDisplayUIScale(GetDisplayIdForUIScaling(), 1.0f);
+ ResetDisplayToDefaultMode(GetDisplayIdForUIScaling());
}
}
« no previous file with comments | « ash/display/display_manager.h ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698