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

Unified Diff: ui/display/chromeos/display_configurator.cc

Issue 597683004: chromeos: Save display power state on config failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 6 years, 3 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 | « ui/display/chromeos/display_configurator.h ('k') | ui/display/chromeos/display_configurator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/chromeos/display_configurator.cc
diff --git a/ui/display/chromeos/display_configurator.cc b/ui/display/chromeos/display_configurator.cc
index d31c27bf75b460232abaa782decfaa3e5779c1d6..1d297bb4d09c416f7293b3bb8df573f6e3178e8e 100644
--- a/ui/display/chromeos/display_configurator.cc
+++ b/ui/display/chromeos/display_configurator.cc
@@ -160,7 +160,8 @@ DisplayConfigurator::DisplayConfigurator()
is_panel_fitting_enabled_(false),
configure_display_(base::SysInfo::IsRunningOnChromeOS()),
display_state_(MULTIPLE_DISPLAY_STATE_INVALID),
- power_state_(chromeos::DISPLAY_POWER_ALL_ON),
+ requested_power_state_(chromeos::DISPLAY_POWER_ALL_ON),
+ current_power_state_(chromeos::DISPLAY_POWER_ALL_ON),
next_display_protection_client_id_(1) {}
DisplayConfigurator::~DisplayConfigurator() {
@@ -179,7 +180,7 @@ void DisplayConfigurator::SetDelegateForTesting(
void DisplayConfigurator::SetInitialDisplayPower(
chromeos::DisplayPowerState power_state) {
DCHECK_EQ(display_state_, MULTIPLE_DISPLAY_STATE_INVALID);
- power_state_ = power_state;
+ requested_power_state_ = current_power_state_ = power_state;
}
void DisplayConfigurator::Init(bool is_panel_fitting_enabled) {
@@ -206,9 +207,10 @@ void DisplayConfigurator::ForceInitialConfigure(
UpdateCachedDisplays();
if (cached_displays_.size() > 1 && background_color_argb)
native_display_delegate_->SetBackgroundColor(background_color_argb);
- const MultipleDisplayState new_state = ChooseDisplayState(power_state_);
- const bool success =
- EnterStateOrFallBackToSoftwareMirroring(new_state, power_state_);
+ const MultipleDisplayState new_state = ChooseDisplayState(
+ requested_power_state_);
+ const bool success = EnterStateOrFallBackToSoftwareMirroring(
+ new_state, requested_power_state_);
// Force the DPMS on chrome startup as the driver doesn't always detect
// that all displays are on when signing out.
@@ -442,7 +444,8 @@ bool DisplayConfigurator::SetDisplayPower(
<< DisplayPowerStateToString(power_state) << " flags=" << flags
<< ", configure timer="
<< (configure_timer_.IsRunning() ? "Running" : "Stopped");
- if (power_state == power_state_ && !(flags & kSetDisplayPowerForceProbe))
+ if (power_state == current_power_state_ &&
+ !(flags & kSetDisplayPowerForceProbe))
return true;
native_display_delegate_->GrabServer();
@@ -470,7 +473,7 @@ bool DisplayConfigurator::SetDisplayPower(
native_display_delegate_->UngrabServer();
if (attempted_change)
NotifyObservers(success, new_state);
- return true;
+ return success;
}
bool DisplayConfigurator::SetDisplayMode(MultipleDisplayState new_state) {
@@ -491,8 +494,8 @@ bool DisplayConfigurator::SetDisplayMode(MultipleDisplayState new_state) {
native_display_delegate_->GrabServer();
UpdateCachedDisplays();
- const bool success =
- EnterStateOrFallBackToSoftwareMirroring(new_state, power_state_);
+ const bool success = EnterStateOrFallBackToSoftwareMirroring(
+ new_state, requested_power_state_);
native_display_delegate_->UngrabServer();
NotifyObservers(success, new_state);
@@ -532,7 +535,7 @@ void DisplayConfigurator::SuspendDisplays() {
// suspending. This shouldn't be very noticeable to the user since the
// backlight is off at this point, and doing this lets us resume directly
// into the "on" state, which greatly reduces resume times.
- if (power_state_ == chromeos::DISPLAY_POWER_ALL_OFF) {
+ if (requested_power_state_ == chromeos::DISPLAY_POWER_ALL_OFF) {
SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
kSetDisplayPowerOnlyIfSingleInternalDisplay);
@@ -551,7 +554,7 @@ void DisplayConfigurator::ResumeDisplays() {
base::TimeDelta::FromMilliseconds(kResumeDelayMs),
base::Bind(base::IgnoreResult(&DisplayConfigurator::SetDisplayPower),
base::Unretained(this),
- power_state_,
+ requested_power_state_,
kSetDisplayPowerForceProbe));
}
@@ -703,9 +706,10 @@ void DisplayConfigurator::ConfigureDisplays() {
native_display_delegate_->GrabServer();
UpdateCachedDisplays();
- const MultipleDisplayState new_state = ChooseDisplayState(power_state_);
- const bool success =
- EnterStateOrFallBackToSoftwareMirroring(new_state, power_state_);
+ const MultipleDisplayState new_state = ChooseDisplayState(
+ requested_power_state_);
+ const bool success = EnterStateOrFallBackToSoftwareMirroring(
+ new_state, requested_power_state_);
native_display_delegate_->UngrabServer();
NotifyObservers(success, new_state);
@@ -731,7 +735,7 @@ bool DisplayConfigurator::EnterStateOrFallBackToSoftwareMirroring(
bool enable_software_mirroring = false;
if (!success && display_state == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) {
if (display_state_ != MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED ||
- power_state_ != power_state)
+ current_power_state_ != power_state)
EnterState(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, power_state);
enable_software_mirroring = success =
display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED;
@@ -749,6 +753,9 @@ bool DisplayConfigurator::EnterState(MultipleDisplayState display_state,
VLOG(1) << "EnterState: display=" << DisplayStateToString(display_state)
<< " power=" << DisplayPowerStateToString(power_state);
+ // Save the requested state so we'll try to use it next time even if we fail.
+ requested_power_state_ = power_state;
+
// Framebuffer dimensions.
gfx::Size size;
@@ -915,7 +922,7 @@ bool DisplayConfigurator::EnterState(MultipleDisplayState display_state,
if (all_succeeded) {
display_state_ = display_state;
- power_state_ = power_state;
+ current_power_state_ = power_state;
framebuffer_size_ = size;
}
return all_succeeded;
« no previous file with comments | « ui/display/chromeos/display_configurator.h ('k') | ui/display/chromeos/display_configurator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698