Merge lp:~mterry/unity-system-compositor/greeter-api into lp:unity-system-compositor

Proposed by Michael Terry
Status: Merged
Merged at revision: 52
Proposed branch: lp:~mterry/unity-system-compositor/greeter-api
Merge into: lp:unity-system-compositor
Diff against target: 171 lines (+84/-2)
4 files modified
src/dm_connection.cpp (+10/-0)
src/dm_connection.h (+4/-1)
src/system_compositor.cpp (+69/-1)
src/system_compositor.h (+1/-0)
To merge this branch: bzr merge lp:~mterry/unity-system-compositor/greeter-api
Reviewer Review Type Date Requested Status
Unity System Compositor Development Team Pending
Review via email: mp+173592@code.launchpad.net

Commit message

Add a DBus API for the benefit of a LightDM greeter.

Description of the change

Add a DBus API for the benefit of a LightDM greeter.

Primarily, this is to support a greeter preparing which session will be below the greeter in the compositing stack, so it can overlay its own surface on top.

To post a comment you must log in.
34. By Michael Terry

Rough cut at supporting a DM message to set the next session; doesn't do anything once that message is received yet

35. By Michael Terry

Merge from trunk

36. By Michael Terry

Separate greeter from normal sessions by depth id

37. By Michael Terry

Lazily create surface_builder, fixing problem where we didn't recognize our own command line arguments

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/dm_connection.cpp'
--- src/dm_connection.cpp 2013-06-11 00:39:33 +0000
+++ src/dm_connection.cpp 2013-08-15 14:47:01 +0000
@@ -90,6 +90,16 @@
90 handler->set_active_session(client_name);90 handler->set_active_session(client_name);
91 break;91 break;
92 }92 }
93 case USCMessageID::set_next_session:
94 {
95 std::ostringstream ss;
96 ss << &message_payload_buffer;
97 auto client_name = ss.str();
98 std::cerr << "set_next_session '" << client_name << "'" << std::endl;
99 if (handler)
100 handler->set_next_session(client_name);
101 break;
102 }
93 default:103 default:
94 std::cerr << "Ignoring unknown message " << (uint16_t) message_id << " with " << payload_length << " octets" << std::endl;104 std::cerr << "Ignoring unknown message " << (uint16_t) message_id << " with " << payload_length << " octets" << std::endl;
95 break;105 break;
96106
=== modified file 'src/dm_connection.h'
--- src/dm_connection.h 2013-04-26 04:30:42 +0000
+++ src/dm_connection.h 2013-08-15 14:47:01 +0000
@@ -25,12 +25,14 @@
25{25{
26public:26public:
27 virtual void set_active_session(std::string client_name) = 0;27 virtual void set_active_session(std::string client_name) = 0;
28 virtual void set_next_session(std::string client_name) = 0;
28};29};
2930
30class NullDMMessageHandler : public DMMessageHandler31class NullDMMessageHandler : public DMMessageHandler
31{32{
32public:33public:
33 void set_active_session(std::string client_name) {};34 void set_active_session(std::string client_name) {};
35 void set_next_session(std::string client_name) {};
34};36};
3537
36enum class USCMessageID38enum class USCMessageID
@@ -39,7 +41,8 @@
39 pong = 1,41 pong = 1,
40 ready = 2,42 ready = 2,
41 session_connected = 3,43 session_connected = 3,
42 set_active_session = 444 set_active_session = 4,
45 set_next_session = 5,
43};46};
4447
45class DMConnection48class DMConnection
4649
=== modified file 'src/system_compositor.cpp'
--- src/system_compositor.cpp 2013-07-10 17:16:32 +0000
+++ src/system_compositor.cpp 2013-08-15 14:47:01 +0000
@@ -21,15 +21,54 @@
21#include <mir/run_mir.h>21#include <mir/run_mir.h>
22#include <mir/shell/session.h>22#include <mir/shell/session.h>
23#include <mir/shell/session_container.h>23#include <mir/shell/session_container.h>
24#include <mir/shell/surface_builder.h>
25#include <mir/shell/surface_creation_parameters.h>
24#include <mir/shell/focus_setter.h>26#include <mir/shell/focus_setter.h>
27#include <mir/surfaces/depth_id.h>
28#include <mir/surfaces/surface_stack_model.h>
25#include <mir/input/cursor_listener.h>29#include <mir/input/cursor_listener.h>
2630
27#include <iostream>31#include <iostream>
28#include <thread>32#include <thread>
2933
30namespace msh = mir::shell;34namespace msh = mir::shell;
35namespace ms = mir::surfaces;
31namespace mi = mir::input;36namespace mi = mir::input;
3237
38class SystemCompositorSurfaceBuilder : public msh::SurfaceBuilder
39{
40public:
41 SystemCompositorSurfaceBuilder(std::shared_ptr<ms::SurfaceStackModel> const& surface_stack)
42 : surface_stack(surface_stack)
43 {
44 }
45
46 std::weak_ptr<ms::Surface> create_surface(msh::Session *session, msh::SurfaceCreationParameters const& params)
47 {
48 static ms::DepthId const default_surface_depth{0};
49 static ms::DepthId const greeter_surface_depth{1};
50
51 auto depth_params = params;
52 if (session->name().find("greeter-") == 0)
53 {
54 depth_params.depth = greeter_surface_depth;
55 }
56 else
57 {
58 depth_params.depth = default_surface_depth;
59 }
60 return surface_stack->create_surface(depth_params);
61 }
62
63 void destroy_surface(std::weak_ptr<ms::Surface> const& surface)
64 {
65 surface_stack->destroy_surface(surface);
66 }
67
68private:
69 std::shared_ptr<ms::SurfaceStackModel> const surface_stack;
70};
71
33class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration72class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration
34{73{
35public:74public:
@@ -41,7 +80,7 @@
41 add_options()80 add_options()
42 ("from-dm-fd", po::value<int>(), "File descriptor of read end of pipe from display manager [int]")81 ("from-dm-fd", po::value<int>(), "File descriptor of read end of pipe from display manager [int]")
43 ("to-dm-fd", po::value<int>(), "File descriptor of write end of pipe to display manager [int]");82 ("to-dm-fd", po::value<int>(), "File descriptor of write end of pipe to display manager [int]");
44 add_options()83 add_options()
45 ("version", "Show version of Unity System Compositor");84 ("version", "Show version of Unity System Compositor");
46 }85 }
4786
@@ -70,6 +109,18 @@
70 };109 };
71 return std::make_shared<NullCursorListener>();110 return std::make_shared<NullCursorListener>();
72 }111 }
112
113 std::shared_ptr<msh::SurfaceBuilder> the_surface_builder() override
114 {
115 return surface_builder(
116 [this]()
117 {
118 return std::make_shared<SystemCompositorSurfaceBuilder>(the_surface_stack_model());
119 });
120 }
121
122private:
123 mir::CachedPtr<msh::SurfaceBuilder> surface_builder;
73};124};
74125
75void SystemCompositor::run(int argc, char const** argv)126void SystemCompositor::run(int argc, char const** argv)
@@ -117,6 +168,23 @@
117 std::cerr << "Unable to set active session, unknown client name " << client_name << std::endl;168 std::cerr << "Unable to set active session, unknown client name " << client_name << std::endl;
118}169}
119170
171void SystemCompositor::set_next_session(std::string client_name)
172{
173 std::cerr << "set_next_session" << std::endl;
174
175 std::shared_ptr<msh::Session> session;
176 config->the_shell_session_container()->for_each([&client_name, &session](std::shared_ptr<msh::Session> const& s)
177 {
178 if (s->name() == client_name)
179 session = s;
180 });
181
182 if (session)
183 config->the_shell_focus_setter()->set_focus_to(session); // depth id will keep it separate from greeter
184 else
185 std::cerr << "Unable to set next session, unknown client name " << client_name << std::endl;
186}
187
120void SystemCompositor::main()188void SystemCompositor::main()
121{189{
122 dm_connection->set_handler(this);190 dm_connection->set_handler(this);
123191
=== modified file 'src/system_compositor.h'
--- src/system_compositor.h 2013-06-20 08:29:14 +0000
+++ src/system_compositor.h 2013-08-15 14:47:01 +0000
@@ -36,6 +36,7 @@
36 std::shared_ptr<DMConnection> dm_connection;36 std::shared_ptr<DMConnection> dm_connection;
3737
38 virtual void set_active_session(std::string client_name);38 virtual void set_active_session(std::string client_name);
39 virtual void set_next_session(std::string client_name);
39 void main();40 void main();
40};41};
4142

Subscribers

People subscribed via source and target branches