Chromium Code Reviews| Index: chromeos/display/output_configurator.cc |
| diff --git a/chromeos/display/output_configurator.cc b/chromeos/display/output_configurator.cc |
| index de22e2c0750d14c719efcb957a0086beaa82d8e2..a7ae5bb9fcb71b185a767f186ac2d281d46f11e6 100644 |
| --- a/chromeos/display/output_configurator.cc |
| +++ b/chromeos/display/output_configurator.cc |
| @@ -650,14 +650,12 @@ bool OutputConfigurator::CycleDisplayMode() { |
| return did_change; |
| } |
| -bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) { |
| - TRACE_EVENT0("chromeos", "OutputConfigurator::ScreenPowerSet"); |
| - VLOG(1) << "OutputConfigurator::SetScreensOn " << power_on |
| - << " all displays " << all_displays; |
| +bool OutputConfigurator::SetDisplayPowerState(DisplayPowerState state) { |
| + TRACE_EVENT0("chromeos", "OutputConfigurator::SetPowerState"); |
| + VLOG(1) << "OutputConfigurator::SetPowerState state " << state; |
| if (!is_running_on_chrome_os_) |
| return false; |
| - bool success = false; |
| Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
| CHECK(display != NULL); |
| XGrabServer(display); |
| @@ -668,7 +666,7 @@ bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) { |
| std::vector<OutputSnapshot> outputs = GetDualOutputs(display, screen); |
| connected_output_count_ = outputs.size(); |
| - if (all_displays && power_on) { |
| + if (state == DISPLAY_POWER_ALL_ON) { |
| // Resume all displays using the current state. |
| if (EnterState(display, screen, window, output_state_, outputs)) { |
| // Force the DPMS on since the driver doesn't always detect that it should |
| @@ -687,32 +685,34 @@ bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) { |
| // Set the CRTCs based on whether we want to turn the power on or off and |
| // select the outputs to operate on by name or all_displays. |
| for (int i = 0; i < connected_output_count_; ++i) { |
| - if (all_displays || outputs[i].is_internal || power_on) { |
| - config.x = 0; |
| - config.y = outputs[i].y; |
| - config.output = outputs[i].output; |
| - config.mode = None; |
| - if (power_on) { |
| + config.x = 0; |
|
Daniel Erat
2013/02/28 01:48:53
I'm not sure how to test that this still works as
|
| + config.y = outputs[i].y; |
| + config.output = outputs[i].output; |
| + |
| + // Workaround for crbug.com/148365: leave internal display in native |
| + // mode so user can move cursor (and hence windows) onto internal |
| + // display even when it's off. |
| + if (connected_output_count_ > 1 && outputs[i].is_internal) { |
| + config.mode = outputs[i].native_mode; |
| + } else { |
| + if (state == DISPLAY_POWER_ALL_ON || |
| + (state == DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON && |
| + !outputs[i].is_internal)) { |
| config.mode = (output_state_ == STATE_DUAL_MIRROR) ? |
| outputs[i].mirror_mode : outputs[i].native_mode; |
| - } else if (connected_output_count_ > 1 && !all_displays && |
| - outputs[i].is_internal) { |
| - // Workaround for crbug.com/148365: leave internal display in native |
| - // mode so user can move cursor (and hence windows) onto internal |
| - // display even when dimmed |
| - config.mode = outputs[i].native_mode; |
| + } else { |
| + config.mode = None; |
| } |
| - config.crtc = GetNextCrtcAfter(display, screen, config.output, |
| - config.crtc); |
| - |
| - ConfigureCrtc(display, screen, &config); |
| - success = true; |
| } |
| + |
| + config.crtc = GetNextCrtcAfter(display, screen, config.output, config.crtc); |
| + ConfigureCrtc(display, screen, &config); |
| } |
| // Force the DPMS on since the driver doesn't always detect that it should |
| // turn on. This is needed when coming back from idle suspend. |
| - if (power_on) { |
| + if (state == DISPLAY_POWER_ALL_ON || |
| + state == DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON) { |
| CHECK(DPMSEnable(display)); |
| CHECK(DPMSForceLevel(display, DPMSModeOn)); |
| } |
| @@ -720,7 +720,7 @@ bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) { |
| XRRFreeScreenResources(screen); |
| XUngrabServer(display); |
| - return success; |
| + return true; |
| } |
| bool OutputConfigurator::SetDisplayMode(OutputState new_state) { |
| @@ -843,7 +843,7 @@ void OutputConfigurator::SuspendDisplays() { |
| // Turn displays on before suspend. At this point, the backlight is off, |
| // so we turn on the internal display so that we can resume directly into |
| // "on" state. This greatly reduces resume times. |
| - ScreenPowerSet(true, true); |
| + SetDisplayPowerState(DISPLAY_POWER_ALL_ON); |
| // 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. |