Merge lp:~alan-griffiths/unity-system-compositor/constructors-and-destructors-for-initialization-and-finalization into lp:unity-system-compositor

Proposed by Alan Griffiths
Status: Work in progress
Proposed branch: lp:~alan-griffiths/unity-system-compositor/constructors-and-destructors-for-initialization-and-finalization
Merge into: lp:unity-system-compositor
Prerequisite: lp:~alan-griffiths/unity-system-compositor/dont-use-SessionContainer
Diff against target: 261 lines (+66/-67)
5 files modified
src/dbus_screen.cpp (+3/-3)
src/dbus_screen.h (+3/-2)
src/main.cpp (+4/-3)
src/system_compositor.cpp (+42/-54)
src/system_compositor.h (+14/-5)
To merge this branch: bzr merge lp:~alan-griffiths/unity-system-compositor/constructors-and-destructors-for-initialization-and-finalization
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity System Compositor Development Team Pending
Review via email: mp+195269@code.launchpad.net

Commit message

Use a SystemCompositor constructor for initializing the system compositor and a destructor for finalizing it.

Description of the change

Use a SystemCompositor constructor for initializing the system compositor and a destructor for finalizing it.

NB the prerequisite needs Mir v0.1.1

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
101. By Alan Griffiths

merge -c 96 lp:unity-system-compositor

102. By Alan Griffiths

merge -c 97 lp:unity-system-compositor

103. By Alan Griffiths

merge -c 98 lp:unity-system-compositor

104. By Alan Griffiths

merge -c 99 lp:unity-system-compositor

105. By Alan Griffiths

merge -c 100 lp:unity-system-compositor

106. By Alan Griffiths

merge -c 101 lp:unity-system-compositor

107. By Alan Griffiths

merge -c 102 lp:unity-system-compositor

108. By Alan Griffiths

merge -c 103 lp:unity-system-compositor

109. By Alan Griffiths

merge -c 104 lp:unity-system-compositor

110. By Alan Griffiths

merge -c 105 lp:unity-system-compositor

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Too many conflicts with current code

Unmerged revisions

110. By Alan Griffiths

merge -c 105 lp:unity-system-compositor

109. By Alan Griffiths

merge -c 104 lp:unity-system-compositor

108. By Alan Griffiths

merge -c 103 lp:unity-system-compositor

107. By Alan Griffiths

merge -c 102 lp:unity-system-compositor

106. By Alan Griffiths

merge -c 101 lp:unity-system-compositor

105. By Alan Griffiths

merge -c 100 lp:unity-system-compositor

104. By Alan Griffiths

merge -c 99 lp:unity-system-compositor

103. By Alan Griffiths

merge -c 98 lp:unity-system-compositor

102. By Alan Griffiths

merge -c 97 lp:unity-system-compositor

101. By Alan Griffiths

merge -c 96 lp:unity-system-compositor

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dbus_screen.cpp'
2--- src/dbus_screen.cpp 2013-10-31 19:16:23 +0000
3+++ src/dbus_screen.cpp 2013-11-26 12:17:27 +0000
4@@ -27,9 +27,10 @@
5 namespace mg = mir::graphics;
6
7 // Note: this class should be created only after when the Mir DisplayServer has started
8-DBusScreen::DBusScreen(std::shared_ptr<mir::DefaultServerConfiguration> config, QObject *parent)
9+DBusScreen::DBusScreen(mir::DefaultServerConfiguration& config, QObject *parent)
10 : QObject(parent)
11- , config(config)
12+ , display(config.the_display())
13+
14 {
15 new DBusScreenAdaptor(this);
16 QDBusConnection bus = QDBusConnection::systemBus();
17@@ -55,7 +56,6 @@
18 return false;
19 }
20
21- std::shared_ptr<mg::Display> display = config->the_display();
22 std::shared_ptr<mg::DisplayConfiguration> displayConfig = display->configuration();
23
24 displayConfig->for_each_output([&](const mg::DisplayConfigurationOutput displayConfigOutput) {
25
26=== modified file 'src/dbus_screen.h'
27--- src/dbus_screen.h 2013-10-31 19:16:23 +0000
28+++ src/dbus_screen.h 2013-11-26 12:17:27 +0000
29@@ -23,6 +23,7 @@
30 namespace mir
31 {
32 class DefaultServerConfiguration;
33+namespace graphics { class Display; }
34 }
35
36 class DBusScreen : public QObject
37@@ -31,13 +32,13 @@
38 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Screen")
39
40 public:
41- explicit DBusScreen(std::shared_ptr<mir::DefaultServerConfiguration> config, QObject *parent = 0);
42+ explicit DBusScreen(mir::DefaultServerConfiguration& config, QObject *parent = 0);
43
44 public Q_SLOTS:
45 bool setScreenPowerMode(const QString &mode);
46
47 private:
48- std::shared_ptr<mir::DefaultServerConfiguration> config;
49+ std::shared_ptr<mir::graphics::Display> const display;
50 };
51
52 #endif /* DBUS_SCREEN_H_ */
53
54=== modified file 'src/main.cpp'
55--- src/main.cpp 2013-10-31 22:00:19 +0000
56+++ src/main.cpp 2013-11-26 12:17:27 +0000
57@@ -20,11 +20,12 @@
58 #include <mir/report_exception.h>
59 #include <iostream>
60
61-int main(int argc, char *argv[])
62+int main(int argc, char const* argv[])
63 try
64 {
65- SystemCompositor system_compositor;
66- system_compositor.run(argc, argv);
67+ SystemCompositor system_compositor(argc, argv);
68+
69+ system_compositor.run();
70
71 return 0;
72 }
73
74=== modified file 'src/system_compositor.cpp'
75--- src/system_compositor.cpp 2013-11-22 16:53:52 +0000
76+++ src/system_compositor.cpp 2013-11-26 12:17:27 +0000
77@@ -87,8 +87,8 @@
78 class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration
79 {
80 public:
81- SystemCompositorServerConfiguration(SystemCompositor *compositor, int argc, char **argv)
82- : mir::DefaultServerConfiguration(argc, (char const **)argv), compositor{compositor}
83+ SystemCompositorServerConfiguration(SystemCompositor *compositor, int argc, char const** argv)
84+ : mir::DefaultServerConfiguration(argc, argv), compositor{compositor}
85 {
86 add_options()
87 ("from-dm-fd", po::value<int>(), "File descriptor of read end of pipe from display manager [int]")
88@@ -108,11 +108,6 @@
89 return the_options()->get("to-dm-fd", -1);
90 }
91
92- bool show_version()
93- {
94- return the_options()->is_set ("version");
95- }
96-
97 std::string blacklist()
98 {
99 auto x = the_options()->get ("blacklist", "");
100@@ -130,6 +125,11 @@
101 setenv("MIR_SERVER_STANDALONE", "true", 0); // Default to standalone
102 mir::DefaultServerConfiguration::parse_options(options_description, options);
103 options.parse_file(options_description, "unity-system-compositor.conf");
104+
105+ if (options.is_set("version"))
106+ {
107+ throw mir::AbnormalExit (std::string("unity-system-compositor ") + USC_VERSION);
108+ }
109 }
110
111 std::shared_ptr<mi::CursorListener> the_cursor_listener() override
112@@ -227,50 +227,37 @@
113 return true;
114 }
115
116-void SystemCompositor::run(int argc, char **argv)
117-{
118- config = std::make_shared<SystemCompositorServerConfiguration>(this, argc, argv);
119-
120- if (config->show_version())
121- {
122- std::cerr << "unity-system-compositor " << USC_VERSION << std::endl;
123- return;
124- }
125-
126- dm_connection = std::make_shared<DMConnection>(io_service, config->from_dm_fd(), config->to_dm_fd());
127-
128- struct ScopeGuard
129- {
130- explicit ScopeGuard(boost::asio::io_service& io_service) : io_service(io_service) {}
131- ~ScopeGuard()
132- {
133- io_service.stop();
134- if (io_thread.joinable())
135- io_thread.join();
136- if (qt_thread.joinable())
137- qt_thread.join();
138- }
139-
140- boost::asio::io_service& io_service;
141- std::thread io_thread;
142- std::thread qt_thread;
143- } guard(io_service);
144-
145- mir::run_mir(*config, [&](mir::DisplayServer&)
146- {
147- auto vendor = (char *) glGetString(GL_VENDOR);
148- auto renderer = (char *) glGetString (GL_RENDERER);
149- auto version = (char *) glGetString (GL_VERSION);
150- std::cerr << "GL_VENDOR = " << vendor << std::endl;
151- std::cerr << "GL_RENDERER = " << renderer << std::endl;
152- std::cerr << "GL_VERSION = " << version << std::endl;
153-
154- if (!check_blacklist(config->blacklist(), vendor, renderer, version))
155- throw mir::AbnormalExit ("Video driver is blacklisted, exiting");
156-
157- shell = config->the_system_compositor_shell();
158- guard.io_thread = std::thread(&SystemCompositor::main, this);
159- guard.qt_thread = std::thread(&SystemCompositor::qt_main, this, argc, argv);
160+SystemCompositor::SystemCompositor(int argc, char const** argv) :
161+ argc(argc),
162+ argv(argv),
163+ config{new SystemCompositorServerConfiguration(this, argc, argv)},
164+ shell{config->the_system_compositor_shell()},
165+ dm_connection{std::make_shared<DMConnection>(io_service, config->from_dm_fd(), config->to_dm_fd())}
166+{
167+ auto vendor = (char *) glGetString(GL_VENDOR);
168+ auto renderer = (char *) glGetString (GL_RENDERER);
169+ auto version = (char *) glGetString (GL_VERSION);
170+ std::cerr << "GL_VENDOR = " << vendor << std::endl;
171+ std::cerr << "GL_RENDERER = " << renderer << std::endl;
172+ std::cerr << "GL_VERSION = " << version << std::endl;
173+
174+ if (!check_blacklist(config->blacklist(), vendor, renderer, version))
175+ throw mir::AbnormalExit ("Video driver is blacklisted, exiting");
176+}
177+
178+SystemCompositor::~SystemCompositor() noexcept
179+{
180+ io_service.stop();
181+ if (thread.joinable()) thread.join();
182+ if (qt_thread.joinable()) qt_thread.join();
183+}
184+
185+void SystemCompositor::run()
186+{
187+ mir::run_mir(*config, [this](mir::DisplayServer&)
188+ {
189+ thread = std::thread(&SystemCompositor::main, this);
190+ qt_thread = std::thread(&SystemCompositor::qt_main, this);
191 });
192 }
193
194@@ -294,6 +281,7 @@
195 {
196 std::cerr << "set_active_session" << std::endl;
197
198+ // TODO the Mir Session hierarchy is odd - we shouldn't really need this cast.
199 active_session = std::static_pointer_cast<mir::shell::Session>(shell->session_named(client_name));
200
201 if (active_session)
202@@ -327,9 +315,9 @@
203 io_service.run();
204 }
205
206-void SystemCompositor::qt_main(int argc, char **argv)
207+void SystemCompositor::qt_main()
208 {
209- QCoreApplication app(argc, argv);
210- DBusScreen dbus_screen(config);
211+ QCoreApplication app(argc, const_cast<char**>(argv));
212+ DBusScreen dbus_screen(*config);
213 app.exec();
214 }
215
216=== modified file 'src/system_compositor.h'
217--- src/system_compositor.h 2013-11-22 16:53:52 +0000
218+++ src/system_compositor.h 2013-11-26 12:17:27 +0000
219@@ -21,6 +21,8 @@
220
221 #include "dm_connection.h"
222
223+#include <thread>
224+
225 namespace mir { namespace shell { class Session; } }
226
227 class SystemCompositorShell;
228@@ -29,21 +31,28 @@
229 class SystemCompositor : public DMMessageHandler
230 {
231 public:
232- void run(int argc, char **argv);
233+ SystemCompositor(int argc, char const** argv);
234+ ~SystemCompositor() noexcept;
235+ void run();
236 void pause();
237 void resume();
238
239 private:
240- std::shared_ptr<SystemCompositorServerConfiguration> config;
241- std::shared_ptr<SystemCompositorShell> shell;
242+ int argc;
243+ char const** const argv;
244+ std::unique_ptr<SystemCompositorServerConfiguration> const config;
245+ std::shared_ptr<SystemCompositorShell> const shell;
246+ std::shared_ptr<DMConnection> const dm_connection;
247+
248 boost::asio::io_service io_service;
249- std::shared_ptr<DMConnection> dm_connection;
250+ std::thread thread;
251+ std::thread qt_thread;
252 std::shared_ptr<mir::shell::Session> active_session;
253
254 void set_active_session(std::string client_name);
255 void set_next_session(std::string client_name);
256 void main();
257- void qt_main(int argc, char **argv);
258+ void qt_main();
259 };
260
261 #endif /* SYSTEM_COMPOSITOR_H_ */

Subscribers

People subscribed via source and target branches