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

Unified Diff: ash/display/display_manager.cc

Issue 2426103004: Specify a default display UI scale to reset the zoom to (Closed)
Patch Set: Clean up, simplify 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
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());
}
}

Powered by Google App Engine
This is Rietveld 408576698