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
=== modified file 'src/dbus_screen.cpp'
--- src/dbus_screen.cpp 2013-10-31 19:16:23 +0000
+++ src/dbus_screen.cpp 2013-11-26 12:17:27 +0000
@@ -27,9 +27,10 @@
27namespace mg = mir::graphics;27namespace mg = mir::graphics;
2828
29// Note: this class should be created only after when the Mir DisplayServer has started29// Note: this class should be created only after when the Mir DisplayServer has started
30DBusScreen::DBusScreen(std::shared_ptr<mir::DefaultServerConfiguration> config, QObject *parent)30DBusScreen::DBusScreen(mir::DefaultServerConfiguration& config, QObject *parent)
31 : QObject(parent)31 : QObject(parent)
32 , config(config)32 , display(config.the_display())
33
33{34{
34 new DBusScreenAdaptor(this);35 new DBusScreenAdaptor(this);
35 QDBusConnection bus = QDBusConnection::systemBus();36 QDBusConnection bus = QDBusConnection::systemBus();
@@ -55,7 +56,6 @@
55 return false;56 return false;
56 }57 }
5758
58 std::shared_ptr<mg::Display> display = config->the_display();
59 std::shared_ptr<mg::DisplayConfiguration> displayConfig = display->configuration();59 std::shared_ptr<mg::DisplayConfiguration> displayConfig = display->configuration();
6060
61 displayConfig->for_each_output([&](const mg::DisplayConfigurationOutput displayConfigOutput) {61 displayConfig->for_each_output([&](const mg::DisplayConfigurationOutput displayConfigOutput) {
6262
=== modified file 'src/dbus_screen.h'
--- src/dbus_screen.h 2013-10-31 19:16:23 +0000
+++ src/dbus_screen.h 2013-11-26 12:17:27 +0000
@@ -23,6 +23,7 @@
23namespace mir23namespace mir
24{24{
25 class DefaultServerConfiguration;25 class DefaultServerConfiguration;
26namespace graphics { class Display; }
26}27}
2728
28class DBusScreen : public QObject29class DBusScreen : public QObject
@@ -31,13 +32,13 @@
31 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Screen")32 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Screen")
3233
33public:34public:
34 explicit DBusScreen(std::shared_ptr<mir::DefaultServerConfiguration> config, QObject *parent = 0);35 explicit DBusScreen(mir::DefaultServerConfiguration& config, QObject *parent = 0);
3536
36public Q_SLOTS:37public Q_SLOTS:
37 bool setScreenPowerMode(const QString &mode);38 bool setScreenPowerMode(const QString &mode);
3839
39private:40private:
40 std::shared_ptr<mir::DefaultServerConfiguration> config;41 std::shared_ptr<mir::graphics::Display> const display;
41};42};
4243
43#endif /* DBUS_SCREEN_H_ */44#endif /* DBUS_SCREEN_H_ */
4445
=== modified file 'src/main.cpp'
--- src/main.cpp 2013-10-31 22:00:19 +0000
+++ src/main.cpp 2013-11-26 12:17:27 +0000
@@ -20,11 +20,12 @@
20#include <mir/report_exception.h>20#include <mir/report_exception.h>
21#include <iostream>21#include <iostream>
2222
23int main(int argc, char *argv[])23int main(int argc, char const* argv[])
24try24try
25{25{
26 SystemCompositor system_compositor;26 SystemCompositor system_compositor(argc, argv);
27 system_compositor.run(argc, argv);27
28 system_compositor.run();
2829
29 return 0;30 return 0;
30}31}
3132
=== modified file 'src/system_compositor.cpp'
--- src/system_compositor.cpp 2013-11-22 16:53:52 +0000
+++ src/system_compositor.cpp 2013-11-26 12:17:27 +0000
@@ -87,8 +87,8 @@
87class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration87class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration
88{88{
89public:89public:
90 SystemCompositorServerConfiguration(SystemCompositor *compositor, int argc, char **argv)90 SystemCompositorServerConfiguration(SystemCompositor *compositor, int argc, char const** argv)
91 : mir::DefaultServerConfiguration(argc, (char const **)argv), compositor{compositor}91 : mir::DefaultServerConfiguration(argc, argv), compositor{compositor}
92 {92 {
93 add_options()93 add_options()
94 ("from-dm-fd", po::value<int>(), "File descriptor of read end of pipe from display manager [int]")94 ("from-dm-fd", po::value<int>(), "File descriptor of read end of pipe from display manager [int]")
@@ -108,11 +108,6 @@
108 return the_options()->get("to-dm-fd", -1);108 return the_options()->get("to-dm-fd", -1);
109 }109 }
110110
111 bool show_version()
112 {
113 return the_options()->is_set ("version");
114 }
115
116 std::string blacklist()111 std::string blacklist()
117 {112 {
118 auto x = the_options()->get ("blacklist", "");113 auto x = the_options()->get ("blacklist", "");
@@ -130,6 +125,11 @@
130 setenv("MIR_SERVER_STANDALONE", "true", 0); // Default to standalone125 setenv("MIR_SERVER_STANDALONE", "true", 0); // Default to standalone
131 mir::DefaultServerConfiguration::parse_options(options_description, options);126 mir::DefaultServerConfiguration::parse_options(options_description, options);
132 options.parse_file(options_description, "unity-system-compositor.conf");127 options.parse_file(options_description, "unity-system-compositor.conf");
128
129 if (options.is_set("version"))
130 {
131 throw mir::AbnormalExit (std::string("unity-system-compositor ") + USC_VERSION);
132 }
133 }133 }
134134
135 std::shared_ptr<mi::CursorListener> the_cursor_listener() override135 std::shared_ptr<mi::CursorListener> the_cursor_listener() override
@@ -227,50 +227,37 @@
227 return true;227 return true;
228}228}
229229
230void SystemCompositor::run(int argc, char **argv)230SystemCompositor::SystemCompositor(int argc, char const** argv) :
231{231 argc(argc),
232 config = std::make_shared<SystemCompositorServerConfiguration>(this, argc, argv);232 argv(argv),
233 233 config{new SystemCompositorServerConfiguration(this, argc, argv)},
234 if (config->show_version())234 shell{config->the_system_compositor_shell()},
235 {235 dm_connection{std::make_shared<DMConnection>(io_service, config->from_dm_fd(), config->to_dm_fd())}
236 std::cerr << "unity-system-compositor " << USC_VERSION << std::endl;236{
237 return;237 auto vendor = (char *) glGetString(GL_VENDOR);
238 }238 auto renderer = (char *) glGetString (GL_RENDERER);
239239 auto version = (char *) glGetString (GL_VERSION);
240 dm_connection = std::make_shared<DMConnection>(io_service, config->from_dm_fd(), config->to_dm_fd());240 std::cerr << "GL_VENDOR = " << vendor << std::endl;
241241 std::cerr << "GL_RENDERER = " << renderer << std::endl;
242 struct ScopeGuard242 std::cerr << "GL_VERSION = " << version << std::endl;
243 {243
244 explicit ScopeGuard(boost::asio::io_service& io_service) : io_service(io_service) {}244 if (!check_blacklist(config->blacklist(), vendor, renderer, version))
245 ~ScopeGuard()245 throw mir::AbnormalExit ("Video driver is blacklisted, exiting");
246 {246}
247 io_service.stop();247
248 if (io_thread.joinable())248SystemCompositor::~SystemCompositor() noexcept
249 io_thread.join();249{
250 if (qt_thread.joinable())250 io_service.stop();
251 qt_thread.join();251 if (thread.joinable()) thread.join();
252 }252 if (qt_thread.joinable()) qt_thread.join();
253253}
254 boost::asio::io_service& io_service;254
255 std::thread io_thread;255void SystemCompositor::run()
256 std::thread qt_thread;256{
257 } guard(io_service);257 mir::run_mir(*config, [this](mir::DisplayServer&)
258258 {
259 mir::run_mir(*config, [&](mir::DisplayServer&)259 thread = std::thread(&SystemCompositor::main, this);
260 {260 qt_thread = std::thread(&SystemCompositor::qt_main, this);
261 auto vendor = (char *) glGetString(GL_VENDOR);
262 auto renderer = (char *) glGetString (GL_RENDERER);
263 auto version = (char *) glGetString (GL_VERSION);
264 std::cerr << "GL_VENDOR = " << vendor << std::endl;
265 std::cerr << "GL_RENDERER = " << renderer << std::endl;
266 std::cerr << "GL_VERSION = " << version << std::endl;
267
268 if (!check_blacklist(config->blacklist(), vendor, renderer, version))
269 throw mir::AbnormalExit ("Video driver is blacklisted, exiting");
270
271 shell = config->the_system_compositor_shell();
272 guard.io_thread = std::thread(&SystemCompositor::main, this);
273 guard.qt_thread = std::thread(&SystemCompositor::qt_main, this, argc, argv);
274 });261 });
275}262}
276263
@@ -294,6 +281,7 @@
294{281{
295 std::cerr << "set_active_session" << std::endl;282 std::cerr << "set_active_session" << std::endl;
296283
284 // TODO the Mir Session hierarchy is odd - we shouldn't really need this cast.
297 active_session = std::static_pointer_cast<mir::shell::Session>(shell->session_named(client_name));285 active_session = std::static_pointer_cast<mir::shell::Session>(shell->session_named(client_name));
298286
299 if (active_session)287 if (active_session)
@@ -327,9 +315,9 @@
327 io_service.run();315 io_service.run();
328}316}
329317
330void SystemCompositor::qt_main(int argc, char **argv)318void SystemCompositor::qt_main()
331{319{
332 QCoreApplication app(argc, argv);320 QCoreApplication app(argc, const_cast<char**>(argv));
333 DBusScreen dbus_screen(config);321 DBusScreen dbus_screen(*config);
334 app.exec();322 app.exec();
335}323}
336324
=== modified file 'src/system_compositor.h'
--- src/system_compositor.h 2013-11-22 16:53:52 +0000
+++ src/system_compositor.h 2013-11-26 12:17:27 +0000
@@ -21,6 +21,8 @@
2121
22#include "dm_connection.h"22#include "dm_connection.h"
2323
24#include <thread>
25
24namespace mir { namespace shell { class Session; } }26namespace mir { namespace shell { class Session; } }
2527
26class SystemCompositorShell;28class SystemCompositorShell;
@@ -29,21 +31,28 @@
29class SystemCompositor : public DMMessageHandler31class SystemCompositor : public DMMessageHandler
30{32{
31public:33public:
32 void run(int argc, char **argv);34 SystemCompositor(int argc, char const** argv);
35 ~SystemCompositor() noexcept;
36 void run();
33 void pause();37 void pause();
34 void resume();38 void resume();
3539
36private:40private:
37 std::shared_ptr<SystemCompositorServerConfiguration> config;41 int argc;
38 std::shared_ptr<SystemCompositorShell> shell;42 char const** const argv;
43 std::unique_ptr<SystemCompositorServerConfiguration> const config;
44 std::shared_ptr<SystemCompositorShell> const shell;
45 std::shared_ptr<DMConnection> const dm_connection;
46
39 boost::asio::io_service io_service;47 boost::asio::io_service io_service;
40 std::shared_ptr<DMConnection> dm_connection;48 std::thread thread;
49 std::thread qt_thread;
41 std::shared_ptr<mir::shell::Session> active_session;50 std::shared_ptr<mir::shell::Session> active_session;
4251
43 void set_active_session(std::string client_name);52 void set_active_session(std::string client_name);
44 void set_next_session(std::string client_name);53 void set_next_session(std::string client_name);
45 void main();54 void main();
46 void qt_main(int argc, char **argv);55 void qt_main();
47};56};
4857
49#endif /* SYSTEM_COMPOSITOR_H_ */58#endif /* SYSTEM_COMPOSITOR_H_ */

Subscribers

People subscribed via source and target branches