Merge lp:~dandrader/qtmir/miral-surfaceLocalPos into lp:qtmir

Proposed by Daniel d'Andrada
Status: Superseded
Proposed branch: lp:~dandrader/qtmir/miral-surfaceLocalPos
Merge into: lp:qtmir
Prerequisite: lp:~unity-team/qtmir/miral-qt-integration
Diff against target: 320 lines (+129/-25)
6 files modified
src/common/debughelpers.cpp (+11/-16)
src/modules/Unity/Application/mirsurface.cpp (+62/-7)
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
Unity8 CI Bot (community) continuous-integration Needs Fixing
Gerry Boland (community) code Approve
Review via email: mp+311976@code.launchpad.net

This proposal has been superseded by a proposal from 2016-11-29.

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 :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

+ // 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 :

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 :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Code looks ok, not tested though

review: Approve (code)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
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

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/common/debughelpers.cpp'
2--- src/common/debughelpers.cpp 2016-11-29 13:05:57 +0000
3+++ src/common/debughelpers.cpp 2016-11-29 13:05:57 +0000
4@@ -115,23 +115,18 @@
5 const char *mirSurfaceTypeToStr(int value)
6 {
7 switch (value) {
8- case mir_surface_type_normal:
9- return "normal";
10- case mir_surface_type_utility:
11- return "utility";
12- case mir_surface_type_dialog:
13- return "dialog";
14- case mir_surface_type_overlay:
15- return "overlay";
16- case mir_surface_type_freestyle:
17- return "freestyle";
18- case mir_surface_type_popover:
19- return "popover";
20- case mir_surface_type_inputmethod:
21- return "inputmethod";
22- default:
23- return "???";
24+ case mir_surface_type_normal: return "normal"; /**< AKA "regular" */
25+ case mir_surface_type_utility: return "utility"; /**< AKA "floating regular" */
26+ case mir_surface_type_dialog: return "dialog";
27+ case mir_surface_type_gloss: return "gloss";
28+ case mir_surface_type_freestyle: return "freestyle";
29+ case mir_surface_type_menu: return "menu";
30+ case mir_surface_type_inputmethod: return "input Method"; /**< AKA "OSK" or handwriting etc. */
31+ case mir_surface_type_satellite: return "satellite"; /**< AKA "toolbox"/"toolbar" */
32+ case mir_surface_type_tip: return "tip"; /**< AKA "tooltip" */
33+ case mir_surface_types: Q_UNREACHABLE();
34 }
35+ return "";
36 }
37
38 const char *mirSurfaceStateToStr(int value)
39
40=== modified file 'src/modules/Unity/Application/mirsurface.cpp'
41--- src/modules/Unity/Application/mirsurface.cpp 2016-11-29 13:05:57 +0000
42+++ src/modules/Unity/Application/mirsurface.cpp 2016-11-29 13:05:57 +0000
43@@ -47,6 +47,7 @@
44 #include <limits>
45
46 using namespace qtmir;
47+namespace unityapi = unity::shell::application;
48
49 #define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__
50 #define WARNING_MSG qCWarning(QTMIR_SURFACES).nospace() << "MirSurface[" << (void*)this << "," << appId() << "]::" << __func__
51@@ -108,7 +109,8 @@
52
53 MirSurface::MirSurface(NewWindow newWindowInfo,
54 WindowControllerInterface* controller,
55- SessionInterface *session)
56+ SessionInterface *session,
57+ MirSurface *parentSurface)
58 : MirSurfaceInterface()
59 , m_window{newWindowInfo.windowInfo.window()}
60 , m_extraInfo{getExtraInfo(newWindowInfo.windowInfo)}
61@@ -129,12 +131,19 @@
62 , m_visible(newWindowInfo.windowInfo.is_visible())
63 , m_live(true)
64 , m_surfaceObserver(std::make_shared<SurfaceObserverImpl>())
65- , m_position(toQPoint(m_window.top_left()))
66 , m_size(toQSize(m_window.size()))
67 , m_state(toQtState(newWindowInfo.windowInfo.state()))
68 , m_shellChrome(Mir::NormalChrome)
69+ , m_parentSurface(parentSurface)
70+ , m_childSurfaceList(new MirSurfaceListModel(this))
71 {
72- DEBUG_MSG << "()";
73+ DEBUG_MSG << "("
74+ << "type=" << mirSurfaceTypeToStr(m_type)
75+ << ",state=" << unityapiMirStateToStr(m_state)
76+ << ",parentSurface=" << m_parentSurface
77+ << ")";
78+
79+ m_position = convertDisplayToLocalCoords(toQPoint(m_window.top_left()));
80
81 SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface.get());
82 m_surface->add_observer(m_surfaceObserver);
83@@ -470,8 +479,9 @@
84 return m_position;
85 }
86
87-void MirSurface::setPosition(const QPoint newPosition)
88+void MirSurface::setPosition(const QPoint newDisplayPosition)
89 {
90+ QPoint newPosition = convertDisplayToLocalCoords(newDisplayPosition);
91 if (m_position != newPosition) {
92 m_position = newPosition;
93 Q_EMIT positionChanged(newPosition);
94@@ -903,7 +913,9 @@
95 void MirSurface::activate()
96 {
97 DEBUG_MSG << "()";
98- m_controller->activate(m_window);
99+ if (m_live) {
100+ m_controller->activate(m_window);
101+ }
102 }
103
104 void MirSurface::onCloseTimedOut()
105@@ -914,7 +926,9 @@
106
107 m_closingState = CloseOverdue;
108
109- m_controller->forceClose(m_window);
110+ if (m_live) {
111+ m_controller->forceClose(m_window);
112+ }
113 }
114
115 void MirSurface::setCloseTimer(AbstractTimer *timer)
116@@ -960,7 +974,12 @@
117 if (point != m_requestedPosition) {
118 m_requestedPosition = point;
119 Q_EMIT requestedPositionChanged(m_requestedPosition);
120- m_controller->move(m_window, m_requestedPosition);
121+
122+ QPoint requestedDisplayPos = convertLocalToDisplayCoords(m_requestedPosition);
123+
124+ if (m_live) {
125+ m_controller->move(m_window, requestedDisplayPos);
126+ }
127 }
128 }
129
130@@ -1173,3 +1192,39 @@
131 DEBUG_MSG << "()";
132 Q_EMIT focusRequested();
133 }
134+
135+QPoint MirSurface::convertDisplayToLocalCoords(const QPoint &displayPos) const
136+{
137+ QPoint localPos = displayPos;
138+
139+ if (m_surface->parent()) {
140+ auto parentPos = m_surface->parent()->top_left();
141+ localPos.rx() -= parentPos.x.as_int();
142+ localPos.ry() -= parentPos.y.as_int();
143+ }
144+
145+ return localPos;
146+}
147+
148+QPoint MirSurface::convertLocalToDisplayCoords(const QPoint &localPos) const
149+{
150+ QPoint displayPos = localPos;
151+
152+ if (m_surface->parent()) {
153+ auto parentPos = m_surface->parent()->top_left();
154+ displayPos.rx() += parentPos.x.as_int();
155+ displayPos.ry() += parentPos.y.as_int();
156+ }
157+
158+ return displayPos;
159+}
160+
161+unityapi::MirSurfaceInterface *MirSurface::parentSurface() const
162+{
163+ return m_parentSurface;
164+}
165+
166+unityapi::MirSurfaceListInterface *MirSurface::childSurfaceList() const
167+{
168+ return m_childSurfaceList;
169+}
170
171=== modified file 'src/modules/Unity/Application/mirsurface.h'
172--- src/modules/Unity/Application/mirsurface.h 2016-11-29 13:05:57 +0000
173+++ src/modules/Unity/Application/mirsurface.h 2016-11-29 13:05:57 +0000
174@@ -43,6 +43,7 @@
175 namespace qtmir {
176
177 class AbstractTimer;
178+class MirSurfaceListModel;
179 class SessionInterface;
180
181 class MirSurface : public MirSurfaceInterface
182@@ -52,7 +53,8 @@
183 public:
184 MirSurface(NewWindow windowInfo,
185 WindowControllerInterface *controller,
186- SessionInterface *session = nullptr);
187+ SessionInterface *session = nullptr,
188+ MirSurface *parentSurface = nullptr);
189 virtual ~MirSurface();
190
191 ////
192@@ -95,6 +97,10 @@
193 bool confinesMousePointer() const override;
194
195 Q_INVOKABLE void activate() override;
196+
197+ unity::shell::application::MirSurfaceInterface *parentSurface() const override;
198+ unity::shell::application::MirSurfaceListInterface *childSurfaceList() const override;
199+
200 Q_INVOKABLE void close() override;
201
202 ////
203@@ -202,6 +208,8 @@
204 void onMaximumHeightChanged(int maxHeight);
205 void onWidthIncrementChanged(int incWidth);
206 void onHeightIncrementChanged(int incHeight);
207+ QPoint convertDisplayToLocalCoords(const QPoint &displayPos) const;
208+ QPoint convertLocalToDisplayCoords(const QPoint &localPos) const;
209
210 const miral::Window m_window;
211 const std::shared_ptr<ExtraWindowInfo> m_extraInfo;
212@@ -265,6 +273,11 @@
213 };
214 ClosingState m_closingState{NotClosing};
215 AbstractTimer *m_closeTimer{nullptr};
216+
217+ // assumes parent won't be destroyed before its children
218+ MirSurface *m_parentSurface;
219+
220+ MirSurfaceListModel *m_childSurfaceList;
221 };
222
223 } // namespace qtmir
224
225=== modified file 'src/modules/Unity/Application/surfacemanager.cpp'
226--- src/modules/Unity/Application/surfacemanager.cpp 2016-11-29 13:05:57 +0000
227+++ src/modules/Unity/Application/surfacemanager.cpp 2016-11-29 13:05:57 +0000
228@@ -22,6 +22,13 @@
229 // mirserver
230 #include "nativeinterface.h"
231
232+// common
233+#include <debughelpers.h>
234+#include <mirqtconversion.h>
235+
236+// Mir
237+#include <mir/scene/surface.h>
238+
239 // Qt
240 #include <QGuiApplication>
241
242@@ -78,14 +85,34 @@
243 }
244 }
245 }
246+
247 void SurfaceManager::onWindowAdded(const NewWindow &window)
248 {
249+ {
250+ std::shared_ptr<mir::scene::Surface> surface = window.surface;
251+ DEBUG_MSG << " mir::scene::Surface[type=" << mirSurfaceTypeToStr(surface->type())
252+ << ",parent=" << (void*)(surface->parent().get())
253+ << ",state=" << mirSurfaceStateToStr(surface->state())
254+ << ",top_left=" << toQPoint(surface->top_left())
255+ << "]";
256+ }
257+
258 auto mirSession = window.windowInfo.window().application();
259 SessionInterface* session = m_sessionManager->findSession(mirSession.get());
260
261- auto surface = new MirSurface(window, m_windowController, session);
262+ MirSurface *parentSurface;
263+ {
264+ std::shared_ptr<mir::scene::Surface> surface = window.windowInfo.window();
265+ parentSurface = find(surface->parent());
266+ }
267+
268+ auto surface = new MirSurface(window, m_windowController, session, parentSurface);
269 rememberMirSurface(surface);
270
271+ if (parentSurface) {
272+ static_cast<MirSurfaceListModel*>(parentSurface->childSurfaceList())->prependSurface(surface);
273+ }
274+
275 if (session)
276 session->registerSurface(surface);
277
278@@ -114,6 +141,16 @@
279 return nullptr;
280 }
281
282+MirSurface *SurfaceManager::find(const std::shared_ptr<mir::scene::Surface> &needle) const
283+{
284+ Q_FOREACH(const auto surface, m_allSurfaces) {
285+ if (surface->window() == needle) {
286+ return surface;
287+ }
288+ }
289+ return nullptr;
290+}
291+
292 void SurfaceManager::onWindowReady(const miral::WindowInfo &windowInfo)
293 {
294 if (auto mirSurface = find(windowInfo)) {
295
296=== modified file 'src/modules/Unity/Application/surfacemanager.h'
297--- src/modules/Unity/Application/surfacemanager.h 2016-11-29 13:05:57 +0000
298+++ src/modules/Unity/Application/surfacemanager.h 2016-11-29 13:05:57 +0000
299@@ -61,6 +61,7 @@
300 void forgetMirSurface(const miral::Window &window);
301 MirSurface* find(const miral::WindowInfo &needle) const;
302 MirSurface* find(const miral::Window &needle) const;
303+ MirSurface* find(const std::shared_ptr<mir::scene::Surface> &needle) const;
304
305 QVector<MirSurface*> m_allSurfaces;
306
307
308=== modified file 'tests/framework/fake_mirsurface.h'
309--- tests/framework/fake_mirsurface.h 2016-11-29 13:05:57 +0000
310+++ tests/framework/fake_mirsurface.h 2016-11-29 13:05:57 +0000
311@@ -79,6 +79,9 @@
312 QRect inputBounds() const override { return QRect(0,0,10,10); }
313 bool confinesMousePointer() const override { return false; }
314
315+ unity::shell::application::MirSurfaceInterface *parentSurface() const override { return nullptr; }
316+ unity::shell::application::MirSurfaceListInterface *childSurfaceList() const override { return nullptr; }
317+
318 void close() override {
319 Q_EMIT closeRequested();
320 }

Subscribers

People subscribed via source and target branches