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

Unified Diff: powerd.cc

Issue 3771002: power_manager: Send BrightnessChanged signal. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/power_manager.git
Patch Set: Created 10 years, 2 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 | « powerd.h ('k') | powerman.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « powerd.h ('k') | powerman.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698