Merge lp:~dandrader/unity-api/mirSurface-15.04 into lp:~unity-team/unity-api/trunk-15.04

Proposed by Daniel d'Andrada on 2015-08-19
Status: Merged
Approved by: Gerry Boland on 2015-08-19
Approved revision: 184
Merged at revision: 184
Proposed branch: lp:~dandrader/unity-api/mirSurface-15.04
Merge into: lp:~unity-team/unity-api/trunk-15.04
Diff against target: 382 lines (+348/-1)
5 files modified
debian/changelog (+6/-0)
include/unity/shell/application/CMakeLists.txt (+1/-1)
include/unity/shell/application/Mir.h (+76/-0)
include/unity/shell/application/MirSurfaceInterface.h (+114/-0)
include/unity/shell/application/MirSurfaceItemInterface.h (+151/-0)
To merge this branch: bzr merge lp:~dandrader/unity-api/mirSurface-15.04
Reviewer Review Type Date Requested Status
Gerry Boland 2015-08-19 Approve on 2015-08-19
Review via email: mp+268484@code.launchpad.net

Commit Message

Added MirSurface and MirSurfaceItem interfaces

To post a comment you must log in.
Gerry Boland (gerboland) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-08-11 14:05:55 +0000
3+++ debian/changelog 2015-08-19 14:04:26 +0000
4@@ -1,3 +1,9 @@
5+unity-api (7.100) UNRELEASED; urgency=medium
6+
7+ * Added MirSurface and MirSurfaceItem interfaces
8+
9+ -- Daniel d'Andrada <daniel.dandrada@canonical.com> Wed, 19 Aug 2015 10:13:05 -0300
10+
11 unity-api (7.99+15.04.20150811-0ubuntu1) vivid; urgency=medium
12
13 * New rebuild forced.
14
15=== modified file 'include/unity/shell/application/CMakeLists.txt'
16--- include/unity/shell/application/CMakeLists.txt 2015-06-19 12:02:05 +0000
17+++ include/unity/shell/application/CMakeLists.txt 2015-08-19 14:04:26 +0000
18@@ -7,7 +7,7 @@
19
20 set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)
21
22-set(VERSION 7)
23+set(VERSION 8)
24 set(PKGCONFIG_NAME "unity-shell-application")
25 set(PKGCONFIG_DESCRIPTION "Unity shell Application APIs")
26 set(PKGCONFIG_REQUIRES "Qt5Core")
27
28=== added file 'include/unity/shell/application/Mir.h'
29--- include/unity/shell/application/Mir.h 1970-01-01 00:00:00 +0000
30+++ include/unity/shell/application/Mir.h 2015-08-19 14:04:26 +0000
31@@ -0,0 +1,76 @@
32+/*
33+ * Copyright (C) 2015 Canonical, Ltd.
34+ *
35+ * This program is free software; you can redistribute it and/or modify
36+ * it under the terms of the GNU General Public License as published by
37+ * the Free Software Foundation; version 3.
38+ *
39+ * This program is distributed in the hope that it will be useful,
40+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
41+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42+ * GNU General Public License for more details.
43+ *
44+ * You should have received a copy of the GNU General Public License
45+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
46+ */
47+
48+#ifndef UNITY_SHELL_APPLICATION_MIR_H
49+#define UNITY_SHELL_APPLICATION_MIR_H
50+
51+#include <QObject>
52+
53+/**
54+ @brief Acting as a namespace to hold enums and such for use in QML
55+ */
56+class Mir
57+{
58+ Q_GADGET
59+ Q_ENUMS(Type)
60+ Q_ENUMS(State)
61+ Q_ENUMS(OrientationAngle)
62+
63+public:
64+ /**
65+ @brief Surface type
66+ */
67+ enum Type {
68+ UnknownType,
69+ NormalType,
70+ UtilityType,
71+ DialogType,
72+ GlossType,
73+ FreeStyleType,
74+ MenuType,
75+ InputMethodType,
76+ SatelliteType,
77+ TipType,
78+ };
79+
80+ /**
81+ @brief Surface state
82+ */
83+ enum State {
84+ UnknownState,
85+ RestoredState,
86+ MinimizedState,
87+ MaximizedState,
88+ VertMaximizedState,
89+ FullscreenState,
90+ HorizMaximizedState,
91+ HiddenState,
92+ };
93+
94+ /**
95+ @brief Surface orientation angle
96+ */
97+ enum OrientationAngle {
98+ Angle0 = 0,
99+ Angle90 = 90,
100+ Angle180 = 180,
101+ Angle270 = 270
102+ };
103+};
104+
105+Q_DECLARE_METATYPE(Mir::OrientationAngle)
106+
107+#endif // UNITY_SHELL_APPLICATION_MIR_H
108
109=== added file 'include/unity/shell/application/MirSurfaceInterface.h'
110--- include/unity/shell/application/MirSurfaceInterface.h 1970-01-01 00:00:00 +0000
111+++ include/unity/shell/application/MirSurfaceInterface.h 2015-08-19 14:04:26 +0000
112@@ -0,0 +1,114 @@
113+/*
114+ * Copyright (C) 2015 Canonical, Ltd.
115+ *
116+ * This program is free software; you can redistribute it and/or modify
117+ * it under the terms of the GNU General Public License as published by
118+ * the Free Software Foundation; version 3.
119+ *
120+ * This program is distributed in the hope that it will be useful,
121+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
122+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
123+ * GNU General Public License for more details.
124+ *
125+ * You should have received a copy of the GNU General Public License
126+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
127+ */
128+
129+#ifndef UNITY_SHELL_APPLICATION_MIRSURFACE_H
130+#define UNITY_SHELL_APPLICATION_MIRSURFACE_H
131+
132+#include <QObject>
133+#include <QSize>
134+
135+#include "Mir.h"
136+
137+namespace unity
138+{
139+namespace shell
140+{
141+namespace application
142+{
143+
144+/**
145+ @brief Holds a Mir surface. Pretty much an opaque class.
146+
147+ All surface manipulation is done by giving it to a MirSurfaceItem and then
148+ using MirSurfaceItem's properties.
149+ */
150+class MirSurfaceInterface : public QObject
151+{
152+ Q_OBJECT
153+
154+ /**
155+ * @brief The surface type
156+ */
157+ Q_PROPERTY(Mir::Type type READ type NOTIFY typeChanged)
158+
159+ /**
160+ * @brief Name of the surface, given by the client application
161+ */
162+ Q_PROPERTY(QString name READ name CONSTANT)
163+
164+ /**
165+ * @brief Size of the current surface buffer, in pixels.
166+ */
167+ Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
168+
169+ /**
170+ * @brief State of the surface
171+ */
172+ Q_PROPERTY(Mir::State state READ state WRITE setState NOTIFY stateChanged)
173+
174+ /**
175+ * @brief True if it has a mir client bound to it.
176+ * A "zombie" (live == false) surface never becomes alive again.
177+ */
178+ Q_PROPERTY(bool live READ live NOTIFY liveChanged)
179+
180+ /**
181+ * @brief Orientation angle of the surface
182+ *
183+ * How many degrees, clockwise, the UI in the surface has to rotate to match shell's UI orientation
184+ */
185+ Q_PROPERTY(Mir::OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
186+ NOTIFY orientationAngleChanged DESIGNABLE false)
187+
188+public:
189+ /// @cond
190+ MirSurfaceInterface(QObject *parent = nullptr) : QObject(parent) {}
191+ virtual ~MirSurfaceInterface() {}
192+
193+ virtual Mir::Type type() const = 0;
194+
195+ virtual QString name() const = 0;
196+
197+ virtual QSize size() const = 0;
198+ virtual void resize(int width, int height) = 0;
199+ virtual void resize(const QSize &size) = 0;
200+
201+ virtual Mir::State state() const = 0;
202+ virtual void setState(Mir::State qmlState) = 0;
203+
204+ virtual bool live() const = 0;
205+
206+ virtual Mir::OrientationAngle orientationAngle() const = 0;
207+ virtual void setOrientationAngle(Mir::OrientationAngle angle) = 0;
208+ /// @endcond
209+
210+Q_SIGNALS:
211+ /// @cond
212+ void typeChanged(Mir::Type value);
213+ void liveChanged(bool value);
214+ void stateChanged(Mir::State value);
215+ void orientationAngleChanged(Mir::OrientationAngle value);
216+ void sizeChanged(const QSize &value);
217+ /// @endcond
218+};
219+
220+} // namespace application
221+} // namespace shell
222+} // namespace unity
223+
224+Q_DECLARE_METATYPE(unity::shell::application::MirSurfaceInterface*)
225+
226+#endif // UNITY_SHELL_APPLICATION_MIRSURFACE_H
227
228=== added file 'include/unity/shell/application/MirSurfaceItemInterface.h'
229--- include/unity/shell/application/MirSurfaceItemInterface.h 1970-01-01 00:00:00 +0000
230+++ include/unity/shell/application/MirSurfaceItemInterface.h 2015-08-19 14:04:26 +0000
231@@ -0,0 +1,151 @@
232+/*
233+ * Copyright (C) 2015 Canonical, Ltd.
234+ *
235+ * This program is free software; you can redistribute it and/or modify
236+ * it under the terms of the GNU General Public License as published by
237+ * the Free Software Foundation; version 3.
238+ *
239+ * This program is distributed in the hope that it will be useful,
240+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
241+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
242+ * GNU General Public License for more details.
243+ *
244+ * You should have received a copy of the GNU General Public License
245+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
246+ */
247+
248+#ifndef UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H
249+#define UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H
250+
251+#include "Mir.h"
252+
253+#include <QQuickItem>
254+
255+namespace unity
256+{
257+namespace shell
258+{
259+namespace application
260+{
261+
262+class MirSurfaceInterface;
263+
264+/**
265+ @brief Renders a MirSurface in a QML scene and forwards the input events it receives to it.
266+
267+ You can have multiple MirSurfaceItems displaying the same MirSurface. But care must
268+ be taken that only one of them feeds the MirSurface with input events and also only
269+ one resizes it.
270+ */
271+class MirSurfaceItemInterface : public QQuickItem
272+{
273+ Q_OBJECT
274+
275+ /**
276+ * @brief The surface to be displayed
277+ */
278+ Q_PROPERTY(unity::shell::application::MirSurfaceInterface* surface READ surface WRITE setSurface NOTIFY surfaceChanged)
279+
280+ /**
281+ * @brief Type of the given surface or Mir.UnknownType if no surface is set
282+ */
283+ Q_PROPERTY(Mir::Type type READ type NOTIFY typeChanged)
284+
285+ /**
286+ * @brief State of the given surface or Mir.UnknownState if no surface is set
287+ */
288+ Q_PROPERTY(Mir::State surfaceState READ surfaceState WRITE setSurfaceState NOTIFY surfaceStateChanged)
289+
290+ /**
291+ * @brief Name of the given surface or an empty string if no surface is set
292+ */
293+ Q_PROPERTY(QString name READ name CONSTANT)
294+
295+ /**
296+ * @brief True if the item has a surface and that surface has a mir client bound to it.
297+ * A "zombie" (live == false) surface never becomes alive again.
298+ */
299+ Q_PROPERTY(bool live READ live NOTIFY liveChanged)
300+
301+ /**
302+ * @brief Orientation angle of the given surface
303+ *
304+ * How many degrees, clockwise, the UI in the surface has to rotate to match shell's UI orientation
305+ */
306+ Q_PROPERTY(Mir::OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
307+ NOTIFY orientationAngleChanged DESIGNABLE false)
308+
309+
310+ /**
311+ * @brief Whether the item will forward activeFocus, touch events, mouse events and key events to its surface.
312+ * It's false by default.
313+ * Only one item should have this property enabled for a given surface.
314+ */
315+ Q_PROPERTY(bool consumesInput READ consumesInput
316+ WRITE setConsumesInput
317+ NOTIFY consumesInputChanged)
318+
319+ /**
320+ * @brief The desired width for the contained MirSurface.
321+ * It's ignored if set to zero or a negative number
322+ * The default value is zero
323+ */
324+ Q_PROPERTY(int surfaceWidth READ surfaceWidth
325+ WRITE setSurfaceWidth
326+ NOTIFY surfaceWidthChanged)
327+
328+ /**
329+ * @brief The desired height for the contained MirSurface.
330+ * It's ignored if set to zero or a negative number
331+ * The default value is zero
332+ */
333+ Q_PROPERTY(int surfaceHeight READ surfaceHeight
334+ WRITE setSurfaceHeight
335+ NOTIFY surfaceHeightChanged)
336+
337+public:
338+ /// @cond
339+ MirSurfaceItemInterface(QQuickItem *parent = 0) : QQuickItem(parent) {}
340+ virtual ~MirSurfaceItemInterface() {}
341+
342+ virtual Mir::Type type() const = 0;
343+ virtual QString name() const = 0;
344+ virtual bool live() const = 0;
345+
346+ virtual Mir::State surfaceState() const = 0;
347+ virtual void setSurfaceState(Mir::State) = 0;
348+
349+ virtual Mir::OrientationAngle orientationAngle() const = 0;
350+ virtual void setOrientationAngle(Mir::OrientationAngle angle) = 0;
351+
352+ virtual MirSurfaceInterface* surface() const = 0;
353+ virtual void setSurface(MirSurfaceInterface*) = 0;
354+
355+ virtual bool consumesInput() const = 0;
356+ virtual void setConsumesInput(bool value) = 0;
357+
358+ virtual int surfaceWidth() const = 0;
359+ virtual void setSurfaceWidth(int value) = 0;
360+
361+ virtual int surfaceHeight() const = 0;
362+ virtual void setSurfaceHeight(int value) = 0;
363+ /// @endcond
364+
365+Q_SIGNALS:
366+ /// @cond
367+ void typeChanged(Mir::Type);
368+ void surfaceStateChanged(Mir::State);
369+ void liveChanged(bool live);
370+ void orientationAngleChanged(Mir::OrientationAngle angle);
371+ void surfaceChanged(MirSurfaceInterface*);
372+ void consumesInputChanged(bool value);
373+ void surfaceWidthChanged(int value);
374+ void surfaceHeightChanged(int value);
375+ /// @endcond
376+};
377+
378+} // namespace application
379+} // namespace shell
380+} // namespace unity
381+
382+#endif // UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H

Subscribers

People subscribed via source and target branches

to all changes: