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

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

Issue 2427843002: Delay display configuration after waking up from suspend with multi displays (Closed)
Patch Set: Nits Created 4 years, 1 month 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 6c3062317944388f13615d2e7ae7d6db5a276a5a..ed55d22e6f2438b7a4383fa624149f64ec3047bb 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);
@@ -68,6 +64,12 @@ bool DisplayConfigurator::TestApi::TriggerConfigureTimeout() {
}
}
+base::TimeDelta DisplayConfigurator::TestApi::GetConfigureDelay() const {
+ return configurator_->configure_timer_.IsRunning()
+ ? configurator_->configure_timer_.GetCurrentDelay()
+ : base::TimeDelta();
+}
+
////////////////////////////////////////////////////////////////////////////////
// DisplayConfigurator::DisplayLayoutManagerImpl implementation
@@ -862,6 +864,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,21 +926,9 @@ 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.
- configure_timer_.Reset();
- } else {
- configure_timer_.Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(kConfigureDelayMs),
- this,
- &DisplayConfigurator::ConfigureDisplays);
- }
+ configure_timer_.Start(FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kConfigureDelayMs),
+ this, &DisplayConfigurator::ConfigureDisplays);
}
void DisplayConfigurator::AddObserver(Observer* observer) {
@@ -972,6 +970,20 @@ void DisplayConfigurator::ResumeDisplays() {
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, so we won't immediately resize the
+ // desktops and the windows on it to fit on a single display.
+ 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,
« 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