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
1=== modified file 'include/server/mir/server.h'
2--- include/server/mir/server.h 2016-10-04 06:35:05 +0000
3+++ include/server/mir/server.h 2016-11-28 14:45:32 +0000
4@@ -56,7 +56,7 @@
5 namespace scene
6 {
7 class ApplicationNotRespondingDetector;
8-class BufferStreamFactory;
9+class BufferStreamFactory;
10 class PromptSessionListener;
11 class PromptSessionManager;
12 class SessionListener;
13@@ -190,6 +190,11 @@
14 * These allow the user to insert logic into startup or error handling.
15 * For obvious reasons they should be called before run().
16 * @{ */
17+ /// Add a callback to be invoked when the settings have been applied, but before
18+ /// the server has been initialized. This allows client code to get access Mir objects.
19+ /// If multiple callbacks are added they will be invoked in the sequence added.
20+ void add_pre_init_callback(std::function<void()> const& pre_init_callback);
21+
22 /// Add a callback to be invoked when the server has been initialized,
23 /// but before it starts. This allows client code to get access Mir objects.
24 /// If multiple callbacks are added they will be invoked in the sequence added.
25
26=== modified file 'src/server/server.cpp'
27--- src/server/server.cpp 2016-11-02 05:07:18 +0000
28+++ src/server/server.cpp 2016-11-28 14:45:32 +0000
29@@ -148,6 +148,7 @@
30 std::string config_file;
31 std::shared_ptr<ServerConfiguration> server_config;
32
33+ std::function<void()> pre_init_callback{[]{}};
34 std::function<void()> init_callback{[]{}};
35 std::function<void()> stop_callback{[]{}};
36 int argc{0};
37@@ -287,6 +288,19 @@
38 self->argv = argv;
39 }
40
41+void mir::Server::add_pre_init_callback(std::function<void()> const& pre_init_callback)
42+{
43+ auto const& existing = self->pre_init_callback;
44+
45+ auto const updated = [=]
46+ {
47+ existing();
48+ pre_init_callback();
49+ };
50+
51+ self->pre_init_callback = updated;
52+}
53+
54 void mir::Server::add_init_callback(std::function<void()> const& init_callback)
55 {
56 auto const& existing = self->init_callback;
57@@ -387,6 +401,8 @@
58 if (self->emergency_cleanup_handler)
59 emergency_cleanup->add(self->emergency_cleanup_handler);
60
61+ self->pre_init_callback();
62+
63 run_mir(
64 *self->server_config,
65 [&](DisplayServer&)
66
67=== modified file 'src/server/symbols.map'
68--- src/server/symbols.map 2016-11-15 23:48:01 +0000
69+++ src/server/symbols.map 2016-11-28 14:45:32 +0000
70@@ -8,7 +8,7 @@
71 VTT?for?mir::shell::SystemCompositorWindowManager;
72
73 # The following symbols come from running a script over the generated docs. Vis:
74-# ../tools/process_doxygen_xml.py doc/xml/*.xml | grep "^mirserver public" | sed "s/mirserver public: / /" | sort
75+# ../tools/process_doxygen_xml.py doc/xml/*.xml | grep "^mirserver public" | sed "s/mirserver public: / /" | sort
76 mir::check_for_termination_exception*;
77 mir::clear_termination_exception*;
78 mir::compositor::Compositor::Compositor*;
79@@ -839,3 +839,10 @@
80 };
81 local: *;
82 };
83+
84+MIR_SERVER_0.26 {
85+ global:
86+ extern "C++" {
87+ mir::Server::add_pre_init_callback*;
88+ };
89+} MIR_SERVER_0.25;

Subscribers

People subscribed via source and target branches