diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-28 10:40:06 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-28 10:40:06 +0000 |
commit | 685442f3419739cc35090343ad7845dc10226fa5 (patch) | |
tree | 4babecfa93e550bb21bd133491595d48cf2a414b /ash/wm/power_button_controller.cc | |
parent | 13413b74727834f0bdf238e5149e99dd26b5225a (diff) | |
download | chromium_src-685442f3419739cc35090343ad7845dc10226fa5.zip chromium_src-685442f3419739cc35090343ad7845dc10226fa5.tar.gz chromium_src-685442f3419739cc35090343ad7845dc10226fa5.tar.bz2 |
chromeos: Honor power button when in docked mode.
Ash ignores power button events while the display's
brightness is set to 0%. Make it honor them if an external
display is still on.
BUG=chrome-os-partner:24912
Review URL: https://codereview.chromium.org/177043004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/power_button_controller.cc')
-rw-r--r-- | ash/wm/power_button_controller.cc | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc index 3df7e689..c7eeefa 100644 --- a/ash/wm/power_button_controller.cc +++ b/ash/wm/power_button_controller.cc @@ -20,18 +20,25 @@ PowerButtonController::PowerButtonController( LockStateController* controller) : power_button_down_(false), lock_button_down_(false), - screen_is_off_(false), + brightness_is_zero_(false), + internal_display_off_and_external_display_on_(false), has_legacy_power_button_( CommandLine::ForCurrentProcess()->HasSwitch( switches::kAuraLegacyPowerButton)), controller_(controller) { +#if defined(OS_CHROMEOS) && defined(USE_X11) + Shell::GetInstance()->output_configurator()->AddObserver(this); +#endif } PowerButtonController::~PowerButtonController() { +#if defined(OS_CHROMEOS) && defined(USE_X11) + Shell::GetInstance()->output_configurator()->RemoveObserver(this); +#endif } void PowerButtonController::OnScreenBrightnessChanged(double percent) { - screen_is_off_ = percent <= 0.001; + brightness_is_zero_ = percent <= 0.001; } void PowerButtonController::OnPowerButtonEvent( @@ -42,8 +49,9 @@ void PowerButtonController::OnPowerButtonEvent( return; // Avoid starting the lock/shutdown sequence if the power button is pressed - // while the screen is off (http://crbug.com/128451). - if (screen_is_off_) + // while the screen is off (http://crbug.com/128451), unless an external + // display is still on (http://crosbug.com/p/24912). + if (brightness_is_zero_ && !internal_display_off_and_external_display_on_) return; const SessionStateDelegate* session_state_delegate = @@ -107,4 +115,23 @@ void PowerButtonController::OnLockButtonEvent( controller_->CancelLockAnimation(); } +#if defined(OS_CHROMEOS) && defined(USE_X11) +void PowerButtonController::OnDisplayModeChanged( + const std::vector<chromeos::OutputConfigurator::OutputSnapshot>& outputs) { + bool internal_display_off = false; + bool external_display_on = false; + for (size_t i = 0; i < outputs.size(); ++i) { + const chromeos::OutputConfigurator::OutputSnapshot& output = outputs[i]; + if (output.type == ui::OUTPUT_TYPE_INTERNAL) { + if (!output.current_mode) + internal_display_off = true; + } else if (output.current_mode) { + external_display_on = true; + } + } + internal_display_off_and_external_display_on_ = + internal_display_off && external_display_on; +} +#endif + } // namespace ash |