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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-12-13 15:31:26 +0000
+++ CMakeLists.txt 2016-12-16 15:01:40 +0000
@@ -88,7 +88,7 @@
88pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)88pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
89pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)89pkg_check_modules(QTDBUSTEST libqtdbustest-1 REQUIRED)
90pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)90pkg_check_modules(QTDBUSMOCK libqtdbusmock-1 REQUIRED)
91pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=23)91pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=24)
92pkg_check_modules(CGMANAGER libcgmanager REQUIRED)92pkg_check_modules(CGMANAGER libcgmanager REQUIRED)
93pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED)93pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED)
9494
@@ -166,10 +166,6 @@
166# Tests166# Tests
167if (NO_TESTS)167if (NO_TESTS)
168 message(STATUS "Tests disabled")168 message(STATUS "Tests disabled")
169# glibc on Vivid+Overlay has a bug which causes LTTng-enabled tests to hang. It is hard to get the glibc version
170# in cmake, so it is easier to check for the LTTng on V+O and gate on that instead.
171elseif (LTTNG_VERSION VERSION_EQUAL 2.7.1)
172 message(STATUS "Tests disabled due to bug with glibc causing lttng to hang (lp:1618201)")
173else()169else()
174 include(CTest)170 include(CTest)
175 enable_testing()171 enable_testing()
176172
=== modified file 'debian/changelog'
--- debian/changelog 2016-12-13 15:31:26 +0000
+++ debian/changelog 2016-12-16 15:01:40 +0000
@@ -1,8 +1,13 @@
1qtmir (0.5.1) UNRELEASED; urgency=medium1qtmir (0.5.1+17.04.20161216-0ubuntu1) zesty; urgency=medium
22
3 [ Gerry Boland ]
3 * First release using MirAL4 * First release using MirAL
45
5 -- Gerry Boland <gerry.boland@canonical.com> Fri, 14 Oct 2016 16:51:26 +01006 [ Daniel d'Andrada ]
7 * Get rid of the ApplicationManager::Factory class
8 * Enable tests in Xenial
9
10 -- Daniel d'Andrada <daniel.dandrada@canonical.com> Fri, 16 Dec 2016 08:25:00 +0000
611
7qtmir (0.5.0+17.04.20161203-0ubuntu1) zesty; urgency=medium12qtmir (0.5.0+17.04.20161203-0ubuntu1) zesty; urgency=medium
813
914
=== modified file 'src/modules/Unity/Application/application_manager.cpp'
--- src/modules/Unity/Application/application_manager.cpp 2016-12-07 11:17:13 +0000
+++ src/modules/Unity/Application/application_manager.cpp 2016-12-16 15:01:40 +0000
@@ -97,7 +97,7 @@
9797
98} // namespace98} // namespace
9999
100ApplicationManager* ApplicationManager::Factory::Factory::create()100ApplicationManager* ApplicationManager::create()
101{101{
102 NativeInterface *nativeInterface = dynamic_cast<NativeInterface*>(QGuiApplication::platformNativeInterface());102 NativeInterface *nativeInterface = dynamic_cast<NativeInterface*>(QGuiApplication::platformNativeInterface());
103103
@@ -150,8 +150,7 @@
150{150{
151 static ApplicationManager* instance;151 static ApplicationManager* instance;
152 if (!instance) {152 if (!instance) {
153 Factory appFactory;153 instance = create();
154 instance = appFactory.create();
155 }154 }
156 return instance;155 return instance;
157}156}
158157
=== modified file 'src/modules/Unity/Application/application_manager.h'
--- src/modules/Unity/Application/application_manager.h 2016-12-07 11:17:13 +0000
+++ src/modules/Unity/Application/application_manager.h 2016-12-16 15:01:40 +0000
@@ -63,12 +63,7 @@
63 Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)63 Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
6464
65public:65public:
66 class Factory66 static ApplicationManager* create();
67 {
68 public:
69 ApplicationManager* create();
70 };
71
72 static ApplicationManager* singleton();67 static ApplicationManager* singleton();
7368
74 explicit ApplicationManager(69 explicit ApplicationManager(
7570
=== modified file 'src/modules/Unity/Application/mirsurface.cpp'
--- src/modules/Unity/Application/mirsurface.cpp 2016-11-25 15:23:36 +0000
+++ src/modules/Unity/Application/mirsurface.cpp 2016-12-16 15:01:40 +0000
@@ -47,6 +47,7 @@
47#include <limits>47#include <limits>
4848
49using namespace qtmir;49using namespace qtmir;
50namespace unityapi = unity::shell::application;
5051
51#define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__52#define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__
52#define WARNING_MSG qCWarning(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__53#define WARNING_MSG qCWarning(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__
@@ -108,7 +109,8 @@
108109
109MirSurface::MirSurface(NewWindow newWindowInfo,110MirSurface::MirSurface(NewWindow newWindowInfo,
110 WindowControllerInterface* controller,111 WindowControllerInterface* controller,
111 SessionInterface *session)112 SessionInterface *session,
113 MirSurface *parentSurface)
112 : MirSurfaceInterface()114 : MirSurfaceInterface()
113 , m_window{newWindowInfo.windowInfo.window()}115 , m_window{newWindowInfo.windowInfo.window()}
114 , m_extraInfo{getExtraInfo(newWindowInfo.windowInfo)}116 , m_extraInfo{getExtraInfo(newWindowInfo.windowInfo)}
@@ -129,16 +131,20 @@
129 , m_visible(newWindowInfo.windowInfo.is_visible())131 , m_visible(newWindowInfo.windowInfo.is_visible())
130 , m_live(true)132 , m_live(true)
131 , m_surfaceObserver(std::make_shared<SurfaceObserverImpl>())133 , m_surfaceObserver(std::make_shared<SurfaceObserverImpl>())
132 , m_position(toQPoint(m_window.top_left()))
133 , m_size(toQSize(m_window.size()))134 , m_size(toQSize(m_window.size()))
134 , m_state(toQtState(newWindowInfo.windowInfo.state()))135 , m_state(toQtState(newWindowInfo.windowInfo.state()))
135 , m_shellChrome(Mir::NormalChrome)136 , m_shellChrome(Mir::NormalChrome)
137 , m_parentSurface(parentSurface)
138 , m_childSurfaceList(new MirSurfaceListModel(this))
136{139{
137 DEBUG_MSG << "("140 DEBUG_MSG << "("
138 << "type=" << mirSurfaceTypeToStr(m_type)141 << "type=" << mirSurfaceTypeToStr(m_type)
139 << ",state=" << unityapiMirStateToStr(m_state)142 << ",state=" << unityapiMirStateToStr(m_state)
143 << ",parentSurface=" << m_parentSurface
140 << ")";144 << ")";
141145
146 m_position = convertDisplayToLocalCoords(toQPoint(m_window.top_left()));
147
142 SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface.get());148 SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface.get());
143 m_surface->add_observer(m_surfaceObserver);149 m_surface->add_observer(m_surfaceObserver);
144150
@@ -473,8 +479,9 @@
473 return m_position;479 return m_position;
474}480}
475481
476void MirSurface::setPosition(const QPoint newPosition)482void MirSurface::setPosition(const QPoint newDisplayPosition)
477{483{
484 QPoint newPosition = convertDisplayToLocalCoords(newDisplayPosition);
478 if (m_position != newPosition) {485 if (m_position != newPosition) {
479 m_position = newPosition;486 m_position = newPosition;
480 Q_EMIT positionChanged(newPosition);487 Q_EMIT positionChanged(newPosition);
@@ -968,8 +975,10 @@
968 m_requestedPosition = point;975 m_requestedPosition = point;
969 Q_EMIT requestedPositionChanged(m_requestedPosition);976 Q_EMIT requestedPositionChanged(m_requestedPosition);
970977
978 QPoint requestedDisplayPos = convertLocalToDisplayCoords(m_requestedPosition);
979
971 if (m_live) {980 if (m_live) {
972 m_controller->move(m_window, m_requestedPosition);981 m_controller->move(m_window, requestedDisplayPos);
973 }982 }
974 }983 }
975}984}
@@ -1183,3 +1192,39 @@
1183 DEBUG_MSG << "()";1192 DEBUG_MSG << "()";
1184 Q_EMIT focusRequested();1193 Q_EMIT focusRequested();
1185}1194}
1195
1196QPoint MirSurface::convertDisplayToLocalCoords(const QPoint &displayPos) const
1197{
1198 QPoint localPos = displayPos;
1199
1200 if (m_surface->parent()) {
1201 auto parentPos = m_surface->parent()->top_left();
1202 localPos.rx() -= parentPos.x.as_int();
1203 localPos.ry() -= parentPos.y.as_int();
1204 }
1205
1206 return localPos;
1207}
1208
1209QPoint MirSurface::convertLocalToDisplayCoords(const QPoint &localPos) const
1210{
1211 QPoint displayPos = localPos;
1212
1213 if (m_surface->parent()) {
1214 auto parentPos = m_surface->parent()->top_left();
1215 displayPos.rx() += parentPos.x.as_int();
1216 displayPos.ry() += parentPos.y.as_int();
1217 }
1218
1219 return displayPos;
1220}
1221
1222unityapi::MirSurfaceInterface *MirSurface::parentSurface() const
1223{
1224 return m_parentSurface;
1225}
1226
1227unityapi::MirSurfaceListInterface *MirSurface::childSurfaceList() const
1228{
1229 return m_childSurfaceList;
1230}
11861231
=== modified file 'src/modules/Unity/Application/mirsurface.h'
--- src/modules/Unity/Application/mirsurface.h 2016-11-22 18:01:11 +0000
+++ src/modules/Unity/Application/mirsurface.h 2016-12-16 15:01:40 +0000
@@ -43,6 +43,7 @@
43namespace qtmir {43namespace qtmir {
4444
45class AbstractTimer;45class AbstractTimer;
46class MirSurfaceListModel;
46class SessionInterface;47class SessionInterface;
4748
48class MirSurface : public MirSurfaceInterface49class MirSurface : public MirSurfaceInterface
@@ -52,7 +53,8 @@
52public:53public:
53 MirSurface(NewWindow windowInfo,54 MirSurface(NewWindow windowInfo,
54 WindowControllerInterface *controller,55 WindowControllerInterface *controller,
55 SessionInterface *session = nullptr);56 SessionInterface *session = nullptr,
57 MirSurface *parentSurface = nullptr);
56 virtual ~MirSurface();58 virtual ~MirSurface();
5759
58 ////60 ////
@@ -95,6 +97,10 @@
95 bool confinesMousePointer() const override;97 bool confinesMousePointer() const override;
9698
97 Q_INVOKABLE void activate() override;99 Q_INVOKABLE void activate() override;
100
101 unity::shell::application::MirSurfaceInterface *parentSurface() const override;
102 unity::shell::application::MirSurfaceListInterface *childSurfaceList() const override;
103
98 Q_INVOKABLE void close() override;104 Q_INVOKABLE void close() override;
99105
100 ////106 ////
@@ -202,6 +208,8 @@
202 void onMaximumHeightChanged(int maxHeight);208 void onMaximumHeightChanged(int maxHeight);
203 void onWidthIncrementChanged(int incWidth);209 void onWidthIncrementChanged(int incWidth);
204 void onHeightIncrementChanged(int incHeight);210 void onHeightIncrementChanged(int incHeight);
211 QPoint convertDisplayToLocalCoords(const QPoint &displayPos) const;
212 QPoint convertLocalToDisplayCoords(const QPoint &localPos) const;
205213
206 const miral::Window m_window;214 const miral::Window m_window;
207 const std::shared_ptr<ExtraWindowInfo> m_extraInfo;215 const std::shared_ptr<ExtraWindowInfo> m_extraInfo;
@@ -265,6 +273,11 @@
265 };273 };
266 ClosingState m_closingState{NotClosing};274 ClosingState m_closingState{NotClosing};
267 AbstractTimer *m_closeTimer{nullptr};275 AbstractTimer *m_closeTimer{nullptr};
276
277 // assumes parent won't be destroyed before its children
278 MirSurface *m_parentSurface;
279
280 MirSurfaceListModel *m_childSurfaceList;
268};281};
269282
270} // namespace qtmir283} // namespace qtmir
271284
=== modified file 'src/modules/Unity/Application/surfacemanager.cpp'
--- src/modules/Unity/Application/surfacemanager.cpp 2016-11-22 20:37:19 +0000
+++ src/modules/Unity/Application/surfacemanager.cpp 2016-12-16 15:01:40 +0000
@@ -22,6 +22,13 @@
22// mirserver22// mirserver
23#include "nativeinterface.h"23#include "nativeinterface.h"
2424
25// common
26#include <debughelpers.h>
27#include <mirqtconversion.h>
28
29// Mir
30#include <mir/scene/surface.h>
31
25// Qt32// Qt
26#include <QGuiApplication>33#include <QGuiApplication>
2734
@@ -78,14 +85,34 @@
78 }85 }
79 }86 }
80}87}
88
81void SurfaceManager::onWindowAdded(const NewWindow &window)89void SurfaceManager::onWindowAdded(const NewWindow &window)
82{90{
91 {
92 std::shared_ptr<mir::scene::Surface> surface = window.surface;
93 DEBUG_MSG << " mir::scene::Surface[type=" << mirSurfaceTypeToStr(surface->type())
94 << ",parent=" << (void*)(surface->parent().get())
95 << ",state=" << mirSurfaceStateToStr(surface->state())
96 << ",top_left=" << toQPoint(surface->top_left())
97 << "]";
98 }
99
83 auto mirSession = window.windowInfo.window().application();100 auto mirSession = window.windowInfo.window().application();
84 SessionInterface* session = m_sessionManager->findSession(mirSession.get());101 SessionInterface* session = m_sessionManager->findSession(mirSession.get());
85102
86 auto surface = new MirSurface(window, m_windowController, session);103 MirSurface *parentSurface;
104 {
105 std::shared_ptr<mir::scene::Surface> surface = window.windowInfo.window();
106 parentSurface = find(surface->parent());
107 }
108
109 auto surface = new MirSurface(window, m_windowController, session, parentSurface);
87 rememberMirSurface(surface);110 rememberMirSurface(surface);
88111
112 if (parentSurface) {
113 static_cast<MirSurfaceListModel*>(parentSurface->childSurfaceList())->prependSurface(surface);
114 }
115
89 if (session)116 if (session)
90 session->registerSurface(surface);117 session->registerSurface(surface);
91118
@@ -114,6 +141,16 @@
114 return nullptr;141 return nullptr;
115}142}
116143
144MirSurface *SurfaceManager::find(const std::shared_ptr<mir::scene::Surface> &needle) const
145{
146 Q_FOREACH(const auto surface, m_allSurfaces) {
147 if (surface->window() == needle) {
148 return surface;
149 }
150 }
151 return nullptr;
152}
153
117void SurfaceManager::onWindowReady(const miral::WindowInfo &windowInfo)154void SurfaceManager::onWindowReady(const miral::WindowInfo &windowInfo)
118{155{
119 if (auto mirSurface = find(windowInfo)) {156 if (auto mirSurface = find(windowInfo)) {
120157
=== modified file 'src/modules/Unity/Application/surfacemanager.h'
--- src/modules/Unity/Application/surfacemanager.h 2016-11-22 18:01:11 +0000
+++ src/modules/Unity/Application/surfacemanager.h 2016-12-16 15:01:40 +0000
@@ -61,6 +61,7 @@
61 void forgetMirSurface(const miral::Window &window);61 void forgetMirSurface(const miral::Window &window);
62 MirSurface* find(const miral::WindowInfo &needle) const;62 MirSurface* find(const miral::WindowInfo &needle) const;
63 MirSurface* find(const miral::Window &needle) const;63 MirSurface* find(const miral::Window &needle) const;
64 MirSurface* find(const std::shared_ptr<mir::scene::Surface> &needle) const;
6465
65 QVector<MirSurface*> m_allSurfaces;66 QVector<MirSurface*> m_allSurfaces;
6667
6768
=== modified file 'tests/framework/fake_mirsurface.h'
--- tests/framework/fake_mirsurface.h 2016-11-22 18:01:11 +0000
+++ tests/framework/fake_mirsurface.h 2016-12-16 15:01:40 +0000
@@ -79,6 +79,9 @@
79 QRect inputBounds() const override { return QRect(0,0,10,10); }79 QRect inputBounds() const override { return QRect(0,0,10,10); }
80 bool confinesMousePointer() const override { return false; }80 bool confinesMousePointer() const override { return false; }
8181
82 unity::shell::application::MirSurfaceInterface *parentSurface() const override { return nullptr; }
83 unity::shell::application::MirSurfaceListInterface *childSurfaceList() const override { return nullptr; }
84
82 void close() override {85 void close() override {
83 Q_EMIT closeRequested();86 Q_EMIT closeRequested();
84 }87 }

Subscribers

People subscribed via source and target branches

to all changes: