on xenial help sign in
Update Powerd plugin and Shell.qml to accommodate changes in the display power state notification.
commit7e2ea99b7fcbc5bee42d0c7e4e46209e465d71cc authorAlberto Aguirre <alberto.aguirre@canonical.com> dateTue 24 Jun 2014, 17:10 (12 years ago) parentad0a13fc1924f5
5 files changed+33−33
plugins/Powerd/Powerd.cpp+16−16 plugins/Powerd/Powerd.h+8−8 qml/Shell.qml+1−1 tests/mocks/Powerd/Powerd.h+7−7 tests/qmltests/tst_Shell.qml+1−1
plugins/Powerd/Powerd.cpp+16−16
@@ -19,35 +19,35 @@
1919#include "Powerd.h"
2020#include <QDBusPendingCall>
2121
22−void autoBrightnessChanged(GSettings *settings, const gchar *key, QDBusInterface *powerd)
22+void autoBrightnessChanged(GSettings *settings, const gchar *key, QDBusInterface *unityScreen)
2323{
2424 bool value = g_settings_get_boolean(settings, key);
25− powerd->asyncCall("userAutobrightnessEnable", QVariant(value));
25+ unityScreen->asyncCall("userAutobrightnessEnable", QVariant(value));
2626}
2727
2828Powerd::Powerd(QObject* parent)
2929 : QObject(parent),
30− powerd(NULL)
30+ unityScreen(NULL)
3131{
32− powerd = new QDBusInterface("com.canonical.powerd",
33− "/com/canonical/powerd",
34− "com.canonical.powerd",
35− QDBusConnection::SM_BUSNAME(), this);
32+ unityScreen = new QDBusInterface("com.canonical.Unity.Screen",
33+ "/com/canonical/Unity/Screen",
34+ "com.canonical.Unity.Screen",
35+ QDBusConnection::SM_BUSNAME(), this);
3636
37− powerd->connection().connect("com.canonical.powerd",
38− "/com/canonical/powerd",
39− "com.canonical.powerd",
40− "DisplayPowerStateChange",
41− this,
42− SIGNAL(displayPowerStateChange(int, unsigned int)));
37+ unityScreen->connection().connect("com.canonical.Unity.Screen",
38+ "/com/canonical/Unity/Screen",
39+ "com.canonical.Unity.Screen",
40+ "DisplayPowerStateChange",
41+ this,
42+ SIGNAL(displayPowerStateChange(int, int)));
4343
4444 systemSettings = g_settings_new("com.ubuntu.touch.system");
45− g_signal_connect(systemSettings, "changed::auto-brightness", G_CALLBACK(autoBrightnessChanged), powerd);
46− autoBrightnessChanged(systemSettings, "auto-brightness", powerd);
45+ g_signal_connect(systemSettings, "changed::auto-brightness", G_CALLBACK(autoBrightnessChanged), unityScreen);
46+ autoBrightnessChanged(systemSettings, "auto-brightness", unityScreen);
4747}
4848
4949Powerd::~Powerd()
5050{
51− g_signal_handlers_disconnect_by_data(systemSettings, powerd);
51+ g_signal_handlers_disconnect_by_data(systemSettings, unityScreen);
5252 g_object_unref(systemSettings);
5353}
plugins/Powerd/Powerd.h+8−8
@@ -28,15 +28,15 @@ class Powerd: public QObject
2828{
2929 Q_OBJECT
3030 Q_ENUMS(Status)
31− Q_FLAGS(DisplayFlag DisplayFlags)
31+ Q_ENUMS(DisplayStateChangeReason)
3232
3333public:
34− enum DisplayFlag {
35− UseProximity = 1, // Use proximity sensor to override screen state
36− DisableAutoBrightness = 2, // Force autobrightness to be disabled
37− Bright = 4, // Request the screen to stay bright
34+ enum DisplayStateChangeReason {
35+ Unknown = 0,
36+ Inactivity = 1, // Display changed state due to inactivity
37+ PowerKey = 2, // Display changed state due to user pressing power key
38+ Proximity = 3, // Display changed state due to proximity events
3839 };
39− Q_DECLARE_FLAGS(DisplayFlags, DisplayFlag)
4040
4141 enum Status {
4242 Off,
@@ -47,10 +47,10 @@ public:
4747 ~Powerd();
4848
4949Q_SIGNALS:
50− void displayPowerStateChange(int status, unsigned int flags);
50+ void displayPowerStateChange(int status, int reason);
5151
5252private:
53− QDBusInterface *powerd;
53+ QDBusInterface *unityScreen;
5454 GSettings *systemSettings;
5555};
5656
qml/Shell.qml+1−1
@@ -452,7 +452,7 @@ FocusScope {
452452 onDisplayPowerStateChange: {
453453 // We ignore any display-off signals when the proximity sensor
454454 // is active. This usually indicates something like a phone call.
455− if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
455+ if (status == Powerd.Off && reason != Powerd.Proximity) {
456456 greeter.showNow();
457457 }
458458
tests/mocks/Powerd/Powerd.h+7−7
@@ -25,15 +25,15 @@ class Powerd: public QObject
2525{
2626 Q_OBJECT
2727 Q_ENUMS(Status)
28− Q_FLAGS(DisplayFlag DisplayFlags)
28+ Q_ENUMS(DisplayStateChangeReason)
2929
3030public:
31− enum DisplayFlag {
32− UseProximity = 1, // Use proximity sensor to override screen state
33− DisableAutoBrightness = 2, // Force autobrightness to be disabled
34− Bright = 4, // Request the screen to stay bright
31+ enum DisplayStateChangeReason {
32+ Unknown = 0,
33+ Inactivity = 1, // Display changed state due to inactivity
34+ PowerKey = 2, // Display changed state due to user pressing power key
35+ Proximity = 3, // Display changed state due to proximity events
3536 };
36− Q_DECLARE_FLAGS(DisplayFlags, DisplayFlag)
3737
3838 enum Status {
3939 Off,
@@ -43,7 +43,7 @@ public:
4343 explicit Powerd(QObject *parent = 0);
4444
4545Q_SIGNALS:
46− void displayPowerStateChange(int status, unsigned int flags);
46+ void displayPowerStateChange(int status, int reason);
4747};
4848
4949#endif
tests/qmltests/tst_Shell.qml+1−1
@@ -195,7 +195,7 @@ Item {
195195 tryCompare(mainApp, "state", ApplicationInfo.Running);
196196
197197 // Try to suspend while proximity is engaged...
198− Powerd.displayPowerStateChange(Powerd.Off, Powerd.UseProximity);
198+ Powerd.displayPowerStateChange(Powerd.Off, Powerd.Proximity);
199199 tryCompare(greeter, "showProgress", 0);
200200
201201 // Now really suspend