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

Proposed by Michael Terry on 2013-07-08
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 2013-07-08 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 on 2013-07-09

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 on 2013-08-12

Merge from trunk

36. By Michael Terry on 2013-08-15

Separate greeter from normal sessions by depth id

37. By Michael Terry on 2013-08-15

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
1=== modified file 'src/dm_connection.cpp'
2--- src/dm_connection.cpp 2013-06-11 00:39:33 +0000
3+++ src/dm_connection.cpp 2013-08-15 14:47:01 +0000
4@@ -90,6 +90,16 @@
5 handler->set_active_session(client_name);
6 break;
7 }
8+ case USCMessageID::set_next_session:
9+ {
10+ std::ostringstream ss;
11+ ss << &message_payload_buffer;
12+ auto client_name = ss.str();
13+ std::cerr << "set_next_session '" << client_name << "'" << std::endl;
14+ if (handler)
15+ handler->set_next_session(client_name);
16+ break;
17+ }
18 default:
19 std::cerr << "Ignoring unknown message " << (uint16_t) message_id << " with " << payload_length << " octets" << std::endl;
20 break;
21
22=== modified file 'src/dm_connection.h'
23--- src/dm_connection.h 2013-04-26 04:30:42 +0000
24+++ src/dm_connection.h 2013-08-15 14:47:01 +0000
25@@ -25,12 +25,14 @@
26 {
27 public:
28 virtual void set_active_session(std::string client_name) = 0;
29+ virtual void set_next_session(std::string client_name) = 0;
30 };
31
32 class NullDMMessageHandler : public DMMessageHandler
33 {
34 public:
35 void set_active_session(std::string client_name) {};
36+ void set_next_session(std::string client_name) {};
37 };
38
39 enum class USCMessageID
40@@ -39,7 +41,8 @@
41 pong = 1,
42 ready = 2,
43 session_connected = 3,
44- set_active_session = 4
45+ set_active_session = 4,
46+ set_next_session = 5,
47 };
48
49 class DMConnection
50
51=== modified file 'src/system_compositor.cpp'
52--- src/system_compositor.cpp 2013-07-10 17:16:32 +0000
53+++ src/system_compositor.cpp 2013-08-15 14:47:01 +0000
54@@ -21,15 +21,54 @@
55 #include <mir/run_mir.h>
56 #include <mir/shell/session.h>
57 #include <mir/shell/session_container.h>
58+#include <mir/shell/surface_builder.h>
59+#include <mir/shell/surface_creation_parameters.h>
60 #include <mir/shell/focus_setter.h>
61+#include <mir/surfaces/depth_id.h>
62+#include <mir/surfaces/surface_stack_model.h>
63 #include <mir/input/cursor_listener.h>
64
65 #include <iostream>
66 #include <thread>
67
68 namespace msh = mir::shell;
69+namespace ms = mir::surfaces;
70 namespace mi = mir::input;
71
72+class SystemCompositorSurfaceBuilder : public msh::SurfaceBuilder
73+{
74+public:
75+ SystemCompositorSurfaceBuilder(std::shared_ptr<ms::SurfaceStackModel> const& surface_stack)
76+ : surface_stack(surface_stack)
77+ {
78+ }
79+
80+ std::weak_ptr<ms::Surface> create_surface(msh::Session *session, msh::SurfaceCreationParameters const& params)
81+ {
82+ static ms::DepthId const default_surface_depth{0};
83+ static ms::DepthId const greeter_surface_depth{1};
84+
85+ auto depth_params = params;
86+ if (session->name().find("greeter-") == 0)
87+ {
88+ depth_params.depth = greeter_surface_depth;
89+ }
90+ else
91+ {
92+ depth_params.depth = default_surface_depth;
93+ }
94+ return surface_stack->create_surface(depth_params);
95+ }
96+
97+ void destroy_surface(std::weak_ptr<ms::Surface> const& surface)
98+ {
99+ surface_stack->destroy_surface(surface);
100+ }
101+
102+private:
103+ std::shared_ptr<ms::SurfaceStackModel> const surface_stack;
104+};
105+
106 class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration
107 {
108 public:
109@@ -41,7 +80,7 @@
110 add_options()
111 ("from-dm-fd", po::value<int>(), "File descriptor of read end of pipe from display manager [int]")
112 ("to-dm-fd", po::value<int>(), "File descriptor of write end of pipe to display manager [int]");
113- add_options()
114+ add_options()
115 ("version", "Show version of Unity System Compositor");
116 }
117
118@@ -70,6 +109,18 @@
119 };
120 return std::make_shared<NullCursorListener>();
121 }
122+
123+ std::shared_ptr<msh::SurfaceBuilder> the_surface_builder() override
124+ {
125+ return surface_builder(
126+ [this]()
127+ {
128+ return std::make_shared<SystemCompositorSurfaceBuilder>(the_surface_stack_model());
129+ });
130+ }
131+
132+private:
133+ mir::CachedPtr<msh::SurfaceBuilder> surface_builder;
134 };
135
136 void SystemCompositor::run(int argc, char const** argv)
137@@ -117,6 +168,23 @@
138 std::cerr << "Unable to set active session, unknown client name " << client_name << std::endl;
139 }
140
141+void SystemCompositor::set_next_session(std::string client_name)
142+{
143+ std::cerr << "set_next_session" << std::endl;
144+
145+ std::shared_ptr<msh::Session> session;
146+ config->the_shell_session_container()->for_each([&client_name, &session](std::shared_ptr<msh::Session> const& s)
147+ {
148+ if (s->name() == client_name)
149+ session = s;
150+ });
151+
152+ if (session)
153+ config->the_shell_focus_setter()->set_focus_to(session); // depth id will keep it separate from greeter
154+ else
155+ std::cerr << "Unable to set next session, unknown client name " << client_name << std::endl;
156+}
157+
158 void SystemCompositor::main()
159 {
160 dm_connection->set_handler(this);
161
162=== modified file 'src/system_compositor.h'
163--- src/system_compositor.h 2013-06-20 08:29:14 +0000
164+++ src/system_compositor.h 2013-08-15 14:47:01 +0000
165@@ -36,6 +36,7 @@
166 std::shared_ptr<DMConnection> dm_connection;
167
168 virtual void set_active_session(std::string client_name);
169+ virtual void set_next_session(std::string client_name);
170 void main();
171 };
172

Subscribers

People subscribed via source and target branches