on xenial help sign in
Listen to display-power-changed rather than system-power-changed signals when showing the greeter; ignore such signals when the proximity sensor is active
commitd777ec617e830081b783397deb8f5e5cb3d3f803 authorMichael Terry <michael.terry@canonical.com> dateTue 20 Aug 2013, 17:04 (13 years ago) parent78832ed
3 files changed+15−6
Shell.qml+5−3 plugins/Powerd/Powerd.cpp+2−2 plugins/Powerd/Powerd.h+8−1
Shell.qml+5−3
@@ -497,11 +497,13 @@ FocusScope {
497497 }
498498 }
499499
500− onPowerStateChange: {
501− if (state == 0) { // suspend
500+ onDisplayPowerStateChange: {
501+ // We ignore any display-off signals when the proximity sensor
502+ // is active. This usually indicates something like a phone call.
503+ if (state == 0 && (flags & Powerd.UseProximity) == 0) {
502504 powerConnection.setFocused(false);
503505 greeter.show();
504− } else if (state == 1) { // active
506+ } else if (state == 1) {
505507 powerConnection.setFocused(true);
506508 }
507509 }
plugins/Powerd/Powerd.cpp+2−2
@@ -30,7 +30,7 @@ Powerd::Powerd(QObject* parent)
3030 powerd->connection().connect("com.canonical.powerd",
3131 "/com/canonical/powerd",
3232 "com.canonical.powerd",
33− "SysPowerStateChange",
33+ "DisplayPowerStateChange",
3434 this,
35− SIGNAL(powerStateChange(int)));
35+ SIGNAL(displayPowerStateChange(int, unsigned int)));
3636}
plugins/Powerd/Powerd.h+8−1
@@ -26,12 +26,19 @@
2626class Powerd: public QObject
2727{
2828 Q_OBJECT
29+ Q_FLAGS(DisplayFlags)
2930
3031public:
32+ enum DisplayFlags {
33+ UseProximity = 1, // Use proximity sensor to override screen state
34+ DisableAutoBrightness = 2, // Force autobrightness to be disabled
35+ Bright = 4, // Request the screen to stay bright
36+ };
37+
3138 explicit Powerd(QObject *parent = 0);
3239
3340Q_SIGNALS:
34− void powerStateChange(int state);
41+ void displayPowerStateChange(int state, unsigned int flags);
3542
3643private:
3744 QDBusInterface *powerd;