Merge lp:~mir-team/qtmir/iteration-0-of-miral-PersistDisplayConfig into lp:qtmir

Proposed by Alan Griffiths
Status: Merged
Approved by: Nick Dedekind
Approved revision: 590
Merged at revision: 598
Proposed branch: lp:~mir-team/qtmir/iteration-0-of-miral-PersistDisplayConfig
Merge into: lp:qtmir
Diff against target: 316 lines (+225/-11)
7 files modified
src/platforms/mirserver/CMakeLists.txt (+3/-0)
src/platforms/mirserver/miral/CMakeLists.txt (+5/-0)
src/platforms/mirserver/miral/persist_display_config.cpp (+151/-0)
src/platforms/mirserver/miral/persist_display_config.h (+52/-0)
src/platforms/mirserver/mirdisplayconfigurationpolicy.cpp (+4/-8)
src/platforms/mirserver/mirdisplayconfigurationpolicy.h (+6/-2)
src/platforms/mirserver/qmirserver_p.cpp (+4/-1)
To merge this branch: bzr merge lp:~mir-team/qtmir/iteration-0-of-miral-PersistDisplayConfig
Reviewer Review Type Date Requested Status
Nick Dedekind (community) Approve
Unity8 CI Bot (community) continuous-integration Approve
Review via email: mp+314137@code.launchpad.net

This proposal supersedes a proposal from 2016-11-24.

Commit message

Iteration 0 of miral::PersistDisplayConfig. This does nothing yet (and breaks nothing in the process). This MP creates a place (miral-prototypes) to build prototype miral features and sketches out what will need to be implemented for PersistDisplayConfig.

To post a comment you must log in.
Revision history for this message
Nick Dedekind (nick-dedekind) wrote : Posted in a previous version of this proposal

Looks fine for iter 0.

review: Approve
Revision history for this message
Nick Dedekind (nick-dedekind) wrote : Posted in a previous version of this proposal

We already have a policy in qmirserver

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> We already have a policy in qmirserver

Added a first pass at incorporating this.

Also plumbed in use of the DisplayConfigurationObserver::base_configuration_updated() coming in Mir-0.26.

RAOF has picked up supplying the EDID - with that we'll be in a position to follow up by tracking hardware changes and persisting the stuff we want.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote : Posted in a previous version of this proposal

Are we changing the namespace to miral::experimental to resolve the conflict?

review: Needs Information
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> Are we changing the namespace to miral::experimental to resolve the conflict?

We could just make it ::miral - we can co-ordinate with upstream well enough. (I'm OOTO today - will pick up in the morning.)

Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> > Are we changing the namespace to miral::experimental to resolve the
> conflict?
>
> We could just make it ::miral - we can co-ordinate with upstream well enough.
> (I'm OOTO today - will pick up in the morning.)

Actually, my flight's delayed so I've pushed the change

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:589
https://unity8-jenkins.ubuntu.com/job/lp-qtmir-ci/439/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3704
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3732
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3576
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3576/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3576
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3576/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3576
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3576/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3576
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3576/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3576
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3576/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3576
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3576/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtmir-ci/439/rebuild

review: Approve (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Still fine.

review: Approve
591. By Alan Griffiths

Fix for Mir-0.26 release

592. By Nick Dedekind

merged trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/mirserver/CMakeLists.txt'
2--- src/platforms/mirserver/CMakeLists.txt 2017-02-02 09:36:07 +0000
3+++ src/platforms/mirserver/CMakeLists.txt 2017-02-08 09:49:14 +0000
4@@ -2,6 +2,8 @@
5 # And also not anymore as pkgconfig module since Qt 5.6.
6 #pkg_check_modules(QT5PLATFORM_SUPPORT Qt5PlatformSupport REQUIRED)
7
8+add_subdirectory(miral)
9+
10 # Hacks for the QPA privates monster.
11 pkg_check_modules(FONTCONFIG fontconfig REQUIRED)
12 add_definitions(-DQ_FONTCONFIGDATABASE)
13@@ -104,6 +106,7 @@
14 offscreensurface.cpp
15 inputdeviceobserver.cpp
16 promptsessionmanager.cpp promptsessionmanager.h promptsession.h
17+ $<TARGET_OBJECTS:miral-prototypes>
18 # We need to run moc on these headers
19 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirMousePointerInterface.h
20 )
21
22=== added directory 'src/platforms/mirserver/miral'
23=== added file 'src/platforms/mirserver/miral/CMakeLists.txt'
24--- src/platforms/mirserver/miral/CMakeLists.txt 1970-01-01 00:00:00 +0000
25+++ src/platforms/mirserver/miral/CMakeLists.txt 2017-02-08 09:49:14 +0000
26@@ -0,0 +1,5 @@
27+include_directories(SYSTEM ${MIRSERVER_INCLUDE_DIRS})
28+
29+add_library(miral-prototypes OBJECT
30+ persist_display_config.cpp persist_display_config.h
31+)
32
33=== added file 'src/platforms/mirserver/miral/persist_display_config.cpp'
34--- src/platforms/mirserver/miral/persist_display_config.cpp 1970-01-01 00:00:00 +0000
35+++ src/platforms/mirserver/miral/persist_display_config.cpp 2017-02-08 09:49:14 +0000
36@@ -0,0 +1,151 @@
37+/*
38+ * Copyright © 2016 Canonical Ltd.
39+ *
40+ * This program is free software: you can redistribute it and/or modify it
41+ * under the terms of the GNU General Public License version 3,
42+ * as published by the Free Software Foundation.
43+ *
44+ * This program is distributed in the hope that it will be useful,
45+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
46+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47+ * GNU General Public License for more details.
48+ *
49+ * You should have received a copy of the GNU General Public License
50+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
51+ *
52+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
53+ */
54+
55+#include "persist_display_config.h"
56+
57+#include <mir/graphics/display_configuration_policy.h>
58+#include <mir/server.h>
59+#include <mir/version.h>
60+
61+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 26, 0)
62+#include <mir/graphics/display_configuration_observer.h>
63+#include <mir/observer_registrar.h>
64+#endif
65+
66+namespace mg = mir::graphics;
67+
68+namespace
69+{
70+struct PersistDisplayConfigPolicy
71+{
72+ PersistDisplayConfigPolicy() = default;
73+ virtual ~PersistDisplayConfigPolicy() = default;
74+ PersistDisplayConfigPolicy(PersistDisplayConfigPolicy const&) = delete;
75+ auto operator=(PersistDisplayConfigPolicy const&) -> PersistDisplayConfigPolicy& = delete;
76+
77+ void apply_to(mg::DisplayConfiguration& conf, mg::DisplayConfigurationPolicy& default_policy);
78+ void save_config(mg::DisplayConfiguration const& base_conf);
79+};
80+
81+struct DisplayConfigurationPolicyAdapter : mg::DisplayConfigurationPolicy
82+{
83+ DisplayConfigurationPolicyAdapter(
84+ std::shared_ptr<PersistDisplayConfigPolicy> const& self,
85+ std::shared_ptr<mg::DisplayConfigurationPolicy> const& wrapped) :
86+ self{self}, default_policy{wrapped}
87+ {}
88+
89+ void apply_to(mg::DisplayConfiguration& conf) override
90+ {
91+ self->apply_to(conf, *default_policy);
92+ }
93+
94+ std::shared_ptr<PersistDisplayConfigPolicy> const self;
95+ std::shared_ptr<mg::DisplayConfigurationPolicy> const default_policy;
96+};
97+
98+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 26, 0)
99+struct DisplayConfigurationObserver : mg::DisplayConfigurationObserver
100+{
101+ void initial_configuration(std::shared_ptr<mg::DisplayConfiguration const> const& /*config*/) override {}
102+
103+ void configuration_applied(std::shared_ptr<mg::DisplayConfiguration const> const& /*config*/) override {}
104+
105+ void configuration_failed(
106+ std::shared_ptr<mg::DisplayConfiguration const> const& /*attempted*/,
107+ std::exception const& /*error*/) override {}
108+
109+ void catastrophic_configuration_error(
110+ std::shared_ptr<mg::DisplayConfiguration const> const& /*failed_fallback*/,
111+ std::exception const& /*error*/) override {}
112+};
113+#else
114+struct DisplayConfigurationObserver { };
115+#endif
116+}
117+
118+struct miral::PersistDisplayConfig::Self : PersistDisplayConfigPolicy, DisplayConfigurationObserver
119+{
120+ Self() = default;
121+ Self(DisplayConfigurationPolicyWrapper const& custom_wrapper) :
122+ custom_wrapper{custom_wrapper} {}
123+
124+ DisplayConfigurationPolicyWrapper const custom_wrapper =
125+ [](const std::shared_ptr<mg::DisplayConfigurationPolicy> &wrapped) { return wrapped; };
126+
127+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 26, 0)
128+ void base_configuration_updated(std::shared_ptr<mg::DisplayConfiguration const> const& base_config) override
129+ {
130+ save_config(*base_config);
131+ }
132+
133+ void session_configuration_applied(std::shared_ptr<mir::frontend::Session> const&,
134+ std::shared_ptr<mg::DisplayConfiguration> const&){}
135+ void session_configuration_removed(std::shared_ptr<mir::frontend::Session> const&) {}
136+#endif
137+};
138+
139+miral::PersistDisplayConfig::PersistDisplayConfig() :
140+ self{std::make_shared<Self>()}
141+{
142+}
143+
144+miral::PersistDisplayConfig::PersistDisplayConfig(DisplayConfigurationPolicyWrapper const& custom_wrapper) :
145+ self{std::make_shared<Self>(custom_wrapper)}
146+{
147+}
148+
149+miral::PersistDisplayConfig::~PersistDisplayConfig() = default;
150+
151+miral::PersistDisplayConfig::PersistDisplayConfig(PersistDisplayConfig const&) = default;
152+
153+auto miral::PersistDisplayConfig::operator=(PersistDisplayConfig const&) -> PersistDisplayConfig& = default;
154+
155+void miral::PersistDisplayConfig::operator()(mir::Server& server)
156+{
157+ server.wrap_display_configuration_policy(
158+ [this](std::shared_ptr<mg::DisplayConfigurationPolicy> const& wrapped)
159+ -> std::shared_ptr<mg::DisplayConfigurationPolicy>
160+ {
161+ return std::make_shared<DisplayConfigurationPolicyAdapter>(self, self->custom_wrapper(wrapped));
162+ });
163+
164+#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 26, 0)
165+ server.add_init_callback([this, &server]
166+ { server.the_display_configuration_observer_registrar()->register_interest(self); });
167+#else
168+ // Up to Mir-0.25 detecting changes to the base display config is only possible client-side
169+ // (and gives a different configuration API)
170+ // If we decide implementing this is necessary for earlier Mir versions then this is where to plumb it in.
171+ (void)&PersistDisplayConfigPolicy::save_config; // Fake "using" the function for now
172+#endif
173+}
174+
175+void PersistDisplayConfigPolicy::apply_to(
176+ mg::DisplayConfiguration& conf,
177+ mg::DisplayConfigurationPolicy& default_policy)
178+{
179+ // TODO if the h/w profile (by some definition) has changed, then apply corresponding saved config (if any).
180+ // TODO Otherwise...
181+ default_policy.apply_to(conf);
182+}
183+
184+void PersistDisplayConfigPolicy::save_config(mg::DisplayConfiguration const& /*base_conf*/)
185+{
186+ // TODO save display config options against the h/w profile
187+}
188
189=== added file 'src/platforms/mirserver/miral/persist_display_config.h'
190--- src/platforms/mirserver/miral/persist_display_config.h 1970-01-01 00:00:00 +0000
191+++ src/platforms/mirserver/miral/persist_display_config.h 2017-02-08 09:49:14 +0000
192@@ -0,0 +1,52 @@
193+/*
194+ * Copyright © 2016 Canonical Ltd.
195+ *
196+ * This program is free software: you can redistribute it and/or modify it
197+ * under the terms of the GNU General Public License version 3,
198+ * as published by the Free Software Foundation.
199+ *
200+ * This program is distributed in the hope that it will be useful,
201+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
202+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
203+ * GNU General Public License for more details.
204+ *
205+ * You should have received a copy of the GNU General Public License
206+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
207+ *
208+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
209+ */
210+
211+#ifndef MIRAL_PERSIST_DISPLAY_CONFIG_H
212+#define MIRAL_PERSIST_DISPLAY_CONFIG_H
213+
214+#include <functional>
215+#include <memory>
216+
217+namespace mir { class Server; namespace graphics { class DisplayConfigurationPolicy; }}
218+
219+// Prototyping namespace for later incorporation in MirAL
220+namespace miral
221+{
222+/// Restores the saved display configuration and saves changes to the base configuration
223+class PersistDisplayConfig
224+{
225+public:
226+ PersistDisplayConfig();
227+ ~PersistDisplayConfig();
228+ PersistDisplayConfig(PersistDisplayConfig const&);
229+ auto operator=(PersistDisplayConfig const&) -> PersistDisplayConfig&;
230+
231+ // TODO factor this out better
232+ using DisplayConfigurationPolicyWrapper =
233+ std::function<std::shared_ptr<mir::graphics::DisplayConfigurationPolicy>(const std::shared_ptr<mir::graphics::DisplayConfigurationPolicy> &wrapped)>;
234+ PersistDisplayConfig(DisplayConfigurationPolicyWrapper const& custom_wrapper);
235+
236+ void operator()(mir::Server& server);
237+
238+private:
239+ struct Self;
240+ std::shared_ptr<Self> self;
241+};
242+}
243+
244+#endif //MIRAL_PERSIST_DISPLAY_CONFIG_H
245
246=== modified file 'src/platforms/mirserver/mirdisplayconfigurationpolicy.cpp'
247--- src/platforms/mirserver/mirdisplayconfigurationpolicy.cpp 2016-11-03 20:17:46 +0000
248+++ src/platforms/mirserver/mirdisplayconfigurationpolicy.cpp 2017-02-08 09:49:14 +0000
249@@ -112,15 +112,11 @@
250 }
251 });
252 }
253+
254 } //namespace
255
256-void qtmir::setDisplayConfigurationPolicy(mir::Server& server)
257+auto qtmir::wrapDisplayConfigurationPolicy(const std::shared_ptr<mg::DisplayConfigurationPolicy>& wrapped)
258+-> std::shared_ptr<mg::DisplayConfigurationPolicy>
259 {
260- server.wrap_display_configuration_policy(
261- [](const std::shared_ptr<mg::DisplayConfigurationPolicy> &wrapped)
262- -> std::shared_ptr<mg::DisplayConfigurationPolicy>
263- {
264- return std::make_shared<MirDisplayConfigurationPolicy>(wrapped);
265- });
266-
267+ return std::make_shared<MirDisplayConfigurationPolicy>(wrapped);
268 }
269
270=== modified file 'src/platforms/mirserver/mirdisplayconfigurationpolicy.h'
271--- src/platforms/mirserver/mirdisplayconfigurationpolicy.h 2016-11-03 20:17:46 +0000
272+++ src/platforms/mirserver/mirdisplayconfigurationpolicy.h 2017-02-08 09:49:14 +0000
273@@ -17,11 +17,15 @@
274 #ifndef MIRDISPLAYCONFIGURATIONPOLICY_H
275 #define MIRDISPLAYCONFIGURATIONPOLICY_H
276
277-namespace mir { class Server; }
278+#include <memory>
279+
280+namespace mir { namespace graphics { class DisplayConfigurationPolicy; }}
281
282 namespace qtmir
283 {
284-void setDisplayConfigurationPolicy(mir::Server& server);
285+
286+auto wrapDisplayConfigurationPolicy(const std::shared_ptr<mir::graphics::DisplayConfigurationPolicy> &wrapped)
287+-> std::shared_ptr<mir::graphics::DisplayConfigurationPolicy>;
288 }
289
290
291
292=== modified file 'src/platforms/mirserver/qmirserver_p.cpp'
293--- src/platforms/mirserver/qmirserver_p.cpp 2017-01-03 20:59:50 +0000
294+++ src/platforms/mirserver/qmirserver_p.cpp 2017-02-08 09:49:14 +0000
295@@ -24,6 +24,9 @@
296 #include "promptsessionmanager.h"
297 #include "setqtcompositor.h"
298
299+// prototyping for later incorporation in miral
300+#include <miral/persist_display_config.h>
301+
302 // miral
303 #include <miral/add_init_callback.h>
304 #include <miral/set_command_line_hander.h>
305@@ -135,11 +138,11 @@
306 m_mirServerHooks,
307 miral::set_window_managment_policy<WindowManagementPolicy>(m_windowModelNotifier, m_windowController,
308 m_appNotifier, screensModel),
309- qtmir::setDisplayConfigurationPolicy,
310 setCommandLineHandler,
311 addInitCallback,
312 qtmir::SetQtCompositor{screensModel},
313 setTerminator,
314+ miral::PersistDisplayConfig{&qtmir::wrapDisplayConfigurationPolicy}
315 });
316 }
317

Subscribers

People subscribed via source and target branches