Mir

Merge lp:~alan-griffiths/mir/add-mir-Server-add_pre_init_callback into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 3851
Proposed branch: lp:~alan-griffiths/mir/add-mir-Server-add_pre_init_callback
Merge into: lp:mir
Diff against target: 89 lines (+30/-2)
3 files modified
include/server/mir/server.h (+6/-1)
src/server/server.cpp (+16/-0)
src/server/symbols.map (+8/-1)
To merge this branch: bzr merge lp:~alan-griffiths/mir/add-mir-Server-add_pre_init_callback
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Kevin DuBois (community) Approve
Cemil Azizoglu (community) Needs Fixing
Andreas Pokorny (community) Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+311941@code.launchpad.net

Commit message

[mirserver] Add mir::Server::add_pre_init_callback() so that downstreams (e.g. lp:miral) can, for example, register DisplayConfigurationObservers before initialization starts (LP: #1645284)

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3850
https://mir-jenkins.ubuntu.com/job/mir-ci/2276/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2951
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3016
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3008
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3008
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/3008
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2980
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2980/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2980
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2980/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2980
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2980/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2980
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2980/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2980
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2980/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2980
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2980/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2276/rebuild

review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

sure

nice chaining..

review: Approve
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

No tests?

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I don't mind (even without tests).

Not sure this chaining approach is better or worse than just using a list...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/server/mir/server.h'
--- include/server/mir/server.h 2016-10-04 06:35:05 +0000
+++ include/server/mir/server.h 2016-11-28 14:45:32 +0000
@@ -56,7 +56,7 @@
56namespace scene56namespace scene
57{57{
58class ApplicationNotRespondingDetector;58class ApplicationNotRespondingDetector;
59class BufferStreamFactory; 59class BufferStreamFactory;
60class PromptSessionListener;60class PromptSessionListener;
61class PromptSessionManager;61class PromptSessionManager;
62class SessionListener;62class SessionListener;
@@ -190,6 +190,11 @@
190 * These allow the user to insert logic into startup or error handling.190 * These allow the user to insert logic into startup or error handling.
191 * For obvious reasons they should be called before run().191 * For obvious reasons they should be called before run().
192 * @{ */192 * @{ */
193 /// Add a callback to be invoked when the settings have been applied, but before
194 /// the server has been initialized. This allows client code to get access Mir objects.
195 /// If multiple callbacks are added they will be invoked in the sequence added.
196 void add_pre_init_callback(std::function<void()> const& pre_init_callback);
197
193 /// Add a callback to be invoked when the server has been initialized,198 /// Add a callback to be invoked when the server has been initialized,
194 /// but before it starts. This allows client code to get access Mir objects.199 /// but before it starts. This allows client code to get access Mir objects.
195 /// If multiple callbacks are added they will be invoked in the sequence added.200 /// If multiple callbacks are added they will be invoked in the sequence added.
196201
=== modified file 'src/server/server.cpp'
--- src/server/server.cpp 2016-11-02 05:07:18 +0000
+++ src/server/server.cpp 2016-11-28 14:45:32 +0000
@@ -148,6 +148,7 @@
148 std::string config_file;148 std::string config_file;
149 std::shared_ptr<ServerConfiguration> server_config;149 std::shared_ptr<ServerConfiguration> server_config;
150150
151 std::function<void()> pre_init_callback{[]{}};
151 std::function<void()> init_callback{[]{}};152 std::function<void()> init_callback{[]{}};
152 std::function<void()> stop_callback{[]{}};153 std::function<void()> stop_callback{[]{}};
153 int argc{0};154 int argc{0};
@@ -287,6 +288,19 @@
287 self->argv = argv;288 self->argv = argv;
288}289}
289290
291void mir::Server::add_pre_init_callback(std::function<void()> const& pre_init_callback)
292{
293 auto const& existing = self->pre_init_callback;
294
295 auto const updated = [=]
296 {
297 existing();
298 pre_init_callback();
299 };
300
301 self->pre_init_callback = updated;
302}
303
290void mir::Server::add_init_callback(std::function<void()> const& init_callback)304void mir::Server::add_init_callback(std::function<void()> const& init_callback)
291{305{
292 auto const& existing = self->init_callback;306 auto const& existing = self->init_callback;
@@ -387,6 +401,8 @@
387 if (self->emergency_cleanup_handler)401 if (self->emergency_cleanup_handler)
388 emergency_cleanup->add(self->emergency_cleanup_handler);402 emergency_cleanup->add(self->emergency_cleanup_handler);
389403
404 self->pre_init_callback();
405
390 run_mir(406 run_mir(
391 *self->server_config,407 *self->server_config,
392 [&](DisplayServer&)408 [&](DisplayServer&)
393409
=== modified file 'src/server/symbols.map'
--- src/server/symbols.map 2016-11-15 23:48:01 +0000
+++ src/server/symbols.map 2016-11-28 14:45:32 +0000
@@ -8,7 +8,7 @@
8 VTT?for?mir::shell::SystemCompositorWindowManager;8 VTT?for?mir::shell::SystemCompositorWindowManager;
99
10# The following symbols come from running a script over the generated docs. Vis:10# The following symbols come from running a script over the generated docs. Vis:
11# ../tools/process_doxygen_xml.py doc/xml/*.xml | grep "^mirserver public" | sed "s/mirserver public: / /" | sort 11# ../tools/process_doxygen_xml.py doc/xml/*.xml | grep "^mirserver public" | sed "s/mirserver public: / /" | sort
12 mir::check_for_termination_exception*;12 mir::check_for_termination_exception*;
13 mir::clear_termination_exception*;13 mir::clear_termination_exception*;
14 mir::compositor::Compositor::Compositor*;14 mir::compositor::Compositor::Compositor*;
@@ -839,3 +839,10 @@
839 };839 };
840 local: *;840 local: *;
841};841};
842
843MIR_SERVER_0.26 {
844 global:
845 extern "C++" {
846 mir::Server::add_pre_init_callback*;
847 };
848} MIR_SERVER_0.25;

Subscribers

People subscribed via source and target branches