on xenial help sign in
Whenever we show a notification, turn the screen on
dbe8d46Michael Terry
plugins/Powerd/Powerd.cpp+7
@@ -74,6 +74,13 @@ Powerd::Status Powerd::status() const
74 return cachedStatus;
74 return cachedStatus;
75}
75}
76
76
77+void Powerd::setStatus(Powerd::Status status, DisplayStateChangeReason reason)
78+{
79+ unityScreen->asyncCall("setScreenPowerMode",
80+ status == Powerd::On ? "on" : "off",
81+ static_cast<qint32>(reason));
82+}
83+
77void Powerd::handleDisplayPowerStateChange(int status, int reason)
84void Powerd::handleDisplayPowerStateChange(int status, int reason)
78{
85{
79 if (cachedStatus != (Status)status) {
86 if (cachedStatus != (Status)status) {
plugins/Powerd/Powerd.h+4
@@ -37,6 +37,7 @@ public:
37 Inactivity = 1, // Display changed state due to inactivity
37 Inactivity = 1, // Display changed state due to inactivity
38 PowerKey = 2, // Display changed state due to user pressing power key
38 PowerKey = 2, // Display changed state due to user pressing power key
39 Proximity = 3, // Display changed state due to proximity events
39 Proximity = 3, // Display changed state due to proximity events
40+ Notification = 4, // Display changed state due to user notification
40 };
41 };
41
42
42 enum Status {
43 enum Status {
@@ -49,6 +50,9 @@ public:
49
50
50 Status status() const;
51 Status status() const;
51
52
53+ // Not exposed via Q_PROPERTY because we need the 'reason' argument too
54+ Q_INVOKABLE void setStatus(Status status, DisplayStateChangeReason reason);
55+
52Q_SIGNALS:
56Q_SIGNALS:
53 void statusChanged(DisplayStateChangeReason reason);
57 void statusChanged(DisplayStateChangeReason reason);
54
58
qml/Notifications/Notification.qml+10−1
@@ -16,6 +16,7 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18import QtMultimedia 5.0
18import QtMultimedia 5.0
19+import Powerd 0.1
19import Ubuntu.Components 1.1
20import Ubuntu.Components 1.1
20import Unity.Notifications 1.0
21import Unity.Notifications 1.0
21import QMenuModel 0.1
22import QMenuModel 0.1
@@ -84,8 +85,16 @@ Item {
84 source: hints["suppress-sound"] !== "true" && hints["sound-file"] !== undefined ? hints["sound-file"] : ""
85 source: hints["suppress-sound"] !== "true" && hints["sound-file"] !== undefined ? hints["sound-file"] : ""
85 }
86 }
86
87
87− // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really
88 Component.onCompleted: {
88 Component.onCompleted: {
89+ // Turn on screen as needed (Powerd.Notification means the screen
90+ // stays on for a shorter amount of time)
91+ if (type == Notification.SnapDecision) {
92+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
93+ } else if (type != Notification.Confirmation) {
94+ Powerd.setStatus(Powerd.On, Powerd.Notification);
95+ }
96+
97+ // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really
89 if (opacity == 1.0 && hints["suppress-sound"] !== "true" && sound.source !== "") {
98 if (opacity == 1.0 && hints["suppress-sound"] !== "true" && sound.source !== "") {
90 sound.play();
99 sound.play();
91 }
100 }