Merge lp:~robert-ancell/unity-system-compositor/app-lifecycle into lp:unity-system-compositor

Proposed by Robert Ancell
Status: Merged
Approved by: Robert Ancell
Approved revision: 79
Merged at revision: 76
Proposed branch: lp:~robert-ancell/unity-system-compositor/app-lifecycle
Merge into: lp:unity-system-compositor
Diff against target: 139 lines (+63/-10)
2 files modified
src/system_compositor.cpp (+57/-8)
src/system_compositor.h (+6/-2)
To merge this branch: bzr merge lp:~robert-ancell/unity-system-compositor/app-lifecycle
Reviewer Review Type Date Requested Status
Chris Halse Rogers Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+186135@code.launchpad.net

Commit message

Set lifecycle state for clients when setting the active session

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :
Revision history for this message
Robert Ancell (robert-ancell) wrote :

A future improvement is to set the client to paused on startup - it might be in the background.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
78. By Robert Ancell

Merge with trunk

79. By Robert Ancell

Use new Mir interface name ServerStatus->PauseResumeListener

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/system_compositor.cpp'
2--- src/system_compositor.cpp 2013-08-21 14:57:43 +0000
3+++ src/system_compositor.cpp 2013-09-19 13:14:57 +0000
4@@ -19,6 +19,8 @@
5 #include "system_compositor.h"
6
7 #include <mir/run_mir.h>
8+#include <mir/pause_resume_listener.h>
9+#include <mir/shell/application_session.h>
10 #include <mir/shell/session.h>
11 #include <mir/shell/session_container.h>
12 #include <mir/shell/focus_setter.h>
13@@ -33,8 +35,8 @@
14 class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration
15 {
16 public:
17- SystemCompositorServerConfiguration(int argc, char const** argv)
18- : mir::DefaultServerConfiguration(argc, argv)
19+ SystemCompositorServerConfiguration(SystemCompositor *compositor, int argc, char const** argv)
20+ : mir::DefaultServerConfiguration(argc, argv), compositor{compositor}
21 {
22 namespace po = boost::program_options;
23
24@@ -70,11 +72,35 @@
25 };
26 return std::make_shared<NullCursorListener>();
27 }
28+
29+ std::shared_ptr<mir::PauseResumeListener> the_pause_resume_listener() override
30+ {
31+ struct PauseResumeListener : public mir::PauseResumeListener
32+ {
33+ PauseResumeListener (SystemCompositor *compositor) : compositor{compositor} {}
34+
35+ void paused() override
36+ {
37+ compositor->pause();
38+ }
39+
40+ void resumed() override
41+ {
42+ compositor->resume();
43+ }
44+
45+ SystemCompositor *compositor;
46+ };
47+ return std::make_shared<PauseResumeListener>(compositor);
48+ }
49+
50+private:
51+ SystemCompositor *compositor;
52 };
53
54 void SystemCompositor::run(int argc, char const** argv)
55 {
56- auto c = std::make_shared<SystemCompositorServerConfiguration>(argc, argv);
57+ auto c = std::make_shared<SystemCompositorServerConfiguration>(this, argc, argv);
58 config = c;
59
60 if (c->show_version())
61@@ -100,19 +126,42 @@
62 });
63 }
64
65+void SystemCompositor::pause()
66+{
67+ std::cerr << "pause" << std::endl;
68+
69+ if (active_session)
70+ active_session->set_lifecycle_state(mir_lifecycle_state_will_suspend);
71+}
72+
73+void SystemCompositor::resume()
74+{
75+ std::cerr << "resume" << std::endl;
76+
77+ if (active_session)
78+ active_session->set_lifecycle_state(mir_lifecycle_state_resumed);
79+}
80+
81 void SystemCompositor::set_active_session(std::string client_name)
82 {
83 std::cerr << "set_active_session" << std::endl;
84
85- std::shared_ptr<msh::Session> session;
86- config->the_shell_session_container()->for_each([&client_name, &session](std::shared_ptr<msh::Session> const& s)
87+ active_session.reset();
88+ config->the_shell_session_container()->for_each([&](std::shared_ptr<msh::Session> const& s)
89 {
90+ auto app_session(std::static_pointer_cast<msh::ApplicationSession>(s));
91+
92 if (s->name() == client_name)
93- session = s;
94+ {
95+ app_session->set_lifecycle_state(mir_lifecycle_state_resumed);
96+ active_session = app_session;
97+ }
98+ else
99+ app_session->set_lifecycle_state(mir_lifecycle_state_will_suspend);
100 });
101
102- if (session)
103- config->the_shell_focus_setter()->set_focus_to(session);
104+ if (active_session)
105+ config->the_shell_focus_setter()->set_focus_to(active_session);
106 else
107 std::cerr << "Unable to set active session, unknown client name " << client_name << std::endl;
108 }
109
110=== modified file 'src/system_compositor.h'
111--- src/system_compositor.h 2013-07-09 19:18:59 +0000
112+++ src/system_compositor.h 2013-09-19 13:14:57 +0000
113@@ -22,6 +22,7 @@
114 #include "dm_connection.h"
115
116 #include <mir/default_server_configuration.h>
117+#include <mir/shell/application_session.h>
118
119 class Configuration;
120
121@@ -29,14 +30,17 @@
122 {
123 public:
124 void run(int argc, char const** argv);
125+ void pause();
126+ void resume();
127
128 private:
129 std::shared_ptr<mir::DefaultServerConfiguration> config;
130 boost::asio::io_service io_service;
131 std::shared_ptr<DMConnection> dm_connection;
132+ std::shared_ptr<mir::shell::ApplicationSession> active_session;
133
134- virtual void set_active_session(std::string client_name);
135- virtual void set_next_session(std::string client_name);
136+ void set_active_session(std::string client_name);
137+ void set_next_session(std::string client_name);
138 void main();
139 };
140

Subscribers

People subscribed via source and target branches