on xenial help sign in
Improve the way notifications interact with power management

The improvements are: 1. PlaceHolder notifications are ignored 2. Notifications send a Powerd.Off event on destruction, to notify the power manager of their lifetime

commitda849f4179c6fc49d966aae864167cef3f63677a authorAlexandros Frantzis <alexandros.frantzis@canonical.com> dateWed 25 May 2016, 20:06 (10 years ago) parent64d3f31
1 file changed+16
qml/Notifications/Notification.qml+16
qml/Notifications/Notification.qml+16
@@ -84,6 +84,10 @@ StyledItem {
8484 }
8585
8686 Component.onCompleted: {
87+ if (type === Notification.PlaceHolder) {
88+ return;
89+ }
90+
8791 // Turn on screen as needed (Powerd.Notification means the screen
8892 // stays on for a shorter amount of time)
8993 if (type === Notification.SnapDecision) {
@@ -98,6 +102,18 @@ StyledItem {
98102 }
99103 }
100104
105+ Component.onDestruction: {
106+ if (type === Notification.PlaceHolder) {
107+ return;
108+ }
109+
110+ if (type === Notification.SnapDecision) {
111+ Powerd.setStatus(Powerd.Off, Powerd.SnapDecision);
112+ } else if (type !== Notification.Confirmation) {
113+ Powerd.setStatus(Powerd.Off, Powerd.Notification);
114+ }
115+ }
116+
101117 function closeNotification() {
102118 if (notification.actions.count > 1) { // perform the "reject" action
103119 notification.notification.invokeAction(notification.actions.data(1, ActionModel.RoleActionId));