Merge lp:~alan-griffiths/qtmir/spike-using-WindowManager into lp:qtmir/devel-mir-next

Proposed by Alan Griffiths on 2015-04-01
Status: Work in progress
Proposed branch: lp:~alan-griffiths/qtmir/spike-using-WindowManager
Merge into: lp:qtmir/devel-mir-next
Prerequisite: lp:~mir-team/qtmir/devel-mir-next-update
Diff against target: 777 lines (+201/-238)
14 files modified
src/modules/Unity/Application/application_manager.h (+1/-1)
src/modules/Unity/Application/mirsurfaceitem.cpp (+2/-2)
src/modules/Unity/Application/mirsurfaceitem.h (+4/-3)
src/modules/Unity/Application/mirsurfacemanager.cpp (+8/-9)
src/modules/Unity/Application/mirsurfacemanager.h (+5/-5)
src/modules/Unity/Application/sessionmanager.cpp (+0/-1)
src/platforms/mirserver/CMakeLists.txt (+1/-1)
src/platforms/mirserver/mirserver.cpp (+32/-50)
src/platforms/mirserver/mirserver.h (+8/-7)
src/platforms/mirserver/mirwindowmanager.cpp (+98/-140)
src/platforms/mirserver/mirwindowmanager.h (+33/-14)
src/platforms/mirserver/nativeinterface.cpp (+7/-2)
src/platforms/mirserver/nativeinterface.h (+1/-1)
tests/modules/common/qtmir_test.h (+1/-2)
To merge this branch: bzr merge lp:~alan-griffiths/qtmir/spike-using-WindowManager
Reviewer Review Type Date Requested Status
Mir development team 2015-04-01 Pending
PS Jenkins bot continuous-integration 2015-04-01 Pending
Review via email: mp+254907@code.launchpad.net

This proposal supersedes a proposal from 2015-03-26.

Commit message

Switch from subclassing mir::shell::AbstractShell to implementing mir::shell::WindowManager

Description of the change

Switch from subclassing mir::shell::AbstractShell to implementing mir::shell::WindowManager

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
278. By Daniel van Vugt on 2015-04-02

Merge lp:~mir-team/qtmir/devel-mir-next-update

279. By Alan Griffiths on 2015-05-01

Mir 0.13.0 fixes

280. By Alan Griffiths on 2015-05-01

Workaround API that uses references to opaque types

281. By Alan Griffiths on 2015-05-01

libmircommon-dev dependency should be versioned

282. By Alan Griffiths on 2015-05-06

merge lp:~alan-griffiths/qtmir/spike-using-WindowManager

283. By Alan Griffiths on 2015-05-06

Very basic version of MirWindowManager::modify_surface()

Alan Griffiths (alan-griffiths) wrote :

* Did you perform an exploratory manual test run of the code change and any related functionality?

Works on manta with Mir 0.13.0 stack

 * Did CI run pass?

Not until 0.13.0 is in archive

Unmerged revisions

283. By Alan Griffiths on 2015-05-06

Very basic version of MirWindowManager::modify_surface()

282. By Alan Griffiths on 2015-05-06

merge lp:~alan-griffiths/qtmir/spike-using-WindowManager

281. By Alan Griffiths on 2015-05-01

libmircommon-dev dependency should be versioned

280. By Alan Griffiths on 2015-05-01

Workaround API that uses references to opaque types

279. By Alan Griffiths on 2015-05-01

Mir 0.13.0 fixes

278. By Daniel van Vugt on 2015-04-02

Merge lp:~mir-team/qtmir/devel-mir-next-update

277. By Daniel van Vugt on 2015-03-27

Update mock headers so they can build again, following racarr's
cursor BufferStream changes.

276. By Daniel van Vugt on 2015-03-27

Migrate to MirEvent 2.1 API, coming in Mir 0.13

275. By Daniel van Vugt on 2015-03-25

Link to libmirclient too. That's where all mir_* client (and input
functions) now correctly reside.

274. By Daniel van Vugt on 2015-03-25

Merge branch lp:~mir-team/qtmir/compatibility-with-mir-API-changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/modules/Unity/Application/application_manager.h'
2--- src/modules/Unity/Application/application_manager.h 2015-01-09 11:23:34 +0000
3+++ src/modules/Unity/Application/application_manager.h 2015-05-06 15:47:57 +0000
4@@ -151,7 +151,7 @@
5
6 Application* findApplicationWithPromptSession(const mir::scene::PromptSession* promptSession);
7
8- QSharedPointer<MirServer> m_mirServer;
9+ const QSharedPointer<MirServer> m_mirServer;
10
11 QList<Application*> m_applications;
12 Application* m_focusedApplication;
13
14=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
15--- src/modules/Unity/Application/mirsurfaceitem.cpp 2015-03-27 07:29:14 +0000
16+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2015-05-06 15:47:57 +0000
17@@ -23,7 +23,6 @@
18 #include "mirbuffersgtexture.h"
19 #include "session.h"
20 #include "mirsurfaceitem.h"
21-#include "mirshell.h"
22 #include "logging.h"
23 #include "ubuntukeyboardinfo.h"
24
25@@ -46,6 +45,7 @@
26 // Mir
27 #include <mir/geometry/rectangle.h>
28 #include <mir/events/event_builders.h>
29+#include <mir/shell/shell.h>
30 #include <mir_toolkit/event.h>
31
32 namespace mg = mir::graphics;
33@@ -187,7 +187,7 @@
34
35 MirSurfaceItem::MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,
36 SessionInterface* session,
37- MirShell *shell,
38+ mir::shell::Shell *shell,
39 std::shared_ptr<SurfaceObserver> observer,
40 QQuickItem *parent)
41 : QQuickItem(parent)
42
43=== modified file 'src/modules/Unity/Application/mirsurfaceitem.h'
44--- src/modules/Unity/Application/mirsurfaceitem.h 2015-02-20 15:52:17 +0000
45+++ src/modules/Unity/Application/mirsurfaceitem.h 2015-05-06 15:47:57 +0000
46@@ -33,8 +33,9 @@
47
48 #include "session_interface.h"
49
50+namespace mir { namespace shell { class Shell; } }
51+
52 class SurfaceObserver;
53-class MirShell;
54
55 namespace qtmir {
56
57@@ -58,7 +59,7 @@
58 public:
59 explicit MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,
60 SessionInterface* session,
61- MirShell *shell,
62+ mir::shell::Shell *shell,
63 std::shared_ptr<SurfaceObserver> observer,
64 QQuickItem *parent = 0);
65 ~MirSurfaceItem();
66@@ -179,7 +180,7 @@
67
68 std::shared_ptr<mir::scene::Surface> m_surface;
69 QPointer<SessionInterface> m_session;
70- MirShell *const m_shell;
71+ mir::shell::Shell *const m_shell;
72 bool m_firstFrameDrawn;
73 bool m_live;
74 Qt::ScreenOrientation m_orientation; //FIXME - have to save the state as Mir has no getter for it (bug:1357429)
75
76=== modified file 'src/modules/Unity/Application/mirsurfacemanager.cpp'
77--- src/modules/Unity/Application/mirsurfacemanager.cpp 2015-02-06 09:47:21 +0000
78+++ src/modules/Unity/Application/mirsurfacemanager.cpp 2015-05-06 15:47:57 +0000
79@@ -31,7 +31,7 @@
80 #include "nativeinterface.h"
81 #include "mirserver.h"
82 #include "sessionlistener.h"
83-#include "mirshell.h"
84+#include "mirwindowmanager.h"
85 #include "logging.h"
86
87 Q_LOGGING_CATEGORY(QTMIR_SURFACES, "qtmir.surfaces")
88@@ -51,9 +51,9 @@
89 manager, &MirSurfaceManager::onSessionDestroyingSurface);
90 }
91
92-void connectToShell(MirSurfaceManager *manager, MirShell *shell)
93+void connectToWindowManager(MirSurfaceManager *manager, MirWindowManager *windowManager)
94 {
95- QObject::connect(shell, &MirShell::surfaceAttributeChanged,
96+ QObject::connect(windowManager, &MirWindowManager::surfaceAttributeChanged,
97 manager, &MirSurfaceManager::onSurfaceAttributeChanged);
98 }
99
100@@ -70,23 +70,22 @@
101 }
102
103 SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener"));
104- MirShell *shell = static_cast<MirShell*>(nativeInterface->nativeResourceForIntegration("Shell"));
105+ MirWindowManager *window_manager = static_cast<MirWindowManager*>(nativeInterface->nativeResourceForIntegration("WindowManager"));
106+ mir::shell::Shell *const shell = static_cast<mir::shell::Shell*>(nativeInterface->nativeResourceForIntegration("mir::shell::Shell"));
107
108- the_surface_manager = new MirSurfaceManager(nativeInterface->m_mirServer, shell, SessionManager::singleton());
109+ the_surface_manager = new MirSurfaceManager(shell, SessionManager::singleton());
110
111 connectToSessionListener(the_surface_manager, sessionListener);
112- connectToShell(the_surface_manager, shell);
113+ connectToWindowManager(the_surface_manager, window_manager);
114 }
115 return the_surface_manager;
116 }
117
118 MirSurfaceManager::MirSurfaceManager(
119- const QSharedPointer<MirServer>& mirServer,
120- MirShell *shell,
121+ mir::shell::Shell *shell,
122 SessionManager* sessionManager,
123 QObject *parent)
124 : MirSurfaceItemModel(parent)
125- , m_mirServer(mirServer)
126 , m_shell(shell)
127 , m_sessionManager(sessionManager)
128 {
129
130=== modified file 'src/modules/Unity/Application/mirsurfacemanager.h'
131--- src/modules/Unity/Application/mirsurfacemanager.h 2015-02-06 09:47:21 +0000
132+++ src/modules/Unity/Application/mirsurfacemanager.h 2015-05-06 15:47:57 +0000
133@@ -37,10 +37,12 @@
134 class Session;
135 class PromptSession;
136 }
137+ namespace shell {
138+ class Shell;
139+ }
140 }
141
142 class MirServer;
143-class MirShell;
144
145 namespace qtmir {
146
147@@ -54,8 +56,7 @@
148
149 public:
150 explicit MirSurfaceManager(
151- const QSharedPointer<MirServer>& mirServer,
152- MirShell *shell,
153+ mir::shell::Shell *shell,
154 SessionManager* sessionManager,
155 QObject *parent = 0
156 );
157@@ -81,8 +82,7 @@
158 QMutex m_mutex;
159
160 private:
161- QSharedPointer<MirServer> m_mirServer;
162- MirShell *const m_shell;
163+ mir::shell::Shell *const m_shell;
164 SessionManager* m_sessionManager;
165 static MirSurfaceManager *the_surface_manager;
166 };
167
168=== modified file 'src/modules/Unity/Application/sessionmanager.cpp'
169--- src/modules/Unity/Application/sessionmanager.cpp 2015-01-28 14:25:36 +0000
170+++ src/modules/Unity/Application/sessionmanager.cpp 2015-05-06 15:47:57 +0000
171@@ -26,7 +26,6 @@
172 #include "nativeinterface.h"
173 #include "mirserver.h"
174 #include "sessionlistener.h"
175-#include "mirshell.h"
176 #include "logging.h"
177 #include "promptsessionlistener.h"
178
179
180=== modified file 'src/platforms/mirserver/CMakeLists.txt'
181--- src/platforms/mirserver/CMakeLists.txt 2015-04-01 11:59:05 +0000
182+++ src/platforms/mirserver/CMakeLists.txt 2015-05-06 15:47:57 +0000
183@@ -37,7 +37,7 @@
184
185 set(MIRSERVER_QPA_PLUGIN_SRC
186 ../../common/debughelpers.cpp
187- mirshell.cpp
188+ mirwindowmanager.cpp
189 qteventfeeder.cpp
190 plugin.cpp
191 qmirserver.cpp
192
193=== modified file 'src/platforms/mirserver/mirserver.cpp'
194--- src/platforms/mirserver/mirserver.cpp 2015-02-09 16:28:40 +0000
195+++ src/platforms/mirserver/mirserver.cpp 2015-05-06 15:47:57 +0000
196@@ -1,5 +1,5 @@
197 /*
198- * Copyright (C) 2013-2014 Canonical, Ltd.
199+ * Copyright (C) 2013-2015 Canonical, Ltd.
200 *
201 * This program is free software: you can redistribute it and/or modify it under
202 * the terms of the GNU Lesser General Public License version 3, as published by
203@@ -19,7 +19,7 @@
204 #include "mirserver.h"
205
206 // local
207-#include "mirshell.h"
208+#include "mirwindowmanager.h"
209 #include "mirglconfig.h"
210 #include "mirserverstatuslistener.h"
211 #include "promptsessionlistener.h"
212@@ -51,19 +51,25 @@
213 set_command_line_handler(&ignore_unparsed_arguments);
214 set_command_line(argc, argv);
215
216- override_the_session_listener([]
217- {
218- return std::make_shared<SessionListener>();
219- });
220-
221- override_the_prompt_session_listener([]
222- {
223- return std::make_shared<PromptSessionListener>();
224- });
225-
226- override_the_session_authorizer([]
227- {
228- return std::make_shared<SessionAuthorizer>();
229+ override_the_session_listener([this]
230+ {
231+ const auto result = std::make_shared<SessionListener>();
232+ m_sessionListener = result;
233+ return result;
234+ });
235+
236+ override_the_prompt_session_listener([this]
237+ {
238+ const auto result = std::make_shared<PromptSessionListener>();
239+ m_promptSessionListener = result;
240+ return result;
241+ });
242+
243+ override_the_session_authorizer([this]
244+ {
245+ const auto result = std::make_shared<SessionAuthorizer>();
246+ m_sessionAuthorizer = result;
247+ return result;
248 });
249
250 override_the_compositor([]
251@@ -86,17 +92,11 @@
252 return std::make_shared<MirServerStatusListener>();
253 });
254
255- override_the_shell([this]
256+ override_the_window_manager_builder([this](mir::shell::FocusController*)
257 {
258- auto const shell = std::make_shared<MirShell>(
259- the_input_targeter(),
260- the_surface_coordinator(),
261- the_session_coordinator(),
262- the_prompt_session_manager(),
263- the_shell_display_layout());
264-
265- m_shell = shell;
266- return shell;
267+ const auto result = std::make_shared<MirWindowManager>(the_shell_display_layout());
268+ m_windowManager = result;
269+ return result;
270 });
271
272 set_terminator([&](int)
273@@ -113,43 +113,25 @@
274
275 /************************************ Shell side ************************************/
276
277-//
278-// Note about the
279-// if (sharedPtr.unique()) return 0;
280-// constructs used in the functions below.
281-// The rationale is that if when you do
282-// the_session_authorizer()
283-// get a pointer that is unique means that Mir is not
284-// holding the pointer and thus when we return from the
285-// sessionAuthorizer()
286-// scope the unique pointer will be destroyed so we return 0
287-//
288+// Note about the"weak_ptr<X>.lock().get();" constructs used in the functions below.
289+// An empty weak_ptr<> means that Mir is not holding the pointer so we return nullptr.
290
291 SessionAuthorizer *MirServer::sessionAuthorizer()
292 {
293- auto sharedPtr = the_session_authorizer();
294- if (sharedPtr.unique()) return 0;
295-
296- return static_cast<SessionAuthorizer*>(sharedPtr.get());
297+ return m_sessionAuthorizer.lock().get();
298 }
299
300 SessionListener *MirServer::sessionListener()
301 {
302- auto sharedPtr = the_session_listener();
303- if (sharedPtr.unique()) return 0;
304-
305- return static_cast<SessionListener*>(sharedPtr.get());
306+ return m_sessionListener.lock().get();
307 }
308
309 PromptSessionListener *MirServer::promptSessionListener()
310 {
311- auto sharedPtr = the_prompt_session_listener();
312- if (sharedPtr.unique()) return 0;
313-
314- return static_cast<PromptSessionListener*>(sharedPtr.get());
315+ return m_promptSessionListener.lock().get();
316 }
317
318-MirShell *MirServer::shell()
319+MirWindowManager *MirServer::windowManager()
320 {
321- return m_shell.lock().get();
322+ return m_windowManager.lock().get();
323 }
324
325=== modified file 'src/platforms/mirserver/mirserver.h'
326--- src/platforms/mirserver/mirserver.h 2015-03-25 14:49:58 +0000
327+++ src/platforms/mirserver/mirserver.h 2015-05-06 15:47:57 +0000
328@@ -23,7 +23,7 @@
329 class QtEventFeeder;
330 class SessionListener;
331 class SessionAuthorizer;
332-class MirShell;
333+class MirWindowManager;
334 class PromptSessionListener;
335
336 // We use virtual inheritance of mir::Server to facilitate derived classes (e.g. testing)
337@@ -34,7 +34,7 @@
338
339 Q_PROPERTY(SessionAuthorizer* sessionAuthorizer READ sessionAuthorizer CONSTANT)
340 Q_PROPERTY(SessionListener* sessionListener READ sessionListener CONSTANT)
341- Q_PROPERTY(MirShell* shell READ shell CONSTANT)
342+ Q_PROPERTY(MirWindowManager* windowManager READ windowManager CONSTANT)
343 Q_PROPERTY(PromptSessionListener* promptSessionListener READ promptSessionListener CONSTANT)
344
345 public:
346@@ -47,21 +47,22 @@
347 using mir::Server::the_display;
348 using mir::Server::the_gl_config;
349 using mir::Server::the_main_loop;
350- using mir::Server::the_prompt_session_listener;
351 using mir::Server::the_prompt_session_manager;
352- using mir::Server::the_session_authorizer;
353- using mir::Server::the_session_listener;
354+ using mir::Server::the_shell;
355
356 /* qt specific */
357 // getters
358 SessionAuthorizer *sessionAuthorizer();
359 SessionListener *sessionListener();
360 PromptSessionListener *promptSessionListener();
361- MirShell *shell();
362+ MirWindowManager *windowManager();
363
364 private:
365 std::shared_ptr<QtEventFeeder> m_qtEventFeeder;
366- std::weak_ptr<MirShell> m_shell;
367+ std::weak_ptr<SessionAuthorizer> m_sessionAuthorizer;
368+ std::weak_ptr<SessionListener> m_sessionListener;
369+ std::weak_ptr<PromptSessionListener> m_promptSessionListener;
370+ std::weak_ptr<MirWindowManager> m_windowManager;
371 };
372
373 #endif // MIRSERVER_H
374
375=== renamed file 'src/platforms/mirserver/mirshell.cpp' => 'src/platforms/mirserver/mirwindowmanager.cpp'
376--- src/platforms/mirserver/mirshell.cpp 2015-05-01 13:21:00 +0000
377+++ src/platforms/mirserver/mirwindowmanager.cpp 2015-05-06 15:47:57 +0000
378@@ -14,163 +14,121 @@
379 * along with this program. If not, see <http://www.gnu.org/licenses/>.
380 */
381
382-#include "mirshell.h"
383+#include "mirwindowmanager.h"
384 #include "logging.h"
385 #include "tracepoints.h" // generated from tracepoints.tp
386
387 #include <mir/geometry/rectangle.h>
388 #include <mir/scene/session.h>
389+#include <mir/scene/surface.h>
390 #include <mir/scene/surface_creation_parameters.h>
391-#include <mir/scene/surface.h>
392 #include <mir/shell/display_layout.h>
393-#include <mir/shell/window_manager.h>
394
395 namespace ms = mir::scene;
396-using mir::shell::AbstractShell;
397-
398-namespace
399-{
400-class NullWindowManager : public mir::shell::WindowManager
401-{
402-public:
403- void add_session(std::shared_ptr<ms::Session> const& session) override;
404-
405- void remove_session(std::shared_ptr<ms::Session> const& session) override;
406-
407- mir::frontend::SurfaceId add_surface(
408- std::shared_ptr<ms::Session> const& session,
409- ms::SurfaceCreationParameters const& params,
410- std::function<mir::frontend::SurfaceId(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)> const& build) override;
411-
412- void remove_surface(
413- std::shared_ptr<ms::Session> const& session,
414- std::weak_ptr<ms::Surface> const& surface) override;
415-
416- void add_display(mir::geometry::Rectangle const& area) override;
417-
418- void remove_display(mir::geometry::Rectangle const& area) override;
419-
420- bool handle_keyboard_event(MirKeyboardEvent const* event) override;
421-
422- bool handle_touch_event(MirTouchEvent const* event) override;
423-
424- bool handle_pointer_event(MirPointerEvent const* event) override;
425-
426- int set_surface_attribute(
427- std::shared_ptr<ms::Session> const& session,
428- std::shared_ptr<ms::Surface> const& surface,
429- MirSurfaceAttrib attrib,
430- int value) override;
431-
432- void modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&);
433-};
434-}
435-
436-
437-MirShell::MirShell(
438- const std::shared_ptr<mir::shell::InputTargeter> &inputTargeter,
439- const std::shared_ptr<mir::scene::SurfaceCoordinator> &surfaceCoordinator,
440- const std::shared_ptr<mir::scene::SessionCoordinator> &sessionCoordinator,
441- const std::shared_ptr<mir::scene::PromptSessionManager> &promptSessionManager,
442- const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout) :
443- AbstractShell(inputTargeter, surfaceCoordinator, sessionCoordinator, promptSessionManager,
444- [](mir::shell::FocusController*) { return std::make_shared<NullWindowManager>(); }),
445- m_displayLayout{displayLayout}
446-{
447- qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::MirShell";
448-}
449-
450-mir::frontend::SurfaceId MirShell::create_surface(const std::shared_ptr<ms::Session> &session, const ms::SurfaceCreationParameters &requestParameters)
451+
452+MirWindowManager::MirWindowManager(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout) :
453+ m_displayLayout{displayLayout}
454+{
455+ qCDebug(QTMIR_MIR_MESSAGES) << "MirWindowManager::MirWindowManager";
456+}
457+
458+auto MirWindowManager::add_surface(
459+ std::shared_ptr<mir::scene::Session> const& session,
460+ mir::scene::SurfaceCreationParameters const& requestParameters,
461+ std::function<mir::frontend::SurfaceId(std::shared_ptr<mir::scene::Session> const& session, mir::scene::SurfaceCreationParameters const& params)> const& build)
462+-> mir::frontend::SurfaceId
463 {
464 tracepoint(qtmirserver, surfacePlacementStart);
465
466- // TODO: Callback unity8 so that it can make a decision on that.
467- // unity8 must bear in mind that the called function will be on a Mir thread though.
468- // The QPA shouldn't be deciding for itself on such things.
469-
470- ms::SurfaceCreationParameters placedParameters = requestParameters;
471-
472- // Just make it fullscreen for now
473- mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size};
474- m_displayLayout->size_to_output(rect);
475- placedParameters.size = rect.size;
476-
477- qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::create_surface(): size requested ("
478- << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and placed ("
479- << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")";
480-
481- tracepoint(qtmirserver, surfacePlacementEnd);
482-
483- return AbstractShell::create_surface(session, placedParameters);
484-}
485-
486-int MirShell::set_surface_attribute(
487- const std::shared_ptr<mir::scene::Session> &session,
488- const std::shared_ptr<mir::scene::Surface> &surface,
489+ // TODO: Callback unity8 so that it can make a decision on that.
490+ // unity8 must bear in mind that the called function will be on a Mir thread though.
491+ // The QPA shouldn't be deciding for itself on such things.
492+
493+ ms::SurfaceCreationParameters placedParameters = requestParameters;
494+
495+ // Just make it fullscreen for now
496+ mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size};
497+ m_displayLayout->size_to_output(rect);
498+ placedParameters.size = rect.size;
499+
500+ qCDebug(QTMIR_MIR_MESSAGES) << "MirWindowManager::add_surface(): size requested ("
501+ << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and placed ("
502+ << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")";
503+
504+ tracepoint(qtmirserver, surfacePlacementEnd);
505+
506+ return build(session, placedParameters);
507+}
508+
509+void MirWindowManager::modify_surface(
510+ std::shared_ptr<mir::scene::Session> const& /*session*/,
511+ std::shared_ptr<mir::scene::Surface> const& surface,
512+ mir::shell::SurfaceSpecification const& modifications)
513+{
514+ // TODO ought to wire up some window management logic around here
515+ // Here's a very basic implementation
516+
517+ if (modifications.name.is_set())
518+ surface->rename(modifications.name.value());
519+
520+ if (modifications.width.is_set() || modifications.height.is_set())
521+ {
522+ auto new_size = surface->size();
523+
524+ if (modifications.width.is_set())
525+ new_size.width = modifications.width.value();
526+
527+ if (modifications.height.is_set())
528+ new_size.height = modifications.height.value();
529+
530+ surface->resize(new_size);
531+ }
532+}
533+
534+int MirWindowManager::set_surface_attribute(
535+ std::shared_ptr<mir::scene::Session> const& /*session*/,
536+ std::shared_ptr<mir::scene::Surface> const& surface,
537 MirSurfaceAttrib attrib,
538 int value)
539 {
540- auto const result = AbstractShell::set_surface_attribute(session, surface, attrib, value);
541+ const auto result = surface->configure(attrib, value);
542 Q_EMIT surfaceAttributeChanged(surface.get(), attrib, result);
543-
544 return result;
545 }
546
547-void NullWindowManager::add_session(std::shared_ptr<ms::Session> const& /*session*/)
548-{
549-}
550-
551-void NullWindowManager::remove_session(std::shared_ptr<ms::Session> const& /*session*/)
552-{
553-}
554-
555-auto NullWindowManager::add_surface(
556- std::shared_ptr<ms::Session> const& session,
557- ms::SurfaceCreationParameters const& params,
558- std::function<mir::frontend::SurfaceId(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)> const& build)
559--> mir::frontend::SurfaceId
560-{
561- return build(session, params);
562-}
563-
564-void NullWindowManager::remove_surface(
565- std::shared_ptr<ms::Session> const& /*session*/,
566- std::weak_ptr<ms::Surface> const& /*surface*/)
567-{
568-}
569-
570-void NullWindowManager::add_display(mir::geometry::Rectangle const& /*area*/)
571-{
572-}
573-
574-void NullWindowManager::remove_display(mir::geometry::Rectangle const& /*area*/)
575-{
576-}
577-
578-bool NullWindowManager::handle_keyboard_event(MirKeyboardEvent const* /*event*/)
579-{
580- return false;
581-}
582-
583-bool NullWindowManager::handle_touch_event(MirTouchEvent const* /*event*/)
584-{
585- return false;
586-}
587-
588-bool NullWindowManager::handle_pointer_event(MirPointerEvent const* /*event*/)
589-{
590- return false;
591-}
592-
593-int NullWindowManager::set_surface_attribute(
594- std::shared_ptr<ms::Session> const& /*session*/,
595- std::shared_ptr<ms::Surface> const& surface,
596- MirSurfaceAttrib attrib,
597- int value)
598-{
599- return surface->configure(attrib, value);
600-}
601-
602-void NullWindowManager::modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&)
603-{
604+void MirWindowManager::add_session(std::shared_ptr<mir::scene::Session> const& /*session*/)
605+{
606+}
607+
608+void MirWindowManager::remove_session(std::shared_ptr<mir::scene::Session> const& /*session*/)
609+{
610+}
611+
612+void MirWindowManager::remove_surface(
613+ std::shared_ptr<mir::scene::Session> const& /*session*/,
614+ std::weak_ptr<mir::scene::Surface> const& /*surface*/)
615+{
616+}
617+
618+void MirWindowManager::add_display(mir::geometry::Rectangle const& /*area*/)
619+{
620+}
621+
622+void MirWindowManager::remove_display(mir::geometry::Rectangle const& /*area*/)
623+{
624+}
625+
626+bool MirWindowManager::handle_keyboard_event(MirKeyboardEvent const* /*event*/)
627+{
628+ return false;
629+}
630+
631+bool MirWindowManager::handle_touch_event(MirTouchEvent const* /*event*/)
632+{
633+ return false;
634+}
635+
636+bool MirWindowManager::handle_pointer_event(MirPointerEvent const* /*event*/)
637+{
638+ return false;
639 }
640
641=== renamed file 'src/platforms/mirserver/mirshell.h' => 'src/platforms/mirserver/mirwindowmanager.h'
642--- src/platforms/mirserver/mirshell.h 2015-02-04 17:17:53 +0000
643+++ src/platforms/mirserver/mirwindowmanager.h 2015-05-06 15:47:57 +0000
644@@ -14,10 +14,10 @@
645 * along with this program. If not, see <http://www.gnu.org/licenses/>.
646 */
647
648-#ifndef QPAMIRSERVER_SHELL_H
649-#define QPAMIRSERVER_SHELL_H
650+#ifndef MIRWINDOWMANAGER_H
651+#define MIRWINDOWMANAGER_H
652
653-#include <mir/shell/abstract_shell.h>
654+#include <mir/shell/window_manager.h>
655 #include <QObject>
656
657 namespace mir {
658@@ -26,26 +26,45 @@
659 }
660 }
661
662-class MirShell : public QObject, public mir::shell::AbstractShell
663+class MirWindowManager : public QObject, public mir::shell::WindowManager
664 {
665 Q_OBJECT
666
667 public:
668- MirShell(
669- const std::shared_ptr<mir::shell::InputTargeter> &inputTargeter,
670- const std::shared_ptr<mir::scene::SurfaceCoordinator> &surfaceCoordinator,
671- const std::shared_ptr<mir::scene::SessionCoordinator> &sessionCoordinator,
672- const std::shared_ptr<mir::scene::PromptSessionManager> &promptSessionManager,
673- const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout);
674+ explicit MirWindowManager(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout);
675
676- virtual mir::frontend::SurfaceId create_surface(const std::shared_ptr<mir::scene::Session>& session, const mir::scene::SurfaceCreationParameters &params);
677+ auto add_surface(
678+ std::shared_ptr<mir::scene::Session> const& session,
679+ mir::scene::SurfaceCreationParameters const& params,
680+ std::function<mir::frontend::SurfaceId(std::shared_ptr<mir::scene::Session> const& session, mir::scene::SurfaceCreationParameters const& params)> const& build)
681+ -> mir::frontend::SurfaceId override;
682
683 int set_surface_attribute(
684- const std::shared_ptr<mir::scene::Session> &session,
685- const std::shared_ptr<mir::scene::Surface> &surface,
686+ std::shared_ptr<mir::scene::Session> const& session,
687+ std::shared_ptr<mir::scene::Surface> const& surface,
688 MirSurfaceAttrib attrib,
689 int value) override;
690
691+ void add_session(std::shared_ptr<mir::scene::Session> const& session) override;
692+
693+ void remove_session(std::shared_ptr<mir::scene::Session> const& session) override;
694+
695+ void remove_surface(
696+ std::shared_ptr<mir::scene::Session> const& session,
697+ std::weak_ptr<mir::scene::Surface> const& surface) override;
698+
699+ void modify_surface(std::shared_ptr<mir::scene::Session> const&, std::shared_ptr<mir::scene::Surface> const&, mir::shell::SurfaceSpecification const&);
700+
701+ void add_display(mir::geometry::Rectangle const& area) override;
702+
703+ void remove_display(mir::geometry::Rectangle const& area) override;
704+
705+ bool handle_keyboard_event(MirKeyboardEvent const* event) override;
706+
707+ bool handle_touch_event(MirTouchEvent const* event) override;
708+
709+ bool handle_pointer_event(MirPointerEvent const* event) override;
710+
711 Q_SIGNALS:
712 void surfaceAttributeChanged(mir::scene::Surface const*, const MirSurfaceAttrib, const int);
713
714@@ -53,4 +72,4 @@
715 std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout;
716 };
717
718-#endif /* QPAMIRSERVER_SHELL_H */
719+#endif /* MIRWINDOWMANAGER_H */
720
721=== modified file 'src/platforms/mirserver/nativeinterface.cpp'
722--- src/platforms/mirserver/nativeinterface.cpp 2015-01-28 14:25:36 +0000
723+++ src/platforms/mirserver/nativeinterface.cpp 2015-05-06 15:47:57 +0000
724@@ -29,12 +29,17 @@
725
726 if (resource == "SessionAuthorizer")
727 result = m_mirServer->sessionAuthorizer();
728- else if (resource == "Shell")
729- result = m_mirServer->shell();
730+ else if (resource == "WindowManager")
731+ result = m_mirServer->windowManager();
732 else if (resource == "SessionListener")
733 result = m_mirServer->sessionListener();
734 else if (resource == "PromptSessionListener")
735 result = m_mirServer->promptSessionListener();
736+ else if (resource == "mir::shell::Shell")
737+ {
738+ const std::weak_ptr<mir::shell::Shell> shell{m_mirServer->the_shell()};
739+ result = shell.lock().get();
740+ }
741
742 return result;
743 }
744
745=== modified file 'src/platforms/mirserver/nativeinterface.h'
746--- src/platforms/mirserver/nativeinterface.h 2014-12-01 11:05:01 +0000
747+++ src/platforms/mirserver/nativeinterface.h 2015-05-06 15:47:57 +0000
748@@ -33,7 +33,7 @@
749
750 virtual void *nativeResourceForIntegration(const QByteArray &resource);
751
752- QSharedPointer<MirServer> m_mirServer;
753+ const QSharedPointer<MirServer> m_mirServer;
754 };
755
756 #endif // NATIVEINTEGRATION_H
757
758=== modified file 'tests/modules/common/qtmir_test.h'
759--- tests/modules/common/qtmir_test.h 2015-02-06 09:47:21 +0000
760+++ tests/modules/common/qtmir_test.h 2015-05-06 15:47:57 +0000
761@@ -109,7 +109,6 @@
762 &applicationManager,
763 }
764 , surfaceManager{
765- mirServer,
766 mirShell,
767 &sessionManager
768 }
769@@ -150,7 +149,7 @@
770 testing::NiceMock<testing::MockDesktopFileReaderFactory> desktopFileReaderFactory;
771 testing::NiceMock<testing::MockSharedWakelock> sharedWakelock;
772 QSharedPointer<FakeMirServer> mirServer;
773- MirShell *mirShell{nullptr};
774+ mir::shell::Shell *mirShell{nullptr};
775 QSharedPointer<TaskController> taskController;
776 ApplicationManager applicationManager;
777 SessionManager sessionManager;

Subscribers

People subscribed via source and target branches