Merge lp:~alan-griffiths/miral/set_window_managment-policy into lp:miral

Proposed by Alan Griffiths on 2016-06-06
Status: Merged
Approved by: Gerry Boland on 2016-06-06
Approved revision: 189
Merged at revision: 188
Proposed branch: lp:~alan-griffiths/miral/set_window_managment-policy
Merge into: lp:miral
Diff against target: 139 lines (+99/-2)
4 files modified
include/miral/set_window_managment_policy.h (+54/-0)
miral-kiosk/kiosk_main.cpp (+2/-2)
miral/CMakeLists.txt (+1/-0)
miral/set_window_managment_policy.cpp (+42/-0)
To merge this branch: bzr merge lp:~alan-griffiths/miral/set_window_managment-policy
Reviewer Review Type Date Requested Status
Gerry Boland 2016-06-06 Approve on 2016-06-06
Review via email: mp+296591@code.launchpad.net

Commit Message

miral::set_window_managment-policy<>() utility

To post a comment you must log in.
Gerry Boland (gerboland) wrote :

Looks ok to me, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'include/miral/set_window_managment_policy.h'
2--- include/miral/set_window_managment_policy.h 1970-01-01 00:00:00 +0000
3+++ include/miral/set_window_managment_policy.h 2016-06-06 18:45:35 +0000
4@@ -0,0 +1,54 @@
5+/*
6+ * Copyright © 2016 Canonical Ltd.
7+ *
8+ * This program is free software: you can redistribute it and/or modify it
9+ * under the terms of the GNU General Public License version 3,
10+ * as published by the Free Software Foundation.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ *
20+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
21+ */
22+
23+#ifndef MIRAL_SET_WINDOW_MANAGER_H
24+#define MIRAL_SET_WINDOW_MANAGER_H
25+
26+#include <memory>
27+
28+namespace mir
29+{
30+class Server;
31+}
32+
33+namespace miral
34+{
35+class WindowManagerTools;
36+class WindowManagementPolicy;
37+
38+class SetWindowManagmentPolicy
39+{
40+public:
41+ SetWindowManagmentPolicy(std::function<std::unique_ptr<WindowManagementPolicy>(WindowManagerTools* tools)> const& builder);
42+ ~SetWindowManagmentPolicy();
43+
44+ void operator()(mir::Server& server) const;
45+
46+private:
47+ std::function<std::unique_ptr<WindowManagementPolicy>(WindowManagerTools* tools)> builder;
48+};
49+
50+template<typename Policy, typename ...Args>
51+auto set_window_managment_policy(Args& ... args) -> SetWindowManagmentPolicy
52+{
53+ return SetWindowManagmentPolicy{[&args...](WindowManagerTools* tools) -> std::unique_ptr<WindowManagementPolicy>
54+ { return std::make_unique<Policy>(tools, args...); }};
55+}
56+}
57+
58+#endif //MIRAL_SET_WINDOW_MANAGER_H
59
60=== modified file 'miral-kiosk/kiosk_main.cpp'
61--- miral-kiosk/kiosk_main.cpp 2016-04-15 16:43:27 +0000
62+++ miral-kiosk/kiosk_main.cpp 2016-06-06 18:45:35 +0000
63@@ -19,7 +19,7 @@
64 #include "kiosk_window_manager.h"
65
66 #include "miral/runner.h"
67-#include "miral/window_management_options.h"
68+#include "miral/set_window_managment_policy.h"
69 #include "miral/startup_internal_client.h"
70
71 int main(int argc, char const* argv[])
72@@ -30,7 +30,7 @@
73
74 return MirRunner{argc, argv}.run_with(
75 {
76- WindowManagerOptions{add_window_manager_policy<KioskWindowManagerPolicy>("kiosk", splash)},
77+ set_window_managment_policy<KioskWindowManagerPolicy>(splash),
78 StartupInternalClient{"Intro", splash}
79 });
80 }
81
82=== modified file 'miral/CMakeLists.txt'
83--- miral/CMakeLists.txt 2016-06-03 14:41:55 +0000
84+++ miral/CMakeLists.txt 2016-06-06 18:45:35 +0000
85@@ -15,6 +15,7 @@
86 window_specification.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_specification.h
87 startup_internal_client.cpp ${CMAKE_SOURCE_DIR}/include/miral/startup_internal_client.h
88 mru_window_list.cpp ${CMAKE_SOURCE_DIR}/include/miral/mru_window_list.h
89+ set_window_managment_policy.cpp ${CMAKE_SOURCE_DIR}/include/miral/set_window_managment_policy.h
90 basic_window_manager.cpp basic_window_manager.h
91 ${CMAKE_SOURCE_DIR}/include/miral/window_management_policy.h
92 ${CMAKE_SOURCE_DIR}/include/miral/window_manager_tools.h
93
94=== added file 'miral/set_window_managment_policy.cpp'
95--- miral/set_window_managment_policy.cpp 1970-01-01 00:00:00 +0000
96+++ miral/set_window_managment_policy.cpp 2016-06-06 18:45:35 +0000
97@@ -0,0 +1,42 @@
98+/*
99+ * Copyright © 2016 Canonical Ltd.
100+ *
101+ * This program is free software: you can redistribute it and/or modify it
102+ * under the terms of the GNU General Public License version 3,
103+ * as published by the Free Software Foundation.
104+ *
105+ * This program is distributed in the hope that it will be useful,
106+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
107+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108+ * GNU General Public License for more details.
109+ *
110+ * You should have received a copy of the GNU General Public License
111+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
112+ *
113+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
114+ */
115+
116+#include "miral/set_window_managment_policy.h"
117+#include "basic_window_manager.h"
118+
119+#include <mir/server.h>
120+
121+namespace msh = mir::shell;
122+
123+miral::SetWindowManagmentPolicy::SetWindowManagmentPolicy(WindowManagementPolicyBuilder const& builder) :
124+ builder{builder}
125+{
126+}
127+
128+miral::SetWindowManagmentPolicy::~SetWindowManagmentPolicy() = default;
129+
130+void miral::SetWindowManagmentPolicy::operator()(mir::Server& server) const
131+{
132+ server.override_the_window_manager_builder([this, &server](msh::FocusController* focus_controller)
133+ -> std::shared_ptr<msh::WindowManager>
134+ {
135+ auto const display_layout = server.the_shell_display_layout();
136+
137+ return std::make_shared<BasicWindowManager>(focus_controller, display_layout, builder);
138+ });
139+}

Subscribers

People subscribed via source and target branches