diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-30 23:42:04 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-30 23:42:04 +0000 |
commit | 429932192b1e0afc28a9f9de1519d98baf04b269 (patch) | |
tree | 1a4dde1612e9501c8bad7bce1fd05b5b7f68bd1e /chromeos | |
parent | 5f4ed93da5d14f807a7db2f43d1afe62438a67cd (diff) | |
download | chromium_src-429932192b1e0afc28a9f9de1519d98baf04b269.zip chromium_src-429932192b1e0afc28a9f9de1519d98baf04b269.tar.gz chromium_src-429932192b1e0afc28a9f9de1519d98baf04b269.tar.bz2 |
chromeos: Add support for dimming the screen.
This makes Chrome listen for messages from the power manager
asking it to dim or undim the screen. We'll use this on
desktop devices with external displays to dim the screen
just before blanking it when the user is idle.
BUG=125176
TEST=added, also did manual testing with powerd changes
Review URL: http://codereview.chromium.org/10263011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134638 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/dbus/power_manager_client.cc | 32 | ||||
-rw-r--r-- | chromeos/dbus/power_manager_client.h | 9 |
2 files changed, 40 insertions, 1 deletions
diff --git a/chromeos/dbus/power_manager_client.cc b/chromeos/dbus/power_manager_client.cc index 26f6705..ca50df7 100644 --- a/chromeos/dbus/power_manager_client.cc +++ b/chromeos/dbus/power_manager_client.cc @@ -111,6 +111,15 @@ class PowerManagerClientImpl : public PowerManagerClient { weak_ptr_factory_.GetWeakPtr()), base::Bind(&PowerManagerClientImpl::SignalConnected, weak_ptr_factory_.GetWeakPtr())); + + power_manager_proxy_->ConnectToSignal( + power_manager::kPowerManagerInterface, + power_manager::kSoftwareScreenDimmingRequestedSignal, + base::Bind( + &PowerManagerClientImpl::SoftwareScreenDimmingRequestedReceived, + weak_ptr_factory_.GetWeakPtr()), + base::Bind(&PowerManagerClientImpl::SignalConnected, + weak_ptr_factory_.GetWeakPtr())); } virtual ~PowerManagerClientImpl() { @@ -435,7 +444,6 @@ class PowerManagerClientImpl : public PowerManagerClient { FOR_EACH_OBSERVER(Observer, observers_, UnlockScreenFailed()); } - void IdleNotifySignalReceived(dbus::Signal* signal) { dbus::MessageReader reader(signal); int64 threshold = 0; @@ -464,6 +472,28 @@ class PowerManagerClientImpl : public PowerManagerClient { FOR_EACH_OBSERVER(Observer, observers_, ActiveNotify()); } + void SoftwareScreenDimmingRequestedReceived(dbus::Signal* signal) { + dbus::MessageReader reader(signal); + int32 signal_state = 0; + if (!reader.PopInt32(&signal_state)) { + LOG(ERROR) << "Screen dimming signal had incorrect parameters: " + << signal->ToString(); + return; + } + + Observer::ScreenDimmingState state = Observer::SCREEN_DIMMING_NONE; + switch (signal_state) { + case power_manager::kSoftwareScreenDimmingNone: + state = Observer::SCREEN_DIMMING_NONE; + break; + case power_manager::kSoftwareScreenDimmingIdle: + state = Observer::SCREEN_DIMMING_IDLE; + break; + default: + LOG(ERROR) << "Unhandled screen dimming state " << signal_state; + } + FOR_EACH_OBSERVER(Observer, observers_, ScreenDimmingRequested(state)); + } dbus::ObjectProxy* power_manager_proxy_; dbus::ObjectProxy* session_manager_proxy_; diff --git a/chromeos/dbus/power_manager_client.h b/chromeos/dbus/power_manager_client.h index eb19947..00c27b8 100644 --- a/chromeos/dbus/power_manager_client.h +++ b/chromeos/dbus/power_manager_client.h @@ -39,6 +39,11 @@ class CHROMEOS_EXPORT PowerManagerClient { // Interface for observing changes from the power manager. class Observer { public: + enum ScreenDimmingState { + SCREEN_DIMMING_NONE = 0, + SCREEN_DIMMING_IDLE, + }; + virtual ~Observer() {} // Called when the brightness is changed. @@ -75,6 +80,10 @@ class CHROMEOS_EXPORT PowerManagerClient { // Called when we go from idle to active. virtual void ActiveNotify() {} + + // Called when a request is received to dim or undim the screen in software + // (as opposed to the more-common method of adjusting the backlight). + virtual void ScreenDimmingRequested(ScreenDimmingState state) {} }; enum UpdateRequestType { |