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

Proposed by Gerry Boland
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
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 surfaceAboutToBeCreatedCallback property to AppMan - allows QML shell override surface creation geometry

Description of the change

AppMan: add surfaceAboutToBeCreatedCallback property to AppMan - allows QML shell override surface creation geometry

 * Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~gerboland/unity8/initialSurfaceGeometry/+merge/231726
https://code.launchpad.net/~gerboland/qtmir/initialSurfaceGeometry/+merge/231725
 * Did you perform an exploratory manual test run of your code change and any related functionality?
Y

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

<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

Revision history for this message
Michał Sawicz (saviq) : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
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?

review: Needs Information
Revision history for this message
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.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
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.

Revision history for this message
Michał Sawicz (saviq) : Posted in a previous version of this proposal
review: Needs Information
Revision history for this message
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.

Revision history for this message
Gerry Boland (gerboland) : Posted in a previous version of this proposal
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) : Posted in a previous version of this proposal
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

> I tried:
>
> Binding {
> target: ApplicationManager
> property: "surfaceAboutToBeCreatedCallback"
> value: function surfaceSizer(surface) { print("Hihi")
> surface.width = 400;
> if (surface.appId && surface.appId == "dialer-app") {
> surface.height = 300;
> }
> return surface;
> }
> }
>
> and got this error:
> file:///usr/share/unity8/Stages/PhoneStage.qml:125:12: Unable to assign a 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
ApplicationManager.surfaceAboutToBeCreatedCallback is not var, how would
your original approach to assign instead of bind work in any case?

I'd say that's worth a QTBUG.

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

> > I tried:
> >
> > Binding {
> > target: ApplicationManager
> > property: "surfaceAboutToBeCreatedCallback"
> > value: function surfaceSizer(surface) { print("Hihi")
> > surface.width = 400;
> > if (surface.appId && surface.appId == "dialer-app") {
> > surface.height = 300;
> > }
> > return surface;
> > }
> > }
> >
> > and got this error:
> > file:///usr/share/unity8/Stages/PhoneStage.qml:125:12: Unable to assign a
> 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
> ApplicationManager.surfaceAboutToBeCreatedCallback is not var, how would
> 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:/src/qml/qml/qmlproperty.cpp does confirm that idea: http://pastebin.ubuntu.com/8099923/ - I don't understand why exactly..

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?

Revision history for this message
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:/src/qml/qml/qmlproperty.cpp does confirm that idea:http://pastebin.ubuntu.com/8099923/ - I don't understand why exactly..

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.

Revision history for this message
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.

review: Needs Fixing
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
Michał Sawicz (saviq) wrote :

Oh yes!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Code looks good, haven't time to test. If nobody beats me to it, i'll do on Monday

review: Approve (code)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Let's wait for https://code.launchpad.net/~gerboland/unity8/initialSurfaceGeometry/+merge/231726 to be finished so we can try it all together

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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-08-26 08:59:22 +0000
+++ debian/changelog 2015-09-07 14:10:05 +0000
@@ -1,3 +1,4 @@
1<<<<<<< TREE
1unity-api (7.99+15.10.20150826-0ubuntu1) wily; urgency=medium2unity-api (7.99+15.10.20150826-0ubuntu1) wily; urgency=medium
23
3 [ Pawel Stolowski ]4 [ Pawel Stolowski ]
@@ -9,6 +10,25 @@
9 -- CI Train Bot <ci-train-bot@canonical.com> Wed, 26 Aug 2015 08:59:21 +000010 -- CI Train Bot <ci-train-bot@canonical.com> Wed, 26 Aug 2015 08:59:21 +0000
1011
11unity-api (7.99+15.10.20150804-0ubuntu1) wily; urgency=medium12unity-api (7.99+15.10.20150804-0ubuntu1) wily; urgency=medium
13=======
14unity-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
24unity-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
30unity-api (7.99+15.04.20150804-0ubuntu1) vivid; urgency=medium
31>>>>>>> MERGE-SOURCE
1232
13 [ Daniel d'Andrada ]33 [ Daniel d'Andrada ]
14 * Remove ApplicationManagerInterface.forceDashActive34 * Remove ApplicationManagerInterface.forceDashActive
@@ -18,13 +38,33 @@
1838
19 -- CI Train Bot <ci-train-bot@canonical.com> Tue, 04 Aug 2015 15:26:16 +000039 -- CI Train Bot <ci-train-bot@canonical.com> Tue, 04 Aug 2015 15:26:16 +0000
2040
21unity-api (7.98+15.10.20150724-0ubuntu1) wily; urgency=medium41unity-api (7.99-0ubuntu1) UNRELEASED; urgency=medium
42
43 * Changes to activate and preview methods of ScopeInterface.
44
45 -- Pawel Stolowski <pawel.stolowski@canonical.com> Mon, 03 Aug 2015 14:03:47 +0000
46
47unity-api (7.99) UNRELEASED; urgency=medium
48
49 * Add surface sizer callback property to AppMan API
50
51 -- Gerry Boland <gerry.boland@canonical.com> Mon, 13 July 2015 13:47:07 +0000
52
53unity-api (7.98+15.04.20150724-0ubuntu1) vivid; urgency=medium
2254
23 [ Mirco Müller (MacSlow) ]55 [ Mirco Müller (MacSlow) ]
24 * added alerting/setAlerting API to LauncherModel and LauncherItem interfaces56 * added alerting/setAlerting API to LauncherModel and LauncherItem interfaces
2557
26 -- CI Train Bot <ci-train-bot@canonical.com> Fri, 24 Jul 2015 09:53:01 +000058 -- CI Train Bot <ci-train-bot@canonical.com> Fri, 24 Jul 2015 09:53:01 +0000
2759
60unity-api (7.98) UNRELEASED; urgency=medium
61
62 * Remove ApplicationManagerInterface.forceDashActive
63 * Remove ApplicationManagerInterface.suspended
64 * Add ApplicationInfoInterface.requestedState
65
66 -- Daniel d'Andrada <daniel.dandrada@canonical.com> Mon, 15 Jun 2015 13:53:07 -0300
67
28unity-api (7.97+15.10.20150721-0ubuntu1) wily; urgency=medium68unity-api (7.97+15.10.20150721-0ubuntu1) wily; urgency=medium
2969
30 [ Michi Henning ]70 [ Michi Henning ]
3171
=== modified file 'include/unity/shell/application/ApplicationManagerInterface.h'
--- include/unity/shell/application/ApplicationManagerInterface.h 2015-06-19 12:02:05 +0000
+++ include/unity/shell/application/ApplicationManagerInterface.h 2015-09-07 14:10:05 +0000
@@ -24,6 +24,7 @@
2424
25#include <QtCore/QObject>25#include <QtCore/QObject>
26#include <QtCore/QAbstractListModel>26#include <QtCore/QAbstractListModel>
27#include <QtQml/QJSValue>
2728
28namespace unity29namespace unity
29{30{
@@ -59,6 +60,36 @@
59 */60 */
60 Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged)61 Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged)
6162
63 /**
64 * @brief Register a Javascript function as a callback for when an application is asking to create a new surface
65 *
66 * Registers a Javascript callback function which ApplicationManager will call when an application is asking
67 * Mir to create a new surface. The function is passed a 'surface' object with properties width, height and
68 * appId. The shell can implement this function to return different width & height to override the geometry
69 * requested by the client.
70 *
71 * Example QML:
72 *
73 * function surfaceSizer(surface) {
74 * surface.width = 400;
75 * if (surface.appId && surface.appId == "dialer-app") {
76 * surface.height = 300;
77 * }
78 * return surface;
79 * }
80 *
81 * Component.onCompleted {
82 * ApplicationManager.surfaceAboutToBeCreatedCallback = surfaceSizer;
83 * }
84 * Component.onDestruction {
85 * ApplicationManager.surfaceAboutToBeCreatedCallback = null;
86 * }
87 *
88 * Warning: the function must live in the QML context thread!
89 */
90 Q_PROPERTY(QJSValue surfaceAboutToBeCreatedCallback READ surfaceAboutToBeCreatedCallback
91 WRITE setSurfaceAboutToBeCreatedCallback NOTIFY surfaceAboutToBeCreatedCallbackChanged)
92
62protected:93protected:
63 /// @cond94 /// @cond
64 ApplicationManagerInterface(QObject* parent = 0): QAbstractListModel(parent)95 ApplicationManagerInterface(QObject* parent = 0): QAbstractListModel(parent)
@@ -108,6 +139,9 @@
108139
109 virtual QString focusedApplicationId() const = 0;140 virtual QString focusedApplicationId() const = 0;
110141
142 virtual QJSValue surfaceAboutToBeCreatedCallback() const = 0;
143 virtual void setSurfaceAboutToBeCreatedCallback(const QJSValue &callback) = 0;
144
111 /// @endcond145 /// @endcond
112146
113 /**147 /**
@@ -177,6 +211,7 @@
177Q_SIGNALS:211Q_SIGNALS:
178 /// @cond212 /// @cond
179 void countChanged();213 void countChanged();
214 void surfaceAboutToBeCreatedCallbackChanged();
180 /// @endcond215 /// @endcond
181216
182 /**217 /**
183218
=== modified file 'include/unity/shell/application/CMakeLists.txt'
--- include/unity/shell/application/CMakeLists.txt 2015-06-19 12:02:05 +0000
+++ include/unity/shell/application/CMakeLists.txt 2015-09-07 14:10:05 +0000
@@ -7,10 +7,10 @@
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 7)10set(VERSION 8)
11set(PKGCONFIG_NAME "unity-shell-application")11set(PKGCONFIG_NAME "unity-shell-application")
12set(PKGCONFIG_DESCRIPTION "Unity shell Application APIs")12set(PKGCONFIG_DESCRIPTION "Unity shell Application APIs")
13set(PKGCONFIG_REQUIRES "Qt5Core")13set(PKGCONFIG_REQUIRES "Qt5Core Qt5Qml")
14set(PKGCONFIG_FILE unity-shell-application.pc)14set(PKGCONFIG_FILE unity-shell-application.pc)
1515
16configure_file(${CMAKE_SOURCE_DIR}/data/unity-shell-api.pc.in16configure_file(${CMAKE_SOURCE_DIR}/data/unity-shell-api.pc.in
1717
=== added file 'include/unity/shell/application/Mir.h'
--- include/unity/shell/application/Mir.h 1970-01-01 00:00:00 +0000
+++ include/unity/shell/application/Mir.h 2015-09-07 14:10:05 +0000
@@ -0,0 +1,76 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITY_SHELL_APPLICATION_MIR_H
18#define UNITY_SHELL_APPLICATION_MIR_H
19
20#include <QObject>
21
22/**
23 @brief Acting as a namespace to hold enums and such for use in QML
24 */
25class Mir
26{
27 Q_GADGET
28 Q_ENUMS(Type)
29 Q_ENUMS(State)
30 Q_ENUMS(OrientationAngle)
31
32public:
33 /**
34 @brief Surface type
35 */
36 enum Type {
37 UnknownType,
38 NormalType,
39 UtilityType,
40 DialogType,
41 GlossType,
42 FreeStyleType,
43 MenuType,
44 InputMethodType,
45 SatelliteType,
46 TipType,
47 };
48
49 /**
50 @brief Surface state
51 */
52 enum State {
53 UnknownState,
54 RestoredState,
55 MinimizedState,
56 MaximizedState,
57 VertMaximizedState,
58 FullscreenState,
59 HorizMaximizedState,
60 HiddenState,
61 };
62
63 /**
64 @brief Surface orientation angle
65 */
66 enum OrientationAngle {
67 Angle0 = 0,
68 Angle90 = 90,
69 Angle180 = 180,
70 Angle270 = 270
71 };
72};
73
74Q_DECLARE_METATYPE(Mir::OrientationAngle)
75
76#endif // UNITY_SHELL_APPLICATION_MIR_H
077
=== added file 'include/unity/shell/application/MirSurfaceInterface.h'
--- include/unity/shell/application/MirSurfaceInterface.h 1970-01-01 00:00:00 +0000
+++ include/unity/shell/application/MirSurfaceInterface.h 2015-09-07 14:10:05 +0000
@@ -0,0 +1,114 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITY_SHELL_APPLICATION_MIRSURFACE_H
18#define UNITY_SHELL_APPLICATION_MIRSURFACE_H
19
20#include <QObject>
21#include <QSize>
22
23#include "Mir.h"
24
25namespace unity
26{
27namespace shell
28{
29namespace application
30{
31
32/**
33 @brief Holds a Mir surface. Pretty much an opaque class.
34
35 All surface manipulation is done by giving it to a MirSurfaceItem and then
36 using MirSurfaceItem's properties.
37 */
38class MirSurfaceInterface : public QObject
39{
40 Q_OBJECT
41
42 /**
43 * @brief The surface type
44 */
45 Q_PROPERTY(Mir::Type type READ type NOTIFY typeChanged)
46
47 /**
48 * @brief Name of the surface, given by the client application
49 */
50 Q_PROPERTY(QString name READ name CONSTANT)
51
52 /**
53 * @brief Size of the current surface buffer, in pixels.
54 */
55 Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
56
57 /**
58 * @brief State of the surface
59 */
60 Q_PROPERTY(Mir::State state READ state WRITE setState NOTIFY stateChanged)
61
62 /**
63 * @brief True if it has a mir client bound to it.
64 * A "zombie" (live == false) surface never becomes alive again.
65 */
66 Q_PROPERTY(bool live READ live NOTIFY liveChanged)
67
68 /**
69 * @brief Orientation angle of the surface
70 *
71 * How many degrees, clockwise, the UI in the surface has to rotate to match shell's UI orientation
72 */
73 Q_PROPERTY(Mir::OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
74 NOTIFY orientationAngleChanged DESIGNABLE false)
75
76public:
77 /// @cond
78 MirSurfaceInterface(QObject *parent = nullptr) : QObject(parent) {}
79 virtual ~MirSurfaceInterface() {}
80
81 virtual Mir::Type type() const = 0;
82
83 virtual QString name() const = 0;
84
85 virtual QSize size() const = 0;
86 virtual void resize(int width, int height) = 0;
87 virtual void resize(const QSize &size) = 0;
88
89 virtual Mir::State state() const = 0;
90 virtual void setState(Mir::State qmlState) = 0;
91
92 virtual bool live() const = 0;
93
94 virtual Mir::OrientationAngle orientationAngle() const = 0;
95 virtual void setOrientationAngle(Mir::OrientationAngle angle) = 0;
96 /// @endcond
97
98Q_SIGNALS:
99 /// @cond
100 void typeChanged(Mir::Type value);
101 void liveChanged(bool value);
102 void stateChanged(Mir::State value);
103 void orientationAngleChanged(Mir::OrientationAngle value);
104 void sizeChanged(const QSize &value);
105 /// @endcond
106};
107
108} // namespace application
109} // namespace shell
110} // namespace unity
111
112Q_DECLARE_METATYPE(unity::shell::application::MirSurfaceInterface*)
113
114#endif // UNITY_SHELL_APPLICATION_MIRSURFACE_H
0115
=== added file 'include/unity/shell/application/MirSurfaceItemInterface.h'
--- include/unity/shell/application/MirSurfaceItemInterface.h 1970-01-01 00:00:00 +0000
+++ include/unity/shell/application/MirSurfaceItemInterface.h 2015-09-07 14:10:05 +0000
@@ -0,0 +1,151 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H
18#define UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H
19
20#include "Mir.h"
21
22#include <QQuickItem>
23
24namespace unity
25{
26namespace shell
27{
28namespace application
29{
30
31class MirSurfaceInterface;
32
33/**
34 @brief Renders a MirSurface in a QML scene and forwards the input events it receives to it.
35
36 You can have multiple MirSurfaceItems displaying the same MirSurface. But care must
37 be taken that only one of them feeds the MirSurface with input events and also only
38 one resizes it.
39 */
40class MirSurfaceItemInterface : public QQuickItem
41{
42 Q_OBJECT
43
44 /**
45 * @brief The surface to be displayed
46 */
47 Q_PROPERTY(unity::shell::application::MirSurfaceInterface* surface READ surface WRITE setSurface NOTIFY surfaceChanged)
48
49 /**
50 * @brief Type of the given surface or Mir.UnknownType if no surface is set
51 */
52 Q_PROPERTY(Mir::Type type READ type NOTIFY typeChanged)
53
54 /**
55 * @brief State of the given surface or Mir.UnknownState if no surface is set
56 */
57 Q_PROPERTY(Mir::State surfaceState READ surfaceState WRITE setSurfaceState NOTIFY surfaceStateChanged)
58
59 /**
60 * @brief Name of the given surface or an empty string if no surface is set
61 */
62 Q_PROPERTY(QString name READ name CONSTANT)
63
64 /**
65 * @brief True if the item has a surface and that surface has a mir client bound to it.
66 * A "zombie" (live == false) surface never becomes alive again.
67 */
68 Q_PROPERTY(bool live READ live NOTIFY liveChanged)
69
70 /**
71 * @brief Orientation angle of the given surface
72 *
73 * How many degrees, clockwise, the UI in the surface has to rotate to match shell's UI orientation
74 */
75 Q_PROPERTY(Mir::OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
76 NOTIFY orientationAngleChanged DESIGNABLE false)
77
78
79 /**
80 * @brief Whether the item will forward activeFocus, touch events, mouse events and key events to its surface.
81 * It's false by default.
82 * Only one item should have this property enabled for a given surface.
83 */
84 Q_PROPERTY(bool consumesInput READ consumesInput
85 WRITE setConsumesInput
86 NOTIFY consumesInputChanged)
87
88 /**
89 * @brief The desired width for the contained MirSurface.
90 * It's ignored if set to zero or a negative number
91 * The default value is zero
92 */
93 Q_PROPERTY(int surfaceWidth READ surfaceWidth
94 WRITE setSurfaceWidth
95 NOTIFY surfaceWidthChanged)
96
97 /**
98 * @brief The desired height for the contained MirSurface.
99 * It's ignored if set to zero or a negative number
100 * The default value is zero
101 */
102 Q_PROPERTY(int surfaceHeight READ surfaceHeight
103 WRITE setSurfaceHeight
104 NOTIFY surfaceHeightChanged)
105
106public:
107 /// @cond
108 MirSurfaceItemInterface(QQuickItem *parent = 0) : QQuickItem(parent) {}
109 virtual ~MirSurfaceItemInterface() {}
110
111 virtual Mir::Type type() const = 0;
112 virtual QString name() const = 0;
113 virtual bool live() const = 0;
114
115 virtual Mir::State surfaceState() const = 0;
116 virtual void setSurfaceState(Mir::State) = 0;
117
118 virtual Mir::OrientationAngle orientationAngle() const = 0;
119 virtual void setOrientationAngle(Mir::OrientationAngle angle) = 0;
120
121 virtual MirSurfaceInterface* surface() const = 0;
122 virtual void setSurface(MirSurfaceInterface*) = 0;
123
124 virtual bool consumesInput() const = 0;
125 virtual void setConsumesInput(bool value) = 0;
126
127 virtual int surfaceWidth() const = 0;
128 virtual void setSurfaceWidth(int value) = 0;
129
130 virtual int surfaceHeight() const = 0;
131 virtual void setSurfaceHeight(int value) = 0;
132 /// @endcond
133
134Q_SIGNALS:
135 /// @cond
136 void typeChanged(Mir::Type);
137 void surfaceStateChanged(Mir::State);
138 void liveChanged(bool live);
139 void orientationAngleChanged(Mir::OrientationAngle angle);
140 void surfaceChanged(MirSurfaceInterface*);
141 void consumesInputChanged(bool value);
142 void surfaceWidthChanged(int value);
143 void surfaceHeightChanged(int value);
144 /// @endcond
145};
146
147} // namespace application
148} // namespace shell
149} // namespace unity
150
151#endif // UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H
0152
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/CMakeLists.txt'
--- test/qmltest/mocks/plugins/Unity/Application/CMakeLists.txt 2014-09-03 22:59:26 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/CMakeLists.txt 2015-09-07 14:10:05 +0000
@@ -20,7 +20,7 @@
2020
21add_library(ApplicationMocks SHARED ${ApplicationMocks_SOURCES})21add_library(ApplicationMocks SHARED ${ApplicationMocks_SOURCES})
2222
23qt5_use_modules(ApplicationMocks Core Gui)23qt5_use_modules(ApplicationMocks Core Gui Qml)
2424
25set(TestApplicationPlugin_SOURCES25set(TestApplicationPlugin_SOURCES
26 TestApplicationPlugin.cpp26 TestApplicationPlugin.cpp
2727
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp'
--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2015-06-19 12:02:05 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2015-09-07 14:10:05 +0000
@@ -22,7 +22,9 @@
2222
23using namespace unity::shell::application;23using namespace unity::shell::application;
2424
25MockApplicationManager::MockApplicationManager(QObject* parent): ApplicationManagerInterface(parent)25MockApplicationManager::MockApplicationManager(QObject* parent)
26 : ApplicationManagerInterface(parent)
27 , m_surfaceAboutToBeCreatedCallback(QJSValue::UndefinedValue)
26{28{
27 MockApplicationInfo *item = new MockApplicationInfo("phone-app", "Phone App", "Telephony application", QUrl("/usr/share/pixmaps/some/icon.png"), this);29 MockApplicationInfo *item = new MockApplicationInfo("phone-app", "Phone App", "Telephony application", QUrl("/usr/share/pixmaps/some/icon.png"), this);
28 m_list.append(item);30 m_list.append(item);
@@ -126,3 +128,17 @@
126 Q_UNUSED(appId)128 Q_UNUSED(appId)
127 return true;129 return true;
128}130}
131
132QJSValue MockApplicationManager::surfaceAboutToBeCreatedCallback() const
133{
134 return m_surfaceAboutToBeCreatedCallback;
135}
136
137void MockApplicationManager::setSurfaceAboutToBeCreatedCallback(const QJSValue &callback)
138{
139 if (m_surfaceAboutToBeCreatedCallback.equals(callback))
140 return;
141
142 m_surfaceAboutToBeCreatedCallback = callback;
143 Q_EMIT surfaceAboutToBeCreatedCallbackChanged();
144}
129145
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h'
--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2015-06-19 12:02:05 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2015-09-07 14:10:05 +0000
@@ -40,6 +40,9 @@
4040
41 QString focusedApplicationId() const;41 QString focusedApplicationId() const;
4242
43 QJSValue surfaceAboutToBeCreatedCallback() const;
44 void setSurfaceAboutToBeCreatedCallback(const QJSValue &callback);
45
43 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(const int index) const;46 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(const int index) const;
4447
45 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const;48 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const;
@@ -56,6 +59,7 @@
5659
57private:60private:
58 QList<MockApplicationInfo*> m_list;61 QList<MockApplicationInfo*> m_list;
62 QJSValue m_surfaceAboutToBeCreatedCallback;
59};63};
6064
61#endif // MOCKAPPLICATIONMANAGER_H65#endif // MOCKAPPLICATIONMANAGER_H
6266
=== modified file 'test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt'
--- test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt 2014-09-03 22:59:26 +0000
+++ test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt 2015-09-07 14:10:05 +0000
@@ -27,7 +27,7 @@
2727
28add_library(LauncherMocks SHARED ${LauncherMocks_SOURCES})28add_library(LauncherMocks SHARED ${LauncherMocks_SOURCES})
2929
30qt5_use_modules(LauncherMocks Core Gui)30qt5_use_modules(LauncherMocks Core Gui Qml)
3131
32set(TestLauncherPlugin_SOURCES32set(TestLauncherPlugin_SOURCES
33 TestLauncherPlugin.cpp33 TestLauncherPlugin.cpp
3434
=== modified file 'test/qmltest/unity/shell/application/tst_Application.qml'
--- test/qmltest/unity/shell/application/tst_Application.qml 2015-06-19 12:02:05 +0000
+++ test/qmltest/unity/shell/application/tst_Application.qml 2015-09-07 14:10:05 +0000
@@ -59,6 +59,11 @@
59 }59 }
60 }60 }
6161
62 function initTestCase() {
63 function surfaceSizer(surface) { return surface; }
64 ApplicationManager.surfaceAboutToBeCreatedCallback = surfaceSizer;
65 }
66
62 /* make sure all the required roles are exposed on ApplicationManager */67 /* make sure all the required roles are exposed on ApplicationManager */
63 function test_model_roles_enum_data() {68 function test_model_roles_enum_data() {
64 return [69 return [
@@ -124,6 +129,7 @@
124 return [129 return [
125 { tag: "ApplicationManager.count", property: "count", type: "number" },130 { tag: "ApplicationManager.count", property: "count", type: "number" },
126 { tag: "ApplicationManager.focusedApplicationId", property: "focusedApplicationId", type: "string" },131 { tag: "ApplicationManager.focusedApplicationId", property: "focusedApplicationId", type: "string" },
132 { tag: "ApplicationManager.surfaceAboutToBeCreatedCallback", property: "surfaceAboutToBeCreatedCallback", type: "function" },
127 ];133 ];
128 }134 }
129135

Subscribers

People subscribed via source and target branches

to all changes: