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

Unified Diff: ash/display/display_manager.cc

Issue 22662005: Don't remember best resolution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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_info_unittest.cc ('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 5943f99b189657af4882dc9d3b7ddaa1e4059bcf..b87fed0bdf7ff0f3d700e3cda3f0641a1f7cb22f 100644
--- a/ash/display/display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -72,6 +72,14 @@ struct DisplayInfoSortFunctor {
}
};
+struct ResolutionMatcher {
+ ResolutionMatcher(const gfx::Size& size) : size(size) {}
+ bool operator()(const Resolution& resolution) {
+ return resolution.size == size;
+ }
+ gfx::Size size;
+};
+
struct ScaleComparator {
ScaleComparator(float s) : scale(s) {}
@@ -326,7 +334,23 @@ void DisplayManager::SetDisplayResolution(int64 display_id,
DCHECK_NE(gfx::Display::InternalDisplayId(), display_id);
if (gfx::Display::InternalDisplayId() == display_id)
return;
- resolutions_[display_id] = resolution;
+ const DisplayInfo& display_info = GetDisplayInfo(display_id);
+ const std::vector<Resolution>& resolutions = display_info.resolutions();
+ DCHECK_NE(0u, resolutions.size());
+ std::vector<Resolution>::const_iterator iter =
+ std::find_if(resolutions.begin(),
+ resolutions.end(),
+ ResolutionMatcher(resolution));
+ if (iter == resolutions.end()) {
+ LOG(WARNING) << "Unsupported resolution was requested:"
+ << resolution.ToString();
+ return;
+ } else if (iter == resolutions.begin()) {
+ // The best resolution was set, so forget it.
+ resolutions_.erase(display_id);
+ } else {
+ resolutions_[display_id] = resolution;
+ }
#if defined(OS_CHROMEOS) && defined(USE_X11)
if (base::chromeos::IsRunningOnChromeOS())
Shell::GetInstance()->output_configurator()->ScheduleConfigureOutputs();
@@ -733,7 +757,7 @@ void DisplayManager::SetMirrorMode(bool mirrored) {
void DisplayManager::AddRemoveDisplay() {
DCHECK(!displays_.empty());
std::vector<DisplayInfo> new_display_info_list;
- DisplayInfo first_display = GetDisplayInfo(displays_[0].id());
+ const DisplayInfo& first_display = GetDisplayInfo(displays_[0].id());
new_display_info_list.push_back(first_display);
// Add if there is only one display connected.
if (num_connected_displays() == 1) {
« no previous file with comments | « ash/display/display_info_unittest.cc ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698