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

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

Issue 1861593002: chromeos: Turn off displays on suspend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« 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 93afee24d063b52d409922d4fd0cd5d65454e5eb..cb5cb9e10a0a7010ba389e8172c9c87b7f07719b 100644
--- a/ui/display/chromeos/display_configurator.cc
+++ b/ui/display/chromeos/display_configurator.cc
@@ -35,12 +35,6 @@ typedef std::vector<const DisplayMode*> DisplayModeList;
// |configure_timer_|.
const int kConfigureDelayMs = 500;
-// The delay spent before reading the display configuration after coming out of
-// suspend. While coming out of suspend the display state may be updating. This
-// is used to wait until the hardware had a chance to update the display state
-// such that we read an up to date state.
-const int kResumeDelayMs = 500;
-
// The EDID specification marks the top bit of the manufacturer id as reserved.
const int16_t kReservedManufacturerID = static_cast<int16_t>(1 << 15);
@@ -476,6 +470,7 @@ DisplayConfigurator::DisplayConfigurator()
current_power_state_(chromeos::DISPLAY_POWER_ALL_ON),
requested_display_state_(MULTIPLE_DISPLAY_STATE_INVALID),
requested_power_state_(chromeos::DISPLAY_POWER_ALL_ON),
+ saved_power_state_(chromeos::DISPLAY_POWER_ALL_OFF),
requested_power_state_change_(false),
requested_power_flags_(kSetDisplayPowerNoFlags),
force_configure_(false),
@@ -928,38 +923,40 @@ void DisplayConfigurator::RemoveObserver(Observer* observer) {
void DisplayConfigurator::SuspendDisplays(
const ConfigurationCallback& callback) {
- // If the display is off due to user inactivity and there's only a single
- // internal display connected, switch to the all-on state before
- // 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 (requested_power_state_ == chromeos::DISPLAY_POWER_ALL_OFF) {
- SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
- kSetDisplayPowerOnlyIfSingleInternalDisplay, callback);
-
- // We need to make sure that the monitor configuration we just did actually
- // completes before we return, because otherwise the X message could be
- // racing with the HandleSuspendReadiness message.
- native_display_delegate_->SyncWithServer();
- } else {
- callback.Run(true);
- }
-
displays_suspended_ = true;
// Stop |configure_timer_| because we will force probe and configure all the
// displays at resume time anyway.
configure_timer_.Stop();
+
+ saved_power_state_ = requested_power_state_;
+ // Turn off the displays for suspend. This way, if we wake up for lucid sleep,
+ // the displays will not turn on (all displays should be off for lucid sleep
+ // unless explicitly requested by lucid sleep code).
+ SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, kSetDisplayPowerNoFlags,
+ callback);
+
+ // We need to make sure that the monitor configuration we just did actually
+ // completes before we return, because otherwise the X message could be
Eric Caruso 2016/04/05 17:33:36 Aren't we not using X anymore?
dbasehore 2016/04/06 04:40:39 Done.
+ // racing with the HandleSuspendReadiness message.
+ native_display_delegate_->SyncWithServer();
}
void DisplayConfigurator::ResumeDisplays() {
- displays_suspended_ = false;
+ chromeos::DisplayPowerState power_state = requested_power_state_;
- configure_timer_.Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(kResumeDelayMs),
- base::Bind(&DisplayConfigurator::RestoreRequestedPowerStateAfterResume,
- base::Unretained(this)));
+ if (power_state == chromeos::DISPLAY_POWER_ALL_OFF)
+ power_state = saved_power_state_;
+
+ displays_suspended_ = false;
+ saved_power_state_ = chromeos::DISPLAY_POWER_ALL_OFF;
Daniel Erat 2016/04/05 14:40:03 what's the reason for resetting this here? doesn't
dbasehore 2016/04/06 04:40:39 Done.
+ if (power_state == chromeos::DISPLAY_POWER_ALL_OFF)
Daniel Erat 2016/04/05 14:40:04 add curly brackets for this if/else
dbasehore 2016/04/06 04:40:39 Done.
+ SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
Daniel Erat 2016/04/05 14:40:03 what happens if the user sets the brightness to ze
dbasehore 2016/04/06 04:40:40 Don't know how, but it doesn't undo what the user
Daniel Erat 2016/04/06 15:04:19 i'm uneasy not knowing how/why this works. so you'
dbasehore 2016/04/06 20:44:45 This seems to be how it works: -Backlight set to 0
dbasehore 2016/04/06 20:53:26 When we update the backlight state in powerd, we s
+ kSetDisplayPowerOnlyIfSingleInternalDisplay,
dnicoara 2016/04/05 16:56:57 I think you still want kSetDisplayPowerForceProbe
dbasehore 2016/04/06 04:40:40 I'm changing how this works for the next version.
+ base::Bind(&DoNothing));
+ else
+ SetDisplayPower(power_state, kSetDisplayPowerForceProbe,
+ base::Bind(&DoNothing));
}
void DisplayConfigurator::ConfigureDisplays() {
@@ -1089,13 +1086,6 @@ void DisplayConfigurator::CallAndClearQueuedCallbacks(bool success) {
queued_configuration_callbacks_.clear();
}
-void DisplayConfigurator::RestoreRequestedPowerStateAfterResume() {
- // Force probing to ensure that we pick up any changes that were made while
- // the system was suspended.
- SetDisplayPower(requested_power_state_, kSetDisplayPowerForceProbe,
- base::Bind(&DoNothing));
-}
-
void DisplayConfigurator::NotifyDisplayStateObservers(
bool success,
MultipleDisplayState attempted_state) {
« 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