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
d777ec6Michael Terry
Shell.qml+5−3
@@ -497,11 +497,13 @@ FocusScope {
497 }
497 }
498 }
498 }
499
499
500− onPowerStateChange: {
500+ onDisplayPowerStateChange: {
501− if (state == 0) { // suspend
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) {
502 powerConnection.setFocused(false);
504 powerConnection.setFocused(false);
503 greeter.show();
505 greeter.show();
504− } else if (state == 1) { // active
506+ } else if (state == 1) {
505 powerConnection.setFocused(true);
507 powerConnection.setFocused(true);
506 }
508 }
507 }
509 }
plugins/Powerd/Powerd.cpp+2−2
@@ -30,7 +30,7 @@ Powerd::Powerd(QObject* parent)
30 powerd->connection().connect("com.canonical.powerd",
30 powerd->connection().connect("com.canonical.powerd",
31 "/com/canonical/powerd",
31 "/com/canonical/powerd",
32 "com.canonical.powerd",
32 "com.canonical.powerd",
33− "SysPowerStateChange",
33+ "DisplayPowerStateChange",
34 this,
34 this,
35− SIGNAL(powerStateChange(int)));
35+ SIGNAL(displayPowerStateChange(int, unsigned int)));
36}
36}
plugins/Powerd/Powerd.h+8−1
@@ -26,12 +26,19 @@
26class Powerd: public QObject
26class Powerd: public QObject
27{
27{
28 Q_OBJECT
28 Q_OBJECT
29+ Q_FLAGS(DisplayFlags)
29
30
30public:
31public:
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+
31 explicit Powerd(QObject *parent = 0);
38 explicit Powerd(QObject *parent = 0);
32
39
33Q_SIGNALS:
40Q_SIGNALS:
34− void powerStateChange(int state);
41+ void displayPowerStateChange(int state, unsigned int flags);
35
42
36private:
43private:
37 QDBusInterface *powerd;
44 QDBusInterface *powerd;