Index: powerd.cc |
diff --git a/powerd.cc b/powerd.cc |
index 246c5f856620dfe83bfb0640401c317d6a158402..5b7e90e583133903375150f80f488c5338c28db0 100644 |
--- a/powerd.cc |
+++ b/powerd.cc |
@@ -296,6 +296,7 @@ GdkFilterReturn Daemon::gdk_event_filter(GdkXEvent* gxevent, GdkEvent*, |
gpointer data) { |
Daemon* daemon = static_cast<Daemon*>(data); |
XEvent* xevent = static_cast<XEvent*>(gxevent); |
+ bool changed_brightness = false; |
if (xevent->type == KeyPress) { |
int keycode = xevent->xkey.keycode; |
if (keycode == daemon->key_brightness_up_ || |
@@ -306,6 +307,7 @@ GdkFilterReturn Daemon::gdk_event_filter(GdkXEvent* gxevent, GdkEvent*, |
LOG(INFO) << "Key press: F7"; |
} |
daemon->ctl_->IncreaseBrightness(); |
+ changed_brightness = true; |
} else if (keycode == daemon->key_brightness_down_ || |
keycode == daemon->key_f6_) { |
if (keycode == daemon->key_brightness_down_) { |
@@ -314,8 +316,16 @@ GdkFilterReturn Daemon::gdk_event_filter(GdkXEvent* gxevent, GdkEvent*, |
LOG(INFO) << "Key press: F6"; |
} |
daemon->ctl_->DecreaseBrightness(); |
+ changed_brightness = true; |
} |
} |
+ |
+ if (changed_brightness) { |
+ int64 brightness = 0; |
+ daemon->ctl_->GetBrightness(&brightness); |
+ daemon->SendBrightnessChangedSignal(static_cast<int>(brightness)); |
+ } |
+ |
return GDK_FILTER_CONTINUE; |
} |
@@ -474,4 +484,19 @@ gboolean Daemon::PrefChangeHandler(const char* name, |
return true; |
} |
+void Daemon::SendBrightnessChangedSignal(int level) { |
+ chromeos::dbus::Proxy proxy(chromeos::dbus::GetSystemBusConnection(), |
+ "/", |
+ kPowerManagerInterface); |
+ DBusMessage* signal = dbus_message_new_signal("/", |
+ kPowerManagerInterface, |
+ kBrightnessChangedSignal); |
+ CHECK(signal); |
+ dbus_message_append_args(signal, |
+ DBUS_TYPE_INT32, &level, |
+ DBUS_TYPE_INVALID); |
+ dbus_g_proxy_send(proxy.gproxy(), signal, NULL); |
+ dbus_message_unref(signal); |
+} |
+ |
} // namespace power_manager |