Merge lp:~dandrader/unity-api/miral into lp:~unity-team/unity-api/miral

Proposed by Daniel d'Andrada on 2016-11-01
Status: Merged
Merged at revision: 255
Proposed branch: lp:~dandrader/unity-api/miral
Merge into: lp:~unity-team/unity-api/miral
Diff against target: 332 lines (+303/-1)
4 files modified
debian/changelog (+6/-0)
include/unity/shell/application/CMakeLists.txt (+1/-1)
include/unity/shell/application/TopLevelWindowModelInterface.h (+152/-0)
include/unity/shell/application/WindowInterface.h (+144/-0)
To merge this branch: bzr merge lp:~dandrader/unity-api/miral
Reviewer Review Type Date Requested Status
Unity Team 2016-11-01 Pending
Review via email: mp+309787@code.launchpad.net

Commit Message

unity::shel::application - changes for the miral way of doing things

Description of the Change

Adds TopLevelWindowModelInterface and WindowInterface

To post a comment you must log in.

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 2016-09-09 14:39:28 +0000
3+++ debian/changelog 2016-11-01 19:35:04 +0000
4@@ -1,3 +1,9 @@
5+unity-api (7.120) UNRELEASED; urgency=medium
6+
7+ * unity::shel::application - changes for the miral way of doing things
8+
9+ -- Daniel d'Andrada <daniel.dandrada@canonical.com> Tue, 01 Nov 2016 17:25:38 -0200
10+
11 unity-api (7.119+16.10.20160909-0ubuntu1) yakkety; urgency=medium
12
13 [ Daniel d'Andrada ]
14
15=== modified file 'include/unity/shell/application/CMakeLists.txt'
16--- include/unity/shell/application/CMakeLists.txt 2016-09-05 13:21:24 +0000
17+++ include/unity/shell/application/CMakeLists.txt 2016-11-01 19:35:04 +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 22)
23+set(VERSION 23)
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/TopLevelWindowModelInterface.h'
29--- include/unity/shell/application/TopLevelWindowModelInterface.h 1970-01-01 00:00:00 +0000
30+++ include/unity/shell/application/TopLevelWindowModelInterface.h 2016-11-01 19:35:04 +0000
31@@ -0,0 +1,152 @@
32+/*
33+ * Copyright (C) 2016 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_TOPLEVELWINDOWMODELINTERFACE_H
49+#define UNITY_SHELL_APPLICATION_TOPLEVELWINDOWMODELINTERFACE_H
50+
51+#include <QAbstractListModel>
52+
53+namespace unity
54+{
55+namespace shell
56+{
57+namespace application
58+{
59+
60+class ApplicationInfoInterface;
61+class MirSurfaceInterface;
62+class WindowInterface;
63+
64+/**
65+ * @brief A model of top-level surfaces
66+ *
67+ * It's an abstraction of top-level application windows.
68+ *
69+ * When an entry first appears, it normaly doesn't have a surface yet, meaning that the application is
70+ * still starting up. A shell should then display a splash screen or saved screenshot of the application
71+ * until its surface comes up.
72+ *
73+ * As applications can have multiple surfaces and you can also have entries without surfaces at all,
74+ * the only way to unambiguously refer to an entry in this model is through its id.
75+ */
76+class TopLevelWindowModelInterface : public QAbstractListModel
77+{
78+ Q_OBJECT
79+
80+ /**
81+ * @brief Number of top-level surfaces in this model
82+ *
83+ * This is the same as rowCount, added in order to keep compatibility with QML ListModels.
84+ */
85+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
86+
87+ /**
88+ * @brief The input method surface, if any
89+ *
90+ * The surface of a onscreen keyboard (akak "virtual keyboard") would be kept here and not in the model itself.
91+ */
92+ Q_PROPERTY(unity::shell::application::MirSurfaceInterface* inputMethodSurface READ inputMethodSurface NOTIFY inputMethodSurfaceChanged)
93+
94+ /**
95+ * @brief The currently focused window, if any
96+ */
97+ Q_PROPERTY(unity::shell::application::WindowInterface* focusedWindow READ focusedWindow
98+ NOTIFY focusedWindowChanged)
99+public:
100+ /**
101+ * @brief The Roles supported by the model
102+ *
103+ * WindowRole - A WindowInterface. It will be null if the application is still starting up
104+ * ApplicationRole - An ApplicationInfoInterface
105+ */
106+ enum Roles {
107+ WindowRole = Qt::UserRole,
108+ ApplicationRole = Qt::UserRole + 1,
109+ };
110+
111+ virtual ~TopLevelWindowModelInterface() {}
112+
113+ QHash<int, QByteArray> roleNames() const override {
114+ QHash<int, QByteArray> roleNames { {WindowRole, "window"},
115+ {ApplicationRole, "application"} };
116+ return roleNames;
117+ }
118+
119+ /// @cond
120+ virtual MirSurfaceInterface* inputMethodSurface() const = 0;
121+ virtual WindowInterface* focusedWindow() const = 0;
122+ /// @endcond
123+
124+public Q_SLOTS:
125+ /**
126+ * @brief Returns the surface at the given index
127+ *
128+ * It will be a nullptr if the application is still starting up and thus hasn't yet created
129+ * and drawn into a surface.
130+ *
131+ * Same as windowAt(index).surface()
132+ */
133+ virtual MirSurfaceInterface *surfaceAt(int index) const = 0;
134+
135+ /**
136+ * @brief Returns the window at the given index
137+ *
138+ * Will always be valid
139+ */
140+ virtual WindowInterface *windowAt(int index) const = 0;
141+
142+ /**
143+ * @brief Returns the application at the given index
144+ */
145+ virtual ApplicationInfoInterface *applicationAt(int index) const = 0;
146+
147+ /**
148+ * @brief Returns the unique id of the element at the given index
149+ */
150+ virtual int idAt(int index) const = 0;
151+
152+ /**
153+ * @brief Returns the index where the row with the given id is located
154+ *
155+ * Returns -1 if there's no row with the given id.
156+ */
157+ virtual int indexForId(int id) const = 0;
158+
159+ /**
160+ * @brief Raises the row with the given id to the top of the window stack (index == count-1)
161+ */
162+ virtual void raiseId(int id) = 0;
163+
164+Q_SIGNALS:
165+ /// @cond
166+ void countChanged();
167+ void inputMethodSurfaceChanged(unity::shell::application::MirSurfaceInterface* inputMethodSurface);
168+ void focusedWindowChanged(unity::shell::application::WindowInterface *focusedWindow);
169+ /// @endcond
170+
171+ /**
172+ * @brief Emitted when the list changes
173+ *
174+ * Emitted when model gains an element, loses an element or when elements exchange positions.
175+ */
176+ void listChanged();
177+};
178+
179+} // namespace application
180+} // namespace shell
181+} // namespace unity
182+
183+#endif // UNITY_SHELL_APPLICATION_TOPLEVELWINDOWMODELINTERFACE_H
184
185=== added file 'include/unity/shell/application/WindowInterface.h'
186--- include/unity/shell/application/WindowInterface.h 1970-01-01 00:00:00 +0000
187+++ include/unity/shell/application/WindowInterface.h 2016-11-01 19:35:04 +0000
188@@ -0,0 +1,144 @@
189+/*
190+ * Copyright (C) 2016 Canonical, Ltd.
191+ *
192+ * This program is free software; you can redistribute it and/or modify
193+ * it under the terms of the GNU General Public License as published by
194+ * the Free Software Foundation; version 3.
195+ *
196+ * This program is distributed in the hope that it will be useful,
197+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
198+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
199+ * GNU General Public License for more details.
200+ *
201+ * You should have received a copy of the GNU General Public License
202+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
203+ */
204+
205+#ifndef UNITY_SHELL_APPLICATION_WINDOW_H
206+#define UNITY_SHELL_APPLICATION_WINDOW_H
207+
208+#include <QObject>
209+#include <QPoint>
210+
211+#include "Mir.h"
212+
213+namespace unity
214+{
215+namespace shell
216+{
217+namespace application
218+{
219+
220+class MirSurfaceInterface;
221+
222+/**
223+ @brief A slightly higher concept than MirSurface
224+
225+ A Window exists before its MirSurface gets created (for splashscreen purposes)
226+ and might also hang around after the backing surface is gone (In case the application
227+ was killed to free up memory, as it should still remain in the window list since the user
228+ did not explicitly close it).
229+ */
230+class WindowInterface : public QObject
231+{
232+ Q_OBJECT
233+
234+ /**
235+ * @brief Position of the current surface buffer, in pixels.
236+ */
237+ Q_PROPERTY(QPoint position READ position NOTIFY positionChanged)
238+
239+ /**
240+ * @brief Requested position of the current surface buffer, in pixels.
241+ */
242+ Q_PROPERTY(QPoint requestedPosition READ requestedPosition WRITE setRequestedPosition NOTIFY requestedPositionChanged)
243+
244+ /**
245+ * @brief State of the surface
246+ */
247+ Q_PROPERTY(Mir::State state READ state NOTIFY stateChanged)
248+
249+ /**
250+ * @brief Whether the surface is focused
251+ *
252+ * It will be true if this surface is MirFocusControllerInterface::focusedSurface
253+ */
254+ Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged)
255+
256+ /**
257+ * @brief Whether the surface wants to confine the mouse pointer within its boundaries
258+ *
259+ * If true, the surface doesn't want the mouse pointer to leave its boundaries while it's focused.
260+ */
261+ Q_PROPERTY(bool confinesMousePointer READ confinesMousePointer NOTIFY confinesMousePointerChanged)
262+
263+ /**
264+ * @brief A unique identifier for this window.
265+ * Useful for telling windows apart in a list model as they get moved around
266+ */
267+ Q_PROPERTY(int id READ id CONSTANT)
268+
269+ /**
270+ * @brief Surface backing up this window
271+ * It might be null if a surface hasn't been created yet (application is starting up) or if
272+ * the corresponding application has been killed (but can still get restarted to continue from
273+ * where it left)
274+ */
275+ Q_PROPERTY(unity::shell::application::MirSurfaceInterface* surface READ surface NOTIFY surfaceChanged)
276+
277+public:
278+ /// @cond
279+ WindowInterface(QObject *parent = nullptr) : QObject(parent) {}
280+ virtual QPoint position() const = 0;
281+ virtual QPoint requestedPosition() const = 0;
282+ virtual void setRequestedPosition(const QPoint &) = 0;
283+ virtual Mir::State state() const = 0;
284+ virtual bool focused() const = 0;
285+ virtual bool confinesMousePointer() const = 0;
286+ virtual int id() const = 0;
287+ virtual MirSurfaceInterface* surface() const = 0;
288+ /// @endcond
289+
290+public Q_SLOTS:
291+ /**
292+ * @brief Requests a change to the specified state
293+ */
294+ virtual void requestState(Mir::State state) = 0;
295+
296+ /**
297+ * @brief Requests focus for this surface
298+ *
299+ * Causes the emission of focusRequested()
300+ */
301+ virtual void requestFocus() = 0;
302+
303+ /**
304+ * @brief Sends a close request
305+ *
306+ */
307+ virtual void close() = 0;
308+
309+Q_SIGNALS:
310+ /// @cond
311+ void positionChanged(QPoint position);
312+ void requestedPositionChanged(QPoint position);
313+ void stateChanged(Mir::State value);
314+ void focusedChanged(bool value);
315+ void confinesMousePointerChanged(bool value);
316+ void surfaceChanged(unity::shell::application::MirSurfaceInterface *surface);
317+ /// @endcond
318+
319+ /**
320+ * @brief Emitted in response to a requestFocus() call
321+ */
322+ void focusRequested();
323+};
324+
325+
326+} // namespace application
327+} // namespace shell
328+} // namespace unity
329+
330+Q_DECLARE_METATYPE(unity::shell::application::WindowInterface*)
331+
332+#endif // UNITY_SHELL_APPLICATION_WINDOw_H

Subscribers

People subscribed via source and target branches

to all changes: