Merge lp:~gerboland/unity-api/surfaceSizerCallback into lp:unity-api
- surfaceSizerCallback
- Merge into trunk
Status: | Work in progress |
---|---|
Proposed branch: | lp:~gerboland/unity-api/surfaceSizerCallback |
Merge into: | lp:unity-api |
Prerequisite: | lp:~dandrader/unity-api/lifecycle |
Diff against target: |
613 lines (+448/-6) (has conflicts) 11 files modified
debian/changelog (+41/-1) include/unity/shell/application/ApplicationManagerInterface.h (+35/-0) include/unity/shell/application/CMakeLists.txt (+2/-2) include/unity/shell/application/Mir.h (+76/-0) include/unity/shell/application/MirSurfaceInterface.h (+114/-0) include/unity/shell/application/MirSurfaceItemInterface.h (+151/-0) test/qmltest/mocks/plugins/Unity/Application/CMakeLists.txt (+1/-1) test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp (+17/-1) test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h (+4/-0) test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt (+1/-1) test/qmltest/unity/shell/application/tst_Application.qml (+6/-0) Text conflict in debian/changelog |
To merge this branch: | bzr merge lp:~gerboland/unity-api/surfaceSizerCallback |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Astals Cid (community) | code | Approve | |
PS Jenkins bot (community) | continuous-integration | Approve | |
Michał Sawicz | Approve | ||
Review via email: mp+231698@code.launchpad.net |
This proposal supersedes a proposal from 2014-08-11.
Commit message
AppMan: add surfaceAboutToB
Description of the change
AppMan: add surfaceAboutToB
* Are there any related MPs required for this MP to build/function as expected? Please list.
https:/
https:/
* Did you perform an exploratory manual test run of your code change and any related functionality?
Y
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal | # |
Michał Sawicz (saviq) : Posted in a previous version of this proposal | # |
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal | # |
Oh and document the signature of the callable please. Will it get info about fullscreen, for example?
I wonder if instead we should just pass availableGeometry, with Mir being responsible for policy, should we involve the shell like this?
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal | # |
> Oh and document the signature of the callable please. Will it get info about
> fullscreen, for example?
Sadly not, I need to add a feature request for Mir for that. IMO the surface type and other info that we get from a standard Mir surface would be good info to have, opposed to this limited subset.
> I wonder if instead we should just pass availableGeometry, with Mir being
> responsible for policy, should we involve the shell like this?
I dislike this idea, as effectively we'd need to educate Mir about the entire QML scene: which areas are off-limits for a non-fullscreen surfaces, what to do for surfaces of different types, stages, etc. Defining a vocabulary for that would be a nightmare IMO. And if Mir makes a decision that shell doesn't like, shell will immediately impose its will anyway - so where's the gain?
Policy I hope to define in Mir relate more to clients expectations, I want to ensure that client surfaces behave in a consistent way across mir server implementations. Shells should treat client surfaces in ways that they expect, that parent/child relationship is obeyed, focus handing is correct, input is delivered to the correct surface, siblings can attach to eachother/their parent and stay there, things like that.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:161
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:162
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal | # |
> > I wonder if instead we should just pass availableGeometry, with Mir being
> > responsible for policy, should we involve the shell like this?
> I dislike this idea, as effectively we'd need to educate Mir about the entire
> QML scene: which areas are off-limits for a non-fullscreen surfaces, what to
> do for surfaces of different types, stages, etc. Defining a vocabulary for
> that would be a nightmare IMO. And if Mir makes a decision that shell doesn't
> like, shell will immediately impose its will anyway - so where's the gain?
I'm thinking about, for example, initial placement based on previous runs and such. Maybe Mir could (optionally?) give up a preferred position and the shell would come back with the same or changed if not possible in current setup or something. Anyway, later. The gain? More logic shared between Mir shells.
> Policy I hope to define in Mir relate more to clients expectations, I want to
> ensure that client surfaces behave in a consistent way across mir server
> implementations. Shells should treat client surfaces in ways that they expect,
> that parent/child relationship is obeyed, focus handing is correct, input is
> delivered to the correct surface, siblings can attach to eachother/their
> parent and stay there, things like that.
What you said above applies here just as well - shell, if not well behaved - can impose its own will.
Michał Sawicz (saviq) : Posted in a previous version of this proposal | # |
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal | # |
> I'm thinking about, for example, initial placement based on previous runs and
> such. Maybe Mir could (optionally?) give up a preferred position and the shell
> would come back with the same or changed if not possible in current setup or
> something. Anyway, later. The gain? More logic shared between Mir shells.
Yeah definitely, that's something Mir can give us, including saving the positions on close so it can inform us where it should re-open.
> > Policy I hope to define in Mir relate more to clients expectations, I want
> to
> > ensure that client surfaces behave in a consistent way across mir server
> > implementations. Shells should treat client surfaces in ways that they
> expect,
> > that parent/child relationship is obeyed, focus handing is correct, input is
> > delivered to the correct surface, siblings can attach to eachother/their
> > parent and stay there, things like that.
>
> What you said above applies here just as well - shell, if not well behaved -
> can impose its own will.
Sure. It's a line we have to walk carefully, but I think it's more important to try guarantee behaviour for clients. Mir can define that policy, and look after surface position/size save/restore, but I don't want to go down the road of trying to educate Mir of everything happening in the QML scene.
Gerry Boland (gerboland) : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:163
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) : Posted in a previous version of this proposal | # |
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal | # |
> I tried:
>
> Binding {
> target: ApplicationManager
> property: "surfaceAboutTo
> value: function surfaceSizer(
> surface.width = 400;
> if (surface.appId && surface.appId == "dialer-app") {
> surface.height = 300;
> }
> return surface;
> }
> }
>
> and got this error:
> file://
Hah! Interesting. Can't say I understand. If Binding.value is of type
other than var, how can it be flexible enough? Otherwise if
ApplicationMana
your original approach to assign instead of bind work in any case?
I'd say that's worth a QTBUG.
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal | # |
> > I tried:
> >
> > Binding {
> > target: ApplicationManager
> > property: "surfaceAboutTo
> > value: function surfaceSizer(
> > surface.width = 400;
> > if (surface.appId && surface.appId == "dialer-app") {
> > surface.height = 300;
> > }
> > return surface;
> > }
> > }
> >
> > and got this error:
> > file://
> function to a property of any type other than var.
>
> Hah! Interesting. Can't say I understand. If Binding.value is of type
> other than var, how can it be flexible enough? Otherwise if
> ApplicationMana
> your original approach to assign instead of bind work in any case?
>
> I'd say that's worth a QTBUG.
My guess is that Binding does some naive type checking, and QJSValue is indeed not a QVariant. qtdeclarative5:
I don't create a binding with my original approach, it's a simple assignment. I would guess the only way around this error is to replace QJSValue with a QVariant. What say you?
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal | # |
> My guess is that Binding does some naive type checking, and QJSValue is indeed not a QVariant. qtdeclarative5:
Yeah.
> I don't create a binding with my original approach, it's a simple assignment. I would guess the only way around this error is to replace QJSValue with a QVariant. What say you?
Doesn't sound like that would help, since you'd still need to go through
a Binding and that would complain that function is not a var.
So it looks like assignment is the only way indeed. Worth a QTBUG IMO.
If you can assign something to a property, you should be able to bind to.
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal | # |
Please rebase on lp:~dandrader/unity-api/lifecycle, no need to bump versions over that one then.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:165
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:166
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:170
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Albert Astals Cid (aacid) wrote : | # |
Code looks good, haven't time to test. If nobody beats me to it, i'll do on Monday
Albert Astals Cid (aacid) wrote : | # |
Let's wait for https:/
- 171. By Gerry Boland
-
Merge trunk
- 172. By Gerry Boland
-
Add unity::
shell:: application: :Globals - 173. By Gerry Boland
-
Merge trunk
- 174. By Gerry Boland
-
Merge app-focus-state branch as prereq
- 175. By Gerry Boland
-
Document the Global class
- 176. By Gerry Boland
-
Revert 175
- 177. By Gerry Boland
-
Remove old Globals idea
- 178. By Gerry Boland
-
Merge trunk
- 179. By Gerry Boland
-
Merge trunk
- 180. By Gerry Boland
-
Remove bad merge atrifacts
Unmerged revisions
- 180. By Gerry Boland
-
Remove bad merge atrifacts
- 179. By Gerry Boland
-
Merge trunk
- 178. By Gerry Boland
-
Merge trunk
- 177. By Gerry Boland
-
Remove old Globals idea
- 176. By Gerry Boland
-
Revert 175
- 175. By Gerry Boland
-
Document the Global class
- 174. By Gerry Boland
-
Merge app-focus-state branch as prereq
- 173. By Gerry Boland
-
Merge trunk
- 172. By Gerry Boland
-
Add unity::
shell:: application: :Globals - 171. By Gerry Boland
-
Merge trunk
Preview Diff
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2015-08-26 08:59:22 +0000 |
3 | +++ debian/changelog 2015-09-07 14:10:05 +0000 |
4 | @@ -1,3 +1,4 @@ |
5 | +<<<<<<< TREE |
6 | unity-api (7.99+15.10.20150826-0ubuntu1) wily; urgency=medium |
7 | |
8 | [ Pawel Stolowski ] |
9 | @@ -9,6 +10,25 @@ |
10 | -- CI Train Bot <ci-train-bot@canonical.com> Wed, 26 Aug 2015 08:59:21 +0000 |
11 | |
12 | unity-api (7.99+15.10.20150804-0ubuntu1) wily; urgency=medium |
13 | +======= |
14 | +unity-api (7.100+15.04.20150827-0ubuntu1) vivid; urgency=medium |
15 | + |
16 | + [ Daniel d'Andrada ] |
17 | + * Added MirSurface and MirSurfaceItem interfaces |
18 | + |
19 | + [ CI Train Bot ] |
20 | + * No-change rebuild. |
21 | + |
22 | + -- CI Train Bot <ci-train-bot@canonical.com> Thu, 27 Aug 2015 08:50:45 +0000 |
23 | + |
24 | +unity-api (7.99+15.04.20150811-0ubuntu1) vivid; urgency=medium |
25 | + |
26 | + * New rebuild forced. |
27 | + |
28 | + -- CI Train Bot <ci-train-bot@canonical.com> Tue, 11 Aug 2015 14:05:55 +0000 |
29 | + |
30 | +unity-api (7.99+15.04.20150804-0ubuntu1) vivid; urgency=medium |
31 | +>>>>>>> MERGE-SOURCE |
32 | |
33 | [ Daniel d'Andrada ] |
34 | * Remove ApplicationManagerInterface.forceDashActive |
35 | @@ -18,13 +38,33 @@ |
36 | |
37 | -- CI Train Bot <ci-train-bot@canonical.com> Tue, 04 Aug 2015 15:26:16 +0000 |
38 | |
39 | -unity-api (7.98+15.10.20150724-0ubuntu1) wily; urgency=medium |
40 | +unity-api (7.99-0ubuntu1) UNRELEASED; urgency=medium |
41 | + |
42 | + * Changes to activate and preview methods of ScopeInterface. |
43 | + |
44 | + -- Pawel Stolowski <pawel.stolowski@canonical.com> Mon, 03 Aug 2015 14:03:47 +0000 |
45 | + |
46 | +unity-api (7.99) UNRELEASED; urgency=medium |
47 | + |
48 | + * Add surface sizer callback property to AppMan API |
49 | + |
50 | + -- Gerry Boland <gerry.boland@canonical.com> Mon, 13 July 2015 13:47:07 +0000 |
51 | + |
52 | +unity-api (7.98+15.04.20150724-0ubuntu1) vivid; urgency=medium |
53 | |
54 | [ Mirco Müller (MacSlow) ] |
55 | * added alerting/setAlerting API to LauncherModel and LauncherItem interfaces |
56 | |
57 | -- CI Train Bot <ci-train-bot@canonical.com> Fri, 24 Jul 2015 09:53:01 +0000 |
58 | |
59 | +unity-api (7.98) UNRELEASED; urgency=medium |
60 | + |
61 | + * Remove ApplicationManagerInterface.forceDashActive |
62 | + * Remove ApplicationManagerInterface.suspended |
63 | + * Add ApplicationInfoInterface.requestedState |
64 | + |
65 | + -- Daniel d'Andrada <daniel.dandrada@canonical.com> Mon, 15 Jun 2015 13:53:07 -0300 |
66 | + |
67 | unity-api (7.97+15.10.20150721-0ubuntu1) wily; urgency=medium |
68 | |
69 | [ Michi Henning ] |
70 | |
71 | === modified file 'include/unity/shell/application/ApplicationManagerInterface.h' |
72 | --- include/unity/shell/application/ApplicationManagerInterface.h 2015-06-19 12:02:05 +0000 |
73 | +++ include/unity/shell/application/ApplicationManagerInterface.h 2015-09-07 14:10:05 +0000 |
74 | @@ -24,6 +24,7 @@ |
75 | |
76 | #include <QtCore/QObject> |
77 | #include <QtCore/QAbstractListModel> |
78 | +#include <QtQml/QJSValue> |
79 | |
80 | namespace unity |
81 | { |
82 | @@ -59,6 +60,36 @@ |
83 | */ |
84 | Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged) |
85 | |
86 | + /** |
87 | + * @brief Register a Javascript function as a callback for when an application is asking to create a new surface |
88 | + * |
89 | + * Registers a Javascript callback function which ApplicationManager will call when an application is asking |
90 | + * Mir to create a new surface. The function is passed a 'surface' object with properties width, height and |
91 | + * appId. The shell can implement this function to return different width & height to override the geometry |
92 | + * requested by the client. |
93 | + * |
94 | + * Example QML: |
95 | + * |
96 | + * function surfaceSizer(surface) { |
97 | + * surface.width = 400; |
98 | + * if (surface.appId && surface.appId == "dialer-app") { |
99 | + * surface.height = 300; |
100 | + * } |
101 | + * return surface; |
102 | + * } |
103 | + * |
104 | + * Component.onCompleted { |
105 | + * ApplicationManager.surfaceAboutToBeCreatedCallback = surfaceSizer; |
106 | + * } |
107 | + * Component.onDestruction { |
108 | + * ApplicationManager.surfaceAboutToBeCreatedCallback = null; |
109 | + * } |
110 | + * |
111 | + * Warning: the function must live in the QML context thread! |
112 | + */ |
113 | + Q_PROPERTY(QJSValue surfaceAboutToBeCreatedCallback READ surfaceAboutToBeCreatedCallback |
114 | + WRITE setSurfaceAboutToBeCreatedCallback NOTIFY surfaceAboutToBeCreatedCallbackChanged) |
115 | + |
116 | protected: |
117 | /// @cond |
118 | ApplicationManagerInterface(QObject* parent = 0): QAbstractListModel(parent) |
119 | @@ -108,6 +139,9 @@ |
120 | |
121 | virtual QString focusedApplicationId() const = 0; |
122 | |
123 | + virtual QJSValue surfaceAboutToBeCreatedCallback() const = 0; |
124 | + virtual void setSurfaceAboutToBeCreatedCallback(const QJSValue &callback) = 0; |
125 | + |
126 | /// @endcond |
127 | |
128 | /** |
129 | @@ -177,6 +211,7 @@ |
130 | Q_SIGNALS: |
131 | /// @cond |
132 | void countChanged(); |
133 | + void surfaceAboutToBeCreatedCallbackChanged(); |
134 | /// @endcond |
135 | |
136 | /** |
137 | |
138 | === modified file 'include/unity/shell/application/CMakeLists.txt' |
139 | --- include/unity/shell/application/CMakeLists.txt 2015-06-19 12:02:05 +0000 |
140 | +++ include/unity/shell/application/CMakeLists.txt 2015-09-07 14:10:05 +0000 |
141 | @@ -7,10 +7,10 @@ |
142 | |
143 | set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE) |
144 | |
145 | -set(VERSION 7) |
146 | +set(VERSION 8) |
147 | set(PKGCONFIG_NAME "unity-shell-application") |
148 | set(PKGCONFIG_DESCRIPTION "Unity shell Application APIs") |
149 | -set(PKGCONFIG_REQUIRES "Qt5Core") |
150 | +set(PKGCONFIG_REQUIRES "Qt5Core Qt5Qml") |
151 | set(PKGCONFIG_FILE unity-shell-application.pc) |
152 | |
153 | configure_file(${CMAKE_SOURCE_DIR}/data/unity-shell-api.pc.in |
154 | |
155 | === added file 'include/unity/shell/application/Mir.h' |
156 | --- include/unity/shell/application/Mir.h 1970-01-01 00:00:00 +0000 |
157 | +++ include/unity/shell/application/Mir.h 2015-09-07 14:10:05 +0000 |
158 | @@ -0,0 +1,76 @@ |
159 | +/* |
160 | + * Copyright (C) 2015 Canonical, Ltd. |
161 | + * |
162 | + * This program is free software; you can redistribute it and/or modify |
163 | + * it under the terms of the GNU General Public License as published by |
164 | + * the Free Software Foundation; version 3. |
165 | + * |
166 | + * This program is distributed in the hope that it will be useful, |
167 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
168 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
169 | + * GNU General Public License for more details. |
170 | + * |
171 | + * You should have received a copy of the GNU General Public License |
172 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
173 | + */ |
174 | + |
175 | +#ifndef UNITY_SHELL_APPLICATION_MIR_H |
176 | +#define UNITY_SHELL_APPLICATION_MIR_H |
177 | + |
178 | +#include <QObject> |
179 | + |
180 | +/** |
181 | + @brief Acting as a namespace to hold enums and such for use in QML |
182 | + */ |
183 | +class Mir |
184 | +{ |
185 | + Q_GADGET |
186 | + Q_ENUMS(Type) |
187 | + Q_ENUMS(State) |
188 | + Q_ENUMS(OrientationAngle) |
189 | + |
190 | +public: |
191 | + /** |
192 | + @brief Surface type |
193 | + */ |
194 | + enum Type { |
195 | + UnknownType, |
196 | + NormalType, |
197 | + UtilityType, |
198 | + DialogType, |
199 | + GlossType, |
200 | + FreeStyleType, |
201 | + MenuType, |
202 | + InputMethodType, |
203 | + SatelliteType, |
204 | + TipType, |
205 | + }; |
206 | + |
207 | + /** |
208 | + @brief Surface state |
209 | + */ |
210 | + enum State { |
211 | + UnknownState, |
212 | + RestoredState, |
213 | + MinimizedState, |
214 | + MaximizedState, |
215 | + VertMaximizedState, |
216 | + FullscreenState, |
217 | + HorizMaximizedState, |
218 | + HiddenState, |
219 | + }; |
220 | + |
221 | + /** |
222 | + @brief Surface orientation angle |
223 | + */ |
224 | + enum OrientationAngle { |
225 | + Angle0 = 0, |
226 | + Angle90 = 90, |
227 | + Angle180 = 180, |
228 | + Angle270 = 270 |
229 | + }; |
230 | +}; |
231 | + |
232 | +Q_DECLARE_METATYPE(Mir::OrientationAngle) |
233 | + |
234 | +#endif // UNITY_SHELL_APPLICATION_MIR_H |
235 | |
236 | === added file 'include/unity/shell/application/MirSurfaceInterface.h' |
237 | --- include/unity/shell/application/MirSurfaceInterface.h 1970-01-01 00:00:00 +0000 |
238 | +++ include/unity/shell/application/MirSurfaceInterface.h 2015-09-07 14:10:05 +0000 |
239 | @@ -0,0 +1,114 @@ |
240 | +/* |
241 | + * Copyright (C) 2015 Canonical, Ltd. |
242 | + * |
243 | + * This program is free software; you can redistribute it and/or modify |
244 | + * it under the terms of the GNU General Public License as published by |
245 | + * the Free Software Foundation; version 3. |
246 | + * |
247 | + * This program is distributed in the hope that it will be useful, |
248 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
249 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
250 | + * GNU General Public License for more details. |
251 | + * |
252 | + * You should have received a copy of the GNU General Public License |
253 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
254 | + */ |
255 | + |
256 | +#ifndef UNITY_SHELL_APPLICATION_MIRSURFACE_H |
257 | +#define UNITY_SHELL_APPLICATION_MIRSURFACE_H |
258 | + |
259 | +#include <QObject> |
260 | +#include <QSize> |
261 | + |
262 | +#include "Mir.h" |
263 | + |
264 | +namespace unity |
265 | +{ |
266 | +namespace shell |
267 | +{ |
268 | +namespace application |
269 | +{ |
270 | + |
271 | +/** |
272 | + @brief Holds a Mir surface. Pretty much an opaque class. |
273 | + |
274 | + All surface manipulation is done by giving it to a MirSurfaceItem and then |
275 | + using MirSurfaceItem's properties. |
276 | + */ |
277 | +class MirSurfaceInterface : public QObject |
278 | +{ |
279 | + Q_OBJECT |
280 | + |
281 | + /** |
282 | + * @brief The surface type |
283 | + */ |
284 | + Q_PROPERTY(Mir::Type type READ type NOTIFY typeChanged) |
285 | + |
286 | + /** |
287 | + * @brief Name of the surface, given by the client application |
288 | + */ |
289 | + Q_PROPERTY(QString name READ name CONSTANT) |
290 | + |
291 | + /** |
292 | + * @brief Size of the current surface buffer, in pixels. |
293 | + */ |
294 | + Q_PROPERTY(QSize size READ size NOTIFY sizeChanged) |
295 | + |
296 | + /** |
297 | + * @brief State of the surface |
298 | + */ |
299 | + Q_PROPERTY(Mir::State state READ state WRITE setState NOTIFY stateChanged) |
300 | + |
301 | + /** |
302 | + * @brief True if it has a mir client bound to it. |
303 | + * A "zombie" (live == false) surface never becomes alive again. |
304 | + */ |
305 | + Q_PROPERTY(bool live READ live NOTIFY liveChanged) |
306 | + |
307 | + /** |
308 | + * @brief Orientation angle of the surface |
309 | + * |
310 | + * How many degrees, clockwise, the UI in the surface has to rotate to match shell's UI orientation |
311 | + */ |
312 | + Q_PROPERTY(Mir::OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle |
313 | + NOTIFY orientationAngleChanged DESIGNABLE false) |
314 | + |
315 | +public: |
316 | + /// @cond |
317 | + MirSurfaceInterface(QObject *parent = nullptr) : QObject(parent) {} |
318 | + virtual ~MirSurfaceInterface() {} |
319 | + |
320 | + virtual Mir::Type type() const = 0; |
321 | + |
322 | + virtual QString name() const = 0; |
323 | + |
324 | + virtual QSize size() const = 0; |
325 | + virtual void resize(int width, int height) = 0; |
326 | + virtual void resize(const QSize &size) = 0; |
327 | + |
328 | + virtual Mir::State state() const = 0; |
329 | + virtual void setState(Mir::State qmlState) = 0; |
330 | + |
331 | + virtual bool live() const = 0; |
332 | + |
333 | + virtual Mir::OrientationAngle orientationAngle() const = 0; |
334 | + virtual void setOrientationAngle(Mir::OrientationAngle angle) = 0; |
335 | + /// @endcond |
336 | + |
337 | +Q_SIGNALS: |
338 | + /// @cond |
339 | + void typeChanged(Mir::Type value); |
340 | + void liveChanged(bool value); |
341 | + void stateChanged(Mir::State value); |
342 | + void orientationAngleChanged(Mir::OrientationAngle value); |
343 | + void sizeChanged(const QSize &value); |
344 | + /// @endcond |
345 | +}; |
346 | + |
347 | +} // namespace application |
348 | +} // namespace shell |
349 | +} // namespace unity |
350 | + |
351 | +Q_DECLARE_METATYPE(unity::shell::application::MirSurfaceInterface*) |
352 | + |
353 | +#endif // UNITY_SHELL_APPLICATION_MIRSURFACE_H |
354 | |
355 | === added file 'include/unity/shell/application/MirSurfaceItemInterface.h' |
356 | --- include/unity/shell/application/MirSurfaceItemInterface.h 1970-01-01 00:00:00 +0000 |
357 | +++ include/unity/shell/application/MirSurfaceItemInterface.h 2015-09-07 14:10:05 +0000 |
358 | @@ -0,0 +1,151 @@ |
359 | +/* |
360 | + * Copyright (C) 2015 Canonical, Ltd. |
361 | + * |
362 | + * This program is free software; you can redistribute it and/or modify |
363 | + * it under the terms of the GNU General Public License as published by |
364 | + * the Free Software Foundation; version 3. |
365 | + * |
366 | + * This program is distributed in the hope that it will be useful, |
367 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
368 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
369 | + * GNU General Public License for more details. |
370 | + * |
371 | + * You should have received a copy of the GNU General Public License |
372 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
373 | + */ |
374 | + |
375 | +#ifndef UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H |
376 | +#define UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H |
377 | + |
378 | +#include "Mir.h" |
379 | + |
380 | +#include <QQuickItem> |
381 | + |
382 | +namespace unity |
383 | +{ |
384 | +namespace shell |
385 | +{ |
386 | +namespace application |
387 | +{ |
388 | + |
389 | +class MirSurfaceInterface; |
390 | + |
391 | +/** |
392 | + @brief Renders a MirSurface in a QML scene and forwards the input events it receives to it. |
393 | + |
394 | + You can have multiple MirSurfaceItems displaying the same MirSurface. But care must |
395 | + be taken that only one of them feeds the MirSurface with input events and also only |
396 | + one resizes it. |
397 | + */ |
398 | +class MirSurfaceItemInterface : public QQuickItem |
399 | +{ |
400 | + Q_OBJECT |
401 | + |
402 | + /** |
403 | + * @brief The surface to be displayed |
404 | + */ |
405 | + Q_PROPERTY(unity::shell::application::MirSurfaceInterface* surface READ surface WRITE setSurface NOTIFY surfaceChanged) |
406 | + |
407 | + /** |
408 | + * @brief Type of the given surface or Mir.UnknownType if no surface is set |
409 | + */ |
410 | + Q_PROPERTY(Mir::Type type READ type NOTIFY typeChanged) |
411 | + |
412 | + /** |
413 | + * @brief State of the given surface or Mir.UnknownState if no surface is set |
414 | + */ |
415 | + Q_PROPERTY(Mir::State surfaceState READ surfaceState WRITE setSurfaceState NOTIFY surfaceStateChanged) |
416 | + |
417 | + /** |
418 | + * @brief Name of the given surface or an empty string if no surface is set |
419 | + */ |
420 | + Q_PROPERTY(QString name READ name CONSTANT) |
421 | + |
422 | + /** |
423 | + * @brief True if the item has a surface and that surface has a mir client bound to it. |
424 | + * A "zombie" (live == false) surface never becomes alive again. |
425 | + */ |
426 | + Q_PROPERTY(bool live READ live NOTIFY liveChanged) |
427 | + |
428 | + /** |
429 | + * @brief Orientation angle of the given surface |
430 | + * |
431 | + * How many degrees, clockwise, the UI in the surface has to rotate to match shell's UI orientation |
432 | + */ |
433 | + Q_PROPERTY(Mir::OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle |
434 | + NOTIFY orientationAngleChanged DESIGNABLE false) |
435 | + |
436 | + |
437 | + /** |
438 | + * @brief Whether the item will forward activeFocus, touch events, mouse events and key events to its surface. |
439 | + * It's false by default. |
440 | + * Only one item should have this property enabled for a given surface. |
441 | + */ |
442 | + Q_PROPERTY(bool consumesInput READ consumesInput |
443 | + WRITE setConsumesInput |
444 | + NOTIFY consumesInputChanged) |
445 | + |
446 | + /** |
447 | + * @brief The desired width for the contained MirSurface. |
448 | + * It's ignored if set to zero or a negative number |
449 | + * The default value is zero |
450 | + */ |
451 | + Q_PROPERTY(int surfaceWidth READ surfaceWidth |
452 | + WRITE setSurfaceWidth |
453 | + NOTIFY surfaceWidthChanged) |
454 | + |
455 | + /** |
456 | + * @brief The desired height for the contained MirSurface. |
457 | + * It's ignored if set to zero or a negative number |
458 | + * The default value is zero |
459 | + */ |
460 | + Q_PROPERTY(int surfaceHeight READ surfaceHeight |
461 | + WRITE setSurfaceHeight |
462 | + NOTIFY surfaceHeightChanged) |
463 | + |
464 | +public: |
465 | + /// @cond |
466 | + MirSurfaceItemInterface(QQuickItem *parent = 0) : QQuickItem(parent) {} |
467 | + virtual ~MirSurfaceItemInterface() {} |
468 | + |
469 | + virtual Mir::Type type() const = 0; |
470 | + virtual QString name() const = 0; |
471 | + virtual bool live() const = 0; |
472 | + |
473 | + virtual Mir::State surfaceState() const = 0; |
474 | + virtual void setSurfaceState(Mir::State) = 0; |
475 | + |
476 | + virtual Mir::OrientationAngle orientationAngle() const = 0; |
477 | + virtual void setOrientationAngle(Mir::OrientationAngle angle) = 0; |
478 | + |
479 | + virtual MirSurfaceInterface* surface() const = 0; |
480 | + virtual void setSurface(MirSurfaceInterface*) = 0; |
481 | + |
482 | + virtual bool consumesInput() const = 0; |
483 | + virtual void setConsumesInput(bool value) = 0; |
484 | + |
485 | + virtual int surfaceWidth() const = 0; |
486 | + virtual void setSurfaceWidth(int value) = 0; |
487 | + |
488 | + virtual int surfaceHeight() const = 0; |
489 | + virtual void setSurfaceHeight(int value) = 0; |
490 | + /// @endcond |
491 | + |
492 | +Q_SIGNALS: |
493 | + /// @cond |
494 | + void typeChanged(Mir::Type); |
495 | + void surfaceStateChanged(Mir::State); |
496 | + void liveChanged(bool live); |
497 | + void orientationAngleChanged(Mir::OrientationAngle angle); |
498 | + void surfaceChanged(MirSurfaceInterface*); |
499 | + void consumesInputChanged(bool value); |
500 | + void surfaceWidthChanged(int value); |
501 | + void surfaceHeightChanged(int value); |
502 | + /// @endcond |
503 | +}; |
504 | + |
505 | +} // namespace application |
506 | +} // namespace shell |
507 | +} // namespace unity |
508 | + |
509 | +#endif // UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H |
510 | |
511 | === modified file 'test/qmltest/mocks/plugins/Unity/Application/CMakeLists.txt' |
512 | --- test/qmltest/mocks/plugins/Unity/Application/CMakeLists.txt 2014-09-03 22:59:26 +0000 |
513 | +++ test/qmltest/mocks/plugins/Unity/Application/CMakeLists.txt 2015-09-07 14:10:05 +0000 |
514 | @@ -20,7 +20,7 @@ |
515 | |
516 | add_library(ApplicationMocks SHARED ${ApplicationMocks_SOURCES}) |
517 | |
518 | -qt5_use_modules(ApplicationMocks Core Gui) |
519 | +qt5_use_modules(ApplicationMocks Core Gui Qml) |
520 | |
521 | set(TestApplicationPlugin_SOURCES |
522 | TestApplicationPlugin.cpp |
523 | |
524 | === modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp' |
525 | --- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2015-06-19 12:02:05 +0000 |
526 | +++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2015-09-07 14:10:05 +0000 |
527 | @@ -22,7 +22,9 @@ |
528 | |
529 | using namespace unity::shell::application; |
530 | |
531 | -MockApplicationManager::MockApplicationManager(QObject* parent): ApplicationManagerInterface(parent) |
532 | +MockApplicationManager::MockApplicationManager(QObject* parent) |
533 | + : ApplicationManagerInterface(parent) |
534 | + , m_surfaceAboutToBeCreatedCallback(QJSValue::UndefinedValue) |
535 | { |
536 | MockApplicationInfo *item = new MockApplicationInfo("phone-app", "Phone App", "Telephony application", QUrl("/usr/share/pixmaps/some/icon.png"), this); |
537 | m_list.append(item); |
538 | @@ -126,3 +128,17 @@ |
539 | Q_UNUSED(appId) |
540 | return true; |
541 | } |
542 | + |
543 | +QJSValue MockApplicationManager::surfaceAboutToBeCreatedCallback() const |
544 | +{ |
545 | + return m_surfaceAboutToBeCreatedCallback; |
546 | +} |
547 | + |
548 | +void MockApplicationManager::setSurfaceAboutToBeCreatedCallback(const QJSValue &callback) |
549 | +{ |
550 | + if (m_surfaceAboutToBeCreatedCallback.equals(callback)) |
551 | + return; |
552 | + |
553 | + m_surfaceAboutToBeCreatedCallback = callback; |
554 | + Q_EMIT surfaceAboutToBeCreatedCallbackChanged(); |
555 | +} |
556 | |
557 | === modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h' |
558 | --- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2015-06-19 12:02:05 +0000 |
559 | +++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2015-09-07 14:10:05 +0000 |
560 | @@ -40,6 +40,9 @@ |
561 | |
562 | QString focusedApplicationId() const; |
563 | |
564 | + QJSValue surfaceAboutToBeCreatedCallback() const; |
565 | + void setSurfaceAboutToBeCreatedCallback(const QJSValue &callback); |
566 | + |
567 | Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(const int index) const; |
568 | |
569 | Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const; |
570 | @@ -56,6 +59,7 @@ |
571 | |
572 | private: |
573 | QList<MockApplicationInfo*> m_list; |
574 | + QJSValue m_surfaceAboutToBeCreatedCallback; |
575 | }; |
576 | |
577 | #endif // MOCKAPPLICATIONMANAGER_H |
578 | |
579 | === modified file 'test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt' |
580 | --- test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt 2014-09-03 22:59:26 +0000 |
581 | +++ test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt 2015-09-07 14:10:05 +0000 |
582 | @@ -27,7 +27,7 @@ |
583 | |
584 | add_library(LauncherMocks SHARED ${LauncherMocks_SOURCES}) |
585 | |
586 | -qt5_use_modules(LauncherMocks Core Gui) |
587 | +qt5_use_modules(LauncherMocks Core Gui Qml) |
588 | |
589 | set(TestLauncherPlugin_SOURCES |
590 | TestLauncherPlugin.cpp |
591 | |
592 | === modified file 'test/qmltest/unity/shell/application/tst_Application.qml' |
593 | --- test/qmltest/unity/shell/application/tst_Application.qml 2015-06-19 12:02:05 +0000 |
594 | +++ test/qmltest/unity/shell/application/tst_Application.qml 2015-09-07 14:10:05 +0000 |
595 | @@ -59,6 +59,11 @@ |
596 | } |
597 | } |
598 | |
599 | + function initTestCase() { |
600 | + function surfaceSizer(surface) { return surface; } |
601 | + ApplicationManager.surfaceAboutToBeCreatedCallback = surfaceSizer; |
602 | + } |
603 | + |
604 | /* make sure all the required roles are exposed on ApplicationManager */ |
605 | function test_model_roles_enum_data() { |
606 | return [ |
607 | @@ -124,6 +129,7 @@ |
608 | return [ |
609 | { tag: "ApplicationManager.count", property: "count", type: "number" }, |
610 | { tag: "ApplicationManager.focusedApplicationId", property: "focusedApplicationId", type: "string" }, |
611 | + { tag: "ApplicationManager.surfaceAboutToBeCreatedCallback", property: "surfaceAboutToBeCreatedCallback", type: "function" }, |
612 | ]; |
613 | } |
614 |
<Saviq> greyback, wonder, could this not ba Q_PROPERTY?
Maybe it could, in which case the API would be prettier. I'll see if it works