Merge lp:~alan-griffiths/miral/pre_init-CommandLineOption into lp:miral

Proposed by Alan Griffiths
Status: Merged
Approved by: Gerry Boland
Approved revision: 578
Merged at revision: 577
Proposed branch: lp:~alan-griffiths/miral/pre_init-CommandLineOption
Merge into: lp:miral
Diff against target: 120 lines (+27/-4)
6 files modified
debian/changelog (+1/-0)
debian/libmiral2.symbols (+1/-0)
include/miral/command_line_option.h (+10/-1)
miral-shell/shell_main.cpp (+2/-2)
miral/command_line_option.cpp (+12/-1)
miral/symbols.map (+1/-0)
To merge this branch: bzr merge lp:~alan-griffiths/miral/pre_init-CommandLineOption
Reviewer Review Type Date Requested Status
Gerry Boland (community) Abstain
Alberto Aguirre (community) Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+329098@code.launchpad.net

Commit message

Enable CommandLineOptions to be processed before server initialization

Description of the change

Enable CommandLineOptions to be processed before server initialization

The need for this became apparent in discussion with Yunit developers. Vis:

    https://github.com/yunit-io/unity-system-compositor/issues/1#issuecomment-322532709

It ought to be generally useful.

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

PASSED: Continuous integration, rev:578
https://mir-jenkins.ubuntu.com/job/miral-ci/64/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-miral/106
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/5086
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/5075
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/5075
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/5075
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=artful/110
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=artful/110/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=xenial/110
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=xenial/110/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=zesty/110
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=zesty/110/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=artful/110
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=artful/110/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=xenial/110
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=xenial/110/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=zesty/110
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=zesty/110/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

I never realized command line args were processed so late in initialization. Is there a reason we want them to be processed post-init at all?

review: Needs Information
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> I never realized command line args were processed so late in initialization.
> Is there a reason we want them to be processed post-init at all?

Good question.

I guess before starting MirAL I "usually" used post_init as that ensures that Mir "structural" objects are accessible. And that default fed into the initial version of CommandLineOption. But, for MirAL users, access to these objects is less relevant.

OTOH I'm reluctant to change the default behaviour even if I *think* no users will be affected.

Revision history for this message
Gerry Boland (gerboland) wrote :

I understand your concern, but IMO current behaviour does break the principle of least surprise, and now having both pre-init and post-init command line parsing strikes me as making that situation worse.

My vote is to change behaviour and document clearly in the changelog.

Revision history for this message
Joseph Wakeling (webdrake) wrote :

For the record, I can confirm that the feature addresses the concern discussed in https://github.com/yunit-io/unity-system-compositor/issues/1#issuecomment-322532709.

As for the question of default behaviour: (i) the flexibility to choose between pre- and post-init handling of command line options seems useful in principle and (ii) I'd rather not have a breaking change in a minor release.

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Unfortunately being a library, we sometimes have to carry some cruft before it can be removed (i.e. removing post-init), so LGTM.

review: Approve
Revision history for this message
Gerry Boland (gerboland) wrote :

Well I'm not proposing any api removal, just a behaviour change. But seems I'm out voted, so I abstain!

review: Abstain
Revision history for this message
Joseph Wakeling (webdrake) wrote :

FWIW I would be happy for the default behaviour to change in a new major release. Would be reluctant to lose the ability to specify post-init handling of command line options, though (just for flexibility).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2017-08-11 09:42:14 +0000
+++ debian/changelog 2017-08-16 11:21:00 +0000
@@ -8,6 +8,7 @@
8 . [libmiral, miral-shell] handle display reconfiguration better and allow8 . [libmiral, miral-shell] handle display reconfiguration better and allow
9 shells to customize maximized placements.9 shells to customize maximized placements.
10 . Fix FTBFS with GMock 1.7 matchers (when compiling against Mir 0.27)10 . Fix FTBFS with GMock 1.7 matchers (when compiling against Mir 0.27)
11 . Enable CommandLineOptions to be processed before server initialization
11 - Bugs fixed:12 - Bugs fixed:
12 . floating window manager allows resizing maximized windows (LP: #1704776)13 . floating window manager allows resizing maximized windows (LP: #1704776)
13 . [miral-shell] doesn't work with breeze X cursor theme (LP: #1699084)14 . [miral-shell] doesn't work with breeze X cursor theme (LP: #1699084)
1415
=== modified file 'debian/libmiral2.symbols'
--- debian/libmiral2.symbols 2017-07-28 13:38:14 +0000
+++ debian/libmiral2.symbols 2017-08-16 11:21:00 +0000
@@ -394,5 +394,6 @@
394 (c++)"miral::WindowManagerTools::start_drag_and_drop(miral::WindowInfo&, std::vector<unsigned char, std::allocator<unsigned char> > const&)@MIRAL_1.4.0" 1.4.0394 (c++)"miral::WindowManagerTools::start_drag_and_drop(miral::WindowInfo&, std::vector<unsigned char, std::allocator<unsigned char> > const&)@MIRAL_1.4.0" 1.4.0
395 (c++)"typeinfo for miral::WindowManagementPolicyAddendum2@MIRAL_1.4.0" 1.4.0395 (c++)"typeinfo for miral::WindowManagementPolicyAddendum2@MIRAL_1.4.0" 1.4.0
396 MIRAL_1.5.0@MIRAL_1.5.0 1.5.0396 MIRAL_1.5.0@MIRAL_1.5.0 1.5.0
397 (c++)"miral::pre_init(miral::CommandLineOption const&)@MIRAL_1.5.0" 1.5.0
397 (c++)"typeinfo for miral::WindowManagementPolicyAddendum3@MIRAL_1.5.0" 1.5.0398 (c++)"typeinfo for miral::WindowManagementPolicyAddendum3@MIRAL_1.5.0" 1.5.0
398 (c++)"miral::WindowManagerTools::active_output()@MIRAL_1.5.0" 1.5.0399 (c++)"miral::WindowManagerTools::active_output()@MIRAL_1.5.0" 1.5.0
399\ No newline at end of file400\ No newline at end of file
400401
=== modified file 'include/miral/command_line_option.h'
--- include/miral/command_line_option.h 2017-08-10 16:59:22 +0000
+++ include/miral/command_line_option.h 2017-08-16 11:21:00 +0000
@@ -30,8 +30,12 @@
30namespace miral30namespace miral
31{31{
32/// Add a user configuration option to Mir's option handling.32/// Add a user configuration option to Mir's option handling.
33/// The callback will be invoked during initialisation with a value supplied33/// By default the callback will be invoked following Mir initialisation but
34/// prior to the server starting. The value supplied to the callback will come
34/// from the command line, environment variable, config file or the default.35/// from the command line, environment variable, config file or the default.
36///
37/// \note Except for re-ordering implied by "pre_init()" the callbacks will be
38/// invoked in the order supplied.
35class CommandLineOption39class CommandLineOption
36{40{
37public:41public:
@@ -87,6 +91,9 @@
8791
88 void operator()(mir::Server& server) const;92 void operator()(mir::Server& server) const;
8993
94 // Call the callback *before* Mir initialization starts
95 friend auto pre_init(CommandLineOption const& clo) -> CommandLineOption;
96
90 ~CommandLineOption();97 ~CommandLineOption();
91 CommandLineOption(CommandLineOption const&);98 CommandLineOption(CommandLineOption const&);
92 auto operator=(CommandLineOption const&) -> CommandLineOption&;99 auto operator=(CommandLineOption const&) -> CommandLineOption&;
@@ -95,6 +102,8 @@
95 struct Self;102 struct Self;
96 std::shared_ptr<Self> self;103 std::shared_ptr<Self> self;
97};104};
105
106auto pre_init(CommandLineOption const& clo) -> CommandLineOption;
98}107}
99108
100#endif //MIRAL_COMMAND_LINE_OPTION_H109#endif //MIRAL_COMMAND_LINE_OPTION_H
101110
=== modified file 'miral-shell/shell_main.cpp'
--- miral-shell/shell_main.cpp 2017-08-10 16:59:22 +0000
+++ miral-shell/shell_main.cpp 2017-08-16 11:21:00 +0000
@@ -92,7 +92,7 @@
92 debug_extensions,92 debug_extensions,
93 AppendEventFilter{quit_on_ctrl_alt_bksp},93 AppendEventFilter{quit_on_ctrl_alt_bksp},
94 StartupInternalClient{"Intro", spinner},94 StartupInternalClient{"Intro", spinner},
95 CommandLineOption{[&](std::string const& typeface) { ::titlebar::font_file(typeface); },95 pre_init(CommandLineOption{[&](std::string const& typeface) { ::titlebar::font_file(typeface); },
96 "shell-titlebar-font", "font file to use for titlebars", ::titlebar::font_file()}96 "shell-titlebar-font", "font file to use for titlebars", ::titlebar::font_file()})
97 });97 });
98}98}
9999
=== modified file 'miral/command_line_option.cpp'
--- miral/command_line_option.cpp 2017-08-10 16:59:22 +0000
+++ miral/command_line_option.cpp 2017-08-16 11:21:00 +0000
@@ -107,6 +107,7 @@
107 {107 {
108 }108 }
109109
110 bool pre_init{false};
110 std::function<void(mir::Server& server)> setup;111 std::function<void(mir::Server& server)> setup;
111 std::function<void(mir::Server& server)> callback;112 std::function<void(mir::Server& server)> callback;
112};113};
@@ -188,10 +189,20 @@
188{189{
189}190}
190191
192auto miral::pre_init(CommandLineOption const& clo) -> CommandLineOption
193{
194 clo.self->pre_init = true;
195 return clo;
196}
197
191void miral::CommandLineOption::operator()(mir::Server& server) const198void miral::CommandLineOption::operator()(mir::Server& server) const
192{199{
193 self->setup(server);200 self->setup(server);
194 server.add_init_callback([&]{ self->callback(server); });201
202 if (self->pre_init)
203 server.add_pre_init_callback([&]{ self->callback(server); });
204 else
205 server.add_init_callback([&]{ self->callback(server); });
195}206}
196207
197miral::CommandLineOption::~CommandLineOption() = default;208miral::CommandLineOption::~CommandLineOption() = default;
198209
=== modified file 'miral/symbols.map'
--- miral/symbols.map 2017-07-28 13:38:14 +0000
+++ miral/symbols.map 2017-08-16 11:21:00 +0000
@@ -430,6 +430,7 @@
430 miral::WindowManagementPolicyAddendum3::WindowManagementPolicyAddendum3*;430 miral::WindowManagementPolicyAddendum3::WindowManagementPolicyAddendum3*;
431 miral::WindowManagementPolicyAddendum3::operator*;431 miral::WindowManagementPolicyAddendum3::operator*;
432 miral::WindowManagerTools::active_output*;432 miral::WindowManagerTools::active_output*;
433 miral::pre_init*;
433 non-virtual?thunk?to?miral::WindowManagementPolicyAddendum3::?WindowManagementPolicyAddendum3*;434 non-virtual?thunk?to?miral::WindowManagementPolicyAddendum3::?WindowManagementPolicyAddendum3*;
434 typeinfo?for?miral::WindowManagementPolicyAddendum3;435 typeinfo?for?miral::WindowManagementPolicyAddendum3;
435 vtable?for?miral::WindowManagementPolicyAddendum3;436 vtable?for?miral::WindowManagementPolicyAddendum3;

Subscribers

People subscribed via source and target branches