Merge lp:~gerboland/unity-mir/surface-notifications into lp:unity-mir

Proposed by Gerry Boland
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 25
Merged at revision: 23
Proposed branch: lp:~gerboland/unity-mir/surface-notifications
Merge into: lp:unity-mir
Diff against target: 595 lines (+147/-118)
12 files modified
src/modules/Unity/ApplicationManager/application_list_model.cpp (+9/-2)
src/modules/Unity/ApplicationManager/application_list_model.h (+1/-0)
src/modules/Unity/ApplicationManager/application_manager.cpp (+33/-14)
src/modules/Unity/ApplicationManager/application_manager.h (+8/-1)
src/modules/Unity/SurfaceManager/mirsurface.cpp (+45/-86)
src/modules/Unity/SurfaceManager/mirsurface.h (+4/-2)
src/modules/Unity/SurfaceManager/mirsurfacemanager.cpp (+23/-4)
src/modules/Unity/SurfaceManager/mirsurfacemanager.h (+4/-3)
src/unity-mir/sessionlistener.cpp (+14/-0)
src/unity-mir/sessionlistener.h (+6/-3)
src/unity-mir/surfacesource.cpp (+0/-2)
src/unity-mir/surfacesource.h (+0/-1)
To merge this branch: bzr merge lp:~gerboland/unity-mir/surface-notifications
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
Review via email: mp+176719@code.launchpad.net

Commit message

Update SurfaceManager and ApplicationManager to make use of new MIR API, which notifies of surface creation and destruction per session/application.

Description of the change

Update SurfaceManager and ApplicationManager to make use of new MIR API, which notifies of surface creation and destruction per session/application.

To post a comment you must log in.
22. By Gerry Boland

Unset mainStageFocusedApplication if it is closed

23. By Gerry Boland

Merge trunk

24. By Gerry Boland

Reset mainStageFocusedApplication in stopProcess, fix crash on app close

25. By Gerry Boland

SurfaceManager: unable to keep msh::Surface as long as we want, so simplify API for now

Revision history for this message
Albert Astals Cid (aacid) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/modules/Unity/ApplicationManager/application_list_model.cpp'
--- src/modules/Unity/ApplicationManager/application_list_model.cpp 2013-07-24 15:07:38 +0000
+++ src/modules/Unity/ApplicationManager/application_list_model.cpp 2013-07-24 17:24:27 +0000
@@ -19,6 +19,8 @@
1919
20#include <mir/shell/application_session.h>20#include <mir/shell/application_session.h>
2121
22namespace msh = mir::shell;
23
22ApplicationListModel::ApplicationListModel(QObject* parent)24ApplicationListModel::ApplicationListModel(QObject* parent)
23: QAbstractListModel(parent)25: QAbstractListModel(parent)
24, m_applications()26, m_applications()
@@ -100,11 +102,16 @@
100 }102 }
101}103}
102104
103Application* ApplicationListModel::getApplicationWithSession(const std::shared_ptr<mir::shell::Session> &session)105Application* ApplicationListModel::getApplicationWithSession(const std::shared_ptr<msh::Session> &session)
106{
107 return getApplicationWithSession(session.get());
108}
109
110Application* ApplicationListModel::getApplicationWithSession(const msh::Session *session)
104{111{
105 Application* app = NULL;112 Application* app = NULL;
106 Q_FOREACH(app, m_applications) {113 Q_FOREACH(app, m_applications) {
107 if (app->session().get() == session.get()) {114 if (app->session().get() == session) {
108 break;115 break;
109 }116 }
110 }117 }
111118
=== modified file 'src/modules/Unity/ApplicationManager/application_list_model.h'
--- src/modules/Unity/ApplicationManager/application_list_model.h 2013-07-24 15:07:38 +0000
+++ src/modules/Unity/ApplicationManager/application_list_model.h 2013-07-24 17:24:27 +0000
@@ -49,6 +49,7 @@
49 void remove(Application* application);49 void remove(Application* application);
5050
51 Application* getApplicationWithSession(const std::shared_ptr<mir::shell::Session> &session);51 Application* getApplicationWithSession(const std::shared_ptr<mir::shell::Session> &session);
52 Application* getApplicationWithSession(const mir::shell::Session *session);
52 Application* getApplicationWithId(const int id);53 Application* getApplicationWithId(const int id);
53 Application* getApplicationWithPid(const int pid);54 Application* getApplicationWithPid(const int pid);
54 Application* getLastExecutedApplication();55 Application* getLastExecutedApplication();
5556
=== modified file 'src/modules/Unity/ApplicationManager/application_manager.cpp'
--- src/modules/Unity/ApplicationManager/application_manager.cpp 2013-07-24 15:44:10 +0000
+++ src/modules/Unity/ApplicationManager/application_manager.cpp 2013-07-24 17:24:27 +0000
@@ -25,6 +25,8 @@
25 #include <pwd.h>25 #include <pwd.h>
26#endif26#endif
2727
28namespace msh = mir::shell;
29
28ApplicationManager::ApplicationManager(QObject *parent)30ApplicationManager::ApplicationManager(QObject *parent)
29: QObject(parent)31: QObject(parent)
30, m_mainStageApplications(new ApplicationListModel())32, m_mainStageApplications(new ApplicationListModel())
@@ -39,17 +41,16 @@
39 }41 }
40 m_mirServer = mirServerApplication->server();42 m_mirServer = mirServerApplication->server();
4143
42 std::shared_ptr<SessionListener> sessionListener44 QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionStarting,
43 = std::dynamic_pointer_cast<SessionListener>(m_mirServer->the_shell_session_listener());
44
45 QObject::connect(sessionListener.get(), &SessionListener::sessionStarting,
46 this, &ApplicationManager::sessionStarting);45 this, &ApplicationManager::sessionStarting);
47 QObject::connect(sessionListener.get(), &SessionListener::sessionStopping,46 QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionStopping,
48 this, &ApplicationManager::sessionStopping);47 this, &ApplicationManager::sessionStopping);
49 QObject::connect(sessionListener.get(), &SessionListener::sessionFocused,48 QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionFocused,
50 this, &ApplicationManager::sessionFocused);49 this, &ApplicationManager::sessionFocused);
51 QObject::connect(sessionListener.get(), &SessionListener::sessionUnfocused,50 QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionUnfocused,
52 this, &ApplicationManager::sessionUnfocused);51 this, &ApplicationManager::sessionUnfocused);
52 QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionCreatedSurface,
53 this, &ApplicationManager::sessionCreatedSurface);
5354
54 std::shared_ptr<SessionAuthorizer> sessionAuthorizer55 std::shared_ptr<SessionAuthorizer> sessionAuthorizer
55 = std::dynamic_pointer_cast<SessionAuthorizer>(m_mirServer->the_session_authorizer());56 = std::dynamic_pointer_cast<SessionAuthorizer>(m_mirServer->the_session_authorizer());
@@ -193,7 +194,13 @@
193 DLOG("ApplicationManager::stopProcess (this=%p, application=%p)", this, application);194 DLOG("ApplicationManager::stopProcess (this=%p, application=%p)", this, application);
194195
195 if (application != NULL) {196 if (application != NULL) {
197 if (application == m_mainStageFocusedApplication) {
198 // TODO(greyback) What to do?? Focus next app, or unfocus everything??
199 m_mainStageFocusedApplication = NULL;
200 Q_EMIT mainStageFocusedApplicationChanged();
201 }
196 m_mainStageApplications->remove(application);202 m_mainStageApplications->remove(application);
203 m_dbusWindowStack->WindowDestroyed(0, application->name());
197204
198 // Start process.205 // Start process.
199 bool result;206 bool result;
@@ -225,7 +232,7 @@
225 }232 }
226}233}
227234
228void ApplicationManager::sessionStarting(std::shared_ptr<mir::shell::ApplicationSession> const& session)235void ApplicationManager::sessionStarting(std::shared_ptr<msh::ApplicationSession> const& session)
229{236{
230 DLOG("ApplicationManager::sessionStarting (this=%p, application=%s)", this, session->name().c_str());237 DLOG("ApplicationManager::sessionStarting (this=%p, application=%s)", this, session->name().c_str());
231238
@@ -234,15 +241,12 @@
234 Application* application = m_mainStageApplications->getLastExecutedApplication();241 Application* application = m_mainStageApplications->getLastExecutedApplication();
235 if (application && application->state() != Application::Running) {242 if (application && application->state() != Application::Running) {
236 application->setSession(session);243 application->setSession(session);
237 application->setState(Application::Running);
238
239 m_dbusWindowStack->WindowCreated(0, application->name());
240 } else {244 } else {
241 DLOG("ApplicationManager::sessionStarting - unauthorized application!!");245 DLOG("ApplicationManager::sessionStarting - unauthorized application!!");
242 }246 }
243}247}
244248
245void ApplicationManager::sessionStopping(std::shared_ptr<mir::shell::ApplicationSession> const& session)249void ApplicationManager::sessionStopping(std::shared_ptr<msh::ApplicationSession> const& session)
246{250{
247 DLOG("ApplicationManager::sessionStopping (this=%p, application=%s)", this, session->name().c_str());251 DLOG("ApplicationManager::sessionStopping (this=%p, application=%s)", this, session->name().c_str());
248252
@@ -250,14 +254,16 @@
250 Application* application = m_mainStageApplications->getApplicationWithSession(session);254 Application* application = m_mainStageApplications->getApplicationWithSession(session);
251 if (application) {255 if (application) {
252 if (application == m_mainStageFocusedApplication) {256 if (application == m_mainStageFocusedApplication) {
253 // TODO(greyback) either focus next app, or unfocus everything257 // TODO(greyback) What to do?? Focus next app, or unfocus everything??
258 m_mainStageFocusedApplication = NULL;
259 Q_EMIT mainStageFocusedApplicationChanged();
254 }260 }
255 m_mainStageApplications->remove(application);261 m_mainStageApplications->remove(application);
256 m_dbusWindowStack->WindowDestroyed(0, application->name());262 m_dbusWindowStack->WindowDestroyed(0, application->name());
257 }263 }
258}264}
259265
260void ApplicationManager::sessionFocused(std::shared_ptr<mir::shell::ApplicationSession> const& session)266void ApplicationManager::sessionFocused(std::shared_ptr<msh::ApplicationSession> const& session)
261{267{
262 DLOG("ApplicationManager::sessionFocused (this=%p, application=%s)", this, session->name().c_str());268 DLOG("ApplicationManager::sessionFocused (this=%p, application=%s)", this, session->name().c_str());
263 Application* application = m_mainStageApplications->getApplicationWithSession(session);269 Application* application = m_mainStageApplications->getApplicationWithSession(session);
@@ -280,3 +286,16 @@
280 }286 }
281}287}
282288
289void ApplicationManager::sessionCreatedSurface(msh::ApplicationSession const* session,
290 std::shared_ptr<msh::Surface> const& surface)
291{
292 DLOG("ApplicationManager::sessionCreatedSurface (this=%p)", this);
293 Q_UNUSED(surface);
294
295 Application* application = m_mainStageApplications->getApplicationWithSession(session);
296 if (application && application->state() == Application::Starting) {
297 application->setState(Application::Running);
298
299 m_dbusWindowStack->WindowCreated(0, application->name());
300 }
301}
283302
=== modified file 'src/modules/Unity/ApplicationManager/application_manager.h'
--- src/modules/Unity/ApplicationManager/application_manager.h 2013-07-24 15:07:38 +0000
+++ src/modules/Unity/ApplicationManager/application_manager.h 2013-07-24 17:24:27 +0000
@@ -14,7 +14,12 @@
14class ShellServerConfiguration;14class ShellServerConfiguration;
15class DBusWindowStack;15class DBusWindowStack;
1616
17namespace mir { namespace shell { class ApplicationSession; }}17namespace mir {
18 namespace shell {
19 class ApplicationSession;
20 class Surface;
21 }
22}
1823
19class ApplicationManager : public QObject24class ApplicationManager : public QObject
20{25{
@@ -77,6 +82,8 @@
77 void sessionFocused(std::shared_ptr<mir::shell::ApplicationSession> const& session);82 void sessionFocused(std::shared_ptr<mir::shell::ApplicationSession> const& session);
78 void sessionUnfocused();83 void sessionUnfocused();
7984
85 void sessionCreatedSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const&);
86
80private:87private:
81 ApplicationListModel* m_mainStageApplications;88 ApplicationListModel* m_mainStageApplications;
82 Application* m_mainStageFocusedApplication; // remove as Mir has API for this89 Application* m_mainStageFocusedApplication; // remove as Mir has API for this
8390
=== modified file 'src/modules/Unity/SurfaceManager/mirsurface.cpp'
--- src/modules/Unity/SurfaceManager/mirsurface.cpp 2013-07-19 17:29:44 +0000
+++ src/modules/Unity/SurfaceManager/mirsurface.cpp 2013-07-24 17:24:27 +0000
@@ -6,7 +6,7 @@
66
7namespace mg = mir::geometry;7namespace mg = mir::geometry;
88
9MirSurface::MirSurface(std::weak_ptr<mir::shell::Surface> surface, QQuickItem *parent)9MirSurface::MirSurface(std::shared_ptr<mir::shell::Surface> surface, QQuickItem *parent)
10 : QQuickItem(parent)10 : QQuickItem(parent)
11 , m_surface(surface)11 , m_surface(surface)
12{12{
@@ -25,22 +25,14 @@
2525
26qreal MirSurface::x() const26qreal MirSurface::x() const
27{27{
28 if (auto surface = m_surface.lock()) {28 int xAbsolute = m_surface->top_left().x.as_int();
29 int xAbsolute = surface->top_left().x.as_int();29 return mapFromScene((QPointF(xAbsolute, 0))).x();
30 return mapFromScene((QPointF(xAbsolute, 0))).x();
31 } else {
32 return 0;
33 }
34}30}
3531
36qreal MirSurface::y() const32qreal MirSurface::y() const
37{33{
38 if (auto surface = m_surface.lock()) {34 int yAbsolute = m_surface->top_left().y.as_int();
39 int yAbsolute = surface->top_left().y.as_int();35 return mapFromScene((QPointF(0, yAbsolute))).y();
40 return mapFromScene((QPointF(0, yAbsolute))).y();
41 } else {
42 return 0;
43 }
44}36}
4537
46void MirSurface::setX(qreal xValue)38void MirSurface::setX(qreal xValue)
@@ -48,13 +40,11 @@
48 using namespace mir::geometry;40 using namespace mir::geometry;
49 qreal xAbsolute = mapToScene(QPointF(xValue, 0)).x();41 qreal xAbsolute = mapToScene(QPointF(xValue, 0)).x();
5042
51 if (auto surface = m_surface.lock()) {43 Point position = m_surface->top_left();
52 Point position = surface->top_left();44 if (position.x.as_int() != (int) xAbsolute) {
53 if (position.x.as_int() != (int) xAbsolute) {45 position.x = X{xAbsolute};
54 position.x = X{xAbsolute};46 m_surface->move_to(position);
55 surface->move_to(position);47 Q_EMIT xChanged();
56 Q_EMIT xChanged();
57 }
58 }48 }
59}49}
6050
@@ -63,45 +53,33 @@
63 using namespace mir::geometry;53 using namespace mir::geometry;
64 qreal yAbsolute = mapToScene(QPointF(0, yValue)).y();54 qreal yAbsolute = mapToScene(QPointF(0, yValue)).y();
6555
66 if (auto surface = m_surface.lock()) {56 Point position = m_surface->top_left();
67 Point position = surface->top_left();57 if (position.y.as_int() != (int) yAbsolute) {
68 if (position.y.as_int() != (int) yAbsolute) {58 position.y = Y{yAbsolute};
69 position.y = Y{yAbsolute};59 m_surface->move_to(position);
70 surface->move_to(position);60 Q_EMIT yChanged();
71 Q_EMIT yChanged();
72 }
73 }61 }
74}62}
7563
76qreal MirSurface::width() const64qreal MirSurface::width() const
77{65{
78 if (auto surface = m_surface.lock()) {66 return m_surface->size().width.as_int();
79 return surface->size().width.as_int();
80 } else {
81 return 0;
82 }
83}67}
8468
85qreal MirSurface::height() const69qreal MirSurface::height() const
86{70{
87 if (auto surface = m_surface.lock()) {71 return m_surface->size().height.as_int();
88 return surface->size().height.as_int();
89 } else {
90 return 0;
91 }
92}72}
9373
94void MirSurface::setWidth(qreal widthValue)74void MirSurface::setWidth(qreal widthValue)
95{75{
96 using namespace mir::geometry;76 using namespace mir::geometry;
9777
98 if (auto surface = m_surface.lock()) {78 Size size = m_surface->size();
99 Size size = surface->size();79 if (size.width.as_int() != (int) widthValue) {
100 if (size.width.as_int() != (int) widthValue) {80 size.width = Width{widthValue};
101 size.width = Width{widthValue};81// m_surface->set_size(size); //MISSING FROM API
102// m_surface->set_size(size); //MISSING FROM API82 Q_EMIT widthChanged();
103 Q_EMIT widthChanged();
104 }
105 }83 }
106}84}
10785
@@ -109,13 +87,11 @@
109{87{
110 using namespace mir::geometry;88 using namespace mir::geometry;
11189
112 if (auto surface = m_surface.lock()) {90 Size size = m_surface->size();
113 Size size = surface->size();91 if (size.height.as_int() != (int) heightValue) {
114 if (size.height.as_int() != (int) heightValue) {92 size.height = Height{heightValue};
115 size.height = Height{heightValue};93// m_surface->set_size(size); //MISSING FROM API
116// m_surface->set_size(size); //MISSING FROM API94 Q_EMIT heightChanged();
117 Q_EMIT heightChanged();
118 }
119 }95 }
120}96}
12197
@@ -128,51 +104,38 @@
128{104{
129 if (visible == m_visible) return;105 if (visible == m_visible) return;
130106
131 if (auto surface = m_surface.lock()) {107 if (visible) {
132 if (visible) {108 m_surface->show();
133 surface->show();109 } else {
134 } else {110 m_surface->hide();
135 surface->hide();
136 }
137 m_visible = visible;
138 Q_EMIT visibleChanged();
139 }111 }
112 m_visible = visible;
113 Q_EMIT visibleChanged();
140}114}
141115
142116
143MirSurface::Type MirSurface::type() const117MirSurface::Type MirSurface::type() const
144{ //FIXME - how to listen to change in this property118{
145 if (auto surface = m_surface.lock()) {119 //FIXME - how to listen to change in this property
146 return static_cast<MirSurface::Type>(surface->type());120 return static_cast<MirSurface::Type>(m_surface->type());
147 } else {
148 return Normal;
149 }
150}121}
151122
152MirSurface::State MirSurface::state() const123MirSurface::State MirSurface::state() const
153{ //FIXME - how to listen to change in this property124{
154 if (auto surface = m_surface.lock()) {125 //FIXME - how to listen to change in this property
155 return static_cast<MirSurface::State>(surface->state());126 return static_cast<MirSurface::State>(m_surface->state());
156 } else {
157 return Unknown;
158 }
159}127}
160128
161QString MirSurface::name() const129QString MirSurface::name() const
162{ //FIXME - how to listen to change in this property130{
163 if (auto surface = m_surface.lock()) {131 //FIXME - how to listen to change in this property
164 return QString::fromStdString(surface->name());132 return QString::fromStdString(m_surface->name());
165 } else {
166 return QString();
167 }
168}133}
169134
170void MirSurface::installInputArea(const InputArea* area)135void MirSurface::installInputArea(const InputArea* area)
171{136{
172 if (auto surface = m_surface.lock()) {137 if (!m_surface->supports_input()) {
173 if (!surface->supports_input()) {138 LOG("MirSurface::installInputArea - surface does not support input");
174 DLOG("MirSurface::installInputArea - surface does not support input");
175 }
176 }139 }
177140
178 m_inputAreas.push_back(area);141 m_inputAreas.push_back(area);
@@ -181,11 +144,7 @@
181 /* WARNING: by default, a surface has an input region covering the whole surface.144 /* WARNING: by default, a surface has an input region covering the whole surface.
182 Once the surface input region is set, the default will *not* be restored when145 Once the surface input region is set, the default will *not* be restored when
183 all input regions are removed/disabled */146 all input regions are removed/disabled */
184 if (auto surface = m_surface.lock()) {147 m_surface->set_input_region(m_mirInputAreas);
185 surface->set_input_region(m_mirInputAreas);
186 } else {
187 DLOG("MirSurface::installInputArea - unable to set surface input region");
188 }
189}148}
190149
191bool MirSurface::removeInputArea(const InputArea* area)150bool MirSurface::removeInputArea(const InputArea* area)
192151
=== modified file 'src/modules/Unity/SurfaceManager/mirsurface.h'
--- src/modules/Unity/SurfaceManager/mirsurface.h 2013-07-19 17:29:44 +0000
+++ src/modules/Unity/SurfaceManager/mirsurface.h 2013-07-24 17:24:27 +0000
@@ -10,6 +10,7 @@
1010
1111
12namespace mir { namespace geometry { struct Rectangle; }}12namespace mir { namespace geometry { struct Rectangle; }}
13class MirSurfaceManager;
13class InputArea;14class InputArea;
1415
15class MirSurface : public QQuickItem16class MirSurface : public QQuickItem
@@ -29,7 +30,7 @@
29 Q_PROPERTY(QString name READ name NOTIFY nameChanged)30 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
3031
31public:32public:
32 explicit MirSurface(std::weak_ptr<mir::shell::Surface> surface, QQuickItem *parent = 0);33 explicit MirSurface(std::shared_ptr<mir::shell::Surface> surface, QQuickItem *parent = 0);
33 ~MirSurface();34 ~MirSurface();
3435
35 enum Type {36 enum Type {
@@ -81,7 +82,7 @@
81 void visibleChanged();82 void visibleChanged();
8283
83protected:84protected:
84 std::weak_ptr<mir::shell::Surface> m_surface;85 std::shared_ptr<mir::shell::Surface> m_surface;
8586
86private:87private:
87 // start of methods used by InputFilter88 // start of methods used by InputFilter
@@ -97,6 +98,7 @@
9798
98 bool m_visible:true; //FIXME(greyback) state should be in Mir::Shell::Surface, not here99 bool m_visible:true; //FIXME(greyback) state should be in Mir::Shell::Surface, not here
99100
101 friend class MirSurfaceManager;
100 friend class InputArea;102 friend class InputArea;
101};103};
102104
103105
=== modified file 'src/modules/Unity/SurfaceManager/mirsurfacemanager.cpp'
--- src/modules/Unity/SurfaceManager/mirsurfacemanager.cpp 2013-07-19 17:29:44 +0000
+++ src/modules/Unity/SurfaceManager/mirsurfacemanager.cpp 2013-07-24 17:24:27 +0000
@@ -5,6 +5,7 @@
5// local5// local
6#include "qmirserverapplication.h"6#include "qmirserverapplication.h"
7#include "shellserverconfiguration.h"7#include "shellserverconfiguration.h"
8#include "sessionlistener.h"
8#include "surfacesource.h"9#include "surfacesource.h"
9#include "mirsurfacemanager.h"10#include "mirsurfacemanager.h"
10#include "mirsurface.h"11#include "mirsurface.h"
@@ -25,8 +26,10 @@
25 }26 }
26 m_mirServer = mirServerApplication->server();27 m_mirServer = mirServerApplication->server();
2728
28 QObject::connect(m_mirServer->surfaceSource(), &SurfaceSource::surfaceCreated,29 QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionCreatedSurface,
29 this, &MirSurfaceManager::mirSurfaceCreated);30 this, &MirSurfaceManager::sessionCreatedSurface);
31 QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionDestroyingSurface,
32 this, &MirSurfaceManager::sessionDestroyingSurface);
30}33}
3134
32MirSurfaceManager::~MirSurfaceManager()35MirSurfaceManager::~MirSurfaceManager()
@@ -39,11 +42,27 @@
39 m_surfaces.clear();42 m_surfaces.clear();
40}43}
4144
42void MirSurfaceManager::mirSurfaceCreated(const std::shared_ptr<msh::Surface> &surface)45void MirSurfaceManager::sessionCreatedSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const& surface)
43{46{
44 DLOG("MirSurfaceManager::surfaceCreated (this=%p) with surface name '%s'", this, surface->name().c_str());47 DLOG("MirSurfaceManager::sessionCreatedSurface (this=%p) with surface name '%s'", this, surface->name().c_str());
45 auto qmlSurface = new MirSurface(surface);48 auto qmlSurface = new MirSurface(surface);
4649
47 m_surfaces.prepend(qmlSurface);50 m_surfaces.prepend(qmlSurface);
48 Q_EMIT surfaceCreated(qmlSurface);51 Q_EMIT surfaceCreated(qmlSurface);
49}52}
53
54void MirSurfaceManager::sessionDestroyingSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const& surface)
55{
56 DLOG("MirSurfaceManager::sessionDestroyingSurface (this=%p) with surface name '%s'", this, surface->name().c_str());
57
58 Q_FOREACH(MirSurface* s, m_surfaces) {
59 if (s->m_surface == surface) {
60 m_surfaces.removeOne(s);
61 Q_EMIT surfaceDestroyed(s);
62 return;
63 }
64 }
65
66 DLOG("MirSurfaceManager::sessionDestroyingSurface: unable to find MirSurface corresponding to surface '%s'", surface->name().c_str());
67}
68
5069
=== modified file 'src/modules/Unity/SurfaceManager/mirsurfacemanager.h'
--- src/modules/Unity/SurfaceManager/mirsurfacemanager.h 2013-07-19 17:29:44 +0000
+++ src/modules/Unity/SurfaceManager/mirsurfacemanager.h 2013-07-24 17:24:27 +0000
@@ -10,7 +10,7 @@
10#include "mirsurface.h"10#include "mirsurface.h"
1111
12class ShellServerConfiguration;12class ShellServerConfiguration;
13namespace mir { namespace shell { class Surface; }}13namespace mir { namespace shell { class Surface; class ApplicationSession; }}
1414
15class MirSurfaceManager : public QObject15class MirSurfaceManager : public QObject
16{16{
@@ -24,12 +24,13 @@
2424
25Q_SIGNALS:25Q_SIGNALS:
26 void surfaceCreated(MirSurface* surface);26 void surfaceCreated(MirSurface* surface);
27// void surfaceDestroyed(MirSurface*);27 void surfaceDestroyed(MirSurface* surface);
28// void surfaceResized(MirSurface*);28// void surfaceResized(MirSurface*);
29// void fullscreenSurfaceChanged();29// void fullscreenSurfaceChanged();
3030
31public Q_SLOTS:31public Q_SLOTS:
32 void mirSurfaceCreated(const std::shared_ptr<mir::shell::Surface>& surface);32 void sessionCreatedSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const&);
33 void sessionDestroyingSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const&);
3334
34private:35private:
35 QList<MirSurface*> m_surfaces;36 QList<MirSurface*> m_surfaces;
3637
=== modified file 'src/unity-mir/sessionlistener.cpp'
--- src/unity-mir/sessionlistener.cpp 2013-07-19 17:29:44 +0000
+++ src/unity-mir/sessionlistener.cpp 2013-07-24 17:24:27 +0000
@@ -45,3 +45,17 @@
45 DLOG("SessionListener::unfocused (this=%p)", this);45 DLOG("SessionListener::unfocused (this=%p)", this);
46 Q_EMIT sessionUnfocused();46 Q_EMIT sessionUnfocused();
47}47}
48
49void SessionListener::surface_created(msh::Session& session, std::shared_ptr<msh::Surface> const& surface)
50{
51 DLOG("SessionListener::surface_created (this=%p, session=%p, surface=%p)", this, &session, (void*)surface.get());
52 msh::ApplicationSession &appSession = dynamic_cast<msh::ApplicationSession &>(session);
53 Q_EMIT sessionCreatedSurface(&appSession, surface);
54}
55
56void SessionListener::destroying_surface(msh::Session& session, std::shared_ptr<mir::shell::Surface> const& surface)
57{
58 DLOG("SessionListener::destroying_surface (this=%p, session=%p, surface=%p)", this, &session, (void*)surface.get());
59 msh::ApplicationSession &appSession = dynamic_cast<msh::ApplicationSession &>(session);
60 Q_EMIT sessionDestroyingSurface(&appSession, surface);
61}
4862
=== modified file 'src/unity-mir/sessionlistener.h'
--- src/unity-mir/sessionlistener.h 2013-07-24 16:34:31 +0000
+++ src/unity-mir/sessionlistener.h 2013-07-24 17:24:27 +0000
@@ -18,14 +18,17 @@
18 void focused(std::shared_ptr<mir::shell::Session> const& session) override;18 void focused(std::shared_ptr<mir::shell::Session> const& session) override;
19 void unfocused() override;19 void unfocused() override;
2020
21 void surface_created(mir::shell::Session&, std::shared_ptr<mir::shell::Surface> const&) override {}21 void surface_created(mir::shell::Session&, std::shared_ptr<mir::shell::Surface> const&) override;
22 void destroying_surface(mir::shell::Session&, std::shared_ptr<mir::shell::Surface> const&) override {}22 void destroying_surface(mir::shell::Session&, std::shared_ptr<mir::shell::Surface> const&) override;
23 23
24Q_SIGNALS:24Q_SIGNALS:
25 void sessionStarting(std::shared_ptr<mir::shell::ApplicationSession> const& session);25 void sessionStarting(std::shared_ptr<mir::shell::ApplicationSession> const& session);
26 void sessionStopping(std::shared_ptr<mir::shell::ApplicationSession> const& session);26 void sessionStopping(std::shared_ptr<mir::shell::ApplicationSession> const& session);
27 void sessionFocused(std::shared_ptr<mir::shell::ApplicationSession> const& session);27 void sessionFocused(std::shared_ptr<mir::shell::ApplicationSession> const& session);
28 void sessionUnfocused();28 void sessionUnfocused();
29
30 void sessionCreatedSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const&);
31 void sessionDestroyingSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const&);
29};32};
3033
31#endif // SESSIONLISTENER_H34#endif // SESSIONLISTENER_H
3235
=== modified file 'src/unity-mir/surfacesource.cpp'
--- src/unity-mir/surfacesource.cpp 2013-07-19 17:29:44 +0000
+++ src/unity-mir/surfacesource.cpp 2013-07-24 17:24:27 +0000
@@ -30,8 +30,6 @@
30 m_shellSurface = mirSurface;30 m_shellSurface = mirSurface;
31 shellSurfaceFound = true;31 shellSurfaceFound = true;
32 Q_EMIT shellSurfaceCreated(mirSurface);32 Q_EMIT shellSurfaceCreated(mirSurface);
33 } else {
34 Q_EMIT surfaceCreated(mirSurface);
35 }33 }
36 return mirSurface;34 return mirSurface;
37}35}
3836
=== modified file 'src/unity-mir/surfacesource.h'
--- src/unity-mir/surfacesource.h 2013-07-19 17:29:44 +0000
+++ src/unity-mir/surfacesource.h 2013-07-24 17:24:27 +0000
@@ -27,7 +27,6 @@
27 std::shared_ptr<mir::shell::Surface> shellSurface() const;27 std::shared_ptr<mir::shell::Surface> shellSurface() const;
2828
29Q_SIGNALS:29Q_SIGNALS:
30 void surfaceCreated(std::shared_ptr<mir::shell::Surface> const& surface);
31 void shellSurfaceCreated(std::shared_ptr<mir::shell::Surface> const& surface);30 void shellSurfaceCreated(std::shared_ptr<mir::shell::Surface> const& surface);
3231
33private:32private:

Subscribers

People subscribed via source and target branches