Chromium Code Reviews| Index: ui/display/chromeos/display_configurator.cc |
| diff --git a/ui/display/chromeos/display_configurator.cc b/ui/display/chromeos/display_configurator.cc |
| index 6c3062317944388f13615d2e7ae7d6db5a276a5a..a78af1acb318ccd9b11fecd942451bea48c40fac 100644 |
| --- a/ui/display/chromeos/display_configurator.cc |
| +++ b/ui/display/chromeos/display_configurator.cc |
| @@ -31,10 +31,6 @@ namespace { |
| typedef std::vector<const DisplayMode*> DisplayModeList; |
| -// The delay to perform configuration after RRNotify. See the comment for |
| -// |configure_timer_|. |
| -const int kConfigureDelayMs = 500; |
| - |
| // The EDID specification marks the top bit of the manufacturer id as reserved. |
| const int16_t kReservedManufacturerID = static_cast<int16_t>(1 << 15); |
| @@ -862,6 +858,14 @@ void DisplayConfigurator::SetDisplayPowerInternal( |
| pending_power_flags_ = flags; |
| queued_configuration_callbacks_.push_back(callback); |
| + if (configure_timer_.IsRunning()) { |
| + // If there is a configuration task scheduled, avoid performing |
| + // configuration immediately. Instead reset the timer to wait for things to |
| + // settle. |
| + configure_timer_.Reset(); |
| + return; |
| + } |
| + |
| RunPendingConfiguration(); |
| } |
| @@ -916,13 +920,11 @@ void DisplayConfigurator::OnConfigurationChanged() { |
| // Configure displays with |kConfigureDelayMs| delay, |
| // so that time-consuming ConfigureDisplays() won't be called multiple times. |
| - if (configure_timer_.IsRunning()) { |
| - // Note: when the timer is running it is possible that a different task |
| - // (RestoreRequestedPowerStateAfterResume()) is scheduled. In these cases, |
| - // prefer the already scheduled task to ConfigureDisplays() since |
| - // ConfigureDisplays() performs only basic configuration while |
| - // RestoreRequestedPowerStateAfterResume() will perform additional |
| - // operations. |
| + if (configure_timer_.IsRunning() && |
| + configure_timer_.GetCurrentDelay() <= |
| + base::TimeDelta::FromMilliseconds(kConfigureDelayMs)) { |
| + // Avoid resetting the timer to a huge delay if we are currently pending |
| + // the delayed configuration after waking up from suspend. |
| configure_timer_.Reset(); |
| } else { |
| configure_timer_.Start( |
| @@ -967,15 +969,34 @@ void DisplayConfigurator::SuspendDisplays( |
| } |
| void DisplayConfigurator::ResumeDisplays() { |
| + ResumeDisplaysWithCallback(base::Bind(&DoNothing)); |
| +} |
| + |
| +void DisplayConfigurator::ResumeDisplaysWithCallback( |
| + const ConfigurationCallback& callback) { |
| if (!configure_display_ || display_externally_controlled_) |
|
Daniel Erat
2016/10/24 16:31:04
should you be running the callback here? SuspendDi
afakhry
2016/10/25 00:37:10
Done.
|
| return; |
| displays_suspended_ = false; |
| + if (current_display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR || |
| + current_display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED || |
| + current_display_state_ == MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED) { |
| + // When waking up from suspend while being in a multi display mode, we |
| + // schedule a delayed forced configuration, which will make |
| + // SetDisplayPowerInternal() avoid performing the configuration immediately. |
| + // This gives a chance to wait for all displays to be added and detected |
| + // before configuration is performed. |
| + configure_timer_.Start(FROM_HERE, |
| + base::TimeDelta::FromMilliseconds( |
| + kResumeConfigureMultiDisplayDelayMs), |
| + this, |
| + &DisplayConfigurator::ConfigureDisplays); |
| + } |
| + |
| // If requested_power_state_ is ALL_OFF due to idle suspend, powerd will turn |
| // the display power on when it enables the backlight. |
| - SetDisplayPower(requested_power_state_, kSetDisplayPowerNoFlags, |
| - base::Bind(&DoNothing)); |
| + SetDisplayPower(requested_power_state_, kSetDisplayPowerNoFlags, callback); |
| } |
| void DisplayConfigurator::ConfigureDisplays() { |