Merge lp:~dandrader/unity-api/app-state-handling into lp:unity-api

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Gerry Boland
Approved revision: no longer in the source branch.
Merged at revision: 179
Proposed branch: lp:~dandrader/unity-api/app-state-handling
Merge into: lp:unity-api
Diff against target: 311 lines (+48/-71)
9 files modified
debian/changelog (+10/-2)
include/unity/shell/application/ApplicationInfoInterface.h (+21/-4)
include/unity/shell/application/ApplicationManagerInterface.h (+0/-29)
include/unity/shell/application/CMakeLists.txt (+1/-1)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp (+9/-0)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h (+3/-4)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp (+1/-21)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h (+1/-7)
test/qmltest/unity/shell/application/tst_Application.qml (+2/-3)
To merge this branch: bzr merge lp:~dandrader/unity-api/app-state-handling
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+258643@code.launchpad.net

Commit message

Let users of the API suspend & resume individual apps at will

API Changes:
- Removed ApplicationManagerInterface.forceDashActive
- Removed ApplicationManagerInterface.suspended
- Added ApplicationInfoInterface.requestedState

Description of the change

Needed for having unity8 handling the application lifecycle (suspending&resuming apps) explicitly instead of having it tied to application focus.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

+ Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
FYI: on Thursday at UOS, we had a session on desktop app lifecycle stuff. There we decided that there will be more states than running/suspended. For the desktop we will want a "throttled" state, i.e. application has throttled CPU usage.

It will be up to unity8 to have that policy, so qtmir needs to export that capability.

In that case, we would prefer a property supporting an enum: Running/Suspended/Throttled

Could you change this property to have Running/Suspended states, with a view to supporting more in future?

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> + Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
> FYI: on Thursday at UOS, we had a session on desktop app lifecycle stuff.
> There we decided that there will be more states than running/suspended. For
> the desktop we will want a "throttled" state, i.e. application has throttled
> CPU usage.
>
> It will be up to unity8 to have that policy, so qtmir needs to export that
> capability.
>
> In that case, we would prefer a property supporting an enum:
> Running/Suspended/Throttled
>
> Could you change this property to have Running/Suspended states, with a view
> to supporting more in future?

Done.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

+ * @brief The aplication's requested state
typo. Also "state" is vague in this context, would elaborate slightly to "application's requested running state"

+ virtual void setRequestedState(RequestedState) = 0;
+ void requestedStateChanged(RequestedState value);
"const RequestedState" would do no harm, and would help compiler slightly

Looks good otherwise. Thanks for the API change

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 11/05/15 08:07, Gerry Boland wrote:
> Review: Needs Fixing
>
> + * @brief The aplication's requested state
> typo. Also "state" is vague in this context, would elaborate slightly to "application's requested running state"

Done.

>
> + virtual void setRequestedState(RequestedState) = 0;
> + void requestedStateChanged(RequestedState value);
> "const RequestedState" would do no harm, and would help compiler slightly

I does do some harm by making the signature longer, and the benefit of
having a "const int" parameter (as merely a hint to the reader) is
arguable in my opinion. Would like a third vote on this.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

> > + virtual void setRequestedState(RequestedState) = 0;
> > + void requestedStateChanged(RequestedState value);
> > "const RequestedState" would do no harm, and would help compiler slightly
>
> I does do some harm by making the signature longer, and the benefit of
> having a "const int" parameter (as merely a hint to the reader) is
> arguable in my opinion. Would like a third vote on this.

As Gerry said earlier, we are in Bikeshed land here, but as you asked for a third opinion, I'm -1 for const int and agree with Daniel here.

Revision history for this message
Gerry Boland (gerboland) wrote :

LGTM

review: Approve
173. By Daniel d'Andrada

Add supportedOrientations and rotatesWindowContents to ApplicationInfo
Approved by: PS Jenkins bot, Gerry Boland

174. By CI Train Bot Account

Releasing 7.97+15.10.20150611-0ubuntu1

175. By Daniel d'Andrada

Changes to application lifecycle APIs

* Removed ApplicationManagerInterface.forceDashActive
* Removed ApplicationManagerInterface.suspended
* Added ApplicationInfoInterface.requestedState

Revision history for this message
Gerry Boland (gerboland) wrote :

ACK

review: Approve
176. By Daniel d'Andrada

Merge trunk

[ Mirco Müller (MacSlow) ]
* added alerting/setAlerting API to LauncherModel and LauncherItem interfaces
[ Michi Henning ]
* Remove dependency on gcc 4.9. (LP: #1452342)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-07-24 09:53:02 +0000
3+++ debian/changelog 2015-08-03 14:07:35 +0000
4@@ -1,3 +1,11 @@
5+unity-api (7.99) UNRELEASED; urgency=medium
6+
7+ * Remove ApplicationManagerInterface.forceDashActive
8+ * Remove ApplicationManagerInterface.suspended
9+ * Add ApplicationInfoInterface.requestedState
10+
11+ -- Daniel d'Andrada <daniel.dandrada@canonical.com> Mon, 15 Jun 2015 13:53:07 -0300
12+
13 unity-api (7.98+15.10.20150724-0ubuntu1) wily; urgency=medium
14
15 [ Mirco Müller (MacSlow) ]
16@@ -123,7 +131,7 @@
17
18 [ Michal Hruby ]
19 * Added header links CategoriesInterface and performQuery() to
20- ScopeInterface
21+ ScopeInterface
22
23 [ Michi Henning ]
24 * A few minor fixes to the doc comments for comparison operators.
25@@ -488,7 +496,7 @@
26
27 unity-api (7.80.1) saucy; urgency=low
28
29- * This project forked from lp:unity/phablet. Updating the versioning to
30+ * This project forked from lp:unity/phablet. Updating the versioning to
31 reflect that.
32
33 -- Sergio Schvezov <sergio.schvezov@canonical.com> Tue, 04 Jun 2013 16:06:54 -0300
34
35=== modified file 'include/unity/shell/application/ApplicationInfoInterface.h'
36--- include/unity/shell/application/ApplicationInfoInterface.h 2015-04-16 16:13:09 +0000
37+++ include/unity/shell/application/ApplicationInfoInterface.h 2015-08-03 14:07:35 +0000
38@@ -12,10 +12,6 @@
39 *
40 * You should have received a copy of the GNU Lesser General Public License
41 * along with this program. If not, see <http://www.gnu.org/licenses/>.
42- *
43- * Authors:
44- * Michael Zanetti <michael.zanetti@canonical.com>
45- * Daniel d'Andrada <daniel.dandrada@canonical.com>
46 */
47
48 #ifndef UNITY_SHELL_APPLICATION_APPLICATIONINFOINTERFACE_H
49@@ -47,6 +43,7 @@
50
51 Q_ENUMS(Stage)
52 Q_ENUMS(State)
53+ Q_ENUMS(RequestedState)
54
55 /**
56 * @brief The appId of the application.
57@@ -93,6 +90,11 @@
58 Q_PROPERTY(State state READ state NOTIFY stateChanged)
59
60 /**
61+ * @brief The application's requested running state
62+ */
63+ Q_PROPERTY(RequestedState requestedState READ requestedState WRITE setRequestedState NOTIFY requestedStateChanged)
64+
65+ /**
66 * @brief The application's focus state.
67 *
68 * Holds the current application focus state. True if focused, false otherwise.
69@@ -235,6 +237,18 @@
70 Stopped
71 };
72
73+ /**
74+ * @brief The desired state of an application
75+ *
76+ * RequestedRunning: If state is Suspended or Stopped, the application will be resumed
77+ * or restarted, respectively.
78+ * RequestedSuspended: If state is Running, the application will be suspended.
79+ */
80+ enum RequestedState {
81+ RequestedRunning = Running,
82+ RequestedSuspended = Suspended
83+ };
84+
85 /// @cond
86 virtual ~ApplicationInfoInterface() {}
87
88@@ -244,6 +258,8 @@
89 virtual QUrl icon() const = 0;
90 virtual Stage stage() const = 0;
91 virtual State state() const = 0;
92+ virtual RequestedState requestedState() const = 0;
93+ virtual void setRequestedState(RequestedState) = 0;
94 virtual bool focused() const = 0;
95 virtual QString splashTitle() const = 0;
96 virtual QUrl splashImage() const = 0;
97@@ -262,6 +278,7 @@
98 void iconChanged(const QUrl &icon);
99 void stageChanged(Stage stage);
100 void stateChanged(State state);
101+ void requestedStateChanged(RequestedState value);
102 void focusedChanged(bool focused);
103 /// @endcond
104 };
105
106=== modified file 'include/unity/shell/application/ApplicationManagerInterface.h'
107--- include/unity/shell/application/ApplicationManagerInterface.h 2014-09-29 13:39:01 +0000
108+++ include/unity/shell/application/ApplicationManagerInterface.h 2015-08-03 14:07:35 +0000
109@@ -59,20 +59,6 @@
110 */
111 Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged)
112
113- /**
114- * @brief The suspended state of the ApplicationManager.
115- *
116- * If this is set to true, all apps (regardless if focused or not) will be suspended.
117- */
118- Q_PROPERTY(bool suspended READ suspended WRITE setSuspended NOTIFY suspendedChanged)
119-
120- /**
121- * @brief Activate the dash, regardless of its focused state.
122- *
123- * If this is set to true, the dash will not be put to suspend or will be woken up from suspend.
124- */
125- Q_PROPERTY(bool forceDashActive READ forceDashActive WRITE setForceDashActive NOTIFY forceDashActiveChanged)
126-
127 protected:
128 /// @cond
129 ApplicationManagerInterface(QObject* parent = 0): QAbstractListModel(parent)
130@@ -122,11 +108,6 @@
131
132 virtual QString focusedApplicationId() const = 0;
133
134- virtual bool suspended() const = 0;
135- virtual void setSuspended(bool suspended) = 0;
136-
137- virtual bool forceDashActive() const = 0;
138- virtual void setForceDashActive(bool forceDashActive) = 0;
139 /// @endcond
140
141 /**
142@@ -212,16 +193,6 @@
143 void focusedApplicationIdChanged();
144
145 /**
146- * @brief Will be emitted when the suspended state of the ApplicationManager changes.
147- */
148- void suspendedChanged();
149-
150- /**
151- * @brief Will be emitted when the forceDashActive property changes.
152- */
153- void forceDashActiveChanged();
154-
155- /**
156 * @brief Will be emitted when an application was added to the model.
157 *
158 * @param appId The appId of the application that was added.
159
160=== modified file 'include/unity/shell/application/CMakeLists.txt'
161--- include/unity/shell/application/CMakeLists.txt 2014-11-05 12:55:55 +0000
162+++ include/unity/shell/application/CMakeLists.txt 2015-08-03 14:07:35 +0000
163@@ -7,7 +7,7 @@
164
165 set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)
166
167-set(VERSION 6)
168+set(VERSION 7)
169 set(PKGCONFIG_NAME "unity-shell-application")
170 set(PKGCONFIG_DESCRIPTION "Unity shell Application APIs")
171 set(PKGCONFIG_REQUIRES "Qt5Core")
172
173=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp'
174--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp 2014-11-05 12:55:55 +0000
175+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp 2015-08-03 14:07:35 +0000
176@@ -126,6 +126,15 @@
177 return QColor(0,0,0,0);
178 }
179
180+ApplicationInfoInterface::RequestedState MockApplicationInfo::requestedState() const
181+{
182+ return RequestedRunning;
183+}
184+
185+void MockApplicationInfo::setRequestedState(RequestedState)
186+{
187+}
188+
189 Qt::ScreenOrientations MockApplicationInfo::supportedOrientations() const
190 {
191 return Qt::PortraitOrientation | Qt::LandscapeOrientation;
192
193=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h'
194--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h 2014-11-05 12:55:55 +0000
195+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h 2015-08-03 14:07:35 +0000
196@@ -1,5 +1,5 @@
197 /*
198- * Copyright 2013 Canonical Ltd.
199+ * Copyright 2013,2015 Canonical Ltd.
200 *
201 * This program is free software; you can redistribute it and/or modify
202 * it under the terms of the GNU Lesser General Public License as published by
203@@ -12,9 +12,6 @@
204 *
205 * You should have received a copy of the GNU Lesser General Public License
206 * along with this program. If not, see <http://www.gnu.org/licenses/>.
207- *
208- * Authors:
209- * Michael Zanetti <michael.zanetti@canonical.com>
210 */
211
212 #ifndef MOCKAPPLICATIONINFO_H
213@@ -52,6 +49,8 @@
214 QColor splashColor() const override;
215 QColor splashColorHeader() const override;
216 QColor splashColorFooter() const override;
217+ RequestedState requestedState() const override;
218+ void setRequestedState(RequestedState) override;
219
220 Qt::ScreenOrientations supportedOrientations() const override;
221 bool rotatesWindowContents() const override;
222
223=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp'
224--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2014-09-29 10:58:06 +0000
225+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2015-08-03 14:07:35 +0000
226@@ -1,5 +1,5 @@
227 /*
228- * Copyright 2013 Canonical Ltd.
229+ * Copyright 2013,2015 Canonical Ltd.
230 *
231 * This program is free software; you can redistribute it and/or modify
232 * it under the terms of the GNU Lesser General Public License as published by
233@@ -98,26 +98,6 @@
234 return (first) ? first->appId() : QString();
235 }
236
237-bool MockApplicationManager::suspended() const
238-{
239- return false;
240-}
241-
242-void MockApplicationManager::setSuspended(bool suspended)
243-{
244- Q_UNUSED(suspended)
245-}
246-
247-bool MockApplicationManager::forceDashActive() const
248-{
249- return false;
250-}
251-
252-void MockApplicationManager::setForceDashActive(bool forceDashActive)
253-{
254- Q_UNUSED(forceDashActive)
255-}
256-
257 bool MockApplicationManager::requestFocusApplication(const QString &appId)
258 {
259 Q_UNUSED(appId)
260
261=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h'
262--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2014-09-29 10:58:06 +0000
263+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2015-08-03 14:07:35 +0000
264@@ -1,5 +1,5 @@
265 /*
266- * Copyright 2013 Canonical Ltd.
267+ * Copyright 2013,2015 Canonical Ltd.
268 *
269 * This program is free software; you can redistribute it and/or modify
270 * it under the terms of the GNU Lesser General Public License as published by
271@@ -40,12 +40,6 @@
272
273 QString focusedApplicationId() const;
274
275- bool suspended() const;
276- void setSuspended(bool suspended);
277-
278- bool forceDashActive() const override;
279- void setForceDashActive(bool forceDashActive) override;
280-
281 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(const int index) const;
282
283 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const;
284
285=== modified file 'test/qmltest/unity/shell/application/tst_Application.qml'
286--- test/qmltest/unity/shell/application/tst_Application.qml 2014-11-05 12:55:55 +0000
287+++ test/qmltest/unity/shell/application/tst_Application.qml 2015-08-03 14:07:35 +0000
288@@ -1,5 +1,5 @@
289 /*
290- * Copyright 2013 Canonical Ltd.
291+ * Copyright 2013,2015 Canonical Ltd.
292 *
293 * This program is free software; you can redistribute it and/or modify
294 * it under the terms of the GNU Lesser General Public License as published by
295@@ -124,8 +124,6 @@
296 return [
297 { tag: "ApplicationManager.count", property: "count", type: "number" },
298 { tag: "ApplicationManager.focusedApplicationId", property: "focusedApplicationId", type: "string" },
299- { tag: "ApplicationManager.suspended", property: "suspended", type: "boolean" },
300- { tag: "ApplicationManager.forceDashActive", property: "forceDashActive", type: "boolean" },
301 ];
302 }
303
304@@ -143,6 +141,7 @@
305 { tag: "ApplicationInfo.properties[icon]", property: "icon", type: "object" },
306 { tag: "ApplicationInfo.properties[stage]", property: "stage", type: "number" },
307 { tag: "ApplicationInfo.properties[state]", property: "state", type: "number" },
308+ { tag: "ApplicationInfo.properties[requestedState]", property: "requestedState", type: "number" },
309 { tag: "ApplicationInfo.properties[focused]", property: "focused", type: "boolean" },
310 { tag: "ApplicationInfo.properties[splashTitle]", constant: "splashTitle", type: "string" },
311 { tag: "ApplicationInfo.properties[splashImage]", constant: "splashImage", type: "url" },

Subscribers

People subscribed via source and target branches

to all changes: