Merge lp:~dandrader/qtmir/miral-surfaceLocalPos into lp:~unity-team/qtmir/miral-qt-integration

Proposed by Daniel d'Andrada
Status: Superseded
Proposed branch: lp:~dandrader/qtmir/miral-surfaceLocalPos
Merge into: lp:~unity-team/qtmir/miral-qt-integration
Diff against target: 342 lines (+116/-22)
9 files modified
CMakeLists.txt (+1/-5)
debian/changelog (+7/-2)
src/modules/Unity/Application/application_manager.cpp (+2/-3)
src/modules/Unity/Application/application_manager.h (+1/-6)
src/modules/Unity/Application/mirsurface.cpp (+49/-4)
src/modules/Unity/Application/mirsurface.h (+14/-1)
src/modules/Unity/Application/surfacemanager.cpp (+38/-1)
src/modules/Unity/Application/surfacemanager.h (+1/-0)
tests/framework/fake_mirsurface.h (+3/-0)
To merge this branch: bzr merge lp:~dandrader/qtmir/miral-surfaceLocalPos
Reviewer Review Type Date Requested Status
Lukáš Tinkl (community) Needs Fixing
Gerry Boland code Pending
Unity8 CI Bot continuous-integration Pending
Review via email: mp+312062@code.launchpad.net

This proposal supersedes a proposal from 2016-11-28.

This proposal has been superseded by a proposal from 2016-12-16.

Commit message

Changes need for child windows support

- MirSurface::parentSurface
- MirSurface::childSurfaceList
- MirSurface::position in local coordinates

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

+ // assumes parent won't be detroyed before its children
typo.
Time will tell how correct this assumption is :)

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

On 29/11/2016 11:03, Gerry Boland wrote:
> Review: Needs Fixing
>
> + // assumes parent won't be detroyed before its children
> typo.
> Time will tell how correct this assumption is :)

Fixed.

Indeed.

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Code looks ok, not tested though

review: Approve (code)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
575. By Brandon Schaefer

Mir 0.25 compat

576. By CI Train Bot Account

Releasing 0.5.0+17.04.20161203-0ubuntu1

577. By CI Train Bot Account

First release using MirAL

578. By Daniel d'Andrada

Get rid of the ApplicationManager::Factory class

It's useless

Approved by: Gerry Boland, Unity8 CI Bot

579. By Daniel d'Andrada

Enable tests in Xenial

This workaround was needed only for the glib version present in Vivid

Approved by: Gerry Boland, Unity8 CI Bot

580. By CI Train Bot Account

Releasing 0.5.1+17.04.20161216-0ubuntu1

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

You should probably reflect the new unity-api dependency here on https://code.launchpad.net/~dandrader/unity-api/parentSurface/+merge/313056 by bumping the required version

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 16/12/2016 12:46, Lukáš Tinkl wrote:
> Review: Needs Fixing
>
> You should probably reflect the new unity-api dependency here on https://code.launchpad.net/~dandrader/unity-api/parentSurface/+merge/313056 by bumping the required version

Done.

581. By Łukasz Zemczak

No-change rebuild against latest miral.

582. By Albert Astals Cid

Specify C++14 in a more CMake-ish way

Works better when building with Qt 5.7 otherwise one would say C++14, the other C++11 and things would not work out (LP: #1653902)

Approved by: Gerry Boland

583. By CI Train Bot Account

Releasing 0.5.1+17.04.20170104-0ubuntu1

584. By CI Train Bot Account

Resync trunk.

585. By Lukáš Tinkl

Some assorted cleanups and small optimizations

Approved by: Gerry Boland, Unity8 CI Bot

586. By Lukáš Tinkl

Apply default device keymap (LP: #1626435)

Approved by: Gerry Boland, Unity8 CI Bot

587. By Gerry Boland

Recalculate MirSurface.visible after first frame swap by client

Fixes issue where OSK would be invisible at startup (LP: #1649077)

Approved by: Nick Dedekind, Unity8 CI Bot

588. By CI Train Bot Account

Releasing 0.5.1+17.04.20170124-0ubuntu1

589. By Cemil Azizoglu

Mir 0.26 compatibility branch for QtMir.

Approved by: Gerry Boland

590. By CI Train Bot Account

Releasing 0.5.1+17.04.20170127-0ubuntu1

591. By Daniel d'Andrada

MirSurface: parentSurface, childSurfaceList and position in local coords

Unmerged revisions

591. By Daniel d'Andrada

MirSurface: parentSurface, childSurfaceList and position in local coords

590. By CI Train Bot Account

Releasing 0.5.1+17.04.20170127-0ubuntu1

589. By Cemil Azizoglu

Mir 0.26 compatibility branch for QtMir.

Approved by: Gerry Boland

588. By CI Train Bot Account

Releasing 0.5.1+17.04.20170124-0ubuntu1

587. By Gerry Boland

Recalculate MirSurface.visible after first frame swap by client

Fixes issue where OSK would be invisible at startup (LP: #1649077)

Approved by: Nick Dedekind, Unity8 CI Bot

586. By Lukáš Tinkl

Apply default device keymap (LP: #1626435)

Approved by: Gerry Boland, Unity8 CI Bot

585. By Lukáš Tinkl

Some assorted cleanups and small optimizations

Approved by: Gerry Boland, Unity8 CI Bot

584. By CI Train Bot Account

Resync trunk.

583. By CI Train Bot Account

Releasing 0.5.1+17.04.20170104-0ubuntu1

582. By Albert Astals Cid

Specify C++14 in a more CMake-ish way

Works better when building with Qt 5.7 otherwise one would say C++14, the other C++11 and things would not work out (LP: #1653902)

Approved by: Gerry Boland

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-12-13 15:31:26 +0000
3+++ CMakeLists.txt 2016-12-16 15:01:40 +0000
4@@ -88,7 +88,7 @@
5 pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
6 pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)
7 pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)
8-pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=23)
9+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=24)
10 pkg_check_modules(CGMANAGER libcgmanager REQUIRED)
11 pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED)
12
13@@ -166,10 +166,6 @@
14 # Tests
15 if (NO_TESTS)
16 message(STATUS "Tests disabled")
17-# glibc on Vivid+Overlay has a bug which causes LTTng-enabled tests to hang. It is hard to get the glibc version
18-# in cmake, so it is easier to check for the LTTng on V+O and gate on that instead.
19-elseif (LTTNG_VERSION VERSION_EQUAL 2.7.1)
20- message(STATUS "Tests disabled due to bug with glibc causing lttng to hang (lp:1618201)")
21 else()
22 include(CTest)
23 enable_testing()
24
25=== modified file 'debian/changelog'
26--- debian/changelog 2016-12-13 15:31:26 +0000
27+++ debian/changelog 2016-12-16 15:01:40 +0000
28@@ -1,8 +1,13 @@
29-qtmir (0.5.1) UNRELEASED; urgency=medium
30+qtmir (0.5.1+17.04.20161216-0ubuntu1) zesty; urgency=medium
31
32+ [ Gerry Boland ]
33 * First release using MirAL
34
35- -- Gerry Boland <gerry.boland@canonical.com> Fri, 14 Oct 2016 16:51:26 +0100
36+ [ Daniel d'Andrada ]
37+ * Get rid of the ApplicationManager::Factory class
38+ * Enable tests in Xenial
39+
40+ -- Daniel d'Andrada <daniel.dandrada@canonical.com> Fri, 16 Dec 2016 08:25:00 +0000
41
42 qtmir (0.5.0+17.04.20161203-0ubuntu1) zesty; urgency=medium
43
44
45=== modified file 'src/modules/Unity/Application/application_manager.cpp'
46--- src/modules/Unity/Application/application_manager.cpp 2016-12-07 11:17:13 +0000
47+++ src/modules/Unity/Application/application_manager.cpp 2016-12-16 15:01:40 +0000
48@@ -97,7 +97,7 @@
49
50 } // namespace
51
52-ApplicationManager* ApplicationManager::Factory::Factory::create()
53+ApplicationManager* ApplicationManager::create()
54 {
55 NativeInterface *nativeInterface = dynamic_cast<NativeInterface*>(QGuiApplication::platformNativeInterface());
56
57@@ -150,8 +150,7 @@
58 {
59 static ApplicationManager* instance;
60 if (!instance) {
61- Factory appFactory;
62- instance = appFactory.create();
63+ instance = create();
64 }
65 return instance;
66 }
67
68=== modified file 'src/modules/Unity/Application/application_manager.h'
69--- src/modules/Unity/Application/application_manager.h 2016-12-07 11:17:13 +0000
70+++ src/modules/Unity/Application/application_manager.h 2016-12-16 15:01:40 +0000
71@@ -63,12 +63,7 @@
72 Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
73
74 public:
75- class Factory
76- {
77- public:
78- ApplicationManager* create();
79- };
80-
81+ static ApplicationManager* create();
82 static ApplicationManager* singleton();
83
84 explicit ApplicationManager(
85
86=== modified file 'src/modules/Unity/Application/mirsurface.cpp'
87--- src/modules/Unity/Application/mirsurface.cpp 2016-11-25 15:23:36 +0000
88+++ src/modules/Unity/Application/mirsurface.cpp 2016-12-16 15:01:40 +0000
89@@ -47,6 +47,7 @@
90 #include <limits>
91
92 using namespace qtmir;
93+namespace unityapi = unity::shell::application;
94
95 #define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__
96 #define WARNING_MSG qCWarning(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__
97@@ -108,7 +109,8 @@
98
99 MirSurface::MirSurface(NewWindow newWindowInfo,
100 WindowControllerInterface* controller,
101- SessionInterface *session)
102+ SessionInterface *session,
103+ MirSurface *parentSurface)
104 : MirSurfaceInterface()
105 , m_window{newWindowInfo.windowInfo.window()}
106 , m_extraInfo{getExtraInfo(newWindowInfo.windowInfo)}
107@@ -129,16 +131,20 @@
108 , m_visible(newWindowInfo.windowInfo.is_visible())
109 , m_live(true)
110 , m_surfaceObserver(std::make_shared<SurfaceObserverImpl>())
111- , m_position(toQPoint(m_window.top_left()))
112 , m_size(toQSize(m_window.size()))
113 , m_state(toQtState(newWindowInfo.windowInfo.state()))
114 , m_shellChrome(Mir::NormalChrome)
115+ , m_parentSurface(parentSurface)
116+ , m_childSurfaceList(new MirSurfaceListModel(this))
117 {
118 DEBUG_MSG << "("
119 << "type=" << mirSurfaceTypeToStr(m_type)
120 << ",state=" << unityapiMirStateToStr(m_state)
121+ << ",parentSurface=" << m_parentSurface
122 << ")";
123
124+ m_position = convertDisplayToLocalCoords(toQPoint(m_window.top_left()));
125+
126 SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface.get());
127 m_surface->add_observer(m_surfaceObserver);
128
129@@ -473,8 +479,9 @@
130 return m_position;
131 }
132
133-void MirSurface::setPosition(const QPoint newPosition)
134+void MirSurface::setPosition(const QPoint newDisplayPosition)
135 {
136+ QPoint newPosition = convertDisplayToLocalCoords(newDisplayPosition);
137 if (m_position != newPosition) {
138 m_position = newPosition;
139 Q_EMIT positionChanged(newPosition);
140@@ -968,8 +975,10 @@
141 m_requestedPosition = point;
142 Q_EMIT requestedPositionChanged(m_requestedPosition);
143
144+ QPoint requestedDisplayPos = convertLocalToDisplayCoords(m_requestedPosition);
145+
146 if (m_live) {
147- m_controller->move(m_window, m_requestedPosition);
148+ m_controller->move(m_window, requestedDisplayPos);
149 }
150 }
151 }
152@@ -1183,3 +1192,39 @@
153 DEBUG_MSG << "()";
154 Q_EMIT focusRequested();
155 }
156+
157+QPoint MirSurface::convertDisplayToLocalCoords(const QPoint &displayPos) const
158+{
159+ QPoint localPos = displayPos;
160+
161+ if (m_surface->parent()) {
162+ auto parentPos = m_surface->parent()->top_left();
163+ localPos.rx() -= parentPos.x.as_int();
164+ localPos.ry() -= parentPos.y.as_int();
165+ }
166+
167+ return localPos;
168+}
169+
170+QPoint MirSurface::convertLocalToDisplayCoords(const QPoint &localPos) const
171+{
172+ QPoint displayPos = localPos;
173+
174+ if (m_surface->parent()) {
175+ auto parentPos = m_surface->parent()->top_left();
176+ displayPos.rx() += parentPos.x.as_int();
177+ displayPos.ry() += parentPos.y.as_int();
178+ }
179+
180+ return displayPos;
181+}
182+
183+unityapi::MirSurfaceInterface *MirSurface::parentSurface() const
184+{
185+ return m_parentSurface;
186+}
187+
188+unityapi::MirSurfaceListInterface *MirSurface::childSurfaceList() const
189+{
190+ return m_childSurfaceList;
191+}
192
193=== modified file 'src/modules/Unity/Application/mirsurface.h'
194--- src/modules/Unity/Application/mirsurface.h 2016-11-22 18:01:11 +0000
195+++ src/modules/Unity/Application/mirsurface.h 2016-12-16 15:01:40 +0000
196@@ -43,6 +43,7 @@
197 namespace qtmir {
198
199 class AbstractTimer;
200+class MirSurfaceListModel;
201 class SessionInterface;
202
203 class MirSurface : public MirSurfaceInterface
204@@ -52,7 +53,8 @@
205 public:
206 MirSurface(NewWindow windowInfo,
207 WindowControllerInterface *controller,
208- SessionInterface *session = nullptr);
209+ SessionInterface *session = nullptr,
210+ MirSurface *parentSurface = nullptr);
211 virtual ~MirSurface();
212
213 ////
214@@ -95,6 +97,10 @@
215 bool confinesMousePointer() const override;
216
217 Q_INVOKABLE void activate() override;
218+
219+ unity::shell::application::MirSurfaceInterface *parentSurface() const override;
220+ unity::shell::application::MirSurfaceListInterface *childSurfaceList() const override;
221+
222 Q_INVOKABLE void close() override;
223
224 ////
225@@ -202,6 +208,8 @@
226 void onMaximumHeightChanged(int maxHeight);
227 void onWidthIncrementChanged(int incWidth);
228 void onHeightIncrementChanged(int incHeight);
229+ QPoint convertDisplayToLocalCoords(const QPoint &displayPos) const;
230+ QPoint convertLocalToDisplayCoords(const QPoint &localPos) const;
231
232 const miral::Window m_window;
233 const std::shared_ptr<ExtraWindowInfo> m_extraInfo;
234@@ -265,6 +273,11 @@
235 };
236 ClosingState m_closingState{NotClosing};
237 AbstractTimer *m_closeTimer{nullptr};
238+
239+ // assumes parent won't be destroyed before its children
240+ MirSurface *m_parentSurface;
241+
242+ MirSurfaceListModel *m_childSurfaceList;
243 };
244
245 } // namespace qtmir
246
247=== modified file 'src/modules/Unity/Application/surfacemanager.cpp'
248--- src/modules/Unity/Application/surfacemanager.cpp 2016-11-22 20:37:19 +0000
249+++ src/modules/Unity/Application/surfacemanager.cpp 2016-12-16 15:01:40 +0000
250@@ -22,6 +22,13 @@
251 // mirserver
252 #include "nativeinterface.h"
253
254+// common
255+#include <debughelpers.h>
256+#include <mirqtconversion.h>
257+
258+// Mir
259+#include <mir/scene/surface.h>
260+
261 // Qt
262 #include <QGuiApplication>
263
264@@ -78,14 +85,34 @@
265 }
266 }
267 }
268+
269 void SurfaceManager::onWindowAdded(const NewWindow &window)
270 {
271+ {
272+ std::shared_ptr<mir::scene::Surface> surface = window.surface;
273+ DEBUG_MSG << " mir::scene::Surface[type=" << mirSurfaceTypeToStr(surface->type())
274+ << ",parent=" << (void*)(surface->parent().get())
275+ << ",state=" << mirSurfaceStateToStr(surface->state())
276+ << ",top_left=" << toQPoint(surface->top_left())
277+ << "]";
278+ }
279+
280 auto mirSession = window.windowInfo.window().application();
281 SessionInterface* session = m_sessionManager->findSession(mirSession.get());
282
283- auto surface = new MirSurface(window, m_windowController, session);
284+ MirSurface *parentSurface;
285+ {
286+ std::shared_ptr<mir::scene::Surface> surface = window.windowInfo.window();
287+ parentSurface = find(surface->parent());
288+ }
289+
290+ auto surface = new MirSurface(window, m_windowController, session, parentSurface);
291 rememberMirSurface(surface);
292
293+ if (parentSurface) {
294+ static_cast<MirSurfaceListModel*>(parentSurface->childSurfaceList())->prependSurface(surface);
295+ }
296+
297 if (session)
298 session->registerSurface(surface);
299
300@@ -114,6 +141,16 @@
301 return nullptr;
302 }
303
304+MirSurface *SurfaceManager::find(const std::shared_ptr<mir::scene::Surface> &needle) const
305+{
306+ Q_FOREACH(const auto surface, m_allSurfaces) {
307+ if (surface->window() == needle) {
308+ return surface;
309+ }
310+ }
311+ return nullptr;
312+}
313+
314 void SurfaceManager::onWindowReady(const miral::WindowInfo &windowInfo)
315 {
316 if (auto mirSurface = find(windowInfo)) {
317
318=== modified file 'src/modules/Unity/Application/surfacemanager.h'
319--- src/modules/Unity/Application/surfacemanager.h 2016-11-22 18:01:11 +0000
320+++ src/modules/Unity/Application/surfacemanager.h 2016-12-16 15:01:40 +0000
321@@ -61,6 +61,7 @@
322 void forgetMirSurface(const miral::Window &window);
323 MirSurface* find(const miral::WindowInfo &needle) const;
324 MirSurface* find(const miral::Window &needle) const;
325+ MirSurface* find(const std::shared_ptr<mir::scene::Surface> &needle) const;
326
327 QVector<MirSurface*> m_allSurfaces;
328
329
330=== modified file 'tests/framework/fake_mirsurface.h'
331--- tests/framework/fake_mirsurface.h 2016-11-22 18:01:11 +0000
332+++ tests/framework/fake_mirsurface.h 2016-12-16 15:01:40 +0000
333@@ -79,6 +79,9 @@
334 QRect inputBounds() const override { return QRect(0,0,10,10); }
335 bool confinesMousePointer() const override { return false; }
336
337+ unity::shell::application::MirSurfaceInterface *parentSurface() const override { return nullptr; }
338+ unity::shell::application::MirSurfaceListInterface *childSurfaceList() const override { return nullptr; }
339+
340 void close() override {
341 Q_EMIT closeRequested();
342 }

Subscribers

People subscribed via source and target branches

to all changes: