Mir

Merge lp:~alan-griffiths/mir/make-window-management-configurable into lp:mir

Proposed by Alan Griffiths on 2015-03-20
Status: Merged
Approved by: Alan Griffiths on 2015-03-26
Approved revision: 2416
Merged at revision: 2429
Proposed branch: lp:~alan-griffiths/mir/make-window-management-configurable
Merge into: lp:mir
Diff against target: 322 lines (+92/-66)
9 files modified
examples/server_example_window_management.cpp (+8/-37)
include/server/mir/server.h (+4/-0)
include/server/mir/shell/abstract_shell.h (+2/-1)
include/server/mir/shell/window_manager_builder.h (+37/-0)
src/include/server/mir/default_server_configuration.h (+2/-0)
src/server/server.cpp (+14/-0)
src/server/shell/default_configuration.cpp (+21/-18)
src/server/symbols.map (+2/-0)
tests/acceptance-tests/test_custom_window_management.cpp (+2/-10)
To merge this branch: bzr merge lp:~alan-griffiths/mir/make-window-management-configurable
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-03-26
Andreas Pokorny (community) Approve on 2015-03-25
Daniel van Vugt Abstain on 2015-03-25
Alexandros Frantzis (community) 2015-03-20 Approve on 2015-03-24
Review via email: mp+253725@code.launchpad.net

Commit Message

shell: Provide a configuration point for the WindowManagement strategy

Description of the Change

shell: Provide a configuration point for the WindowManagement strategy

To post a comment you must log in.
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve
Daniel van Vugt (vanvugt) wrote :

"WindowManager" ideally should not be a class if we're doing a good job. Because window management is just one of many behaviours of a Shell.

But I don't think this proposal makes the situation any worse.

review: Abstain
Andreas Pokorny (andreas-pokorny) wrote :

looks good.

review: Approve
Alan Griffiths (alan-griffiths) wrote :

I'm pretty sure that neither failure is introduced by this MP...

> Build timed out (after 60 minutes). Marking the build as failed.
> Build was aborted

https://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-mako/4741/console
(mako-05)

> 27 - mir_acceptance_tests.NestedServer.* (SEGFAULT)

https://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/1831/console

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/server_example_window_management.cpp'
2--- examples/server_example_window_management.cpp 2015-03-24 16:02:48 +0000
3+++ examples/server_example_window_management.cpp 2015-03-24 17:20:59 +0000
4@@ -115,56 +115,27 @@
5
6 void me::add_window_manager_option_to(Server& server)
7 {
8- server.add_configuration_option(wm_option, wm_description, mir::OptionType::string);
9+ server.add_configuration_option(wm_option, wm_description, wm_canonical);
10
11- server.override_the_shell([&server]()
12- -> std::shared_ptr<msh::Shell>
13+ server.override_the_window_manager_builder([&server](msh::FocusController* focus_controller)
14+ -> std::shared_ptr<msh::WindowManager>
15 {
16 auto const options = server.get_options();
17-
18- if (!options->is_set(wm_option))
19- return std::shared_ptr<msh::Shell>{};
20-
21 auto const selection = options->get<std::string>(wm_option);
22
23- std::function<std::shared_ptr<msh::WindowManager>(msh::FocusController* focus_controller)> wm_builder;
24-
25 if (selection == wm_tiling)
26 {
27- wm_builder = [&server](msh::FocusController* focus_controller) -> std::shared_ptr<msh::WindowManager>
28- {
29- return std::make_shared<TilingWindowManager>(focus_controller);
30- };
31+ return std::make_shared<TilingWindowManager>(focus_controller);
32 }
33 else if (selection == wm_fullscreen)
34 {
35- wm_builder = [&server](msh::FocusController* focus_controller) -> std::shared_ptr<msh::WindowManager>
36- {
37- return std::make_shared<FullscreenWindowManager>(focus_controller, server.the_shell_display_layout());
38- };
39+ return std::make_shared<FullscreenWindowManager>(focus_controller, server.the_shell_display_layout());
40 }
41 else if (selection == wm_canonical)
42 {
43- wm_builder = [&server](msh::FocusController* focus_controller) -> std::shared_ptr<msh::WindowManager>
44- {
45- return std::make_shared<CanonicalWindowManager>(
46- focus_controller,
47- server.the_shell_display_layout());
48- };
49+ return std::make_shared<CanonicalWindowManager>(focus_controller, server.the_shell_display_layout());
50 }
51- else
52- throw mir::AbnormalExit("Unknown window manager: " + selection);
53-
54-
55- auto tmp = std::make_shared<msh::AbstractShell>(
56- server.the_input_targeter(),
57- server.the_surface_coordinator(),
58- server.the_session_coordinator(),
59- server.the_prompt_session_manager(),
60- wm_builder);
61-
62- server.the_composite_event_filter()->prepend(tmp);
63-
64- return tmp;
65+
66+ throw mir::AbnormalExit("Unknown window manager: " + selection);
67 });
68 }
69
70=== modified file 'include/server/mir/server.h'
71--- include/server/mir/server.h 2015-03-24 16:02:48 +0000
72+++ include/server/mir/server.h 2015-03-24 17:20:59 +0000
73@@ -19,6 +19,7 @@
74 #ifndef MIR_SERVER_H_
75 #define MIR_SERVER_H_
76
77+#include "mir/shell/window_manager_builder.h"
78 #include "mir_toolkit/common.h"
79
80 #include <functional>
81@@ -254,6 +255,9 @@
82 /// Sets an override functor for creating the surface configurator.
83 void override_the_surface_configurator(Builder<scene::SurfaceConfigurator> const& surface_configurator_builder);
84
85+ /// Sets an override functor for creating the window manager.
86+ void override_the_window_manager_builder(shell::WindowManagerBuilder const wmb);
87+
88 /// Each of the wrap functions takes a wrapper functor of the same form
89 template<typename T> using Wrapper = std::function<std::shared_ptr<T>(std::shared_ptr<T> const&)>;
90
91
92=== modified file 'include/server/mir/shell/abstract_shell.h'
93--- include/server/mir/shell/abstract_shell.h 2015-03-24 16:02:48 +0000
94+++ include/server/mir/shell/abstract_shell.h 2015-03-24 17:20:59 +0000
95@@ -20,6 +20,7 @@
96 #define MIR_SHELL_ABSTRACT_SHELL_H_
97
98 #include "mir/shell/shell.h"
99+#include "mir/shell/window_manager_builder.h"
100
101 #include <mutex>
102
103@@ -38,7 +39,7 @@
104 std::shared_ptr<scene::SurfaceCoordinator> const& surface_coordinator,
105 std::shared_ptr<scene::SessionCoordinator> const& session_coordinator,
106 std::shared_ptr<scene::PromptSessionManager> const& prompt_session_manager,
107- std::function<std::shared_ptr<WindowManager>(FocusController* focus_controller)> const& wm_builder);
108+ WindowManagerBuilder const& wm_builder);
109
110 ~AbstractShell() noexcept;
111
112
113=== added file 'include/server/mir/shell/window_manager_builder.h'
114--- include/server/mir/shell/window_manager_builder.h 1970-01-01 00:00:00 +0000
115+++ include/server/mir/shell/window_manager_builder.h 2015-03-24 17:20:59 +0000
116@@ -0,0 +1,37 @@
117+/*
118+ * Copyright © 2015 Canonical Ltd.
119+ *
120+ * This program is free software: you can redistribute it and/or modify it
121+ * under the terms of the GNU General Public License version 3,
122+ * as published by the Free Software Foundation.
123+ *
124+ * This program is distributed in the hope that it will be useful,
125+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
126+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
127+ * GNU General Public License for more details.
128+ *
129+ * You should have received a copy of the GNU General Public License
130+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
131+ *
132+ * Authored By: Alan Griffiths <alan@octopull.co.uk>
133+ */
134+
135+#ifndef INCLUDE_SERVER_MIR_SHELL_WINDOW_MANAGER_BUILDER_H_
136+#define INCLUDE_SERVER_MIR_SHELL_WINDOW_MANAGER_BUILDER_H_
137+
138+#include <functional>
139+#include <memory>
140+
141+namespace mir
142+{
143+namespace shell
144+{
145+class WindowManager;
146+class FocusController;
147+
148+/// WindowManagers are built while initializing an AbstractShell, so a builder functor is needed
149+using WindowManagerBuilder =
150+ std::function<std::shared_ptr<WindowManager>(FocusController* focus_controller)>;
151+}
152+}
153+#endif /* INCLUDE_SERVER_MIR_SHELL_WINDOW_MANAGER_BUILDER_H_ */
154
155=== modified file 'src/include/server/mir/default_server_configuration.h'
156--- src/include/server/mir/default_server_configuration.h 2015-03-24 16:02:48 +0000
157+++ src/include/server/mir/default_server_configuration.h 2015-03-24 17:20:59 +0000
158@@ -20,6 +20,7 @@
159
160 #include "mir/cached_ptr.h"
161 #include "mir/server_configuration.h"
162+#include "mir/shell/window_manager_builder.h"
163
164 #include <memory>
165 #include <string>
166@@ -251,6 +252,7 @@
167 * configurable interfaces for modifying shell
168 * @{ */
169 virtual auto the_shell() -> std::shared_ptr<shell::Shell>;
170+ virtual auto the_window_manager_builder() -> shell::WindowManagerBuilder;
171 virtual std::shared_ptr<scene::PlacementStrategy> the_placement_strategy();
172 virtual std::shared_ptr<scene::SessionListener> the_session_listener();
173 virtual std::shared_ptr<shell::DisplayLayout> the_shell_display_layout();
174
175=== modified file 'src/server/server.cpp'
176--- src/server/server.cpp 2015-03-24 16:02:48 +0000
177+++ src/server/server.cpp 2015-03-24 17:20:59 +0000
178@@ -119,6 +119,8 @@
179
180 FOREACH_OVERRIDE(MIR_SERVER_BUILDER)
181
182+ shell::WindowManagerBuilder wmb;
183+
184 FOREACH_WRAPPER(MIR_SERVER_WRAPPER)
185 };
186
187@@ -209,6 +211,12 @@
188
189 FOREACH_WRAPPER(MIR_SERVER_CONFIG_WRAP)
190
191+ auto the_window_manager_builder() -> shell::WindowManagerBuilder override
192+ {
193+ if (self->wmb) return self->wmb;
194+ return mir::DefaultServerConfiguration::the_window_manager_builder();
195+ }
196+
197 Self* const self;
198 };
199
200@@ -450,6 +458,12 @@
201
202 #undef MIR_SERVER_OVERRIDE
203
204+void mir::Server::override_the_window_manager_builder(shell::WindowManagerBuilder const wmb)
205+{
206+ verify_setting_allowed(self->server_config);
207+ self->wmb = wmb;
208+}
209+
210 #define MIR_SERVER_WRAP(name)\
211 void mir::Server::wrap_##name(decltype(Self::name##_wrapper) const& value)\
212 {\
213
214=== modified file 'src/server/shell/default_configuration.cpp'
215--- src/server/shell/default_configuration.cpp 2015-03-24 16:02:48 +0000
216+++ src/server/shell/default_configuration.cpp 2015-03-24 17:20:59 +0000
217@@ -22,6 +22,7 @@
218
219 #include "default_placement_strategy.h"
220 #include "default_window_manager.h"
221+#include "mir/input/composite_event_filter.h"
222 #include "mir/shell/abstract_shell.h"
223 #include "frontend_shell.h"
224 #include "graphics_display_layout.h"
225@@ -35,27 +36,29 @@
226 {
227 return shell([this]
228 {
229- auto const input_targeter = the_input_targeter();
230- auto const surface_coordinator = the_surface_coordinator();
231- auto const session_coordinator = the_session_coordinator();
232- auto const prompt_session_manager = the_prompt_session_manager();
233-
234- auto const builder = [&](msh::FocusController* focus_controller)
235- { return std::make_shared<msh::DefaultWindowManager>(
236- focus_controller,
237- the_placement_strategy(),
238- session_coordinator,
239- the_surface_configurator()); };
240-
241- return wrap_shell(std::make_shared<msh::AbstractShell>(
242- input_targeter,
243- surface_coordinator,
244- session_coordinator,
245- prompt_session_manager,
246- builder));
247+ auto const result = wrap_shell(std::make_shared<msh::AbstractShell>(
248+ the_input_targeter(),
249+ the_surface_coordinator(),
250+ the_session_coordinator(),
251+ the_prompt_session_manager(),
252+ the_window_manager_builder()));
253+
254+ the_composite_event_filter()->prepend(result);
255+
256+ return result;
257 });
258 }
259
260+auto mir::DefaultServerConfiguration::the_window_manager_builder() -> shell::WindowManagerBuilder
261+{
262+ return [this](msh::FocusController* focus_controller)
263+ { return std::make_shared<msh::DefaultWindowManager>(
264+ focus_controller,
265+ the_placement_strategy(),
266+ the_session_coordinator(),
267+ the_surface_configurator()); };
268+}
269+
270 auto mir::DefaultServerConfiguration::wrap_shell(std::shared_ptr<msh::Shell> const& wrapped) -> std::shared_ptr<msh::Shell>
271 {
272 return wrapped;
273
274=== modified file 'src/server/symbols.map'
275--- src/server/symbols.map 2015-03-24 16:02:48 +0000
276+++ src/server/symbols.map 2015-03-24 17:20:59 +0000
277@@ -152,6 +152,7 @@
278 mir::Server::override_the_session_mediator_report*;
279 mir::Server::override_the_shell*;
280 mir::Server::override_the_surface_configurator*;
281+ mir::Server::override_the_window_manager_builder*;
282 mir::Server::run*;
283 mir::Server::Server*;
284 mir::Server::set_command_line*;
285@@ -597,6 +598,7 @@
286 mir::DefaultServerConfiguration::the_surface_factory*;
287 mir::DefaultServerConfiguration::the_surface_stack_model*;
288 mir::DefaultServerConfiguration::the_touch_visualizer*;
289+ mir::DefaultServerConfiguration::the_window_manager_builder*;
290 mir::DefaultServerConfiguration::wrap_cursor_listener*;
291 mir::DefaultServerConfiguration::wrap_display_buffer_compositor_factory*;
292 mir::DefaultServerConfiguration::wrap_display_configuration_policy*;
293
294=== modified file 'tests/acceptance-tests/test_custom_window_management.cpp'
295--- tests/acceptance-tests/test_custom_window_management.cpp 2015-03-24 16:02:48 +0000
296+++ tests/acceptance-tests/test_custom_window_management.cpp 2015-03-24 17:20:59 +0000
297@@ -16,7 +16,6 @@
298 * Authored by: Alan Griffiths <alan@octopull.co.uk>
299 */
300
301-#include "mir/shell/abstract_shell.h"
302 #include "mir/geometry/rectangle.h"
303 #include "mir/scene/session.h"
304
305@@ -105,15 +104,8 @@
306
307 initial_display_layout(display_geometry);
308
309- server.override_the_shell([this]
310- {
311- return std::make_shared<msh::AbstractShell>(
312- server.the_input_targeter(),
313- server.the_surface_coordinator(),
314- server.the_session_coordinator(),
315- server.the_prompt_session_manager(),
316- [this](msh::FocusController*) { return mt::fake_shared(window_manager); });
317- });
318+ server.override_the_window_manager_builder([this]
319+ (msh::FocusController*) { return mt::fake_shared(window_manager); });
320 }
321
322 void TearDown() override

Subscribers

People subscribed via source and target branches