Merge lp:~alan-griffiths/miral/spike-miral-qt-integration into lp:miral

Proposed by Alan Griffiths on 2016-08-17
Status: Superseded
Proposed branch: lp:~alan-griffiths/miral/spike-miral-qt-integration
Merge into: lp:miral
Prerequisite: lp:~alan-griffiths/miral/rework-server-stop-logic
Diff against target: 711 lines (+214/-216)
12 files modified
miral-qt/src/platforms/mirserver/CMakeLists.txt (+1/-1)
miral-qt/src/platforms/mirserver/mirserver.cpp (+0/-78)
miral-qt/src/platforms/mirserver/mirserver.h (+4/-9)
miral-qt/src/platforms/mirserver/qmirserver.cpp (+7/-9)
miral-qt/src/platforms/mirserver/qmirserver_p.cpp (+97/-46)
miral-qt/src/platforms/mirserver/qmirserver_p.h (+26/-50)
miral-qt/src/platforms/mirserver/screensmodel.cpp (+6/-6)
miral-qt/src/platforms/mirserver/screensmodel.h (+7/-5)
miral-qt/src/platforms/mirserver/setqtcompositor.cpp (+29/-5)
miral-qt/src/platforms/mirserver/setqtcompositor.h (+25/-5)
miral-qt/tests/framework/fake_displayconfigurationoutput.h (+11/-1)
miral-qt/tests/mirserver/ScreensModel/testable_screensmodel.h (+1/-1)
To merge this branch: bzr merge lp:~alan-griffiths/miral/spike-miral-qt-integration
Reviewer Review Type Date Requested Status
Mir development team 2016-08-17 Pending
Review via email: mp+303165@code.launchpad.net

This proposal has been superseded by a proposal from 2016-08-18.

Commit Message

Another pass at removing MirServer so that its use can be replaced by miral::MirRunner

To post a comment you must log in.
301. By Alan Griffiths on 2016-08-18

Revert change to startup wait

302. By Alan Griffiths on 2016-08-18

merge lp:~alan-griffiths/miral/add-MirRunner-add_start_callback

303. By Alan Griffiths on 2016-08-18

Replace miral-qt MirServer with miral::MirRunner

304. By Alan Griffiths on 2016-08-18

Delete mysteryous FIXME

305. By Alan Griffiths on 2016-08-18

QMirServerPrivate can't be a functor, don't force it to look like one

306. By Alan Griffiths on 2016-08-18

A bit more tidy-up

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'miral-qt/src/platforms/mirserver/CMakeLists.txt'
2--- miral-qt/src/platforms/mirserver/CMakeLists.txt 2016-08-15 16:13:40 +0000
3+++ miral-qt/src/platforms/mirserver/CMakeLists.txt 2016-08-18 07:54:15 +0000
4@@ -83,7 +83,7 @@
5 windowmanagementpolicy.cpp
6 windowmodel.cpp
7 tracepoints.c
8- usingqtcompositor.cpp usingqtcompositor.h
9+ setqtcompositor.cpp setqtcompositor.h
10 # We need to run moc on these headers
11 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
12 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirMousePointerInterface.h
13
14=== modified file 'miral-qt/src/platforms/mirserver/mirserver.cpp'
15--- miral-qt/src/platforms/mirserver/mirserver.cpp 2016-08-16 14:32:17 +0000
16+++ miral-qt/src/platforms/mirserver/mirserver.cpp 2016-08-18 07:54:15 +0000
17@@ -14,82 +14,4 @@
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21-#include <QCoreApplication>
22-
23 #include "mirserver.h"
24-
25-// local
26-#include "argvHelper.h"
27-#include "screensmodel.h"
28-#include "logging.h"
29-#include "usingqtcompositor.h"
30-
31-// std
32-#include <memory>
33-
34-// egl
35-#define MESA_EGL_NO_X11_HEADERS
36-#include <EGL/egl.h>
37-
38-// mir
39-#include <mir/shell/shell.h>
40-
41-// miral
42-#include <miral/set_terminator.h>
43-
44-namespace mg = mir::graphics;
45-namespace mo = mir::options;
46-namespace msh = mir::shell;
47-namespace ms = mir::scene;
48-
49-MirServer::MirServer(int &argc, char **argv,
50- const QSharedPointer<ScreensModel> &screensModel, QObject* parent)
51- : QObject(parent)
52- , m_screensModel(screensModel)
53-{
54- bool unknownArgsFound = false;
55- set_command_line_handler([&argc, &argv, &unknownArgsFound](int filteredCount, const char* const filteredArgv[]) {
56- unknownArgsFound = true;
57- // Want to edit argv to match that which Mir returns, as those are for to Qt alone to process. Edit existing
58- // argc as filteredArgv only defined in this scope.
59- qtmir::editArgvToMatch(argc, argv, filteredCount, filteredArgv);
60- });
61-
62- // Casting char** to be a const char** safe as Mir won't change it, nor will we
63- set_command_line(argc, const_cast<const char **>(argv));
64-
65- usingQtCompositor(*this);
66-
67- miral::SetTerminator{[](int)
68- {
69- qDebug() << "Signal caught by Mir, stopping Mir server..";
70- QCoreApplication::quit();
71- }}(*this);
72-
73- add_init_callback([this, &screensModel] {
74- screensModel->init(the_display(), the_compositor(), the_shell());
75- });
76-
77- if (!unknownArgsFound) { // mir parsed all the arguments, so edit argv to pretend to have just argv[0]
78- argc = 1;
79- }
80-
81- qCDebug(QTMIR_MIR_MESSAGES) << "MirServer created";
82- qCDebug(QTMIR_MIR_MESSAGES) << "Command line arguments passed to Qt:" << QCoreApplication::arguments();
83-}
84-
85-// Override default implementation to ensure we terminate the ScreensModel first.
86-// Code path followed when Qt tries to shutdown the server.
87-void MirServer::stop()
88-{
89- m_screensModel->terminate();
90- mir::Server::stop();
91-}
92-
93-
94-/************************************ Shell side ************************************/
95-
96-QSharedPointer<ScreensModel> MirServer::screensModel() const
97-{
98- return m_screensModel;
99-}
100
101=== modified file 'miral-qt/src/platforms/mirserver/mirserver.h'
102--- miral-qt/src/platforms/mirserver/mirserver.h 2016-08-15 11:39:14 +0000
103+++ miral-qt/src/platforms/mirserver/mirserver.h 2016-08-18 07:54:15 +0000
104@@ -35,16 +35,11 @@
105 Q_OBJECT
106
107 public:
108- MirServer(int &argc, char **argv, const QSharedPointer<ScreensModel> &, QObject* parent = 0);
109+ MirServer(QObject* parent = 0) : QObject(parent)
110+ {
111+ }
112+
113 ~MirServer() = default;
114-
115- void stop();
116-
117- QSharedPointer<ScreensModel> screensModel() const;
118-
119-private:
120-
121- const QSharedPointer<ScreensModel> m_screensModel;
122 };
123
124 #endif // MIRSERVER_H
125
126=== modified file 'miral-qt/src/platforms/mirserver/qmirserver.cpp'
127--- miral-qt/src/platforms/mirserver/qmirserver.cpp 2016-08-12 16:55:12 +0000
128+++ miral-qt/src/platforms/mirserver/qmirserver.cpp 2016-08-18 07:54:15 +0000
129@@ -16,7 +16,6 @@
130
131 // Qt
132 #include <QObject>
133-#include <QCoreApplication>
134 #include <QDebug>
135 #include <QOpenGLContext>
136
137@@ -24,7 +23,6 @@
138 #include "mirserver.h"
139 #include "qmirserver.h"
140 #include "qmirserver_p.h"
141-#include "screen.h"
142 #include "miropenglcontext.h"
143
144 QMirServer::QMirServer(int &argc, char **argv, QObject *parent)
145@@ -33,9 +31,9 @@
146 {
147 Q_D(QMirServer);
148
149- d->server = QSharedPointer<MirServer>(new MirServer(argc, argv, d->screensModel));
150+ d->server = QSharedPointer<MirServer>(new MirServer());
151
152- d->serverThread = new MirServerThread(d);
153+ d->serverThread = new MirServerThread(argc, argv, d);
154
155 connect(d->serverThread, &MirServerThread::stopped, this, &QMirServer::stopped);
156 }
157@@ -110,15 +108,15 @@
158
159 if (d->server) {
160 if (resource == "SessionAuthorizer")
161- result = d->m_usingQtMirSessionAuthorizer.the_application_authorizer().get();
162+ result = d->the_application_authorizer().get();
163 else if (resource == "SessionListener")
164- result = d->m_usingQtMirSessionListener.sessionListener();
165+ result = d->sessionListener();
166 else if (resource == "PromptSessionListener")
167- result = d->m_usingQtMirPromptSessionListener.promptSessionListener();
168+ result = d->promptSessionListener();
169 else if (resource == "WindowController")
170- result = d->m_usingQtMirWindowManager.windowController();
171+ result = d->windowController();
172 else if (resource == "WindowModel")
173- result = d->m_usingQtMirWindowManager.windowModel();
174+ result = d->windowModel();
175 else if (resource == "ScreensController")
176 result = screensController().data();
177 }
178
179=== modified file 'miral-qt/src/platforms/mirserver/qmirserver_p.cpp'
180--- miral-qt/src/platforms/mirserver/qmirserver_p.cpp 2016-08-15 11:52:27 +0000
181+++ miral-qt/src/platforms/mirserver/qmirserver_p.cpp 2016-08-18 07:54:15 +0000
182@@ -15,6 +15,7 @@
183 */
184
185 #include "qmirserver_p.h"
186+#include <QCoreApplication>
187
188 // Mir
189 #include <mir/main_loop.h>
190@@ -27,15 +28,54 @@
191 #include "sessionlistener.h"
192 #include "sessionauthorizer.h"
193 #include "windowmanagementpolicy.h"
194+#include "argvHelper.h"
195+#include "setqtcompositor.h"
196+
197+// miral
198+#include <miral/add_init_callback.h>
199+#include <miral/set_command_line_hander.h>
200+#include <miral/set_terminator.h>
201+#include <miral/set_window_managment_policy.h>
202
203 void MirServerThread::run()
204 {
205- // This should eventually be replaced by miral::MirRunner::run()
206- server->m_usingQtMirSessionAuthorizer(*server->server);
207- server->m_usingQtMirSessionListener(*server->server);
208- server->m_usingQtMirPromptSessionListener(*server->server);
209- server->m_usingQtMirWindowManager(*server->server);
210+ bool unknownArgsFound = false;
211+
212+ miral::SetCommandLineHandler setCommandLineHandler{[this, &unknownArgsFound](int filteredCount, const char* const filteredArgv[])
213+ {
214+ unknownArgsFound = true;
215+ // Want to edit argv to match that which Mir returns, as those are for to Qt alone to process. Edit existing
216+ // argc as filteredArgv only defined in this scope.
217+ qtmir::editArgvToMatch(argc, argv, filteredCount, filteredArgv);
218+ }};
219+
220+ miral::AddInitCallback addInitCallback{[&, this]
221+ {
222+ if (!unknownArgsFound) { // mir parsed all the arguments, so edit argv to pretend to have just argv[0]
223+ argc = 1;
224+ }
225+ qCDebug(QTMIR_MIR_MESSAGES) << "MirServer created";
226+ qCDebug(QTMIR_MIR_MESSAGES) << "Command line arguments passed to Qt:" << QCoreApplication::arguments();
227+ }};
228+
229+ miral::SetTerminator setTerminator{[](int)
230+ {
231+ qDebug() << "Signal caught by Mir, stopping Mir server..";
232+ QCoreApplication::quit();
233+ }};
234+
235+ qtmir::SetQtCompositor setQtCompositor{server->screensModel};
236+
237+ // Casting char** to be a const char** safe as Mir won't change it, nor will we
238+ server->server->set_command_line(argc, const_cast<const char **>(argv));
239+
240+ // This should eventually be replaced by miral::MirRunner::run_with()
241+ (*server)(*server->server);
242 mir_display_configuration_policy(*server->server);
243+ setCommandLineHandler(*server->server);
244+ addInitCallback(*server->server);
245+ setQtCompositor(*server->server);
246+ setTerminator(*server->server);
247
248 try {
249 server->server->apply_settings();
250@@ -63,6 +103,7 @@
251
252 void MirServerThread::stop()
253 {
254+ server->screensModel->terminate();
255 server->server->stop();
256 }
257
258@@ -73,54 +114,64 @@
259 return mir_running;
260 }
261
262-void UsingQtMirSessionListener::operator()(mir::Server& server)
263-{
264+struct QMirServerPrivate::Self
265+{
266+ Self(const QSharedPointer<ScreensModel> &model);
267+ const QSharedPointer<ScreensModel> &m_screensModel;
268+ miral::SetWindowManagmentPolicy m_policy;
269+ qtmir::WindowController m_windowController;
270+ qtmir::WindowModel m_windowModel;
271+ std::weak_ptr<SessionListener> m_sessionListener;
272+ std::weak_ptr<PromptSessionListener> m_promptSessionListener;
273+};
274+
275+SessionListener *QMirServerPrivate::sessionListener() const
276+{
277+ return self->m_sessionListener.lock().get();
278+}
279+
280+QMirServerPrivate::Self::Self(const QSharedPointer<ScreensModel> &model)
281+ : m_screensModel(model)
282+ , m_policy(miral::set_window_managment_policy<WindowManagementPolicy>(m_windowModel, m_windowController, m_screensModel))
283+{
284+}
285+
286+qtmir::WindowModelInterface *QMirServerPrivate::windowModel() const
287+{
288+ return &self->m_windowModel;
289+}
290+
291+qtmir::WindowControllerInterface *QMirServerPrivate::windowController() const
292+{
293+ return &self->m_windowController;
294+}
295+
296+QMirServerPrivate::QMirServerPrivate() :
297+ self{std::make_shared<Self>(screensModel)}
298+{
299+}
300+
301+PromptSessionListener *QMirServerPrivate::promptSessionListener() const
302+{
303+ return self->m_promptSessionListener.lock().get();
304+}
305+
306+void QMirServerPrivate::operator()(mir::Server& server)
307+{
308+ qtmir::SetSessionAuthorizer::operator()(server);
309 server.override_the_session_listener([this]
310 {
311 auto const result = std::make_shared<SessionListener>();
312- m_sessionListener = result;
313+ self->m_sessionListener = result;
314 return result;
315 });
316-}
317-
318-SessionListener *UsingQtMirSessionListener::sessionListener()
319-{
320- return m_sessionListener.lock().get();
321-}
322-
323-void UsingQtMirPromptSessionListener::operator()(mir::Server& server)
324-{
325+
326 server.override_the_prompt_session_listener([this]
327 {
328 auto const result = std::make_shared<PromptSessionListener>();
329- m_promptSessionListener = result;
330+ self->m_promptSessionListener = result;
331 return result;
332 });
333-}
334-
335-PromptSessionListener *UsingQtMirPromptSessionListener::promptSessionListener()
336-{
337- return m_promptSessionListener.lock().get();
338-}
339-
340-UsingQtMirWindowManager::UsingQtMirWindowManager(const QSharedPointer<ScreensModel> &model)
341- : m_screensModel(model)
342- , m_policy(miral::set_window_managment_policy<WindowManagementPolicy>(m_windowModel, m_windowController, m_screensModel))
343-{
344-}
345-
346-void UsingQtMirWindowManager::operator()(mir::Server& server)
347-{
348- m_policy(server);
349-}
350-
351-qtmir::WindowModelInterface *UsingQtMirWindowManager::windowModel()
352-{
353- return &m_windowModel;
354-}
355-
356-qtmir::WindowControllerInterface *UsingQtMirWindowManager::windowController()
357-{
358- return &m_windowController;
359-}
360-
361+
362+ self->m_policy(server);
363+}
364
365=== modified file 'miral-qt/src/platforms/mirserver/qmirserver_p.h'
366--- miral-qt/src/platforms/mirserver/qmirserver_p.h 2016-08-12 16:55:12 +0000
367+++ miral-qt/src/platforms/mirserver/qmirserver_p.h 2016-08-18 07:54:15 +0000
368@@ -33,7 +33,6 @@
369
370 //miral
371 #include <miral/application_authorizer.h>
372-#include "miral/set_window_managment_policy.h"
373
374 class MirServer;
375 class QMirServer;
376@@ -42,57 +41,32 @@
377 class SessionListener;
378 class SessionAuthorizer;
379
380-// TODO the UsingQtMirXXX classes introduced here are a step towards
381-// decoupling from libmirserver and using a libmiral-style API
382-using UsingQtMirSessionAuthorizer = miral::SetApplicationAuthorizer<SessionAuthorizer>;
383-
384-class UsingQtMirSessionListener
385-{
386-public:
387- void operator()(mir::Server& server);
388- SessionListener *sessionListener();
389-
390-private:
391- std::weak_ptr<SessionListener> m_sessionListener;
392-};
393-
394-class UsingQtMirPromptSessionListener
395-{
396-public:
397- void operator()(mir::Server& server);
398- PromptSessionListener *promptSessionListener();
399-
400-private:
401- std::weak_ptr<PromptSessionListener> m_promptSessionListener;
402-};
403-
404-class UsingQtMirWindowManager
405-{
406-public:
407- UsingQtMirWindowManager(const QSharedPointer<ScreensModel> &model);
408- void operator()(mir::Server& server);
409- qtmir::WindowModelInterface *windowModel();
410- qtmir::WindowControllerInterface *windowController();
411-
412-private:
413- const QSharedPointer<ScreensModel> &m_screensModel;
414- miral::SetWindowManagmentPolicy m_policy;
415- qtmir::WindowController m_windowController;
416- qtmir::WindowModel m_windowModel;
417-};
418-
419-class QMirServerPrivate
420-{
421-public:
422- QSharedPointer<ScreensModel> screensModel{new ScreensModel()};
423+namespace qtmir
424+{
425+using SetSessionAuthorizer = miral::SetApplicationAuthorizer<SessionAuthorizer>;
426+}
427+
428+class QMirServerPrivate : private qtmir::SetSessionAuthorizer
429+{
430+public:
431+ QMirServerPrivate();
432+ const QSharedPointer<ScreensModel> screensModel{new ScreensModel()};
433 QSharedPointer<MirServer> server;
434 QSharedPointer<ScreensController> screensController;
435 MirServerThread *serverThread;
436
437- UsingQtMirSessionAuthorizer m_usingQtMirSessionAuthorizer;
438- UsingQtMirSessionListener mutable m_usingQtMirSessionListener;
439- UsingQtMirPromptSessionListener mutable m_usingQtMirPromptSessionListener;
440- UsingQtMirWindowManager mutable m_usingQtMirWindowManager{screensModel};
441+ void operator()(mir::Server& server);
442+
443+ SessionListener *sessionListener() const;
444+ PromptSessionListener *promptSessionListener() const;
445+ qtmir::WindowModelInterface *windowModel() const;
446+ qtmir::WindowControllerInterface *windowController() const;
447+
448+ using qtmir::SetSessionAuthorizer::the_application_authorizer;
449+
450+private:
451+ struct Self;
452+ std::shared_ptr<Self> const self;
453 };
454
455 class MirServerThread : public QThread
456@@ -100,8 +74,8 @@
457 Q_OBJECT
458
459 public:
460- MirServerThread(QMirServerPrivate* server)
461- : server(server)
462+ MirServerThread(int &argc, char **argv, QMirServerPrivate* server)
463+ : argc{argc}, argv{argv}, server(server)
464 {}
465
466 bool waitForMirStartup();
467@@ -118,6 +92,8 @@
468 std::condition_variable started_cv;
469 bool mir_running{false};
470
471+ int &argc;
472+ char **argv;
473 QMirServerPrivate* const server;
474 };
475
476
477=== modified file 'miral-qt/src/platforms/mirserver/screensmodel.cpp'
478--- miral-qt/src/platforms/mirserver/screensmodel.cpp 2016-08-16 14:15:26 +0000
479+++ miral-qt/src/platforms/mirserver/screensmodel.cpp 2016-08-18 07:54:15 +0000
480@@ -48,9 +48,10 @@
481 }
482
483 // init only after MirServer has initialized - runs on MirServerThread!!!
484-void ScreensModel::init(const std::shared_ptr<mir::graphics::Display> &display,
485- const std::shared_ptr<mir::compositor::Compositor> &compositor,
486- const std::shared_ptr<mir::compositor::DisplayListener> &displayListener)
487+void ScreensModel::init(
488+ const std::shared_ptr<mir::graphics::Display>& display,
489+ const std::shared_ptr<QtCompositor>& compositor,
490+ const std::shared_ptr<mir::compositor::DisplayListener>& displayListener)
491 {
492 m_display = display;
493 m_compositor = compositor;
494@@ -59,7 +60,7 @@
495 // Use a Blocking Queued Connection to enforce synchronization of Qt GUI thread with Mir thread(s)
496 // on compositor shutdown. Compositor startup can be lazy.
497 // Queued connections work because the thread affinity of this class is with the Qt GUI thread.
498- auto qtCompositor = static_cast<QtCompositor *>(compositor.get());
499+ auto qtCompositor = compositor.get();
500 connect(qtCompositor, &QtCompositor::starting,
501 this, &ScreensModel::onCompositorStarting);
502 connect(qtCompositor, &QtCompositor::stopping,
503@@ -70,8 +71,7 @@
504 // Runs on MirServerThread!!!
505 void ScreensModel::terminate()
506 {
507- auto qtCompositor = static_cast<QtCompositor *>(m_compositor.get());
508- qtCompositor->disconnect();
509+ m_compositor->disconnect();
510 }
511
512 void ScreensModel::onCompositorStarting()
513
514=== modified file 'miral-qt/src/platforms/mirserver/screensmodel.h'
515--- miral-qt/src/platforms/mirserver/screensmodel.h 2016-08-16 14:15:26 +0000
516+++ miral-qt/src/platforms/mirserver/screensmodel.h 2016-08-18 07:54:15 +0000
517@@ -28,10 +28,11 @@
518
519 namespace mir {
520 namespace graphics { class Display; }
521- namespace compositor { class Compositor; class DisplayListener; }
522+ namespace compositor { class DisplayListener; }
523 }
524 class Screen;
525 class QWindow;
526+class QtCompositor;
527
528 /*
529 * ScreensModel monitors the Mir display configuration and compositor status, and updates
530@@ -73,9 +74,10 @@
531
532 public:
533 // called by MirServer
534- void init(const std::shared_ptr<mir::graphics::Display> &display,
535- const std::shared_ptr<mir::compositor::Compositor> &compositor,
536- const std::shared_ptr<mir::compositor::DisplayListener> &displayListener);
537+ void init(
538+ const std::shared_ptr<mir::graphics::Display>& display,
539+ const std::shared_ptr<QtCompositor>& compositor,
540+ const std::shared_ptr<mir::compositor::DisplayListener>& displayListener);
541 void terminate();
542
543 // override for testing purposes
544@@ -91,7 +93,7 @@
545 void allWindowsSetExposed(bool exposed);
546
547 std::weak_ptr<mir::graphics::Display> m_display;
548- std::shared_ptr<mir::compositor::Compositor> m_compositor;
549+ std::shared_ptr<QtCompositor> m_compositor;
550 std::shared_ptr<mir::compositor::DisplayListener> m_displayListener;
551 QList<Screen*> m_screenList;
552 bool m_compositing;
553
554=== renamed file 'miral-qt/src/platforms/mirserver/usingqtcompositor.cpp' => 'miral-qt/src/platforms/mirserver/setqtcompositor.cpp'
555--- miral-qt/src/platforms/mirserver/usingqtcompositor.cpp 2016-08-15 16:13:40 +0000
556+++ miral-qt/src/platforms/mirserver/setqtcompositor.cpp 2016-08-18 07:54:15 +0000
557@@ -16,17 +16,19 @@
558 * Authored by: Alan Griffiths <alan@octopull.co.uk>
559 */
560
561-#include "usingqtcompositor.h"
562+#include "setqtcompositor.h"
563
564 // local
565 #include "mircursorimages.h"
566 #include "mirglconfig.h"
567 #include "mirserverstatuslistener.h"
568 #include "qtcompositor.h"
569+#include "screensmodel.h"
570
571 // mir
572 #include <mir/graphics/cursor.h>
573 #include <mir/server.h>
574+#include <mir/shell/shell.h>
575
576 namespace mg = mir::graphics;
577
578@@ -47,10 +49,19 @@
579 };
580 }
581
582-void usingQtCompositor(mir::Server& server)
583-{
584- server.override_the_compositor([]
585- { return std::make_shared<QtCompositor>(); });
586+qtmir::SetQtCompositor::SetQtCompositor(QSharedPointer<ScreensModel> const& screensModel) :
587+ m_screensModel{screensModel}
588+{
589+}
590+
591+void qtmir::SetQtCompositor::operator()(mir::Server& server)
592+{
593+ server.override_the_compositor([this]
594+ {
595+ auto result = std::make_shared<QtCompositor>();
596+ m_compositor = result;
597+ return result;
598+ });
599
600 server.override_the_gl_config([]
601 { return std::make_shared<MirGLConfig>(); });
602@@ -63,4 +74,17 @@
603
604 server.wrap_cursor([&](std::shared_ptr<mg::Cursor> const& wrapped)
605 { return std::make_shared<HiddenCursorWrapper>(wrapped); });
606+
607+ server.add_init_callback([&, this]
608+ {
609+ if (auto const compositor = m_compositor.lock())
610+ {
611+ m_screensModel->init(server.the_display(), compositor, server.the_shell());
612+ }
613+ else
614+ {
615+ throw std::logic_error("No m_compositor available. Server not running?");
616+ }
617+ });
618 }
619+
620
621=== renamed file 'miral-qt/src/platforms/mirserver/usingqtcompositor.h' => 'miral-qt/src/platforms/mirserver/setqtcompositor.h'
622--- miral-qt/src/platforms/mirserver/usingqtcompositor.h 2016-08-15 16:14:50 +0000
623+++ miral-qt/src/platforms/mirserver/setqtcompositor.h 2016-08-18 07:54:15 +0000
624@@ -16,12 +16,32 @@
625 * Authored by: Alan Griffiths <alan@octopull.co.uk>
626 */
627
628-#ifndef USING_QT_COMPOSITOR_H
629-#define USING_QT_COMPOSITOR_H
630+#ifndef QTMIR_SET_QT_COMPOSITOR_H
631+#define QTMIR_SET_QT_COMPOSITOR_H
632+
633+#include <QSharedPointer>
634+
635+#include <memory>
636
637 namespace mir { class Server; }
638
639+class QtCompositor;
640+class ScreensModel;
641+
642+namespace qtmir
643+{
644 // Configure the server for using the Qt compositor
645-void usingQtCompositor(mir::Server& server);
646-
647-#endif //USING_QT_COMPOSITOR_H
648+class SetQtCompositor
649+{
650+public:
651+ explicit SetQtCompositor(QSharedPointer<ScreensModel> const& screensModel);
652+
653+ void operator()(mir::Server& server);
654+
655+private:
656+ QSharedPointer<ScreensModel> const m_screensModel;
657+ std::weak_ptr<QtCompositor> m_compositor;
658+};
659+}
660+
661+#endif //QTMIR_SET_QT_COMPOSITOR_H
662
663=== modified file 'miral-qt/tests/framework/fake_displayconfigurationoutput.h'
664--- miral-qt/tests/framework/fake_displayconfigurationoutput.h 2016-06-01 22:06:51 +0000
665+++ miral-qt/tests/framework/fake_displayconfigurationoutput.h 2016-08-18 07:54:15 +0000
666@@ -18,6 +18,7 @@
667 #define FAKE_DISPLAYCONFIGURATIONOUTPUT_H
668
669 #include <mir/graphics/display_configuration.h>
670+#include <mir/version.h>
671
672 namespace mg = mir::graphics;
673 namespace geom = mir::geometry;
674@@ -46,7 +47,12 @@
675 mir_orientation_normal,
676 1.0f,
677 mir_form_factor_unknown
678-};
679+
680+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
681+ ,
682+ mir_subpixel_arrangement_unknown
683+#endif
684+ };
685
686 const mg::DisplayConfigurationOutput fakeOutput2
687 {
688@@ -72,6 +78,10 @@
689 mir_orientation_left,
690 1.0f,
691 mir_form_factor_unknown
692+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 25, 0)
693+ ,
694+ mir_subpixel_arrangement_unknown
695+#endif
696 };
697
698 #endif // FAKE_DISPLAYCONFIGURATIONOUTPUT_H
699
700=== modified file 'miral-qt/tests/mirserver/ScreensModel/testable_screensmodel.h'
701--- miral-qt/tests/mirserver/ScreensModel/testable_screensmodel.h 2016-07-27 13:59:34 +0000
702+++ miral-qt/tests/mirserver/ScreensModel/testable_screensmodel.h 2016-08-18 07:54:15 +0000
703@@ -28,7 +28,7 @@
704 }
705
706 void do_init(const std::shared_ptr<mir::graphics::Display> &display,
707- const std::shared_ptr<mir::compositor::Compositor> &compositor,
708+ const std::shared_ptr<QtCompositor> &compositor,
709 const std::shared_ptr<mir::compositor::DisplayListener> &displayListener)
710 {
711 init(display, compositor, displayListener);

Subscribers

People subscribed via source and target branches