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
=== modified file 'src/common/debughelpers.cpp'
--- src/common/debughelpers.cpp 2016-11-29 13:05:57 +0000
+++ src/common/debughelpers.cpp 2016-11-29 13:05:57 +0000
@@ -115,23 +115,18 @@
115const char *mirSurfaceTypeToStr(int value)115const char *mirSurfaceTypeToStr(int value)
116{116{
117 switch (value) {117 switch (value) {
118 case mir_surface_type_normal:118 case mir_surface_type_normal: return "normal"; /**< AKA "regular" */
119 return "normal";119 case mir_surface_type_utility: return "utility"; /**< AKA "floating regular" */
120 case mir_surface_type_utility:120 case mir_surface_type_dialog: return "dialog";
121 return "utility";121 case mir_surface_type_gloss: return "gloss";
122 case mir_surface_type_dialog:122 case mir_surface_type_freestyle: return "freestyle";
123 return "dialog";123 case mir_surface_type_menu: return "menu";
124 case mir_surface_type_overlay:124 case mir_surface_type_inputmethod: return "input Method"; /**< AKA "OSK" or handwriting etc. */
125 return "overlay";125 case mir_surface_type_satellite: return "satellite"; /**< AKA "toolbox"/"toolbar" */
126 case mir_surface_type_freestyle:126 case mir_surface_type_tip: return "tip"; /**< AKA "tooltip" */
127 return "freestyle";127 case mir_surface_types: Q_UNREACHABLE();
128 case mir_surface_type_popover:
129 return "popover";
130 case mir_surface_type_inputmethod:
131 return "inputmethod";
132 default:
133 return "???";
134 }128 }
129 return "";
135}130}
136131
137const char *mirSurfaceStateToStr(int value)132const char *mirSurfaceStateToStr(int value)
138133
=== modified file 'src/modules/Unity/Application/mirsurface.cpp'
--- src/modules/Unity/Application/mirsurface.cpp 2016-11-29 13:05:57 +0000
+++ src/modules/Unity/Application/mirsurface.cpp 2016-11-29 13:05:57 +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,12 +131,19 @@
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 << "("
141 << "type=" << mirSurfaceTypeToStr(m_type)
142 << ",state=" << unityapiMirStateToStr(m_state)
143 << ",parentSurface=" << m_parentSurface
144 << ")";
145
146 m_position = convertDisplayToLocalCoords(toQPoint(m_window.top_left()));
138147
139 SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface.get());148 SurfaceObserver::registerObserverForSurface(m_surfaceObserver.get(), m_surface.get());
140 m_surface->add_observer(m_surfaceObserver);149 m_surface->add_observer(m_surfaceObserver);
@@ -470,8 +479,9 @@
470 return m_position;479 return m_position;
471}480}
472481
473void MirSurface::setPosition(const QPoint newPosition)482void MirSurface::setPosition(const QPoint newDisplayPosition)
474{483{
484 QPoint newPosition = convertDisplayToLocalCoords(newDisplayPosition);
475 if (m_position != newPosition) {485 if (m_position != newPosition) {
476 m_position = newPosition;486 m_position = newPosition;
477 Q_EMIT positionChanged(newPosition);487 Q_EMIT positionChanged(newPosition);
@@ -903,7 +913,9 @@
903void MirSurface::activate()913void MirSurface::activate()
904{914{
905 DEBUG_MSG << "()";915 DEBUG_MSG << "()";
906 m_controller->activate(m_window);916 if (m_live) {
917 m_controller->activate(m_window);
918 }
907}919}
908920
909void MirSurface::onCloseTimedOut()921void MirSurface::onCloseTimedOut()
@@ -914,7 +926,9 @@
914926
915 m_closingState = CloseOverdue;927 m_closingState = CloseOverdue;
916928
917 m_controller->forceClose(m_window);929 if (m_live) {
930 m_controller->forceClose(m_window);
931 }
918}932}
919933
920void MirSurface::setCloseTimer(AbstractTimer *timer)934void MirSurface::setCloseTimer(AbstractTimer *timer)
@@ -960,7 +974,12 @@
960 if (point != m_requestedPosition) {974 if (point != m_requestedPosition) {
961 m_requestedPosition = point;975 m_requestedPosition = point;
962 Q_EMIT requestedPositionChanged(m_requestedPosition);976 Q_EMIT requestedPositionChanged(m_requestedPosition);
963 m_controller->move(m_window, m_requestedPosition);977
978 QPoint requestedDisplayPos = convertLocalToDisplayCoords(m_requestedPosition);
979
980 if (m_live) {
981 m_controller->move(m_window, requestedDisplayPos);
982 }
964 }983 }
965}984}
966985
@@ -1173,3 +1192,39 @@
1173 DEBUG_MSG << "()";1192 DEBUG_MSG << "()";
1174 Q_EMIT focusRequested();1193 Q_EMIT focusRequested();
1175}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}
11761231
=== modified file 'src/modules/Unity/Application/mirsurface.h'
--- src/modules/Unity/Application/mirsurface.h 2016-11-29 13:05:57 +0000
+++ src/modules/Unity/Application/mirsurface.h 2016-11-29 13:05:57 +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-29 13:05:57 +0000
+++ src/modules/Unity/Application/surfacemanager.cpp 2016-11-29 13:05:57 +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-29 13:05:57 +0000
+++ src/modules/Unity/Application/surfacemanager.h 2016-11-29 13:05:57 +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-29 13:05:57 +0000
+++ tests/framework/fake_mirsurface.h 2016-11-29 13:05:57 +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