Merge lp:~alan-griffiths/unity-system-compositor/decouple-WindowManager-from-DMMessageHandler into lp:unity-system-compositor

Proposed by Alan Griffiths on 2015-06-03
Status: Merged
Approved by: Alan Griffiths on 2015-06-04
Approved revision: 222
Merged at revision: 218
Proposed branch: lp:~alan-griffiths/unity-system-compositor/decouple-WindowManager-from-DMMessageHandler
Merge into: lp:unity-system-compositor
Prerequisite: lp:~alan-griffiths/unity-system-compositor/use-mir-SurfaceReadyObserver
Diff against target: 211 lines (+79/-32)
4 files modified
src/session_monitor.h (+63/-0)
src/session_switcher.h (+6/-23)
src/window_manager.cpp (+6/-6)
src/window_manager.h (+4/-3)
To merge this branch: bzr merge lp:~alan-griffiths/unity-system-compositor/decouple-WindowManager-from-DMMessageHandler
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) 2015-06-03 Approve on 2015-06-04
PS Jenkins bot continuous-integration Approve on 2015-06-03
Review via email: mp+260979@code.launchpad.net

Commit Message

Decouple the WindowManager from the display manager message handler (DMMessageHandler)

Description of the Change

Decouple the WindowManager from the display manager message handler (DMMessageHandler)

This is a step towards separating the system manager's window management policy into a service provided by Mir.

To post a comment you must log in.
Alexandros Frantzis (afrantzis) wrote :

Looks good.

Nit:

57 + virtual ~SessionMonitor() = default;
58 +
59 + SessionMonitor(SessionMonitor const&) = delete;
60 +
61 + SessionMonitor& operator=(SessionMonitor const&) = delete;
62 +
63 + virtual void add(std::shared_ptr<Session> const& session, pid_t pid) = 0;
64 +
65 + virtual void remove(
66 + std::shared_ptr<mir::frontend::Session> const& session) = 0;
67 +
68 + virtual void mark_ready(mir::frontend::Session const* session) = 0;
69 +};

Grouping the functions (construction/destruction vs others) by strategically placing blank lines would make the class easier to read (IMO).

review: Approve
221. By Alan Griffiths on 2015-06-04

Regroup contents of SessionMonitor definition

222. By Alan Griffiths on 2015-06-04

merge lp:unity-system-compositor

Alexandros Frantzis (afrantzis) wrote :

Great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'src/session_monitor.h'
2--- src/session_monitor.h 1970-01-01 00:00:00 +0000
3+++ src/session_monitor.h 2015-06-04 13:37:00 +0000
4@@ -0,0 +1,63 @@
5+/*
6+ * Copyright © 2015 Canonical Ltd.
7+ *
8+ * This program is free software: you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License version 3 as
10+ * published by the Free Software Foundation.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ *
20+ * Authored by: Alan Griffiths <alan.griffiths@canonical.com>
21+ */
22+
23+#ifndef USC_SESSION_MONITOR_H
24+#define USC_SESSION_MONITOR_H
25+
26+#include <sys/types.h>
27+
28+#include <memory>
29+#include <string>
30+
31+namespace mir { namespace frontend { class Session; }};
32+
33+namespace usc
34+{
35+class Session
36+{
37+public:
38+ virtual ~Session() = default;
39+
40+ virtual std::string name() = 0;
41+ virtual void show() = 0;
42+ virtual void hide() = 0;
43+ virtual void raise_and_focus() = 0;
44+ virtual bool corresponds_to(mir::frontend::Session const*) = 0;
45+
46+protected:
47+ Session() = default;
48+ Session(Session const&) = delete;
49+ Session& operator=(Session const&) = delete;
50+};
51+
52+class SessionMonitor
53+{
54+public:
55+ virtual void add(std::shared_ptr<Session> const& session, pid_t pid) = 0;
56+ virtual void remove(std::shared_ptr<mir::frontend::Session> const& session) = 0;
57+ virtual void mark_ready(mir::frontend::Session const* session) = 0;
58+
59+protected:
60+ SessionMonitor() = default;
61+ SessionMonitor(SessionMonitor const&) = delete;
62+ SessionMonitor& operator=(SessionMonitor const&) = delete;
63+ virtual ~SessionMonitor() = default;
64+};
65+}
66+
67+#endif //USC_SESSION_MONITOR_H
68
69=== modified file 'src/session_switcher.h'
70--- src/session_switcher.h 2014-10-22 19:31:57 +0000
71+++ src/session_switcher.h 2015-06-04 13:37:00 +0000
72@@ -20,41 +20,24 @@
73 #define USC_SESSION_SWITCHER_H_
74
75 #include "dm_connection.h"
76+#include "session_monitor.h"
77
78 #include <map>
79-#include <memory>
80 #include <mutex>
81
82-namespace mir { namespace frontend { class Session; }};
83 namespace usc
84 {
85 class Spinner;
86
87-class Session
88-{
89-public:
90- virtual ~Session() = default;
91-
92- virtual std::string name() = 0;
93- virtual void show() = 0;
94- virtual void hide() = 0;
95- virtual void raise_and_focus() = 0;
96- virtual bool corresponds_to(mir::frontend::Session const*) = 0;
97-
98-protected:
99- Session() = default;
100- Session(Session const&) = delete;
101- Session& operator=(Session const&) = delete;
102-};
103-
104-class SessionSwitcher : public DMMessageHandler
105+class SessionSwitcher : public DMMessageHandler, public SessionMonitor
106 {
107 public:
108 explicit SessionSwitcher(std::shared_ptr<Spinner> const& spinner);
109
110- void add(std::shared_ptr<Session> const& session, pid_t pid);
111- void remove(std::shared_ptr<mir::frontend::Session> const& session);
112- void mark_ready(mir::frontend::Session const* session);
113+ /* From SessionMonitor */
114+ void add(std::shared_ptr<Session> const& session, pid_t pid) override;
115+ void remove(std::shared_ptr<mir::frontend::Session> const& session) override;
116+ void mark_ready(mir::frontend::Session const* session) override;
117
118 /* From DMMessageHandler */
119 void set_active_session(std::string const& name) override;
120
121=== modified file 'src/window_manager.cpp'
122--- src/window_manager.cpp 2015-06-03 11:35:04 +0000
123+++ src/window_manager.cpp 2015-06-04 13:37:00 +0000
124@@ -18,7 +18,7 @@
125
126 #include "window_manager.h"
127
128-#include "session_switcher.h"
129+#include "session_monitor.h"
130
131 #include "mir/geometry/rectangle.h"
132 #include "mir/shell/surface_ready_observer.h"
133@@ -88,11 +88,11 @@
134 mir::shell::FocusController* focus_controller,
135 std::shared_ptr<mir::shell::DisplayLayout> const& display_layout,
136 std::shared_ptr<ms::SessionCoordinator> const& session_coordinator,
137- std::shared_ptr<SessionSwitcher> const& session_switcher) :
138+ std::shared_ptr<SessionMonitor> const& session_monitor) :
139 focus_controller{focus_controller},
140 display_layout{display_layout},
141 session_coordinator{session_coordinator},
142- session_switcher{session_switcher}
143+ session_monitor{session_monitor}
144 {
145 }
146
147@@ -104,7 +104,7 @@
148
149 auto const usc_session = std::make_shared<UscSession>(session, *focus_controller);
150
151- session_switcher->add(usc_session, session->process_id());
152+ session_monitor->add(usc_session, session->process_id());
153 }
154
155 void usc::WindowManager::remove_session(std::shared_ptr<ms::Session> const& session)
156@@ -117,7 +117,7 @@
157 else
158 focus_controller->set_focus_to(next_session, {});
159
160- session_switcher->remove(session);
161+ session_monitor->remove(session);
162 }
163
164 auto usc::WindowManager::add_surface(
165@@ -146,7 +146,7 @@
166 auto const session_ready_observer = std::make_shared<msh::SurfaceReadyObserver>(
167 [this](std::shared_ptr<ms::Session> const& session, std::shared_ptr<ms::Surface> const& surface)
168 {
169- session_switcher->mark_ready(session.get());
170+ session_monitor->mark_ready(session.get());
171 },
172 session,
173 surface);
174
175=== modified file 'src/window_manager.h'
176--- src/window_manager.h 2015-04-09 11:27:06 +0000
177+++ src/window_manager.h 2015-06-04 13:37:00 +0000
178@@ -20,6 +20,7 @@
179 #define USC_WINDOW_MANAGER_H_
180
181 #include <mir/shell/window_manager.h>
182+#include "session_monitor.h"
183
184 namespace mir
185 {
186@@ -29,7 +30,7 @@
187
188 namespace usc
189 {
190-class SessionSwitcher;
191+class SessionMonitor;
192
193 class WindowManager : public mir::shell::WindowManager
194 {
195@@ -38,7 +39,7 @@
196 mir::shell::FocusController* focus_controller,
197 std::shared_ptr<mir::shell::DisplayLayout> const& display_layout,
198 std::shared_ptr<mir::scene::SessionCoordinator> const& session_coordinator,
199- std::shared_ptr<SessionSwitcher> const& session_switcher);
200+ std::shared_ptr<SessionMonitor> const& session_switcher);
201
202 void add_session(std::shared_ptr<mir::scene::Session> const& session) override;
203
204@@ -78,7 +79,7 @@
205 mir::shell::FocusController* const focus_controller;
206 std::shared_ptr<mir::shell::DisplayLayout> const display_layout;
207 std::shared_ptr<mir::scene::SessionCoordinator> const session_coordinator;
208- std::shared_ptr<SessionSwitcher> const session_switcher;
209+ std::shared_ptr<SessionMonitor> const session_monitor;
210 };
211 }
212

Subscribers

People subscribed via source and target branches