Mir

Merge lp:~vanvugt/mir/wire-up-SurfaceController into lp:mir

Proposed by Daniel van Vugt
Status: Rejected
Rejected by: Daniel van Vugt
Proposed branch: lp:~vanvugt/mir/wire-up-SurfaceController
Merge into: lp:mir
Diff against target: 249 lines (+54/-9)
15 files modified
include/server/mir/frontend/session.h (+1/-0)
include/server/mir/scene/surface_coordinator.h (+2/-1)
include/server/mir/shell/surface_coordinator_wrapper.h (+1/-1)
server-ABI-sha1sums (+3/-3)
src/server/frontend/session_mediator.cpp (+1/-2)
src/server/scene/application_session.cpp (+9/-0)
src/server/scene/application_session.h (+1/-0)
src/server/scene/surface_controller.cpp (+9/-0)
src/server/scene/surface_controller.h (+3/-1)
src/server/shell/surface_coordinator_wrapper.cpp (+7/-0)
src/server/symbols.map (+1/-0)
tests/include/mir_test_doubles/mock_surface_coordinator.h (+2/-1)
tests/include/mir_test_doubles/stub_scene_session.h (+5/-0)
tests/include/mir_test_doubles/stub_session.h (+5/-0)
tests/unit-tests/scene/test_application_session.cpp (+4/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/wire-up-SurfaceController
Reviewer Review Type Date Requested Status
Alan Griffiths Disapprove
PS Jenkins bot (community) continuous-integration Approve
Robert Carr (community) Disapprove
Review via email: mp+246281@code.launchpad.net

Commit message

Wire up SurfaceController to incoming configure_surface messages from
clients so that it may intercept them and implement WM policy... or
call something else to implement some WM policy.

Description of the change

This is an independent activity to the managed-surface branch. Regardless
of your school of thought, everyone seems to have suggested we will need
this for something eventually. As SurfaceController will have a place in
inter-surface policy in the least.

This branch is something like 10%-20% of the infamous 'states' branch that got shelved.

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
Robert Carr (robertcarr) wrote :

This is the "wrong surface controller" so to speak.

We can see that it doesn't quite work as a controller when we look at ApplicationSession::configure_surface...if ApplicationSession is part of the model why is it acting as a "Controller-Proxy" in this case.

I think we'd like to reduce Session and Surface to real model components, and thus extract the surface coordinator from their dependencies. A caller (e.g. frontend, shell) looking to change surface state would then directly invoke the surface controller themselves.

As previously mentioned this allows for extraction of the control hierarchy from the Session and Surface dependencies (e.g. they no longer need a view of the surface controller or scene, as the external surface controller is responsible for maintaining this relationship). Furthermore it allows for a split of the implementation responsibilities in session...which currently acts as a Factory, a Model, and somewhat of a controller (or at least a controller proxy).

Obviously this is an existing problem but there is work in progress to fix it and this branch seems to be a step in the wrong direction.

review: Disapprove
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Ironic this code was ripped from the branch you said you preferred the most.

Yeah, I can see we probably can remove ApplicationSession from the code path here. Although it's hard to make any progress if every reviewer wants us to fix the whole server architecture before landing anything else. We've been on that path for 2+ years.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Apparently I forgot the details that led me to this design a couple of months ago.

Getting the SurfaceCoordinator (SurfaceController) isn't so much the problem. The issue is to use SurfaceCoordinator we want a scene::Surface. And this being the frontend, we only have frontend::Surface. So to avoid a dynamic_cast, I chose to go through ApplicationSession which is the only class that knows how to cleanly map a SurfaceId (from client messages) to scene::Surface for the SurfaceController/SurfaceCoordinator.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

This is the "wrong surface controller" so to speak.

Obviously this is an existing problem but there is work in progress to fix it and this branch seems to be a step in the wrong direction.

review: Disapprove
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

For the current implementation, it is correct surface controller...

143 +++ src/server/scene/surface_controller.h 2015-01-15 08:10:56 +0000
148 -/// Will grow up to provide synchronization of model updates

SurfaceController is the implementation of SurfaceCoordinator. There is only one surface controller interface in Mir right now, so if it's the wrong one then we're blocking waiting for another architectural overhaul that hasn't happened yet.

I appreciate Mir is not perfect, and we all want to make it better, but it's a slow journey if we keep disapproving enhancements on the basis of the foundations being wrong and needing to be replaced first. We've been repeatedly rewriting those same foundations for around 3+ years. That said, I do endorse any attempts to improve the foundations. But we can't keep blocking feature development when it's the same two people repeatedly rewriting the same foundations. It's a bit of a bottleneck for a team that's bigger than two people and most of us are asked to add new features.

As for the Session stuff above, yeah I agree that's not quite right yet. That could benefit from a further simplification of the Surface hierarchy.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

And now we have unresolvable conflicts (Alan's branch changes the same code).

Unmerged revisions

2220. By Daniel van Vugt

Merge latest trunk

2219. By Daniel van Vugt

Revert back to r2216, which at least works.

The problem is only ApplicationSession knows how to convert a SurfaceId
into a scene::Surface to pass to SurfaceCoordinator/SurfaceController.
So we go through ApplicationSession.

2218. By Daniel van Vugt

More work in progress.

Still doesn't build because the frontend doesn't (and shouldn't?) know how
to convert a frontend::Surface into a scene::Surface for SurfaceController.

2217. By Daniel van Vugt

Start removing Session from the Controller path

2216. By Daniel van Vugt

Merge latest trunk

2215. By Daniel van Vugt

Merge latest trunk

2214. By Daniel van Vugt

Merge latest trunk and fix a conflict.

2213. By Daniel van Vugt

Update sha1sums

2212. By Daniel van Vugt

Backport SurfaceController wiring from the 'states' branch, with all
WM code removed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/server/mir/frontend/session.h'
2--- include/server/mir/frontend/session.h 2014-12-28 08:33:45 +0000
3+++ include/server/mir/frontend/session.h 2015-01-15 08:10:56 +0000
4@@ -49,6 +49,7 @@
5 virtual SurfaceId create_surface(scene::SurfaceCreationParameters const& params) = 0;
6 virtual void destroy_surface(SurfaceId surface) = 0;
7 virtual std::shared_ptr<Surface> get_surface(SurfaceId surface) const = 0;
8+ virtual int configure_surface(SurfaceId, MirSurfaceAttrib, int) = 0;
9
10 virtual std::string name() const = 0;
11
12
13=== modified file 'include/server/mir/scene/surface_coordinator.h'
14--- include/server/mir/scene/surface_coordinator.h 2014-12-28 08:33:45 +0000
15+++ include/server/mir/scene/surface_coordinator.h 2015-01-15 08:10:56 +0000
16@@ -20,6 +20,7 @@
17 #ifndef MIR_SCENE_SURFACE_COORDINATOR_H_
18 #define MIR_SCENE_SURFACE_COORDINATOR_H_
19
20+#include "mir_toolkit/common.h"
21 #include <memory>
22
23 namespace mir
24@@ -39,7 +40,7 @@
25 Session* session) = 0;
26
27 virtual void raise(std::weak_ptr<Surface> const& surface) = 0;
28-
29+ virtual int configure_surface(Surface&, MirSurfaceAttrib, int) = 0;
30 virtual void remove_surface(std::weak_ptr<Surface> const& surface) = 0;
31 protected:
32 SurfaceCoordinator() = default;
33
34=== modified file 'include/server/mir/shell/surface_coordinator_wrapper.h'
35--- include/server/mir/shell/surface_coordinator_wrapper.h 2014-05-23 10:00:46 +0000
36+++ include/server/mir/shell/surface_coordinator_wrapper.h 2015-01-15 08:10:56 +0000
37@@ -35,7 +35,7 @@
38 scene::Session* session) override;
39
40 void raise(std::weak_ptr<scene::Surface> const& surface) override;
41-
42+ int configure_surface(scene::Surface&, MirSurfaceAttrib, int) override;
43 void remove_surface(std::weak_ptr<scene::Surface> const& surface) override;
44
45 protected:
46
47=== modified file 'server-ABI-sha1sums'
48--- server-ABI-sha1sums 2015-01-14 12:48:51 +0000
49+++ server-ABI-sha1sums 2015-01-15 08:10:56 +0000
50@@ -62,7 +62,7 @@
51 59d6703def2a0ff840e5eb75390a5af76fd93f58 include/server/mir/frontend/prompt_session.h
52 b729a7710c37d9f1fba56a6f8e8eae1c2559f57a include/server/mir/frontend/session_authorizer.h
53 34ce482df448fd2fc5f0c4ae5ac8b7fecbd228c9 include/server/mir/frontend/session_credentials.h
54-e5ea465ed7e05f0e1d6a837d0d6b3a04c2d7fc19 include/server/mir/frontend/session.h
55+27a64aaf03b9df6dd2a0013d36b33e65142e628b include/server/mir/frontend/session.h
56 d754e5bb057f3018d7228170cf9a0c66d75d8cc2 include/server/mir/frontend/session_mediator_report.h
57 68468aa2298c4e2cdc1bbb7cb5f250a914ae16c9 include/server/mir/frontend/shell.h
58 1b55b05c39f6b38782cd333a1726d1fa20af6cef include/server/mir/frontend/surface.h
59@@ -95,7 +95,7 @@
60 7f5f26000fd2312373817d05c488a6a950a47c82 include/server/mir/scene/snapshot.h
61 5bab4dc0a6488b8b9d47e958c6bab94f1dcf2c57 include/server/mir/scene/surface_buffer_access.h
62 bbc9e2e2bb71634cd6f1c5c0430093e10e74fa23 include/server/mir/scene/surface_configurator.h
63-e5e4dd7bcaf186810043fa0f05be42d7e49b0843 include/server/mir/scene/surface_coordinator.h
64+8cd7f2588cf721e578fbb8a7c3bf6f7ba40f2fd9 include/server/mir/scene/surface_coordinator.h
65 8e3636b736700d72520709c8a61f5e85d9231d4c include/server/mir/scene/surface_creation_parameters.h
66 7da48dbedb4430ce322a50ef8f4e93ce08bdf147 include/server/mir/scene/surface.h
67 587e22d751656ce2d9536afdf5659276ff9bbc46 include/server/mir/scene/surface_observer.h
68@@ -108,7 +108,7 @@
69 f8d415af54b4a477338fb9dbe20db01aa4544029 include/server/mir/shell/host_lifecycle_event_listener.h
70 4f50c37bb8e36a1aa4918af6aa01b0f032ed0984 include/server/mir/shell/input_targeter.h
71 de7d7ad64da45b4c5dedef8eaa1d720c9f307f4c include/server/mir/shell/session_coordinator_wrapper.h
72-18e869c5b87ab8be4bc185d2cd55a93d699cde72 include/server/mir/shell/surface_coordinator_wrapper.h
73+3c75fa2a78674029d64969e7855d10f668937bcc include/server/mir/shell/surface_coordinator_wrapper.h
74 114cc8c0b12ee4fd78d86c8f3309546e4dc68c9f include/server/mir/terminate_with_current_exception.h
75 1b8c2a763c8f5f00b737c3a187db2304676f8076 include/server/mir/time/alarm.h
76 a134c7b86e9c3b191f1004abe7bbdceed8ac42ee include/server/mir/time/timer.h
77
78=== modified file 'src/server/frontend/session_mediator.cpp'
79--- src/server/frontend/session_mediator.cpp 2015-01-14 02:35:56 +0000
80+++ src/server/frontend/session_mediator.cpp 2015-01-15 08:10:56 +0000
81@@ -388,8 +388,7 @@
82
83 auto const id = mf::SurfaceId(request->surfaceid().value());
84 int value = request->ivalue();
85- auto const surface = session->get_surface(id);
86- int newvalue = surface->configure(attrib, value);
87+ int newvalue = session->configure_surface(id, attrib, value);
88
89 response->set_ivalue(newvalue);
90 }
91
92=== modified file 'src/server/scene/application_session.cpp'
93--- src/server/scene/application_session.cpp 2014-12-28 08:33:45 +0000
94+++ src/server/scene/application_session.cpp 2015-01-15 08:10:56 +0000
95@@ -115,6 +115,15 @@
96 return checked_find(id)->second;
97 }
98
99+int ms::ApplicationSession::configure_surface(mf::SurfaceId surface_id,
100+ MirSurfaceAttrib attrib,
101+ int value)
102+{
103+ std::unique_lock<std::mutex> lock(surfaces_mutex);
104+ auto surface = checked_find(surface_id)->second;
105+ return surface_coordinator->configure_surface(*surface, attrib, value);
106+}
107+
108 void ms::ApplicationSession::take_snapshot(SnapshotCallback const& snapshot_taken)
109 {
110 if (auto surface = default_surface())
111
112=== modified file 'src/server/scene/application_session.h'
113--- src/server/scene/application_session.h 2014-12-28 08:33:45 +0000
114+++ src/server/scene/application_session.h 2015-01-15 08:10:56 +0000
115@@ -55,6 +55,7 @@
116 frontend::SurfaceId create_surface(SurfaceCreationParameters const& params) override;
117 void destroy_surface(frontend::SurfaceId surface) override;
118 std::shared_ptr<frontend::Surface> get_surface(frontend::SurfaceId surface) const override;
119+ int configure_surface(frontend::SurfaceId, MirSurfaceAttrib, int) override;
120
121 void take_snapshot(SnapshotCallback const& snapshot_taken) override;
122 std::shared_ptr<Surface> default_surface() const override;
123
124=== modified file 'src/server/scene/surface_controller.cpp'
125--- src/server/scene/surface_controller.cpp 2014-12-28 08:33:45 +0000
126+++ src/server/scene/surface_controller.cpp 2015-01-15 08:10:56 +0000
127@@ -54,3 +54,12 @@
128 {
129 surface_stack->raise(surface);
130 }
131+
132+int ms::SurfaceController::configure_surface(Surface& surface,
133+ MirSurfaceAttrib attrib,
134+ int value)
135+{
136+ // TODO: Impose some policy here
137+ return surface.configure(attrib, value);
138+}
139+
140
141=== modified file 'src/server/scene/surface_controller.h'
142--- src/server/scene/surface_controller.h 2014-12-28 08:33:45 +0000
143+++ src/server/scene/surface_controller.h 2015-01-15 08:10:56 +0000
144@@ -30,7 +30,7 @@
145 class SurfaceStackModel;
146 class SurfaceFactory;
147
148-/// Will grow up to provide synchronization of model updates
149+/// Will soon grow up to provide synchronization of model updates
150 class SurfaceController : public SurfaceCoordinator
151 {
152 public:
153@@ -47,6 +47,8 @@
154
155 void raise(std::weak_ptr<Surface> const& surface) override;
156
157+ int configure_surface(Surface&, MirSurfaceAttrib, int) override;
158+
159 private:
160 std::shared_ptr<SurfaceFactory> const surface_factory;
161 std::shared_ptr<PlacementStrategy> const placement_strategy;
162
163=== modified file 'src/server/shell/surface_coordinator_wrapper.cpp'
164--- src/server/shell/surface_coordinator_wrapper.cpp 2014-05-23 10:00:46 +0000
165+++ src/server/shell/surface_coordinator_wrapper.cpp 2015-01-15 08:10:56 +0000
166@@ -44,3 +44,10 @@
167 {
168 wrapped->remove_surface(surface);
169 }
170+
171+int msh::SurfaceCoordinatorWrapper::configure_surface(ms::Surface& surface,
172+ MirSurfaceAttrib attrib,
173+ int value)
174+{
175+ return wrapped->configure_surface(surface, attrib, value);
176+}
177
178=== modified file 'src/server/symbols.map'
179--- src/server/symbols.map 2015-01-15 07:52:30 +0000
180+++ src/server/symbols.map 2015-01-15 08:10:56 +0000
181@@ -498,6 +498,7 @@
182 mir::shell::SessionCoordinatorWrapper::stop_prompt_session*;
183 mir::shell::SurfaceCoordinatorWrapper::add_surface*;
184 mir::shell::SurfaceCoordinatorWrapper::raise*;
185+ mir::shell::SurfaceCoordinatorWrapper::configure_surface*;
186 mir::shell::SurfaceCoordinatorWrapper::remove_surface*;
187 mir::shell::SurfaceCoordinatorWrapper::SurfaceCoordinatorWrapper*;
188 mir::terminate_with_current_exception*;
189
190=== modified file 'tests/include/mir_test_doubles/mock_surface_coordinator.h'
191--- tests/include/mir_test_doubles/mock_surface_coordinator.h 2014-12-28 08:33:45 +0000
192+++ tests/include/mir_test_doubles/mock_surface_coordinator.h 2015-01-15 08:10:56 +0000
193@@ -34,7 +34,8 @@
194 struct MockSurfaceCoordinator : public scene::SurfaceCoordinator
195 {
196 MOCK_METHOD1(raise, void(std::weak_ptr<scene::Surface> const&));
197-
198+ MOCK_METHOD3(configure_surface,
199+ int(scene::Surface&, MirSurfaceAttrib, int));
200 MOCK_METHOD2(add_surface, std::shared_ptr<scene::Surface>(
201 scene::SurfaceCreationParameters const& params,
202 scene::Session* session));
203
204=== modified file 'tests/include/mir_test_doubles/stub_scene_session.h'
205--- tests/include/mir_test_doubles/stub_scene_session.h 2014-12-28 08:33:45 +0000
206+++ tests/include/mir_test_doubles/stub_scene_session.h 2015-01-15 08:10:56 +0000
207@@ -43,6 +43,11 @@
208 {
209 return std::shared_ptr<frontend::Surface>();
210 }
211+ int configure_surface(frontend::SurfaceId, MirSurfaceAttrib,
212+ int value) override
213+ {
214+ return value;
215+ }
216 std::string name() const override
217 {
218 return std::string();
219
220=== modified file 'tests/include/mir_test_doubles/stub_session.h'
221--- tests/include/mir_test_doubles/stub_session.h 2014-12-28 08:33:45 +0000
222+++ tests/include/mir_test_doubles/stub_session.h 2015-01-15 08:10:56 +0000
223@@ -41,6 +41,11 @@
224 {
225 return std::shared_ptr<frontend::Surface>();
226 }
227+ int configure_surface(frontend::SurfaceId, MirSurfaceAttrib,
228+ int value) override
229+ {
230+ return value;
231+ }
232 std::string name() const override
233 {
234 return std::string();
235
236=== modified file 'tests/unit-tests/scene/test_application_session.cpp'
237--- tests/unit-tests/scene/test_application_session.cpp 2014-12-28 08:33:45 +0000
238+++ tests/unit-tests/scene/test_application_session.cpp 2015-01-15 08:10:56 +0000
239@@ -89,6 +89,10 @@
240 void remove_surface(std::weak_ptr<ms::Surface> const&) override
241 {
242 }
243+ int configure_surface(ms::Surface&, MirSurfaceAttrib, int val) override
244+ {
245+ return val;
246+ }
247 };
248
249 struct ApplicationSession : public testing::Test

Subscribers

People subscribed via source and target branches