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

Unified Diff: ash/display/resolution_notification_controller.cc

Issue 2799963003: Fix errors in display resolution change notifications (Closed)
Patch Set: Update commit message Created 3 years, 8 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/resolution_notification_controller.cc
diff --git a/ash/display/resolution_notification_controller.cc b/ash/display/resolution_notification_controller.cc
index b6db541a490252540d856899479872648ca8c82b..8d472b6674f645c8d2f02873fe24f51bc74cf572 100644
--- a/ash/display/resolution_notification_controller.cc
+++ b/ash/display/resolution_notification_controller.cc
@@ -162,7 +162,7 @@ ResolutionNotificationController::~ResolutionNotificationController() {
display::Screen::GetScreen()->RemoveObserver(this);
}
-void ResolutionNotificationController::PrepareNotification(
+bool ResolutionNotificationController::PrepareNotificationAndSetDisplayMode(
int64_t display_id,
const scoped_refptr<display::ManagedDisplayMode>& old_resolution,
const scoped_refptr<display::ManagedDisplayMode>& new_resolution,
@@ -170,7 +170,14 @@ void ResolutionNotificationController::PrepareNotification(
DCHECK(old_resolution);
DCHECK(new_resolution);
- DCHECK(!display::Display::IsInternalDisplayId(display_id));
+ display::DisplayManager* const display_manager =
+ Shell::Get()->display_manager();
+ if (display::Display::IsInternalDisplayId(display_id)) {
+ // We don't show notifications to confirm/revert the resolution change in
+ // the case of an internal display.
+ return display_manager->SetDisplayMode(display_id, new_resolution);
+ }
+
// If multiple resolution changes are invoked for the same display,
// the original resolution for the first resolution change has to be used
// instead of the specified |old_resolution|.
@@ -192,6 +199,15 @@ void ResolutionNotificationController::PrepareNotification(
new_resolution, accept_callback));
if (original_resolution && !original_resolution->size().IsEmpty())
change_info_->old_resolution = original_resolution;
+
+ if (!display_manager->SetDisplayMode(display_id, new_resolution)) {
+ // Discard the prepared notification data since we failed to set the new
+ // resolution.
+ change_info_.reset();
+ return false;
+ }
+
+ return true;
}
bool ResolutionNotificationController::DoesNotificationTimeout() {
« no previous file with comments | « ash/display/resolution_notification_controller.h ('k') | ash/display/resolution_notification_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698