on xenial help sign in
Whenever we show a notification, turn the screen on
commitdbe8d4611c6552706b78a4538c9a85ae5a220511 authorMichael Terry <michael.terry@canonical.com> dateMon 10 Aug 2015, 18:29 (11 years ago) parente949943
3 files changed+21−1
plugins/Powerd/Powerd.cpp+7 plugins/Powerd/Powerd.h+4 qml/Notifications/Notification.qml+10−1
plugins/Powerd/Powerd.cpp+7
@@ -74,6 +74,13 @@ Powerd::Status Powerd::status() const
7474 return cachedStatus;
7575}
7676
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+
7784void Powerd::handleDisplayPowerStateChange(int status, int reason)
7885{
7986 if (cachedStatus != (Status)status) {
plugins/Powerd/Powerd.h+4
@@ -37,6 +37,7 @@ public:
3737 Inactivity = 1, // Display changed state due to inactivity
3838 PowerKey = 2, // Display changed state due to user pressing power key
3939 Proximity = 3, // Display changed state due to proximity events
40+ Notification = 4, // Display changed state due to user notification
4041 };
4142
4243 enum Status {
@@ -49,6 +50,9 @@ public:
4950
5051 Status status() const;
5152
53+ // Not exposed via Q_PROPERTY because we need the 'reason' argument too
54+ Q_INVOKABLE void setStatus(Status status, DisplayStateChangeReason reason);
55+
5256Q_SIGNALS:
5357 void statusChanged(DisplayStateChangeReason reason);
5458
qml/Notifications/Notification.qml+10−1
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.0
1818import QtMultimedia 5.0
19+import Powerd 0.1
1920import Ubuntu.Components 1.1
2021import Unity.Notifications 1.0
2122import QMenuModel 0.1
@@ -84,8 +85,16 @@ Item {
8485 source: hints["suppress-sound"] !== "true" && hints["sound-file"] !== undefined ? hints["sound-file"] : ""
8586 }
8687
87− // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really
8888 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
8998 if (opacity == 1.0 && hints["suppress-sound"] !== "true" && sound.source !== "") {
9099 sound.play();
91100 }