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

Proposed by Michael Terry
Status: Merged
Approved by: kevin gunn
Approved revision: 104
Merged at revision: 120
Proposed branch: lp:~mterry/unity-system-compositor/greeter-depth
Merge into: lp:unity-system-compositor
Diff against target: 128 lines (+37/-17)
2 files modified
src/system_compositor.cpp (+37/-16)
src/system_compositor.h (+0/-1)
To merge this branch: bzr merge lp:~mterry/unity-system-compositor/greeter-depth
Reviewer Review Type Date Requested Status
Alberto Aguirre (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Unity System Compositor Development Team Pending
Review via email: mp+207549@code.launchpad.net

Commit message

Make sure that the active session has focus when multiple sessions are opened.

Description of the change

Make sure that the active session has focus.

This branch fixes a few problems when using USC with multiple sessions:

1) There is a race between when LightDM tells us what the active session should be and when that session might get around to registering with us. This branch solves that by keeping track of the requested session name and focusing it when it is opened.

2) If later sessions open, Mir gives them the focus by default. This branch makes sure that as new sessions open, we give focus back to the proper active session, as determined by LightDM.

3) This branch implements set_next_session, which was previously merely TODO. This way LightDM can tell us which session to stack underneath the active one.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Looks good, I had seen this race.

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 2014-02-10 14:55:13 +0000
3+++ src/system_compositor.cpp 2014-02-26 18:33:00 +0000
4@@ -45,13 +45,36 @@
5 class SystemCompositorShell : public mf::Shell
6 {
7 public:
8- SystemCompositorShell(std::shared_ptr<mf::Shell> const& self) : self(self) {}
9+ SystemCompositorShell(std::shared_ptr<mf::Shell> const& self,
10+ std::shared_ptr<msh::FocusController> const& focus_controller)
11+ : self(self), focus_controller{focus_controller} {}
12
13 std::shared_ptr<mf::Session> session_named(std::string const& name)
14 {
15 return sessions[name];
16 }
17
18+ void set_active_session(std::string const& name)
19+ {
20+ active_session = name;
21+
22+ if (auto session = std::static_pointer_cast<msh::Session>(session_named(name)))
23+ focus_controller->set_focus_to(session);
24+ else
25+ std::cerr << "Unable to set active session, unknown client name " << name << std::endl;
26+ }
27+
28+ void set_next_session(std::string const& name)
29+ {
30+ if (auto const session = std::static_pointer_cast<msh::Session>(session_named(name)))
31+ {
32+ focus_controller->set_focus_to(session); // raise session inside its depth id set
33+ set_active_session(active_session); // to restore input focus to where it should be
34+ }
35+ else
36+ std::cerr << "Unable to set next session, unknown client name " << name << std::endl;
37+ }
38+
39 private:
40 std::shared_ptr<mf::Session> open_session(
41 pid_t client_pid,
42@@ -60,6 +83,11 @@
43 {
44 auto result = self->open_session(client_pid, name, sink);
45 sessions[name] = result;
46+
47+ // Opening a new session will steal focus from our active session, so
48+ // restore the focus if needed.
49+ set_active_session(active_session);
50+
51 return result;
52 }
53
54@@ -82,7 +110,9 @@
55 }
56
57 std::shared_ptr<mf::Shell> const self;
58+ std::shared_ptr<msh::FocusController> const focus_controller;
59 std::map<std::string, std::shared_ptr<mf::Session>> sessions;
60+ std::string active_session;
61 };
62
63 class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration
64@@ -180,7 +210,8 @@
65 return sc_shell([this]
66 {
67 return std::make_shared<SystemCompositorShell>(
68- mir::DefaultServerConfiguration::the_frontend_shell());
69+ mir::DefaultServerConfiguration::the_frontend_shell(),
70+ the_focus_controller());
71 });
72 }
73
74@@ -279,7 +310,7 @@
75 {
76 std::cerr << "pause" << std::endl;
77
78- if (active_session)
79+ if (auto active_session = config->the_focus_controller()->focussed_application().lock())
80 active_session->set_lifecycle_state(mir_lifecycle_state_will_suspend);
81 }
82
83@@ -287,30 +318,20 @@
84 {
85 std::cerr << "resume" << std::endl;
86
87- if (active_session)
88+ if (auto active_session = config->the_focus_controller()->focussed_application().lock())
89 active_session->set_lifecycle_state(mir_lifecycle_state_resumed);
90 }
91
92 void SystemCompositor::set_active_session(std::string client_name)
93 {
94 std::cerr << "set_active_session" << std::endl;
95-
96- active_session = std::static_pointer_cast<mir::shell::Session>(shell->session_named(client_name));
97-
98- if (active_session)
99- config->the_focus_controller()->set_focus_to(active_session);
100- else
101- std::cerr << "Unable to set active session, unknown client name " << client_name << std::endl;
102+ shell->set_active_session(client_name);
103 }
104
105 void SystemCompositor::set_next_session(std::string client_name)
106 {
107 std::cerr << "set_next_session" << std::endl;
108-
109- if (auto const session = shell->session_named(client_name))
110- ; // TODO: implement this
111- else
112- std::cerr << "Unable to set next session, unknown client name " << client_name << std::endl;
113+ shell->set_next_session(client_name);
114 }
115
116 void SystemCompositor::main()
117
118=== modified file 'src/system_compositor.h'
119--- src/system_compositor.h 2013-11-22 16:53:52 +0000
120+++ src/system_compositor.h 2014-02-26 18:33:00 +0000
121@@ -38,7 +38,6 @@
122 std::shared_ptr<SystemCompositorShell> shell;
123 boost::asio::io_service io_service;
124 std::shared_ptr<DMConnection> dm_connection;
125- std::shared_ptr<mir::shell::Session> active_session;
126
127 void set_active_session(std::string client_name);
128 void set_next_session(std::string client_name);

Subscribers

People subscribed via source and target branches