Merge lp:~dandrader/qtmir/detachPromptSurfaces into lp:qtmir

Proposed by Daniel d'Andrada
Status: Superseded
Proposed branch: lp:~dandrader/qtmir/detachPromptSurfaces
Merge into: lp:qtmir
Prerequisite: lp:~dandrader/qtmir/fixProxySurfaceListCount
Diff against target: 397 lines (+44/-88)
14 files modified
debian/control (+2/-2)
debian/gles-patches/convert-to-gles.patch (+1/-1)
src/modules/Unity/Application/application.cpp (+7/-0)
src/modules/Unity/Application/application.h (+2/-0)
src/modules/Unity/Application/mirsurface.cpp (+0/-5)
src/modules/Unity/Application/mirsurface.h (+0/-4)
src/modules/Unity/Application/mirsurfacelistmodel.cpp (+11/-0)
src/modules/Unity/Application/session.cpp (+12/-24)
src/modules/Unity/Application/session.h (+2/-5)
src/modules/Unity/Application/session_interface.h (+3/-0)
tests/framework/fake_mirsurface.h (+0/-4)
tests/framework/fake_session.cpp (+2/-0)
tests/framework/fake_session.h (+2/-0)
tests/modules/SessionManager/session_test.cpp (+0/-43)
To merge this branch: bzr merge lp:~dandrader/qtmir/detachPromptSurfaces
Reviewer Review Type Date Requested Status
Nick Dedekind (community) Needs Fixing
Unity8 CI Bot (community) continuous-integration Needs Fixing
Review via email: mp+294954@code.launchpad.net

This proposal has been superseded by a proposal from 2016-05-18.

Commit message

Move prompt surfaces from MirSurface to Application and emit firstChanged signal

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~dandrader/unity-api/detachPromptSurfaces/+merge/294955
https://code.launchpad.net/~dandrader/unity8/detachPromptSurfaces/+merge/294959

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable

To post a comment you must log in.
489. By Daniel d'Andrada

Update unity-api versions

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
490. By Daniel d'Andrada

Fix code

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) :
review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Replied to inline comment

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2016-04-28 12:48:42 +0000
3+++ debian/control 2016-05-17 19:58:11 +0000
4@@ -22,7 +22,7 @@
5 libubuntu-app-launch2-dev (>= 0.9),
6 libubuntu-application-api-dev (>= 2.1.0),
7 libudev-dev,
8- libunity-api-dev (>= 7.110),
9+ libunity-api-dev (>= 7.112),
10 liburl-dispatcher1-dev,
11 libxkbcommon-dev,
12 libxrender-dev,
13@@ -93,7 +93,7 @@
14 Conflicts: libqtmir,
15 libunity-mir1,
16 Provides: unity-application-impl,
17- unity-application-impl-15,
18+ unity-application-impl-16,
19 Description: Qt plugin for Unity specific Mir APIs
20 QtMir provides Qt/QML bindings for Mir features that are exposed through the
21 qtmir-desktop or qtmir-android QPA plugin such as Application management
22
23=== modified file 'debian/gles-patches/convert-to-gles.patch'
24--- debian/gles-patches/convert-to-gles.patch 2016-04-06 18:12:31 +0000
25+++ debian/gles-patches/convert-to-gles.patch 2016-05-17 19:58:11 +0000
26@@ -84,7 +84,7 @@
27 -Conflicts: libqtmir,
28 - libunity-mir1,
29 -Provides: unity-application-impl,
30-- unity-application-impl-15,
31+- unity-application-impl-16,
32 -Description: Qt plugin for Unity specific Mir APIs
33 - QtMir provides Qt/QML bindings for Mir features that are exposed through the
34 - qtmir-desktop or qtmir-android QPA plugin such as Application management
35
36=== modified file 'src/modules/Unity/Application/application.cpp'
37--- src/modules/Unity/Application/application.cpp 2016-04-26 08:56:36 +0000
38+++ src/modules/Unity/Application/application.cpp 2016-05-17 19:58:11 +0000
39@@ -486,6 +486,7 @@
40
41 if (m_session) {
42 m_proxySurfaceList.setSourceList(nullptr);
43+ m_proxyPromptSurfaceList.setSourceList(nullptr);
44 m_session->disconnect(this);
45 m_session->surfaceList()->disconnect(this);
46 m_session->setApplication(nullptr);
47@@ -527,6 +528,7 @@
48 Q_EMIT fullscreenChanged(fullscreen());
49
50 m_proxySurfaceList.setSourceList(m_session->surfaceList());
51+ m_proxyPromptSurfaceList.setSourceList(m_session->promptSurfaceList());
52 } else {
53 // this can only happen after the session has stopped
54 Q_ASSERT(m_state == InternalState::Stopped || m_state == InternalState::StoppedResumable
55@@ -829,6 +831,11 @@
56 return &m_proxySurfaceList;
57 }
58
59+unityapp::MirSurfaceListInterface* Application::promptSurfaceList()
60+{
61+ return &m_proxyPromptSurfaceList;
62+}
63+
64 void Application::requestFocus()
65 {
66 if (m_proxySurfaceList.rowCount() > 0) {
67
68=== modified file 'src/modules/Unity/Application/application.h'
69--- src/modules/Unity/Application/application.h 2016-04-26 08:56:36 +0000
70+++ src/modules/Unity/Application/application.h 2016-05-17 19:58:11 +0000
71@@ -109,6 +109,7 @@
72 QSize initialSurfaceSize() const override;
73 void setInitialSurfaceSize(const QSize &size) override;
74 unity::shell::application::MirSurfaceListInterface* surfaceList() override;
75+ unity::shell::application::MirSurfaceListInterface* promptSurfaceList() override;
76
77 ProcessState processState() const { return m_processState; }
78 void setProcessState(ProcessState value);
79@@ -191,6 +192,7 @@
80 bool m_closing{false};
81
82 ProxySurfaceListModel m_proxySurfaceList;
83+ ProxySurfaceListModel m_proxyPromptSurfaceList;
84
85 friend class ApplicationManager;
86 friend class SessionManager;
87
88=== modified file 'src/modules/Unity/Application/mirsurface.cpp'
89--- src/modules/Unity/Application/mirsurface.cpp 2016-04-26 08:30:26 +0000
90+++ src/modules/Unity/Application/mirsurface.cpp 2016-05-17 19:58:11 +0000
91@@ -956,11 +956,6 @@
92 return m_focused;
93 }
94
95-unity::shell::application::MirSurfaceListInterface* MirSurface::promptSurfaceList()
96-{
97- return &m_promptSurfaceList;
98-}
99-
100 void MirSurface::requestFocus()
101 {
102 DEBUG_MSG << "()";
103
104=== modified file 'src/modules/Unity/Application/mirsurface.h'
105--- src/modules/Unity/Application/mirsurface.h 2016-04-26 08:30:26 +0000
106+++ src/modules/Unity/Application/mirsurface.h 2016-05-17 19:58:11 +0000
107@@ -88,8 +88,6 @@
108
109 bool focused() const override;
110
111- unity::shell::application::MirSurfaceListInterface* promptSurfaceList() override;
112-
113 Q_INVOKABLE void requestFocus() override;
114 Q_INVOKABLE void close() override;
115 Q_INVOKABLE void raise() override;
116@@ -229,8 +227,6 @@
117 };
118 ClosingState m_closingState{NotClosing};
119 AbstractTimer *m_closeTimer{nullptr};
120-
121- MirSurfaceListModel m_promptSurfaceList;
122 };
123
124 } // namespace qtmir
125
126=== modified file 'src/modules/Unity/Application/mirsurfacelistmodel.cpp'
127--- src/modules/Unity/Application/mirsurfacelistmodel.cpp 2016-05-17 19:58:11 +0000
128+++ src/modules/Unity/Application/mirsurfacelistmodel.cpp 2016-05-17 19:58:11 +0000
129@@ -68,6 +68,7 @@
130 Q_EMIT countChanged();
131 if (count() == 1) {
132 Q_EMIT emptyChanged();
133+ Q_EMIT firstChanged();
134 }
135 }
136
137@@ -88,6 +89,9 @@
138 if (count() == 0) {
139 Q_EMIT emptyChanged();
140 }
141+ if (i == 0) {
142+ Q_EMIT firstChanged();
143+ }
144 }
145 }
146
147@@ -105,6 +109,10 @@
148 m_surfaceList.move(from, to);
149 endMoveRows();
150 }
151+
152+ if ((from == 0 || to == 0) && m_surfaceList.count() > 1) {
153+ Q_EMIT firstChanged();
154+ }
155 }
156
157 unityapp::MirSurfaceInterface *MirSurfaceListModel::get(int index)
158@@ -143,6 +151,7 @@
159 if (wasEmpty) {
160 Q_EMIT emptyChanged();
161 }
162+ Q_EMIT firstChanged();
163 }
164
165 void MirSurfaceListModel::addSurfaceList(MirSurfaceListModel *surfaceListModel)
166@@ -233,6 +242,8 @@
167 connect(m_sourceList, &QObject::destroyed, this, [this]() { this->setSourceList(nullptr); });
168 connect(m_sourceList, &unityapp::MirSurfaceListInterface::countChanged,
169 this, &unityapp::MirSurfaceListInterface::countChanged);
170+ connect(m_sourceList, &unityapp::MirSurfaceListInterface::firstChanged,
171+ this, &unityapp::MirSurfaceListInterface::firstChanged);
172 }
173
174 endResetModel();
175
176=== modified file 'src/modules/Unity/Application/session.cpp'
177--- src/modules/Unity/Application/session.cpp 2016-05-10 20:13:37 +0000
178+++ src/modules/Unity/Application/session.cpp 2016-05-17 19:58:11 +0000
179@@ -137,6 +137,11 @@
180 return &m_surfaceList;
181 }
182
183+MirSurfaceListModel* Session::promptSurfaceList()
184+{
185+ return &m_promptSurfaceList;
186+}
187+
188 Session::State Session::state() const
189 {
190 return m_state;
191@@ -199,14 +204,8 @@
192 if (newSurface->isFirstFrameDrawn()) {
193 prependSurface(newSurface);
194 } else {
195- m_blankSurfaces.append(newSurface);
196- connect(newSurface, &QObject::destroyed, this, [this, newSurface]()
197- {
198- this->m_blankSurfaces.removeAll(newSurface);
199- });
200 connect(newSurface, &MirSurfaceInterface::firstFrameDrawn, this, [this, newSurface]()
201 {
202- this->m_blankSurfaces.removeAll(newSurface);
203 newSurface->disconnect(this);
204 this->prependSurface(newSurface);
205 });
206@@ -393,32 +392,19 @@
207 void Session::addChildSession(SessionInterface* session)
208 {
209 insertChildSession(m_children->rowCount(), session);
210-
211- if (m_surfaceList.count() > 0) {
212- // we assume that the top-most surface is the one that caused the prompt session to show up.
213- auto promptSurfaceList = static_cast<MirSurfaceListModel*>(m_surfaceList.get(0)->promptSurfaceList());
214- promptSurfaceList->addSurfaceList(session->surfaceList());
215- } else if (m_blankSurfaces.count() > 0) {
216- // Prompt session came in too early.
217- // Parent session might be blocked until the prompt session is dismissed.
218- // So we cannot wait anymore and must put that blank surface on the surface list so that the
219- // user can see the prompt surface on top of that it and interact.
220- auto blankSurface = m_blankSurfaces.takeFirst();
221-
222- auto promptSurfaceList = static_cast<MirSurfaceListModel*>(blankSurface->promptSurfaceList());
223- promptSurfaceList->addSurfaceList(session->surfaceList());
224-
225- blankSurface->disconnect(this);
226- prependSurface(blankSurface);
227- }
228 }
229
230 void Session::insertChildSession(uint index, SessionInterface* session)
231 {
232 qCDebug(QTMIR_SESSIONS) << "Session::insertChildSession - " << session->name() << " to " << name() << " @ " << index;
233+ Q_ASSERT(!m_children->contains(session));
234
235 m_children->insert(index, session);
236
237+ // Flatten the list of prompt surfaces
238+ m_promptSurfaceList.addSurfaceList(session->surfaceList());
239+ m_promptSurfaceList.addSurfaceList(session->promptSurfaceList());
240+
241 connect(session, &QObject::destroyed, this, [this, session]() { this->removeChildSession(session); });
242
243 switch (m_state) {
244@@ -444,6 +430,8 @@
245
246 if (m_children->contains(session)) {
247 m_children->remove(session);
248+ m_promptSurfaceList.removeSurfaceList(session->surfaceList());
249+ m_promptSurfaceList.removeSurfaceList(session->promptSurfaceList());
250 }
251
252 deleteIfZombieAndEmpty();
253
254=== modified file 'src/modules/Unity/Application/session.h'
255--- src/modules/Unity/Application/session.h 2016-05-10 20:13:37 +0000
256+++ src/modules/Unity/Application/session.h 2016-05-17 19:58:11 +0000
257@@ -51,6 +51,7 @@
258 QString name() const override;
259 unity::shell::application::ApplicationInfoInterface* application() const override;
260 MirSurfaceListModel* surfaceList() override;
261+ MirSurfaceListModel* promptSurfaceList() override;
262 State state() const override;
263 bool fullscreen() const override;
264 bool live() const override;
265@@ -107,11 +108,7 @@
266 std::shared_ptr<mir::scene::Session> m_session;
267 Application* m_application;
268 MirSurfaceListModel m_surfaceList;
269-
270- // Registered surfaces that haven't yet drawn their first frames.
271- // Once they do, they get moved to m_surfaceList.
272- // So this list is just a temporary holder and most of the time it's gonna be empty.
273- QList<MirSurfaceInterface*> m_blankSurfaces;
274+ MirSurfaceListModel m_promptSurfaceList;
275
276 SessionModel* m_children;
277 bool m_fullscreen;
278
279=== modified file 'src/modules/Unity/Application/session_interface.h'
280--- src/modules/Unity/Application/session_interface.h 2016-04-06 16:52:49 +0000
281+++ src/modules/Unity/Application/session_interface.h 2016-05-17 19:58:11 +0000
282@@ -68,6 +68,9 @@
283 // List of surfaces in this session. Surfaces that are being forcibly closed are not present in this list
284 virtual MirSurfaceListModel* surfaceList() = 0;
285
286+ // List of prompt surfaces under this session (and its children)
287+ virtual MirSurfaceListModel* promptSurfaceList() = 0;
288+
289 virtual SessionModel* childSessions() const = 0;
290 virtual State state() const = 0;
291 virtual bool fullscreen() const = 0;
292
293=== modified file 'tests/framework/fake_mirsurface.h'
294--- tests/framework/fake_mirsurface.h 2016-04-26 08:30:26 +0000
295+++ tests/framework/fake_mirsurface.h 2016-05-17 19:58:11 +0000
296@@ -77,8 +77,6 @@
297
298 bool focused() const override { return false; }
299
300- unity::shell::application::MirSurfaceListInterface* promptSurfaceList() override { return &m_promptSurfaceList;}
301-
302 void requestFocus() override {
303 Q_EMIT focusRequested();
304 }
305@@ -175,8 +173,6 @@
306
307 QList<TouchEvent> m_touchesReceived;
308
309- MirSurfaceListModel m_promptSurfaceList;
310-
311 SessionInterface *m_session{nullptr};
312 };
313
314
315=== modified file 'tests/framework/fake_session.cpp'
316--- tests/framework/fake_session.cpp 2016-03-28 18:02:26 +0000
317+++ tests/framework/fake_session.cpp 2016-05-17 19:58:11 +0000
318@@ -36,6 +36,8 @@
319
320 MirSurfaceListModel* FakeSession::surfaceList() { return &m_surfaceList; }
321
322+MirSurfaceListModel* FakeSession::promptSurfaceList() { return &m_promptSurfaceList; }
323+
324 SessionModel *FakeSession::childSessions() const { return nullptr; }
325
326 SessionInterface::State FakeSession::state() const { return m_state; }
327
328=== modified file 'tests/framework/fake_session.h'
329--- tests/framework/fake_session.h 2016-03-28 18:02:26 +0000
330+++ tests/framework/fake_session.h 2016-05-17 19:58:11 +0000
331@@ -34,6 +34,7 @@
332 QString name() const override;
333 unity::shell::application::ApplicationInfoInterface* application() const override;
334 MirSurfaceListModel* surfaceList() override;
335+ MirSurfaceListModel* promptSurfaceList() override;
336 SessionModel* childSessions() const override;
337 State state() const override;
338 bool fullscreen() const override;
339@@ -81,6 +82,7 @@
340 State m_state;
341 std::shared_ptr<mir::scene::Session> m_session;
342 MirSurfaceListModel m_surfaceList;
343+ MirSurfaceListModel m_promptSurfaceList;
344 };
345
346 } // namespace qtmi
347
348=== modified file 'tests/modules/SessionManager/session_test.cpp'
349--- tests/modules/SessionManager/session_test.cpp 2016-05-10 20:13:37 +0000
350+++ tests/modules/SessionManager/session_test.cpp 2016-05-17 19:58:11 +0000
351@@ -311,46 +311,3 @@
352 EXPECT_EQ(Session::Stopped, session->state());
353 EXPECT_FALSE(session->m_suspendTimer->isRunning());
354 }
355-
356-/*
357- Regression test for https://bugs.launchpad.net/ubuntu/+source/qtmir/+bug/1578665
358-
359- A child prompt session was arriving before the application surface got a chance to draw
360- its first frame. And on top of that, the application was blocked from drawing anything
361- until that prompt session gone away.
362- */
363-TEST_F(SessionTests, ChildSessionArrivesBeforeSurfaceDrawnFirstFrame)
364-{
365- using namespace testing;
366-
367- const QString appId("test-app");
368- const pid_t procId = 5551;
369-
370- auto mirSession = std::make_shared<MockSession>(appId.toStdString(), procId);
371-
372- auto session = std::make_shared<qtmir::Session>(mirSession, promptSessionManager);
373-
374- FakeMirSurface *blankSurface = new FakeMirSurface;
375- session->registerSurface(blankSurface);
376-
377- // Surface doesn't appear in this list as it has not drawn its first frame yet
378- EXPECT_EQ(0, session->surfaceList()->count());
379-
380- Session* childSession = new Session(mirSession, promptSessionManager);
381- session->addChildSession(childSession);
382-
383- FakeMirSurface *promptSurface = new FakeMirSurface;
384- childSession->registerSurface(promptSurface);
385- promptSurface->drawFirstFrame();
386-
387- // Even though blankSurface still hasn't drawn its first frame (ie, it's still blank),
388- // it should now appear in this list as it now has a child prompt surface, which the
389- // user must interact with.
390- auto sessionSurfaceList = static_cast<MirSurfaceListModel*>(session->surfaceList());
391- EXPECT_EQ(1, sessionSurfaceList->count());
392- EXPECT_TRUE(sessionSurfaceList->contains(blankSurface));
393-
394- auto promptSurfaceList = static_cast<MirSurfaceListModel*>(blankSurface->promptSurfaceList());
395- EXPECT_EQ(1, promptSurfaceList->count());
396- EXPECT_TRUE(promptSurfaceList->contains(promptSurface));
397-}

Subscribers

People subscribed via source and target branches