Merge lp:~gerboland/unity-mir/surface-notifications into lp:unity-mir
- surface-notifications
- Merge into trunk
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 |
Related bugs: |
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/
Description of the change
Update SurfaceManager and ApplicationManager to make use of new MIR API, which notifies of surface creation and destruction per session/
To post a comment you must log in.
- 22. By Gerry Boland
-
Unset mainStageFocuse
dApplication if it is closed - 23. By Gerry Boland
-
Merge trunk
- 24. By Gerry Boland
-
Reset mainStageFocuse
dApplication 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
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/modules/Unity/ApplicationManager/application_list_model.cpp' | |||
2 | --- src/modules/Unity/ApplicationManager/application_list_model.cpp 2013-07-24 15:07:38 +0000 | |||
3 | +++ src/modules/Unity/ApplicationManager/application_list_model.cpp 2013-07-24 17:24:27 +0000 | |||
4 | @@ -19,6 +19,8 @@ | |||
5 | 19 | 19 | ||
6 | 20 | #include <mir/shell/application_session.h> | 20 | #include <mir/shell/application_session.h> |
7 | 21 | 21 | ||
8 | 22 | namespace msh = mir::shell; | ||
9 | 23 | |||
10 | 22 | ApplicationListModel::ApplicationListModel(QObject* parent) | 24 | ApplicationListModel::ApplicationListModel(QObject* parent) |
11 | 23 | : QAbstractListModel(parent) | 25 | : QAbstractListModel(parent) |
12 | 24 | , m_applications() | 26 | , m_applications() |
13 | @@ -100,11 +102,16 @@ | |||
14 | 100 | } | 102 | } |
15 | 101 | } | 103 | } |
16 | 102 | 104 | ||
18 | 103 | Application* ApplicationListModel::getApplicationWithSession(const std::shared_ptr<mir::shell::Session> &session) | 105 | Application* ApplicationListModel::getApplicationWithSession(const std::shared_ptr<msh::Session> &session) |
19 | 106 | { | ||
20 | 107 | return getApplicationWithSession(session.get()); | ||
21 | 108 | } | ||
22 | 109 | |||
23 | 110 | Application* ApplicationListModel::getApplicationWithSession(const msh::Session *session) | ||
24 | 104 | { | 111 | { |
25 | 105 | Application* app = NULL; | 112 | Application* app = NULL; |
26 | 106 | Q_FOREACH(app, m_applications) { | 113 | Q_FOREACH(app, m_applications) { |
28 | 107 | if (app->session().get() == session.get()) { | 114 | if (app->session().get() == session) { |
29 | 108 | break; | 115 | break; |
30 | 109 | } | 116 | } |
31 | 110 | } | 117 | } |
32 | 111 | 118 | ||
33 | === modified file 'src/modules/Unity/ApplicationManager/application_list_model.h' | |||
34 | --- src/modules/Unity/ApplicationManager/application_list_model.h 2013-07-24 15:07:38 +0000 | |||
35 | +++ src/modules/Unity/ApplicationManager/application_list_model.h 2013-07-24 17:24:27 +0000 | |||
36 | @@ -49,6 +49,7 @@ | |||
37 | 49 | void remove(Application* application); | 49 | void remove(Application* application); |
38 | 50 | 50 | ||
39 | 51 | Application* getApplicationWithSession(const std::shared_ptr<mir::shell::Session> &session); | 51 | Application* getApplicationWithSession(const std::shared_ptr<mir::shell::Session> &session); |
40 | 52 | Application* getApplicationWithSession(const mir::shell::Session *session); | ||
41 | 52 | Application* getApplicationWithId(const int id); | 53 | Application* getApplicationWithId(const int id); |
42 | 53 | Application* getApplicationWithPid(const int pid); | 54 | Application* getApplicationWithPid(const int pid); |
43 | 54 | Application* getLastExecutedApplication(); | 55 | Application* getLastExecutedApplication(); |
44 | 55 | 56 | ||
45 | === modified file 'src/modules/Unity/ApplicationManager/application_manager.cpp' | |||
46 | --- src/modules/Unity/ApplicationManager/application_manager.cpp 2013-07-24 15:44:10 +0000 | |||
47 | +++ src/modules/Unity/ApplicationManager/application_manager.cpp 2013-07-24 17:24:27 +0000 | |||
48 | @@ -25,6 +25,8 @@ | |||
49 | 25 | #include <pwd.h> | 25 | #include <pwd.h> |
50 | 26 | #endif | 26 | #endif |
51 | 27 | 27 | ||
52 | 28 | namespace msh = mir::shell; | ||
53 | 29 | |||
54 | 28 | ApplicationManager::ApplicationManager(QObject *parent) | 30 | ApplicationManager::ApplicationManager(QObject *parent) |
55 | 29 | : QObject(parent) | 31 | : QObject(parent) |
56 | 30 | , m_mainStageApplications(new ApplicationListModel()) | 32 | , m_mainStageApplications(new ApplicationListModel()) |
57 | @@ -39,17 +41,16 @@ | |||
58 | 39 | } | 41 | } |
59 | 40 | m_mirServer = mirServerApplication->server(); | 42 | m_mirServer = mirServerApplication->server(); |
60 | 41 | 43 | ||
65 | 42 | std::shared_ptr<SessionListener> sessionListener | 44 | QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionStarting, |
62 | 43 | = std::dynamic_pointer_cast<SessionListener>(m_mirServer->the_shell_session_listener()); | ||
63 | 44 | |||
64 | 45 | QObject::connect(sessionListener.get(), &SessionListener::sessionStarting, | ||
66 | 46 | this, &ApplicationManager::sessionStarting); | 45 | this, &ApplicationManager::sessionStarting); |
68 | 47 | QObject::connect(sessionListener.get(), &SessionListener::sessionStopping, | 46 | QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionStopping, |
69 | 48 | this, &ApplicationManager::sessionStopping); | 47 | this, &ApplicationManager::sessionStopping); |
71 | 49 | QObject::connect(sessionListener.get(), &SessionListener::sessionFocused, | 48 | QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionFocused, |
72 | 50 | this, &ApplicationManager::sessionFocused); | 49 | this, &ApplicationManager::sessionFocused); |
74 | 51 | QObject::connect(sessionListener.get(), &SessionListener::sessionUnfocused, | 50 | QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionUnfocused, |
75 | 52 | this, &ApplicationManager::sessionUnfocused); | 51 | this, &ApplicationManager::sessionUnfocused); |
76 | 52 | QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionCreatedSurface, | ||
77 | 53 | this, &ApplicationManager::sessionCreatedSurface); | ||
78 | 53 | 54 | ||
79 | 54 | std::shared_ptr<SessionAuthorizer> sessionAuthorizer | 55 | std::shared_ptr<SessionAuthorizer> sessionAuthorizer |
80 | 55 | = std::dynamic_pointer_cast<SessionAuthorizer>(m_mirServer->the_session_authorizer()); | 56 | = std::dynamic_pointer_cast<SessionAuthorizer>(m_mirServer->the_session_authorizer()); |
81 | @@ -193,7 +194,13 @@ | |||
82 | 193 | DLOG("ApplicationManager::stopProcess (this=%p, application=%p)", this, application); | 194 | DLOG("ApplicationManager::stopProcess (this=%p, application=%p)", this, application); |
83 | 194 | 195 | ||
84 | 195 | if (application != NULL) { | 196 | if (application != NULL) { |
85 | 197 | if (application == m_mainStageFocusedApplication) { | ||
86 | 198 | // TODO(greyback) What to do?? Focus next app, or unfocus everything?? | ||
87 | 199 | m_mainStageFocusedApplication = NULL; | ||
88 | 200 | Q_EMIT mainStageFocusedApplicationChanged(); | ||
89 | 201 | } | ||
90 | 196 | m_mainStageApplications->remove(application); | 202 | m_mainStageApplications->remove(application); |
91 | 203 | m_dbusWindowStack->WindowDestroyed(0, application->name()); | ||
92 | 197 | 204 | ||
93 | 198 | // Start process. | 205 | // Start process. |
94 | 199 | bool result; | 206 | bool result; |
95 | @@ -225,7 +232,7 @@ | |||
96 | 225 | } | 232 | } |
97 | 226 | } | 233 | } |
98 | 227 | 234 | ||
100 | 228 | void ApplicationManager::sessionStarting(std::shared_ptr<mir::shell::ApplicationSession> const& session) | 235 | void ApplicationManager::sessionStarting(std::shared_ptr<msh::ApplicationSession> const& session) |
101 | 229 | { | 236 | { |
102 | 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()); |
103 | 231 | 238 | ||
104 | @@ -234,15 +241,12 @@ | |||
105 | 234 | Application* application = m_mainStageApplications->getLastExecutedApplication(); | 241 | Application* application = m_mainStageApplications->getLastExecutedApplication(); |
106 | 235 | if (application && application->state() != Application::Running) { | 242 | if (application && application->state() != Application::Running) { |
107 | 236 | application->setSession(session); | 243 | application->setSession(session); |
108 | 237 | application->setState(Application::Running); | ||
109 | 238 | |||
110 | 239 | m_dbusWindowStack->WindowCreated(0, application->name()); | ||
111 | 240 | } else { | 244 | } else { |
112 | 241 | DLOG("ApplicationManager::sessionStarting - unauthorized application!!"); | 245 | DLOG("ApplicationManager::sessionStarting - unauthorized application!!"); |
113 | 242 | } | 246 | } |
114 | 243 | } | 247 | } |
115 | 244 | 248 | ||
117 | 245 | void ApplicationManager::sessionStopping(std::shared_ptr<mir::shell::ApplicationSession> const& session) | 249 | void ApplicationManager::sessionStopping(std::shared_ptr<msh::ApplicationSession> const& session) |
118 | 246 | { | 250 | { |
119 | 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()); |
120 | 248 | 252 | ||
121 | @@ -250,14 +254,16 @@ | |||
122 | 250 | Application* application = m_mainStageApplications->getApplicationWithSession(session); | 254 | Application* application = m_mainStageApplications->getApplicationWithSession(session); |
123 | 251 | if (application) { | 255 | if (application) { |
124 | 252 | if (application == m_mainStageFocusedApplication) { | 256 | if (application == m_mainStageFocusedApplication) { |
126 | 253 | // TODO(greyback) either focus next app, or unfocus everything | 257 | // TODO(greyback) What to do?? Focus next app, or unfocus everything?? |
127 | 258 | m_mainStageFocusedApplication = NULL; | ||
128 | 259 | Q_EMIT mainStageFocusedApplicationChanged(); | ||
129 | 254 | } | 260 | } |
130 | 255 | m_mainStageApplications->remove(application); | 261 | m_mainStageApplications->remove(application); |
131 | 256 | m_dbusWindowStack->WindowDestroyed(0, application->name()); | 262 | m_dbusWindowStack->WindowDestroyed(0, application->name()); |
132 | 257 | } | 263 | } |
133 | 258 | } | 264 | } |
134 | 259 | 265 | ||
136 | 260 | void ApplicationManager::sessionFocused(std::shared_ptr<mir::shell::ApplicationSession> const& session) | 266 | void ApplicationManager::sessionFocused(std::shared_ptr<msh::ApplicationSession> const& session) |
137 | 261 | { | 267 | { |
138 | 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()); |
139 | 263 | Application* application = m_mainStageApplications->getApplicationWithSession(session); | 269 | Application* application = m_mainStageApplications->getApplicationWithSession(session); |
140 | @@ -280,3 +286,16 @@ | |||
141 | 280 | } | 286 | } |
142 | 281 | } | 287 | } |
143 | 282 | 288 | ||
144 | 289 | void ApplicationManager::sessionCreatedSurface(msh::ApplicationSession const* session, | ||
145 | 290 | std::shared_ptr<msh::Surface> const& surface) | ||
146 | 291 | { | ||
147 | 292 | DLOG("ApplicationManager::sessionCreatedSurface (this=%p)", this); | ||
148 | 293 | Q_UNUSED(surface); | ||
149 | 294 | |||
150 | 295 | Application* application = m_mainStageApplications->getApplicationWithSession(session); | ||
151 | 296 | if (application && application->state() == Application::Starting) { | ||
152 | 297 | application->setState(Application::Running); | ||
153 | 298 | |||
154 | 299 | m_dbusWindowStack->WindowCreated(0, application->name()); | ||
155 | 300 | } | ||
156 | 301 | } | ||
157 | 283 | 302 | ||
158 | === modified file 'src/modules/Unity/ApplicationManager/application_manager.h' | |||
159 | --- src/modules/Unity/ApplicationManager/application_manager.h 2013-07-24 15:07:38 +0000 | |||
160 | +++ src/modules/Unity/ApplicationManager/application_manager.h 2013-07-24 17:24:27 +0000 | |||
161 | @@ -14,7 +14,12 @@ | |||
162 | 14 | class ShellServerConfiguration; | 14 | class ShellServerConfiguration; |
163 | 15 | class DBusWindowStack; | 15 | class DBusWindowStack; |
164 | 16 | 16 | ||
166 | 17 | namespace mir { namespace shell { class ApplicationSession; }} | 17 | namespace mir { |
167 | 18 | namespace shell { | ||
168 | 19 | class ApplicationSession; | ||
169 | 20 | class Surface; | ||
170 | 21 | } | ||
171 | 22 | } | ||
172 | 18 | 23 | ||
173 | 19 | class ApplicationManager : public QObject | 24 | class ApplicationManager : public QObject |
174 | 20 | { | 25 | { |
175 | @@ -77,6 +82,8 @@ | |||
176 | 77 | void sessionFocused(std::shared_ptr<mir::shell::ApplicationSession> const& session); | 82 | void sessionFocused(std::shared_ptr<mir::shell::ApplicationSession> const& session); |
177 | 78 | void sessionUnfocused(); | 83 | void sessionUnfocused(); |
178 | 79 | 84 | ||
179 | 85 | void sessionCreatedSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const&); | ||
180 | 86 | |||
181 | 80 | private: | 87 | private: |
182 | 81 | ApplicationListModel* m_mainStageApplications; | 88 | ApplicationListModel* m_mainStageApplications; |
183 | 82 | Application* m_mainStageFocusedApplication; // remove as Mir has API for this | 89 | Application* m_mainStageFocusedApplication; // remove as Mir has API for this |
184 | 83 | 90 | ||
185 | === modified file 'src/modules/Unity/SurfaceManager/mirsurface.cpp' | |||
186 | --- src/modules/Unity/SurfaceManager/mirsurface.cpp 2013-07-19 17:29:44 +0000 | |||
187 | +++ src/modules/Unity/SurfaceManager/mirsurface.cpp 2013-07-24 17:24:27 +0000 | |||
188 | @@ -6,7 +6,7 @@ | |||
189 | 6 | 6 | ||
190 | 7 | namespace mg = mir::geometry; | 7 | namespace mg = mir::geometry; |
191 | 8 | 8 | ||
193 | 9 | MirSurface::MirSurface(std::weak_ptr<mir::shell::Surface> surface, QQuickItem *parent) | 9 | MirSurface::MirSurface(std::shared_ptr<mir::shell::Surface> surface, QQuickItem *parent) |
194 | 10 | : QQuickItem(parent) | 10 | : QQuickItem(parent) |
195 | 11 | , m_surface(surface) | 11 | , m_surface(surface) |
196 | 12 | { | 12 | { |
197 | @@ -25,22 +25,14 @@ | |||
198 | 25 | 25 | ||
199 | 26 | qreal MirSurface::x() const | 26 | qreal MirSurface::x() const |
200 | 27 | { | 27 | { |
207 | 28 | if (auto surface = m_surface.lock()) { | 28 | int xAbsolute = m_surface->top_left().x.as_int(); |
208 | 29 | int xAbsolute = surface->top_left().x.as_int(); | 29 | return mapFromScene((QPointF(xAbsolute, 0))).x(); |
203 | 30 | return mapFromScene((QPointF(xAbsolute, 0))).x(); | ||
204 | 31 | } else { | ||
205 | 32 | return 0; | ||
206 | 33 | } | ||
209 | 34 | } | 30 | } |
210 | 35 | 31 | ||
211 | 36 | qreal MirSurface::y() const | 32 | qreal MirSurface::y() const |
212 | 37 | { | 33 | { |
219 | 38 | if (auto surface = m_surface.lock()) { | 34 | int yAbsolute = m_surface->top_left().y.as_int(); |
220 | 39 | int yAbsolute = surface->top_left().y.as_int(); | 35 | return mapFromScene((QPointF(0, yAbsolute))).y(); |
215 | 40 | return mapFromScene((QPointF(0, yAbsolute))).y(); | ||
216 | 41 | } else { | ||
217 | 42 | return 0; | ||
218 | 43 | } | ||
221 | 44 | } | 36 | } |
222 | 45 | 37 | ||
223 | 46 | void MirSurface::setX(qreal xValue) | 38 | void MirSurface::setX(qreal xValue) |
224 | @@ -48,13 +40,11 @@ | |||
225 | 48 | using namespace mir::geometry; | 40 | using namespace mir::geometry; |
226 | 49 | qreal xAbsolute = mapToScene(QPointF(xValue, 0)).x(); | 41 | qreal xAbsolute = mapToScene(QPointF(xValue, 0)).x(); |
227 | 50 | 42 | ||
235 | 51 | if (auto surface = m_surface.lock()) { | 43 | Point position = m_surface->top_left(); |
236 | 52 | Point position = surface->top_left(); | 44 | if (position.x.as_int() != (int) xAbsolute) { |
237 | 53 | if (position.x.as_int() != (int) xAbsolute) { | 45 | position.x = X{xAbsolute}; |
238 | 54 | position.x = X{xAbsolute}; | 46 | m_surface->move_to(position); |
239 | 55 | surface->move_to(position); | 47 | Q_EMIT xChanged(); |
233 | 56 | Q_EMIT xChanged(); | ||
234 | 57 | } | ||
240 | 58 | } | 48 | } |
241 | 59 | } | 49 | } |
242 | 60 | 50 | ||
243 | @@ -63,45 +53,33 @@ | |||
244 | 63 | using namespace mir::geometry; | 53 | using namespace mir::geometry; |
245 | 64 | qreal yAbsolute = mapToScene(QPointF(0, yValue)).y(); | 54 | qreal yAbsolute = mapToScene(QPointF(0, yValue)).y(); |
246 | 65 | 55 | ||
254 | 66 | if (auto surface = m_surface.lock()) { | 56 | Point position = m_surface->top_left(); |
255 | 67 | Point position = surface->top_left(); | 57 | if (position.y.as_int() != (int) yAbsolute) { |
256 | 68 | if (position.y.as_int() != (int) yAbsolute) { | 58 | position.y = Y{yAbsolute}; |
257 | 69 | position.y = Y{yAbsolute}; | 59 | m_surface->move_to(position); |
258 | 70 | surface->move_to(position); | 60 | Q_EMIT yChanged(); |
252 | 71 | Q_EMIT yChanged(); | ||
253 | 72 | } | ||
259 | 73 | } | 61 | } |
260 | 74 | } | 62 | } |
261 | 75 | 63 | ||
262 | 76 | qreal MirSurface::width() const | 64 | qreal MirSurface::width() const |
263 | 77 | { | 65 | { |
269 | 78 | if (auto surface = m_surface.lock()) { | 66 | return m_surface->size().width.as_int(); |
265 | 79 | return surface->size().width.as_int(); | ||
266 | 80 | } else { | ||
267 | 81 | return 0; | ||
268 | 82 | } | ||
270 | 83 | } | 67 | } |
271 | 84 | 68 | ||
272 | 85 | qreal MirSurface::height() const | 69 | qreal MirSurface::height() const |
273 | 86 | { | 70 | { |
279 | 87 | if (auto surface = m_surface.lock()) { | 71 | return m_surface->size().height.as_int(); |
275 | 88 | return surface->size().height.as_int(); | ||
276 | 89 | } else { | ||
277 | 90 | return 0; | ||
278 | 91 | } | ||
280 | 92 | } | 72 | } |
281 | 93 | 73 | ||
282 | 94 | void MirSurface::setWidth(qreal widthValue) | 74 | void MirSurface::setWidth(qreal widthValue) |
283 | 95 | { | 75 | { |
284 | 96 | using namespace mir::geometry; | 76 | using namespace mir::geometry; |
285 | 97 | 77 | ||
293 | 98 | if (auto surface = m_surface.lock()) { | 78 | Size size = m_surface->size(); |
294 | 99 | Size size = surface->size(); | 79 | if (size.width.as_int() != (int) widthValue) { |
295 | 100 | if (size.width.as_int() != (int) widthValue) { | 80 | size.width = Width{widthValue}; |
296 | 101 | size.width = Width{widthValue}; | 81 | // m_surface->set_size(size); //MISSING FROM API |
297 | 102 | // m_surface->set_size(size); //MISSING FROM API | 82 | Q_EMIT widthChanged(); |
291 | 103 | Q_EMIT widthChanged(); | ||
292 | 104 | } | ||
298 | 105 | } | 83 | } |
299 | 106 | } | 84 | } |
300 | 107 | 85 | ||
301 | @@ -109,13 +87,11 @@ | |||
302 | 109 | { | 87 | { |
303 | 110 | using namespace mir::geometry; | 88 | using namespace mir::geometry; |
304 | 111 | 89 | ||
312 | 112 | if (auto surface = m_surface.lock()) { | 90 | Size size = m_surface->size(); |
313 | 113 | Size size = surface->size(); | 91 | if (size.height.as_int() != (int) heightValue) { |
314 | 114 | if (size.height.as_int() != (int) heightValue) { | 92 | size.height = Height{heightValue}; |
315 | 115 | size.height = Height{heightValue}; | 93 | // m_surface->set_size(size); //MISSING FROM API |
316 | 116 | // m_surface->set_size(size); //MISSING FROM API | 94 | Q_EMIT heightChanged(); |
310 | 117 | Q_EMIT heightChanged(); | ||
311 | 118 | } | ||
317 | 119 | } | 95 | } |
318 | 120 | } | 96 | } |
319 | 121 | 97 | ||
320 | @@ -128,51 +104,38 @@ | |||
321 | 128 | { | 104 | { |
322 | 129 | if (visible == m_visible) return; | 105 | if (visible == m_visible) return; |
323 | 130 | 106 | ||
332 | 131 | if (auto surface = m_surface.lock()) { | 107 | if (visible) { |
333 | 132 | if (visible) { | 108 | m_surface->show(); |
334 | 133 | surface->show(); | 109 | } else { |
335 | 134 | } else { | 110 | m_surface->hide(); |
328 | 135 | surface->hide(); | ||
329 | 136 | } | ||
330 | 137 | m_visible = visible; | ||
331 | 138 | Q_EMIT visibleChanged(); | ||
336 | 139 | } | 111 | } |
337 | 112 | m_visible = visible; | ||
338 | 113 | Q_EMIT visibleChanged(); | ||
339 | 140 | } | 114 | } |
340 | 141 | 115 | ||
341 | 142 | 116 | ||
342 | 143 | MirSurface::Type MirSurface::type() const | 117 | MirSurface::Type MirSurface::type() const |
349 | 144 | { //FIXME - how to listen to change in this property | 118 | { |
350 | 145 | if (auto surface = m_surface.lock()) { | 119 | //FIXME - how to listen to change in this property |
351 | 146 | return static_cast<MirSurface::Type>(surface->type()); | 120 | return static_cast<MirSurface::Type>(m_surface->type()); |
346 | 147 | } else { | ||
347 | 148 | return Normal; | ||
348 | 149 | } | ||
352 | 150 | } | 121 | } |
353 | 151 | 122 | ||
354 | 152 | MirSurface::State MirSurface::state() const | 123 | MirSurface::State MirSurface::state() const |
361 | 153 | { //FIXME - how to listen to change in this property | 124 | { |
362 | 154 | if (auto surface = m_surface.lock()) { | 125 | //FIXME - how to listen to change in this property |
363 | 155 | return static_cast<MirSurface::State>(surface->state()); | 126 | return static_cast<MirSurface::State>(m_surface->state()); |
358 | 156 | } else { | ||
359 | 157 | return Unknown; | ||
360 | 158 | } | ||
364 | 159 | } | 127 | } |
365 | 160 | 128 | ||
366 | 161 | QString MirSurface::name() const | 129 | QString MirSurface::name() const |
373 | 162 | { //FIXME - how to listen to change in this property | 130 | { |
374 | 163 | if (auto surface = m_surface.lock()) { | 131 | //FIXME - how to listen to change in this property |
375 | 164 | return QString::fromStdString(surface->name()); | 132 | return QString::fromStdString(m_surface->name()); |
370 | 165 | } else { | ||
371 | 166 | return QString(); | ||
372 | 167 | } | ||
376 | 168 | } | 133 | } |
377 | 169 | 134 | ||
378 | 170 | void MirSurface::installInputArea(const InputArea* area) | 135 | void MirSurface::installInputArea(const InputArea* area) |
379 | 171 | { | 136 | { |
384 | 172 | if (auto surface = m_surface.lock()) { | 137 | if (!m_surface->supports_input()) { |
385 | 173 | if (!surface->supports_input()) { | 138 | LOG("MirSurface::installInputArea - surface does not support input"); |
382 | 174 | DLOG("MirSurface::installInputArea - surface does not support input"); | ||
383 | 175 | } | ||
386 | 176 | } | 139 | } |
387 | 177 | 140 | ||
388 | 178 | m_inputAreas.push_back(area); | 141 | m_inputAreas.push_back(area); |
389 | @@ -181,11 +144,7 @@ | |||
390 | 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. |
391 | 182 | Once the surface input region is set, the default will *not* be restored when | 145 | Once the surface input region is set, the default will *not* be restored when |
392 | 183 | all input regions are removed/disabled */ | 146 | all input regions are removed/disabled */ |
398 | 184 | if (auto surface = m_surface.lock()) { | 147 | m_surface->set_input_region(m_mirInputAreas); |
394 | 185 | surface->set_input_region(m_mirInputAreas); | ||
395 | 186 | } else { | ||
396 | 187 | DLOG("MirSurface::installInputArea - unable to set surface input region"); | ||
397 | 188 | } | ||
399 | 189 | } | 148 | } |
400 | 190 | 149 | ||
401 | 191 | bool MirSurface::removeInputArea(const InputArea* area) | 150 | bool MirSurface::removeInputArea(const InputArea* area) |
402 | 192 | 151 | ||
403 | === modified file 'src/modules/Unity/SurfaceManager/mirsurface.h' | |||
404 | --- src/modules/Unity/SurfaceManager/mirsurface.h 2013-07-19 17:29:44 +0000 | |||
405 | +++ src/modules/Unity/SurfaceManager/mirsurface.h 2013-07-24 17:24:27 +0000 | |||
406 | @@ -10,6 +10,7 @@ | |||
407 | 10 | 10 | ||
408 | 11 | 11 | ||
409 | 12 | namespace mir { namespace geometry { struct Rectangle; }} | 12 | namespace mir { namespace geometry { struct Rectangle; }} |
410 | 13 | class MirSurfaceManager; | ||
411 | 13 | class InputArea; | 14 | class InputArea; |
412 | 14 | 15 | ||
413 | 15 | class MirSurface : public QQuickItem | 16 | class MirSurface : public QQuickItem |
414 | @@ -29,7 +30,7 @@ | |||
415 | 29 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) | 30 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) |
416 | 30 | 31 | ||
417 | 31 | public: | 32 | public: |
419 | 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); |
420 | 33 | ~MirSurface(); | 34 | ~MirSurface(); |
421 | 34 | 35 | ||
422 | 35 | enum Type { | 36 | enum Type { |
423 | @@ -81,7 +82,7 @@ | |||
424 | 81 | void visibleChanged(); | 82 | void visibleChanged(); |
425 | 82 | 83 | ||
426 | 83 | protected: | 84 | protected: |
428 | 84 | std::weak_ptr<mir::shell::Surface> m_surface; | 85 | std::shared_ptr<mir::shell::Surface> m_surface; |
429 | 85 | 86 | ||
430 | 86 | private: | 87 | private: |
431 | 87 | // start of methods used by InputFilter | 88 | // start of methods used by InputFilter |
432 | @@ -97,6 +98,7 @@ | |||
433 | 97 | 98 | ||
434 | 98 | bool m_visible:true; //FIXME(greyback) state should be in Mir::Shell::Surface, not here | 99 | bool m_visible:true; //FIXME(greyback) state should be in Mir::Shell::Surface, not here |
435 | 99 | 100 | ||
436 | 101 | friend class MirSurfaceManager; | ||
437 | 100 | friend class InputArea; | 102 | friend class InputArea; |
438 | 101 | }; | 103 | }; |
439 | 102 | 104 | ||
440 | 103 | 105 | ||
441 | === modified file 'src/modules/Unity/SurfaceManager/mirsurfacemanager.cpp' | |||
442 | --- src/modules/Unity/SurfaceManager/mirsurfacemanager.cpp 2013-07-19 17:29:44 +0000 | |||
443 | +++ src/modules/Unity/SurfaceManager/mirsurfacemanager.cpp 2013-07-24 17:24:27 +0000 | |||
444 | @@ -5,6 +5,7 @@ | |||
445 | 5 | // local | 5 | // local |
446 | 6 | #include "qmirserverapplication.h" | 6 | #include "qmirserverapplication.h" |
447 | 7 | #include "shellserverconfiguration.h" | 7 | #include "shellserverconfiguration.h" |
448 | 8 | #include "sessionlistener.h" | ||
449 | 8 | #include "surfacesource.h" | 9 | #include "surfacesource.h" |
450 | 9 | #include "mirsurfacemanager.h" | 10 | #include "mirsurfacemanager.h" |
451 | 10 | #include "mirsurface.h" | 11 | #include "mirsurface.h" |
452 | @@ -25,8 +26,10 @@ | |||
453 | 25 | } | 26 | } |
454 | 26 | m_mirServer = mirServerApplication->server(); | 27 | m_mirServer = mirServerApplication->server(); |
455 | 27 | 28 | ||
458 | 28 | QObject::connect(m_mirServer->surfaceSource(), &SurfaceSource::surfaceCreated, | 29 | QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionCreatedSurface, |
459 | 29 | this, &MirSurfaceManager::mirSurfaceCreated); | 30 | this, &MirSurfaceManager::sessionCreatedSurface); |
460 | 31 | QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionDestroyingSurface, | ||
461 | 32 | this, &MirSurfaceManager::sessionDestroyingSurface); | ||
462 | 30 | } | 33 | } |
463 | 31 | 34 | ||
464 | 32 | MirSurfaceManager::~MirSurfaceManager() | 35 | MirSurfaceManager::~MirSurfaceManager() |
465 | @@ -39,11 +42,27 @@ | |||
466 | 39 | m_surfaces.clear(); | 42 | m_surfaces.clear(); |
467 | 40 | } | 43 | } |
468 | 41 | 44 | ||
470 | 42 | void MirSurfaceManager::mirSurfaceCreated(const std::shared_ptr<msh::Surface> &surface) | 45 | void MirSurfaceManager::sessionCreatedSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const& surface) |
471 | 43 | { | 46 | { |
473 | 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()); |
474 | 45 | auto qmlSurface = new MirSurface(surface); | 48 | auto qmlSurface = new MirSurface(surface); |
475 | 46 | 49 | ||
476 | 47 | m_surfaces.prepend(qmlSurface); | 50 | m_surfaces.prepend(qmlSurface); |
477 | 48 | Q_EMIT surfaceCreated(qmlSurface); | 51 | Q_EMIT surfaceCreated(qmlSurface); |
478 | 49 | } | 52 | } |
479 | 53 | |||
480 | 54 | void MirSurfaceManager::sessionDestroyingSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const& surface) | ||
481 | 55 | { | ||
482 | 56 | DLOG("MirSurfaceManager::sessionDestroyingSurface (this=%p) with surface name '%s'", this, surface->name().c_str()); | ||
483 | 57 | |||
484 | 58 | Q_FOREACH(MirSurface* s, m_surfaces) { | ||
485 | 59 | if (s->m_surface == surface) { | ||
486 | 60 | m_surfaces.removeOne(s); | ||
487 | 61 | Q_EMIT surfaceDestroyed(s); | ||
488 | 62 | return; | ||
489 | 63 | } | ||
490 | 64 | } | ||
491 | 65 | |||
492 | 66 | DLOG("MirSurfaceManager::sessionDestroyingSurface: unable to find MirSurface corresponding to surface '%s'", surface->name().c_str()); | ||
493 | 67 | } | ||
494 | 68 | |||
495 | 50 | 69 | ||
496 | === modified file 'src/modules/Unity/SurfaceManager/mirsurfacemanager.h' | |||
497 | --- src/modules/Unity/SurfaceManager/mirsurfacemanager.h 2013-07-19 17:29:44 +0000 | |||
498 | +++ src/modules/Unity/SurfaceManager/mirsurfacemanager.h 2013-07-24 17:24:27 +0000 | |||
499 | @@ -10,7 +10,7 @@ | |||
500 | 10 | #include "mirsurface.h" | 10 | #include "mirsurface.h" |
501 | 11 | 11 | ||
502 | 12 | class ShellServerConfiguration; | 12 | class ShellServerConfiguration; |
504 | 13 | namespace mir { namespace shell { class Surface; }} | 13 | namespace mir { namespace shell { class Surface; class ApplicationSession; }} |
505 | 14 | 14 | ||
506 | 15 | class MirSurfaceManager : public QObject | 15 | class MirSurfaceManager : public QObject |
507 | 16 | { | 16 | { |
508 | @@ -24,12 +24,13 @@ | |||
509 | 24 | 24 | ||
510 | 25 | Q_SIGNALS: | 25 | Q_SIGNALS: |
511 | 26 | void surfaceCreated(MirSurface* surface); | 26 | void surfaceCreated(MirSurface* surface); |
513 | 27 | // void surfaceDestroyed(MirSurface*); | 27 | void surfaceDestroyed(MirSurface* surface); |
514 | 28 | // void surfaceResized(MirSurface*); | 28 | // void surfaceResized(MirSurface*); |
515 | 29 | // void fullscreenSurfaceChanged(); | 29 | // void fullscreenSurfaceChanged(); |
516 | 30 | 30 | ||
517 | 31 | public Q_SLOTS: | 31 | public Q_SLOTS: |
519 | 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&); |
520 | 33 | void sessionDestroyingSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const&); | ||
521 | 33 | 34 | ||
522 | 34 | private: | 35 | private: |
523 | 35 | QList<MirSurface*> m_surfaces; | 36 | QList<MirSurface*> m_surfaces; |
524 | 36 | 37 | ||
525 | === modified file 'src/unity-mir/sessionlistener.cpp' | |||
526 | --- src/unity-mir/sessionlistener.cpp 2013-07-19 17:29:44 +0000 | |||
527 | +++ src/unity-mir/sessionlistener.cpp 2013-07-24 17:24:27 +0000 | |||
528 | @@ -45,3 +45,17 @@ | |||
529 | 45 | DLOG("SessionListener::unfocused (this=%p)", this); | 45 | DLOG("SessionListener::unfocused (this=%p)", this); |
530 | 46 | Q_EMIT sessionUnfocused(); | 46 | Q_EMIT sessionUnfocused(); |
531 | 47 | } | 47 | } |
532 | 48 | |||
533 | 49 | void SessionListener::surface_created(msh::Session& session, std::shared_ptr<msh::Surface> const& surface) | ||
534 | 50 | { | ||
535 | 51 | DLOG("SessionListener::surface_created (this=%p, session=%p, surface=%p)", this, &session, (void*)surface.get()); | ||
536 | 52 | msh::ApplicationSession &appSession = dynamic_cast<msh::ApplicationSession &>(session); | ||
537 | 53 | Q_EMIT sessionCreatedSurface(&appSession, surface); | ||
538 | 54 | } | ||
539 | 55 | |||
540 | 56 | void SessionListener::destroying_surface(msh::Session& session, std::shared_ptr<mir::shell::Surface> const& surface) | ||
541 | 57 | { | ||
542 | 58 | DLOG("SessionListener::destroying_surface (this=%p, session=%p, surface=%p)", this, &session, (void*)surface.get()); | ||
543 | 59 | msh::ApplicationSession &appSession = dynamic_cast<msh::ApplicationSession &>(session); | ||
544 | 60 | Q_EMIT sessionDestroyingSurface(&appSession, surface); | ||
545 | 61 | } | ||
546 | 48 | 62 | ||
547 | === modified file 'src/unity-mir/sessionlistener.h' | |||
548 | --- src/unity-mir/sessionlistener.h 2013-07-24 16:34:31 +0000 | |||
549 | +++ src/unity-mir/sessionlistener.h 2013-07-24 17:24:27 +0000 | |||
550 | @@ -18,14 +18,17 @@ | |||
551 | 18 | void focused(std::shared_ptr<mir::shell::Session> const& session) override; | 18 | void focused(std::shared_ptr<mir::shell::Session> const& session) override; |
552 | 19 | void unfocused() override; | 19 | void unfocused() override; |
553 | 20 | 20 | ||
557 | 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; |
558 | 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; |
559 | 23 | 23 | ||
560 | 24 | Q_SIGNALS: | 24 | Q_SIGNALS: |
561 | 25 | void sessionStarting(std::shared_ptr<mir::shell::ApplicationSession> const& session); | 25 | void sessionStarting(std::shared_ptr<mir::shell::ApplicationSession> const& session); |
562 | 26 | void sessionStopping(std::shared_ptr<mir::shell::ApplicationSession> const& session); | 26 | void sessionStopping(std::shared_ptr<mir::shell::ApplicationSession> const& session); |
563 | 27 | void sessionFocused(std::shared_ptr<mir::shell::ApplicationSession> const& session); | 27 | void sessionFocused(std::shared_ptr<mir::shell::ApplicationSession> const& session); |
564 | 28 | void sessionUnfocused(); | 28 | void sessionUnfocused(); |
565 | 29 | |||
566 | 30 | void sessionCreatedSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const&); | ||
567 | 31 | void sessionDestroyingSurface(mir::shell::ApplicationSession const*, std::shared_ptr<mir::shell::Surface> const&); | ||
568 | 29 | }; | 32 | }; |
569 | 30 | 33 | ||
570 | 31 | #endif // SESSIONLISTENER_H | 34 | #endif // SESSIONLISTENER_H |
571 | 32 | 35 | ||
572 | === modified file 'src/unity-mir/surfacesource.cpp' | |||
573 | --- src/unity-mir/surfacesource.cpp 2013-07-19 17:29:44 +0000 | |||
574 | +++ src/unity-mir/surfacesource.cpp 2013-07-24 17:24:27 +0000 | |||
575 | @@ -30,8 +30,6 @@ | |||
576 | 30 | m_shellSurface = mirSurface; | 30 | m_shellSurface = mirSurface; |
577 | 31 | shellSurfaceFound = true; | 31 | shellSurfaceFound = true; |
578 | 32 | Q_EMIT shellSurfaceCreated(mirSurface); | 32 | Q_EMIT shellSurfaceCreated(mirSurface); |
579 | 33 | } else { | ||
580 | 34 | Q_EMIT surfaceCreated(mirSurface); | ||
581 | 35 | } | 33 | } |
582 | 36 | return mirSurface; | 34 | return mirSurface; |
583 | 37 | } | 35 | } |
584 | 38 | 36 | ||
585 | === modified file 'src/unity-mir/surfacesource.h' | |||
586 | --- src/unity-mir/surfacesource.h 2013-07-19 17:29:44 +0000 | |||
587 | +++ src/unity-mir/surfacesource.h 2013-07-24 17:24:27 +0000 | |||
588 | @@ -27,7 +27,6 @@ | |||
589 | 27 | std::shared_ptr<mir::shell::Surface> shellSurface() const; | 27 | std::shared_ptr<mir::shell::Surface> shellSurface() const; |
590 | 28 | 28 | ||
591 | 29 | Q_SIGNALS: | 29 | Q_SIGNALS: |
592 | 30 | void surfaceCreated(std::shared_ptr<mir::shell::Surface> const& surface); | ||
593 | 31 | void shellSurfaceCreated(std::shared_ptr<mir::shell::Surface> const& surface); | 30 | void shellSurfaceCreated(std::shared_ptr<mir::shell::Surface> const& surface); |
594 | 32 | 31 | ||
595 | 33 | private: | 32 | private: |
Looks good