Merge lp:~gerboland/unity-api/appManVersion2 into lp:unity-api

Proposed by Gerry Boland
Status: Work in progress
Proposed branch: lp:~gerboland/unity-api/appManVersion2
Merge into: lp:unity-api
Diff against target: 527 lines (+187/-103)
9 files modified
debian/changelog (+6/-0)
include/unity/shell/application/ApplicationInfoInterface.h (+29/-6)
include/unity/shell/application/ApplicationManagerInterface.h (+31/-40)
include/unity/shell/application/CMakeLists.txt (+1/-1)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp (+7/-1)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h (+15/-13)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp (+14/-16)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h (+19/-23)
test/qmltest/unity/shell/application/tst_Application.qml (+65/-3)
To merge this branch: bzr merge lp:~gerboland/unity-api/appManVersion2
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+219403@code.launchpad.net

This proposal supersedes a proposal from 2014-05-01.

Commit message

Revised ApplicationManager and ApplicationInfo APIs to ease transition to the QtMirCompositor project

Description of the change

Revised ApplicationManager and ApplicationInfo APIs for QtMirCompositor project

 * Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~gerboland/unity-mir/appManV2-compat/+merge/219407
https://code.launchpad.net/~gerboland/unity8/appManV2-compat/+merge/219673
 * Did you perform an exploratory manual test run of your code change and any related functionality?
Y
 * Did you make sure that your branch does not contain spurious tags?
Y
 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Y
 * If you changed the UI, has there been a design review?
N/A - no UI change

To post a comment you must log in.
Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

Here's a couple of comments of things we should think of. Not necessarily disagreeing with them, just worth a though/discussion imo:

====

20 + Q_PROPERTY(Stages supportedStages READ supportedStages NOTIFY supportedStagesChanged)

Do we assume that if an app claims support for both stages, all of its surfaces will support them? Probably yes.

====

31 + * Holds the current application focus state. True if a surface of this application is focused, false otherwise.

Really needed? what would we gain with this information? Wouldn't it make more sense to obtain it the other was round? For instance:

var focusedApp = SurfaceManager.appId(SurfaceManager.focusedSurfaceId)

====

78 + Q_INVOKABLE virtual bool suspend() = 0;
89 + Q_INVOKABLE virtual bool resume() = 0;

Where would you call this from? I'm not sure if we should expose this to unity but rather handle this stuff internally in the applicationmanager. We might add something like inhibitSuspension() at a later point if we want to give the user control over it.

Also it doesn't really match with the existing API, given that we have startApplication() and stopApplication() in ApplicationManager (not ApplicationInfo) such things should be at the same place. If we decide to expose this to the shell, I'm not opposed to have them in both places (ApplicationManager::suspendApplication(appId) and ApplicationInfo::suspend()).

====

301 void setFocused(bool focused);

What would this do?

review: Needs Information
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

On 01.05.2014 15:11, Michael Zanetti wrote:
> ====
>
> 20 + Q_PROPERTY(Stages supportedStages READ supportedStages NOTIFY supportedStagesChanged)
>
> Do we assume that if an app claims support for both stages, all of its surfaces will support them? Probably yes.

When thinking about stages, we're only considering single-surface apps.
So yes.

Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

> Here's a couple of comments of things we should think of. Not necessarily
> disagreeing with them, just worth a though/discussion imo:
Sure. I'm just making up stuff as I go along

> 20 + Q_PROPERTY(Stages supportedStages READ supportedStages NOTIFY
> supportedStagesChanged)
> Do we assume that if an app claims support for both stages, all of its
> surfaces will support them? Probably yes.
Yes. This is property of an application. If it claims to support a stage, then its surface can be resized to suit that stage, and it can't stop that. One app can't have surfaces on both stage either. Note also that "stage" is a property shell will have to save when the app is closed, so user preference is retained.

> 31 + * Holds the current application focus state. True if a surface of
> this application is focused, false otherwise.
> Really needed? what would we gain with this information? Wouldn't it make more
> sense to obtain it the other was round? For instance:
I kept this as I thought it would make the job of the launcher easier. I can remove if you don't think it's worth it.

> 78 + Q_INVOKABLE virtual bool suspend() = 0;
> 89 + Q_INVOKABLE virtual bool resume() = 0;
>
> Where would you call this from? I'm not sure if we should expose this to unity
> but rather handle this stuff internally in the applicationmanager. We might
> add something like inhibitSuspension() at a later point if we want to give the
> user control over it.
>
> Also it doesn't really match with the existing API, given that we have
> startApplication() and stopApplication() in ApplicationManager (not
> ApplicationInfo) such things should be at the same place. If we decide to
> expose this to the shell, I'm not opposed to have them in both places
> (ApplicationManager::suspendApplication(appId) and
> ApplicationInfo::suspend()).

Not a bad point. I thought it a good idea to have shell decide when to suspend/resume apps, as only shell really knows what is visible or not, and shell implements the policy (on phone/tablet, all non-visible apps suspended, on desktop can be more flexible, maybe apps can opt-in to being suspended). I've been trying to make AppMan device independent, because I fear having some policy in AppMan, and some in shell, will end up with conflicts.

Another way this could be done by shell setting the surface visible flags, and if all an app's surfaces are hidden, it can be suspended. But then we tie rendering control to lifecycle control, which I don't like.

You're right, the API is not consistent. Will look more.

> ====
>
> 301 void setFocused(bool focused);
>
> What would this do?
That was in the Mock before. I dunno why it's there. I can remove

Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

> > 31 + * Holds the current application focus state. True if a surface of
> > this application is focused, false otherwise.
> > Really needed? what would we gain with this information? Wouldn't it make
> more
> > sense to obtain it the other was round? For instance:
> I kept this as I thought it would make the job of the launcher easier. I can
> remove if you don't think it's worth it.

Right... Works for me. Thanks for caring about the Launcher :)

>
>
>
> > 78 + Q_INVOKABLE virtual bool suspend() = 0;
> > 89 + Q_INVOKABLE virtual bool resume() = 0;
> >
> > Where would you call this from? I'm not sure if we should expose this to
> unity
> > but rather handle this stuff internally in the applicationmanager. We might
> > add something like inhibitSuspension() at a later point if we want to give
> the
> > user control over it.
> >
> > Also it doesn't really match with the existing API, given that we have
> > startApplication() and stopApplication() in ApplicationManager (not
> > ApplicationInfo) such things should be at the same place. If we decide to
> > expose this to the shell, I'm not opposed to have them in both places
> > (ApplicationManager::suspendApplication(appId) and
> > ApplicationInfo::suspend()).
>
> Not a bad point. I thought it a good idea to have shell decide when to
> suspend/resume apps, as only shell really knows what is visible or not, and
> shell implements the policy (on phone/tablet, all non-visible apps suspended,
> on desktop can be more flexible, maybe apps can opt-in to being suspended).
> I've been trying to make AppMan device independent, because I fear having some
> policy in AppMan, and some in shell, will end up with conflicts.

You're right... Makes more sense in the shell. I was still thinking too much like the old approach. But now that focused is something that's only available in QML this obviously doesn't work the old way any more.

>
> Another way this could be done by shell setting the surface visible flags, and
> if all an app's surfaces are hidden, it can be suspended. But then we tie
> rendering control to lifecycle control, which I don't like.

Yeah... doesn't sound much better than the above.

>
> You're right, the API is not consistent. Will look more.

Jup... Again, I'm fine with having them in both. We need to keep startApplication() in AppMan which makes it natural to have stopApplication() there too, and with it suspend/resume. But I can see how it would be convenient to have that as an ApplicationInfo object's property in QML.

So I'd probably go for
ApplicationManager:
startApplication()
stopApplication()
suspendApplication()
resumeApplication()

and ApplicationInfo:
stop()
Q_PROPERTY(suspended)

We can even implement and test those in the abstract interface so there's little risk an implementation would get them out of sync.

Revision history for this message
kevin gunn (kgunn72) wrote : Posted in a previous version of this proposal

> > Here's a couple of comments of things we should think of. Not necessarily
> > disagreeing with them, just worth a though/discussion imo:
> Sure. I'm just making up stuff as I go along
>
>
> > 20 + Q_PROPERTY(Stages supportedStages READ supportedStages NOTIFY
> > supportedStagesChanged)
> > Do we assume that if an app claims support for both stages, all of its
> > surfaces will support them? Probably yes.
> Yes. This is property of an application. If it claims to support a stage, then
> its surface can be resized to suit that stage, and it can't stop that. One app
> can't have surfaces on both stage either. Note also that "stage" is a property
> shell will have to save when the app is closed, so user preference is
> retained.
>

So my comment/question might be irrelevant. But I could foresee that trusted sessions might create a case where an app could be open on mainstage but invoked for a second surface within the trust session on side stage (or vice versa). Would your assumptions/implementation preclude this ?

Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

On 01.05.2014 20:30, kevin gunn wrote:
> So my comment/question might be irrelevant. But I could foresee that trusted sessions might create a case where an app could be open on mainstage but invoked for a second surface within the trust session on side stage (or vice versa). Would your assumptions/implementation preclude this ?

The second surface will not be an app, it will be just a surface, from a
separate process, it will be part of the original "invoking" app.

So no, everything's good here.

Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

> Jup... Again, I'm fine with having them in both. We need to keep
> startApplication() in AppMan which makes it natural to have stopApplication()
> there too, and with it suspend/resume. But I can see how it would be
> convenient to have that as an ApplicationInfo object's property in QML.
>
> So I'd probably go for
> ApplicationManager:
> startApplication()
> stopApplication()
> suspendApplication()
> resumeApplication()

Ok, I can do those

> and ApplicationInfo:
> Q_PROPERTY(suspended)

This one I'm not so sure about. We already use 'state' to get the process state, so adding the "suspended" property duplicates info. I also dislike it as some apps are excluded from lifecycle, so shell setting myApp.suspended=true is just incorrect.

I prefer just using the first part of your proposal - with {suspend,resume}Application() returning bool, so that shell knows if asking an app to suspend was actually acted upon or not.

I don't think shell really needs to know if an app is lifecycle-exempt, but it would care if suspendApplication returns false. Main use-case I can think of is there's no need for shell to save a screenshot to disk for a lifecycle-exempt app's surface, as there's no way that app will be killed.

> stop()
I might leave this out for the time being, just for ease of implementation, if you don't mind.

Also maybe just putting the process control methods (start/stop/suspend/resume) in AppManager is enough for a start.

Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

ack. works for me

Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

The stages and State enums are not tested. Can you please add a test that checks for all the values, but also that Stages are flags and can be used as such in QML?

===

Now that Stages are flags, we need to define their values explicitly in the enum definition. Now we have 0 and 1. ORing them loses information about 0.

===

Otherwise I think we're good now in terms of the API itself.

review: Needs Fixing
Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

I guess we should bump the package version too

review: Needs Fixing
Revision history for this message
Michael Zanetti (mzanetti) wrote :

the changelog in unity-api changed by now and conflicts.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
151. By Gerry Boland

debian: package version 7.90

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

I've resumed work on this branch after a long delay

Main changes:
- I restored the "screenshot" taking methods and role in the AppManager model, as they are useful for generating the Dash App's lens application snapshot images
- Bumped debian package version to 7.90

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

+1

review: Approve

Unmerged revisions

151. By Gerry Boland

debian: package version 7.90

150. By Gerry Boland

Merge trunk

149. By Gerry Boland

changelog correction

148. By Gerry Boland

Update changelog

147. By Gerry Boland

Merge trunk

146. By Gerry Boland

Restore the Application screenshot API for now

145. By Gerry Boland

Resolve conflict

144. By Gerry Boland

Bump debian version

143. By Gerry Boland

Add test for flags operator |

142. By Gerry Boland

Add tests to verify state & stage enums

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2014-06-16 14:45:10 +0000
+++ debian/changelog 2014-06-24 23:00:14 +0000
@@ -1,3 +1,9 @@
1unity-api (7.90) UNRELEASED; urgency=medium
2
3 * Version 3 of ApplicationManager and ApplicationInfo APIs, in preparation for QtCompositor
4
5 -- Gerry Boland <gerry.boland@canonical.com> Thu, 19 Jun 2014 12:46:15 +0100
6
1unity-api (7.82+14.10.20140616-0ubuntu1) utopic; urgency=medium7unity-api (7.82+14.10.20140616-0ubuntu1) utopic; urgency=medium
28
3 [ Albert Astals Cid ]9 [ Albert Astals Cid ]
410
=== modified file 'include/unity/shell/application/ApplicationInfoInterface.h'
--- include/unity/shell/application/ApplicationInfoInterface.h 2013-12-11 11:04:11 +0000
+++ include/unity/shell/application/ApplicationInfoInterface.h 2014-06-24 23:00:14 +0000
@@ -45,6 +45,7 @@
4545
46 Q_ENUMS(Stage)46 Q_ENUMS(Stage)
47 Q_ENUMS(State)47 Q_ENUMS(State)
48 Q_FLAGS(Stages)
4849
49 /**50 /**
50 * @brief The appId of the application.51 * @brief The appId of the application.
@@ -84,6 +85,13 @@
84 Q_PROPERTY(Stage stage READ stage NOTIFY stageChanged)85 Q_PROPERTY(Stage stage READ stage NOTIFY stageChanged)
8586
86 /**87 /**
88 * @brief The stages the application supports.
89 *
90 * OR-combination of Stage enum values denoting the stages this application supports.
91 */
92 Q_PROPERTY(Stages supportedStages READ supportedStages NOTIFY supportedStagesChanged)
93
94 /**
87 * @brief The application's state.95 * @brief The application's state.
88 *96 *
89 * Holds the current application state.97 * Holds the current application state.
@@ -93,7 +101,7 @@
93 /**101 /**
94 * @brief The application's focus state.102 * @brief The application's focus state.
95 *103 *
96 * Holds the current application focus state. True if focused, false otherwise.104 * Holds the current application focus state. True if a surface of this application is focused, false otherwise.
97 */105 */
98 Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged)106 Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged)
99107
@@ -104,6 +112,7 @@
104 */112 */
105 Q_PROPERTY(QUrl screenshot READ screenshot NOTIFY screenshotChanged)113 Q_PROPERTY(QUrl screenshot READ screenshot NOTIFY screenshotChanged)
106114
115
107protected:116protected:
108 /// @cond117 /// @cond
109 ApplicationInfoInterface(const QString &appId, QObject* parent = 0): QObject(parent) { Q_UNUSED(appId) }118 ApplicationInfoInterface(const QString &appId, QObject* parent = 0): QObject(parent) { Q_UNUSED(appId) }
@@ -119,9 +128,10 @@
119 * applications.128 * applications.
120 */129 */
121 enum Stage {130 enum Stage {
122 MainStage,131 MainStage = 0x01,
123 SideStage132 SideStage = 0x02,
124 };133 };
134 Q_DECLARE_FLAGS(Stages, Stage)
125135
126 /**136 /**
127 * @brief An application's state.137 * @brief An application's state.
@@ -150,19 +160,30 @@
150 virtual QString comment() const = 0;160 virtual QString comment() const = 0;
151 virtual QUrl icon() const = 0;161 virtual QUrl icon() const = 0;
152 virtual Stage stage() const = 0;162 virtual Stage stage() const = 0;
163 virtual Stages supportedStages() const = 0;
153 virtual State state() const = 0;164 virtual State state() const = 0;
154 virtual bool focused() const = 0;165 virtual bool focused() const = 0;
155 virtual QUrl screenshot() const = 0;166 virtual QUrl screenshot() const = 0;
156 /// @endcond167 /// @endcond
157168
169 /**
170 * @brief Set stage
171 *
172 * Applications may not support all stages, so this method only returns true if the stage is supported.
173 * @returns true if stage supported so value set, false if not supported.
174 */
175 Q_INVOKABLE virtual bool setStage(const Stage) = 0;
176
177
158Q_SIGNALS:178Q_SIGNALS:
159 /// @cond179 /// @cond
160 void nameChanged(const QString &name);180 void nameChanged(const QString &name);
161 void commentChanged(const QString &comment);181 void commentChanged(const QString &comment);
162 void iconChanged(const QUrl &icon);182 void iconChanged(const QUrl &icon);
163 void stageChanged(Stage stage);183 void stageChanged(const Stage stage);
164 void stateChanged(State state);184 void supportedStagesChanged(const Stages stages);
165 void focusedChanged(bool focused);185 void stateChanged(const State state);
186 void focusedChanged(const bool focused);
166 void screenshotChanged(const QUrl &screenshot);187 void screenshotChanged(const QUrl &screenshot);
167 /// @endcond188 /// @endcond
168};189};
@@ -171,4 +192,6 @@
171} // namespace shell192} // namespace shell
172} // namespace unity193} // namespace unity
173194
195Q_DECLARE_OPERATORS_FOR_FLAGS(unity::shell::application::ApplicationInfoInterface::Stages)
196
174#endif // UNITY_SHELL_APPLICATIONMANAGER_APPLICATIONINFOINTERFACE_H197#endif // UNITY_SHELL_APPLICATIONMANAGER_APPLICATIONINFOINTERFACE_H
175198
=== modified file 'include/unity/shell/application/ApplicationManagerInterface.h'
--- include/unity/shell/application/ApplicationManagerInterface.h 2014-03-10 12:40:25 +0000
+++ include/unity/shell/application/ApplicationManagerInterface.h 2014-06-24 23:00:14 +0000
@@ -53,9 +53,7 @@
53 Q_PROPERTY(int count READ count NOTIFY countChanged)53 Q_PROPERTY(int count READ count NOTIFY countChanged)
5454
55 /**55 /**
56 * @brief The currently focused application.56 * @brief The app ID of the currently focused application.
57 *
58 * Use focusApplication() and unfocusCurrentApplication() to modify this.
59 */57 */
60 Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged)58 Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged)
6159
@@ -75,6 +73,7 @@
75 m_roleNames.insert(RoleComment, "comment");73 m_roleNames.insert(RoleComment, "comment");
76 m_roleNames.insert(RoleIcon, "icon");74 m_roleNames.insert(RoleIcon, "icon");
77 m_roleNames.insert(RoleStage, "stage");75 m_roleNames.insert(RoleStage, "stage");
76 m_roleNames.insert(RoleSupportedStages, "supportedStages");
78 m_roleNames.insert(RoleState, "state");77 m_roleNames.insert(RoleState, "state");
79 m_roleNames.insert(RoleFocused, "focused");78 m_roleNames.insert(RoleFocused, "focused");
80 m_roleNames.insert(RoleScreenshot, "screenshot");79 m_roleNames.insert(RoleScreenshot, "screenshot");
@@ -98,6 +97,7 @@
98 RoleComment,97 RoleComment,
99 RoleIcon,98 RoleIcon,
100 RoleStage,99 RoleStage,
100 RoleSupportedStages,
101 RoleState,101 RoleState,
102 RoleFocused,102 RoleFocused,
103 RoleScreenshot,103 RoleScreenshot,
@@ -142,40 +142,14 @@
142 Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const = 0;142 Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const = 0;
143143
144 /**144 /**
145 * @brief Request to focus a given application
146 *
147 * This will request the shell to focus the given application.
148 *
149 * @param appId The appId of the app to be focused.
150 * @returns True if the request will processed, false if it was discarded (i.e. the given appid could not be found)
151 */
152 Q_INVOKABLE virtual bool requestFocusApplication(const QString &appId) = 0;
153
154 /**
155 * @brief Focus the given application.
156 *
157 * This will immediately focus the given application. Usually you should not use this
158 * but instead call requestFocusApplication() in order to allow the shell to prepare
159 * for the upcoming animation or even block the focus request (e.g. focus stealing prevention)
160 *
161 * @param appId The application to be focused.
162 * @returns True if appId found and application focused, else false.
163 */
164 Q_INVOKABLE virtual bool focusApplication(const QString &appId) = 0;
165
166 /**
167 * @brief Unfocus the currently focused application.
168 */
169 Q_INVOKABLE virtual void unfocusCurrentApplication() = 0;
170
171 /**
172 * @brief Start an application.145 * @brief Start an application.
173 *146 *
174 * @param appId The appId for the application to be spawned.147 * @param appId The appId for the application to be spawned.
175 * @param arguments Any arguments to be passed to the process.148 * @param arguments Any arguments to be passed to the process.
176 * @returns The created application item if start successful, else null.149 * @returns The created application item if start successful, else null.
177 */150 */
178 Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *startApplication(const QString &appId, const QStringList &arguments) = 0;151 Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface
152 *startApplication(const QString &appId, const QStringList &arguments) = 0;
179153
180 /**154 /**
181 * @brief Stops an application.155 * @brief Stops an application.
@@ -193,24 +167,41 @@
193 * you can request the ApplicationManager to update it now.167 * you can request the ApplicationManager to update it now.
194 *168 *
195 * @param appId The application for which the screenshot should be updated.169 * @param appId The application for which the screenshot should be updated.
196 * @returns True if the screenshot update operation was scheduled successfully, false otherwise (i.e. the given appId could not be found)170 * @returns True if the screenshot update operation was scheduled successfully, false otherwise (i.e. the given
171 * appId could not be found)
197 */172 */
198 Q_INVOKABLE virtual bool updateScreenshot(const QString &appId) = 0;173 Q_INVOKABLE virtual bool updateScreenshot(const QString &appId) = 0;
199174
175 /**
176 * @brief Request the application suspends
177 *
178 * If application supports lifecycling and is in a running state, calling this method notifies the
179 * app of pending suspension and a few seconds later suspends the app, updating the "state" property
180 * to "Suspended". Method is non-blocking.
181 * @param appId The application to be stopped.
182 * @returns True if app is running and supports lifecycle suspension, false otherwise.
183 */
184 Q_INVOKABLE virtual bool suspendApplication(const QString &appId) = 0;
185
186 /**
187 * @brief Request the application resumes from suspends
188 *
189 * If application supports lifecycling and is in a suspended state, calling this method resumes it
190 * updating the "state" property to "Running". If application was stopped, it will be relaunched and
191 * will restore its internal state - the state property set to "Running" only when app ready. Method
192 * is non-blocking.
193 * @param appId The application to be stopped.
194 * @returns true if app is lifecycle suspended, false otherwise.
195 */
196 Q_INVOKABLE virtual bool resumeApplication(const QString &appId) = 0;
197
198
200Q_SIGNALS:199Q_SIGNALS:
201 /// @cond200 /// @cond
202 void countChanged();201 void countChanged();
203 /// @endcond202 /// @endcond
204203
205 /**204 /**
206 * @brief Will be emitted right before the focused application changes.
207 *
208 * This can be used to prepare for an upcoming focus change. For example starting
209 * an animation.
210 */
211 void focusRequested(const QString &appId);
212
213 /**
214 * @brief Will be emitted whenever the focused application changes.205 * @brief Will be emitted whenever the focused application changes.
215 */206 */
216 void focusedApplicationIdChanged();207 void focusedApplicationIdChanged();
217208
=== modified file 'include/unity/shell/application/CMakeLists.txt'
--- include/unity/shell/application/CMakeLists.txt 2014-03-04 10:50:44 +0000
+++ include/unity/shell/application/CMakeLists.txt 2014-06-24 23:00:14 +0000
@@ -7,7 +7,7 @@
77
8set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)8set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)
99
10set(VERSION 2)10set(VERSION 3)
11set(PKGCONFIG_NAME "unity-shell-appliction")11set(PKGCONFIG_NAME "unity-shell-appliction")
12set(PKGCONFIG_DESCRIPTION "Unity shell Application APIs")12set(PKGCONFIG_DESCRIPTION "Unity shell Application APIs")
13set(PKGCONFIG_REQUIRES "Qt5Core")13set(PKGCONFIG_REQUIRES "Qt5Core")
1414
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp'
--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp 2013-12-11 11:28:22 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp 2014-06-24 23:00:14 +0000
@@ -64,13 +64,19 @@
64 return m_stage;64 return m_stage;
65}65}
6666
67void MockApplicationInfo::setStage(ApplicationInfoInterface::Stage stage)67bool MockApplicationInfo::setStage(ApplicationInfoInterface::Stage stage)
68{68{
69 if (m_stage != stage)69 if (m_stage != stage)
70 {70 {
71 m_stage = stage;71 m_stage = stage;
72 Q_EMIT stageChanged(m_stage);72 Q_EMIT stageChanged(m_stage);
73 }73 }
74 return true;
75}
76
77ApplicationInfoInterface::Stages MockApplicationInfo::supportedStages() const
78{
79 return ApplicationInfoInterface::MainStage | ApplicationInfoInterface::SideStage;
74}80}
7581
76ApplicationInfoInterface::State MockApplicationInfo::state() const82ApplicationInfoInterface::State MockApplicationInfo::state() const
7783
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h'
--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h 2013-12-11 11:28:22 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h 2014-06-24 23:00:14 +0000
@@ -32,19 +32,21 @@
32public:32public:
33 MockApplicationInfo(const QString &appId, const QString& name, const QString& comment, const QUrl& icon, QObject* parent = 0);33 MockApplicationInfo(const QString &appId, const QString& name, const QString& comment, const QUrl& icon, QObject* parent = 0);
3434
35 QString appId() const;35 QString appId() const override;
36 QString name() const;36 QString name() const override;
37 QString comment() const;37 QString comment() const override;
38 QUrl icon() const;38 QUrl icon() const override;
39 QUrl screenshot() const;39 QUrl screenshot() const override;
4040
41 ApplicationInfoInterface::Stage stage() const;41 ApplicationInfoInterface::Stage stage() const override;
42 void setStage(ApplicationInfoInterface::Stage stage);42 bool setStage(const ApplicationInfoInterface::Stage stage) override;
4343
44 ApplicationInfoInterface::State state() const;44 ApplicationInfoInterface::Stages supportedStages() const override;
45 void setState(ApplicationInfoInterface::State state);45
4646 ApplicationInfoInterface::State state() const override;
47 bool focused() const;47 void setState(const ApplicationInfoInterface::State state);
48
49 bool focused() const override;
48 void setFocused(bool focused);50 void setFocused(bool focused);
4951
50private:52private:
5153
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp'
--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2014-05-23 08:35:43 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2014-06-24 23:00:14 +0000
@@ -62,6 +62,8 @@
62 return item->icon();62 return item->icon();
63 case RoleStage:63 case RoleStage:
64 return item->stage();64 return item->stage();
65 case RoleSupportedStages:
66 return static_cast<int>(item->supportedStages());
65 case RoleState:67 case RoleState:
66 return item->state();68 return item->state();
67 case RoleFocused:69 case RoleFocused:
@@ -110,22 +112,6 @@
110 Q_UNUSED(suspended)112 Q_UNUSED(suspended)
111}113}
112114
113bool MockApplicationManager::requestFocusApplication(const QString &appId)
114{
115 Q_UNUSED(appId)
116 return true;
117}
118
119bool MockApplicationManager::focusApplication(const QString &appId)
120{
121 Q_UNUSED(appId)
122 return true;
123}
124
125void MockApplicationManager::unfocusCurrentApplication()
126{
127}
128
129unity::shell::application::ApplicationInfoInterface *MockApplicationManager::startApplication(const QString &appId, const QStringList &arguments)115unity::shell::application::ApplicationInfoInterface *MockApplicationManager::startApplication(const QString &appId, const QStringList &arguments)
130{116{
131 Q_UNUSED(arguments)117 Q_UNUSED(arguments)
@@ -144,3 +130,15 @@
144 Q_UNUSED(appId)130 Q_UNUSED(appId)
145 return true;131 return true;
146}132}
133
134bool MockApplicationManager::suspendApplication(const QString &appId)
135{
136 Q_UNUSED(appId)
137 return true;
138}
139
140bool MockApplicationManager::resumeApplication(const QString &appId)
141{
142 Q_UNUSED(appId)
143 return true;
144}
147145
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h'
--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2014-03-10 12:34:16 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2014-06-24 23:00:14 +0000
@@ -34,31 +34,27 @@
34 MockApplicationManager(QObject* parent = 0);34 MockApplicationManager(QObject* parent = 0);
35 ~MockApplicationManager();35 ~MockApplicationManager();
3636
37 int rowCount(const QModelIndex& parent) const;37 int rowCount(const QModelIndex& parent) const override;
3838
39 QVariant data(const QModelIndex& index, int role) const;39 QVariant data(const QModelIndex& index, int role) const override;
4040
41 QString focusedApplicationId() const;41 QString focusedApplicationId() const override;
4242
43 bool suspended() const;43 bool suspended() const override;
44 void setSuspended(bool suspended);44 void setSuspended(bool suspended) override;
4545
46 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(const int index) const;46 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(const int index) const override;
4747
48 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const;48 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const override;
4949
50 Q_INVOKABLE bool requestFocusApplication(const QString &appId);50 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface
5151 *startApplication(const QString &appId, const QStringList &arguments) override;
52 Q_INVOKABLE bool focusApplication(const QString &appId);52
5353 Q_INVOKABLE bool stopApplication(const QString &appId) override;
54 Q_INVOKABLE void unfocusCurrentApplication();54 Q_INVOKABLE bool suspendApplication(const QString &appId) override;
5555 Q_INVOKABLE bool resumeApplication(const QString &appId) override;
56 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *startApplication(const QString &appId, const QStringList &arguments);
57
58 Q_INVOKABLE bool stopApplication(const QString &appId);
5956
60 Q_INVOKABLE bool updateScreenshot(const QString &appId);57 Q_INVOKABLE bool updateScreenshot(const QString &appId);
61
62private:58private:
63 QList<MockApplicationInfo*> m_list;59 QList<MockApplicationInfo*> m_list;
64};60};
6561
=== modified file 'test/qmltest/unity/shell/application/tst_Application.qml'
--- test/qmltest/unity/shell/application/tst_Application.qml 2014-03-10 12:34:16 +0000
+++ test/qmltest/unity/shell/application/tst_Application.qml 2014-06-24 23:00:14 +0000
@@ -67,6 +67,7 @@
67 { enum: "RoleComment" },67 { enum: "RoleComment" },
68 { enum: "RoleIcon" },68 { enum: "RoleIcon" },
69 { enum: "RoleStage" },69 { enum: "RoleStage" },
70 { enum: "RoleSupportedStages"},
70 { enum: "RoleState" },71 { enum: "RoleState" },
71 { enum: "RoleFocused" },72 { enum: "RoleFocused" },
72 { enum: "RoleScreenshot" },73 { enum: "RoleScreenshot" },
@@ -87,6 +88,7 @@
87 { tag: "ApplicationManager.roles[comment]", role: "comment", type: "string" },88 { tag: "ApplicationManager.roles[comment]", role: "comment", type: "string" },
88 { tag: "ApplicationManager.roles[icon]", role: "icon", type: "object" },89 { tag: "ApplicationManager.roles[icon]", role: "icon", type: "object" },
89 { tag: "ApplicationManager.roles[stage]", role: "stage", type: "number" },90 { tag: "ApplicationManager.roles[stage]", role: "stage", type: "number" },
91 { tag: "ApplicationManager.roles[supportedStages]", role: "supportedStages", type: "number" },
90 { tag: "ApplicationManager.roles[state]", role: "state", type: "number" },92 { tag: "ApplicationManager.roles[state]", role: "state", type: "number" },
91 { tag: "ApplicationManager.roles[focused]", role: "focused", type: "boolean" },93 { tag: "ApplicationManager.roles[focused]", role: "focused", type: "boolean" },
92 { tag: "ApplicationManager.roles[screenshot]", role: "screenshot", type: "object" },94 { tag: "ApplicationManager.roles[screenshot]", role: "screenshot", type: "object" },
@@ -108,11 +110,10 @@
108 return [110 return [
109 { tag: "ApplicationManager.methods[get]", method: "get" },111 { tag: "ApplicationManager.methods[get]", method: "get" },
110 { tag: "ApplicationManager.methods[findApplication]", method: "findApplication" },112 { tag: "ApplicationManager.methods[findApplication]", method: "findApplication" },
111 { tag: "ApplicationManager.methods[requestFocusApplication]", method: "requestFocusApplication" },
112 { tag: "ApplicationManager.methods[focusApplication]", method: "focusApplication" },
113 { tag: "ApplicationManager.methods[unfocusCurrentApplication]", method: "unfocusCurrentApplication" },
114 { tag: "ApplicationManager.methods[startApplication]", method: "startApplication" },113 { tag: "ApplicationManager.methods[startApplication]", method: "startApplication" },
115 { tag: "ApplicationManager.methods[stopApplication]", method: "stopApplication" },114 { tag: "ApplicationManager.methods[stopApplication]", method: "stopApplication" },
115 { tag: "ApplicationManager.methods[suspendApplication]", method: "suspendApplication" },
116 { tag: "ApplicationManager.methods[resumeApplication]", method: "resumeApplication" },
116 { tag: "ApplicationManager.methods[updateScreenshot]", method: "updateScreenshot" },117 { tag: "ApplicationManager.methods[updateScreenshot]", method: "updateScreenshot" },
117 ];118 ];
118 }119 }
@@ -144,6 +145,7 @@
144 { tag: "ApplicationInfo.properties[comment]", property: "comment", type: "string" },145 { tag: "ApplicationInfo.properties[comment]", property: "comment", type: "string" },
145 { tag: "ApplicationInfo.properties[icon]", property: "icon", type: "object" },146 { tag: "ApplicationInfo.properties[icon]", property: "icon", type: "object" },
146 { tag: "ApplicationInfo.properties[stage]", property: "stage", type: "number" },147 { tag: "ApplicationInfo.properties[stage]", property: "stage", type: "number" },
148 { tag: "ApplicationInfo.properties[supportedStages]", property: "supportedStages", type: "number" },
147 { tag: "ApplicationInfo.properties[state]", property: "state", type: "number" },149 { tag: "ApplicationInfo.properties[state]", property: "state", type: "number" },
148 { tag: "ApplicationInfo.properties[focused]", property: "focused", type: "boolean" },150 { tag: "ApplicationInfo.properties[focused]", property: "focused", type: "boolean" },
149 { tag: "ApplicationInfo.properties[screenshot]", property: "screenshot", type: "object" },151 { tag: "ApplicationInfo.properties[screenshot]", property: "screenshot", type: "object" },
@@ -161,5 +163,65 @@
161163
162 verifyData(data)164 verifyData(data)
163 }165 }
166
167 function test_item_methods_data() {
168 return [
169 { tag: "ApplicationInfo.methods[setStage]", method: "setStage" },
170 ];
171 }
172
173 function test_item_methods(data) {
174 name = "ApplicationInfo";
175 try {
176 object = ApplicationManager.get(0)
177 } catch(err) {
178 object = undefined;
179 print(err)
180 }
181 verifyData(data);
182 }
183
184 function test_item_stage_flags_data() {
185 return [
186 { enum: "MainStage" },
187 { enum: "SideStage" },
188 ];
189 }
190
191 function test_item_stage_flags(data) {
192 name = "Application";
193 try {
194 object = ApplicationInfo
195 } catch(err) {
196 object = undefined;
197 print(err)
198 }
199 verifyData(data);
200 }
201
202 function test_item_stage_flags_operator() {
203 // check that flags operator functional
204 verify(ApplicationInfo.MainStage | ApplicationInfo.SideStage, 0x003)
205 }
206
207 function test_item_state_enum_data() {
208 return [
209 { enum: "Starting" },
210 { enum: "Running" },
211 { enum: "Suspended" },
212 { enum: "Stopped" },
213 ];
214 }
215
216 function test_item_state_enum(data) {
217 name = "Application";
218 try {
219 object = ApplicationInfo
220 } catch(err) {
221 object = undefined;
222 print(err)
223 }
224 verifyData(data);
225 }
164 }226 }
165}227}

Subscribers

People subscribed via source and target branches

to all changes: