Mir

Merge lp:~alan-griffiths/mir/eliminate-shell-SurfaceFactory-and-Surface into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1535
Proposed branch: lp:~alan-griffiths/mir/eliminate-shell-SurfaceFactory-and-Surface
Merge into: lp:mir
Prerequisite: lp:~alan-griffiths/mir/make-use-of-scene-Surface
Diff against target: 1800 lines (+251/-544)
41 files modified
examples/demo-shell/window_manager.cpp (+2/-2)
examples/render_surfaces.cpp (+3/-3)
include/server/mir/default_server_configuration.h (+0/-2)
include/server/mir/scene/surface.h (+28/-10)
include/server/mir/scene/surface_coordinator.h (+3/-0)
include/server/mir/shell/null_session_listener.h (+2/-2)
include/server/mir/shell/session.h (+3/-3)
include/server/mir/shell/session_listener.h (+3/-3)
include/server/mir/shell/surface.h (+0/-62)
include/server/mir/shell/surface_factory.h (+0/-52)
include/test/mir_test_doubles/mock_session_listener.h (+2/-2)
include/test/mir_test_doubles/mock_shell_session.h (+1/-1)
include/test/mir_test_doubles/mock_surface.h (+0/-1)
include/test/mir_test_doubles/mock_surface_coordinator.h (+2/-1)
include/test/mir_test_doubles/mock_surface_factory.h (+0/-48)
include/test/mir_test_doubles/stub_shell_session.h (+2/-2)
src/server/scene/application_session.cpp (+9/-9)
src/server/scene/application_session.h (+4/-4)
src/server/scene/default_configuration.cpp (+2/-1)
src/server/scene/session_manager.cpp (+4/-5)
src/server/scene/session_manager.h (+3/-3)
src/server/scene/surface_controller.cpp (+8/-2)
src/server/scene/surface_controller.h (+5/-0)
src/server/shell/CMakeLists.txt (+0/-1)
src/server/shell/default_configuration.cpp (+0/-13)
src/server/shell/default_focus_mechanism.cpp (+1/-1)
src/server/shell/default_focus_mechanism.h (+2/-3)
src/server/shell/organising_surface_factory.cpp (+0/-56)
src/server/shell/organising_surface_factory.h (+0/-61)
tests/acceptance-tests/test_client_input.cpp (+20/-16)
tests/acceptance-tests/test_focus_selection.cpp (+0/-1)
tests/integration-tests/graphics/android/test_internal_client.cpp (+14/-3)
tests/integration-tests/test_session.cpp (+2/-2)
tests/integration-tests/test_session_manager.cpp (+3/-3)
tests/unit-tests/frontend/test_session_mediator.cpp (+0/-1)
tests/unit-tests/scene/test_application_session.cpp (+34/-36)
tests/unit-tests/scene/test_default_focus_mechanism.cpp (+1/-2)
tests/unit-tests/scene/test_session_manager.cpp (+11/-11)
tests/unit-tests/scene/test_surface_controller.cpp (+77/-13)
tests/unit-tests/shell/CMakeLists.txt (+0/-1)
tests/unit-tests/shell/test_organising_surface_factory.cpp (+0/-102)
To merge this branch: bzr merge lp:~alan-griffiths/mir/eliminate-shell-SurfaceFactory-and-Surface
Reviewer Review Type Date Requested Status
Andreas Pokorny (community) Approve
Gerry Boland (community) functional Approve
Alexandros Frantzis (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+214041@code.launchpad.net

Commit message

shell: Eliminate shell::SurfaceFactory and shell::Surface and use scene::SurfaceCoordinator and scene::Surface instead

Description of the change

shell: Eliminate shell::SurfaceFactory and shell::Surface and use scene::SurfaceCoordinator and scene::Surface instead

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

"Build was aborted
"Aborted by Paul Larson"

Rebuilding

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
Alan Griffiths (alan-griffiths) wrote :

The corresponding platform-api changes are here: lp:~alan-griffiths/platform-api/compatibility-with-proposed-mir-changes

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve
Revision history for this message
Gerry Boland (gerboland) wrote :

+1 from me

review: Approve (functional)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/demo-shell/window_manager.cpp'
2--- examples/demo-shell/window_manager.cpp 2014-03-26 05:48:59 +0000
3+++ examples/demo-shell/window_manager.cpp 2014-04-04 08:28:33 +0000
4@@ -21,7 +21,7 @@
5
6 #include "mir/shell/focus_controller.h"
7 #include "mir/shell/session.h"
8-#include "mir/shell/surface.h"
9+#include "mir/scene/surface.h"
10 #include "mir/graphics/display.h"
11 #include "mir/graphics/display_configuration.h"
12 #include "mir/compositor/compositor.h"
13@@ -207,7 +207,7 @@
14 {
15 // FIXME: We need to be able to select individual surfaces in
16 // future and not just the "default" one.
17- std::shared_ptr<msh::Surface> surf = app->default_surface();
18+ auto const surf = app->default_surface();
19
20 if (surf &&
21 (event.motion.modifiers & mir_key_modifier_alt ||
22
23=== modified file 'examples/render_surfaces.cpp'
24--- examples/render_surfaces.cpp 2014-03-28 17:47:07 +0000
25+++ examples/render_surfaces.cpp 2014-04-04 08:28:33 +0000
26@@ -30,7 +30,6 @@
27 #include "mir/graphics/display.h"
28 #include "mir/graphics/display_buffer.h"
29 #include "mir/graphics/gl_context.h"
30-#include "mir/shell/surface_factory.h"
31 #include "mir/scene/surface.h"
32 #include "mir/scene/surface_coordinator.h"
33 #include "mir/run_mir.h"
34@@ -195,7 +194,7 @@
35 {
36 public:
37 Moveable() {}
38- Moveable(std::shared_ptr<msh::Surface> const& s, const geom::Size& display_size,
39+ Moveable(std::shared_ptr<ms::Surface> const& s, const geom::Size& display_size,
40 float dx, float dy, const glm::vec3& rotation_axis, float alpha_offset)
41 : surface(s), display_size(display_size),
42 x{static_cast<float>(s->top_left().x.as_uint32_t())},
43@@ -251,7 +250,7 @@
44 }
45
46 private:
47- std::shared_ptr<msh::Surface> surface;
48+ std::shared_ptr<ms::Surface> surface;
49 geom::Size display_size;
50 float x;
51 float y;
52@@ -469,6 +468,7 @@
53 msh::a_surface().of_size(surface_size)
54 .of_pixel_format(surface_pf)
55 .of_buffer_usage(mg::BufferUsage::hardware),
56+ nullptr,
57 {});
58
59 /*
60
61=== modified file 'include/server/mir/default_server_configuration.h'
62--- include/server/mir/default_server_configuration.h 2014-04-02 16:39:12 +0000
63+++ include/server/mir/default_server_configuration.h 2014-04-04 08:28:33 +0000
64@@ -199,7 +199,6 @@
65 /** @name shell configuration - customization
66 * configurable interfaces for modifying shell
67 * @{ */
68- virtual std::shared_ptr<shell::SurfaceFactory> the_shell_surface_factory();
69 virtual std::shared_ptr<shell::FocusSetter> the_shell_focus_setter();
70 virtual std::shared_ptr<shell::PlacementStrategy> the_shell_placement_strategy();
71 virtual std::shared_ptr<shell::SessionListener> the_shell_session_listener();
72@@ -285,7 +284,6 @@
73 CachedPtr<scene::SurfaceStack> surface_stack;
74 CachedPtr<scene::SceneReport> scene_report;
75
76- CachedPtr<shell::SurfaceFactory> shell_surface_factory;
77 CachedPtr<scene::SurfaceFactory> surface_factory;
78 CachedPtr<scene::SessionContainer> session_container;
79 CachedPtr<shell::FocusSetter> shell_focus_setter;
80
81=== modified file 'include/server/mir/scene/surface.h'
82--- include/server/mir/scene/surface.h 2014-03-31 16:51:06 +0000
83+++ include/server/mir/scene/surface.h 2014-04-04 08:28:33 +0000
84@@ -21,11 +21,16 @@
85
86 #include "mir/graphics/renderable.h"
87 #include "mir/input/surface.h"
88-#include "mir/shell/surface.h"
89+#include "mir/shell/surface_buffer_access.h"
90+#include "mir/frontend/surface.h"
91+
92+#include <vector>
93
94 namespace mir
95 {
96 namespace input { class InputChannel; }
97+namespace shell { class InputTargeter; }
98+namespace geometry { class Rectangle; }
99
100 namespace scene
101 {
102@@ -34,23 +39,36 @@
103 class Surface :
104 public graphics::Renderable,
105 public input::Surface,
106- public shell::Surface
107+ public frontend::Surface,
108+ public shell::SurfaceBufferAccess
109 {
110 public:
111 // resolve ambiguous member function names
112- std::string name() const = 0;
113- geometry::Size size() const = 0;
114- geometry::Point top_left() const = 0;
115- float alpha() const = 0;
116+ std::string name() const override = 0;
117+ geometry::Size size() const override = 0;
118+ geometry::Point top_left() const override = 0;
119+ float alpha() const override = 0;
120
121 // member functions that don't exist in base classes
122- // TODO input_channel() and on_change() relate to
123- // TODO adding and removing the surface from the scene and are probably not
124- // TODO cleanest interface for this.
125- virtual std::shared_ptr<input::InputChannel> input_channel() const = 0;
126+ virtual MirSurfaceType type() const = 0;
127+ virtual MirSurfaceState state() const = 0;
128+ virtual void hide() = 0;
129+ virtual void show() = 0;
130+ virtual void move_to(geometry::Point const& top_left) = 0;
131+ virtual void take_input_focus(std::shared_ptr<shell::InputTargeter> const& targeter) = 0;
132+ virtual void set_input_region(std::vector<geometry::Rectangle> const& region) = 0;
133+ virtual void allow_framedropping(bool) = 0;
134+ virtual void resize(geometry::Size const& size) = 0;
135+ virtual void set_transformation(glm::mat4 const& t) = 0;
136+ virtual void set_alpha(float alpha) = 0;
137+ virtual void force_requests_to_complete() = 0;
138
139 virtual void add_observer(std::shared_ptr<SurfaceObserver> const& observer) = 0;
140 virtual void remove_observer(std::shared_ptr<SurfaceObserver> const& observer) = 0;
141+
142+ // TODO input_channel() relates to adding and removing the surface
143+ // TODO from the scene and is probably not cleanest interface for this.
144+ virtual std::shared_ptr<input::InputChannel> input_channel() const = 0;
145 };
146 }
147 }
148
149=== modified file 'include/server/mir/scene/surface_coordinator.h'
150--- include/server/mir/scene/surface_coordinator.h 2014-04-02 16:39:12 +0000
151+++ include/server/mir/scene/surface_coordinator.h 2014-04-04 08:28:33 +0000
152@@ -26,11 +26,13 @@
153 {
154 namespace shell
155 {
156+struct Session;
157 struct SurfaceCreationParameters;
158 }
159
160 namespace scene
161 {
162+using shell::Session;
163 class Surface;
164 class SurfaceObserver;
165
166@@ -39,6 +41,7 @@
167 public:
168 virtual std::shared_ptr<Surface> add_surface(
169 shell::SurfaceCreationParameters const& params,
170+ Session* session,
171 std::shared_ptr<SurfaceObserver> const& observer) = 0;
172
173 virtual void raise(std::weak_ptr<Surface> const& surface) = 0;
174
175=== modified file 'include/server/mir/shell/null_session_listener.h'
176--- include/server/mir/shell/null_session_listener.h 2013-08-28 03:41:48 +0000
177+++ include/server/mir/shell/null_session_listener.h 2014-04-04 08:28:33 +0000
178@@ -38,8 +38,8 @@
179 void focused(std::shared_ptr<Session> const&) override {}
180 void unfocused() override {}
181
182- void surface_created(Session&, std::shared_ptr<Surface> const&) override {}
183- void destroying_surface(Session&, std::shared_ptr<Surface> const&) override {}
184+ void surface_created(Session&, std::shared_ptr<scene::Surface> const&) override {}
185+ void destroying_surface(Session&, std::shared_ptr<scene::Surface> const&) override {}
186
187 protected:
188 NullSessionListener(const NullSessionListener&) = delete;
189
190=== modified file 'include/server/mir/shell/session.h'
191--- include/server/mir/shell/session.h 2014-04-02 14:12:58 +0000
192+++ include/server/mir/shell/session.h 2014-04-04 08:28:33 +0000
193@@ -26,10 +26,10 @@
194
195 namespace mir
196 {
197+namespace scene { class Surface; }
198+
199 namespace shell
200 {
201-class Surface;
202-
203 class Session : public frontend::Session
204 {
205 public:
206@@ -37,7 +37,7 @@
207 virtual pid_t process_id() const = 0;
208
209 virtual void take_snapshot(SnapshotCallback const& snapshot_taken) = 0;
210- virtual std::shared_ptr<Surface> default_surface() const = 0;
211+ virtual std::shared_ptr<scene::Surface> default_surface() const = 0;
212 virtual void set_lifecycle_state(MirLifecycleState state) = 0;
213 virtual void send_display_config(graphics::DisplayConfiguration const&) = 0;
214 };
215
216=== modified file 'include/server/mir/shell/session_listener.h'
217--- include/server/mir/shell/session_listener.h 2014-03-06 06:05:17 +0000
218+++ include/server/mir/shell/session_listener.h 2014-04-04 08:28:33 +0000
219@@ -23,10 +23,10 @@
220
221 namespace mir
222 {
223+namespace scene { class Surface; }
224 namespace shell
225 {
226 class Session;
227-class Surface;
228
229 class SessionListener
230 {
231@@ -36,8 +36,8 @@
232 virtual void focused(std::shared_ptr<Session> const& session) = 0;
233 virtual void unfocused() = 0;
234
235- virtual void surface_created(Session& session, std::shared_ptr<Surface> const& surface) = 0;
236- virtual void destroying_surface(Session& session, std::shared_ptr<Surface> const& surface) = 0;
237+ virtual void surface_created(Session& session, std::shared_ptr<scene::Surface> const& surface) = 0;
238+ virtual void destroying_surface(Session& session, std::shared_ptr<scene::Surface> const& surface) = 0;
239
240 protected:
241 SessionListener() = default;
242
243=== removed file 'include/server/mir/shell/surface.h'
244--- include/server/mir/shell/surface.h 2014-04-02 16:39:12 +0000
245+++ include/server/mir/shell/surface.h 1970-01-01 00:00:00 +0000
246@@ -1,62 +0,0 @@
247-/*
248- * Copyright © 2013 Canonical Ltd.
249- *
250- * This program is free software: you can redistribute it and/or modify it
251- * under the terms of the GNU General Public License version 3,
252- * as published by the Free Software Foundation.
253- *
254- * This program is distributed in the hope that it will be useful,
255- * but WITHOUT ANY WARRANTY; without even the implied warranty of
256- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
257- * GNU General Public License for more details.
258- *
259- * You should have received a copy of the GNU General Public License
260- * along with this program. If not, see <http://www.gnu.org/licenses/>.
261- *
262- * Authored by: Alan Griffiths <alan@octopull.co.uk>
263- */
264-
265-
266-#ifndef MIR_SHELL_SURFACE_H_
267-#define MIR_SHELL_SURFACE_H_
268-
269-#include "mir/shell/surface_buffer_access.h"
270-#include "mir/geometry/rectangle.h"
271-#include "mir/frontend/surface.h"
272-
273-#include <string>
274-#include <vector>
275-
276-namespace mir
277-{
278-namespace shell
279-{
280-class InputTargeter;
281-
282-class Surface : public frontend::Surface, public shell::SurfaceBufferAccess
283-{
284-public:
285- virtual std::string name() const = 0;
286- virtual MirSurfaceType type() const = 0;
287- virtual MirSurfaceState state() const = 0;
288- virtual void hide() = 0;
289- virtual void show() = 0;
290- virtual void move_to(geometry::Point const& top_left) = 0;
291- virtual geometry::Point top_left() const = 0;
292-
293- virtual void take_input_focus(std::shared_ptr<InputTargeter> const& targeter) = 0;
294- virtual void set_input_region(std::vector<geometry::Rectangle> const& region) = 0;
295-
296- virtual void allow_framedropping(bool) = 0;
297-
298- virtual void resize(geometry::Size const& size) = 0;
299- virtual void set_transformation(glm::mat4 const& t) = 0;
300-
301- virtual float alpha() const = 0;
302- virtual void set_alpha(float alpha) = 0;
303- virtual void force_requests_to_complete() = 0;
304-};
305-}
306-}
307-
308-#endif /* MIR_SHELL_SURFACE_H_ */
309
310=== removed file 'include/server/mir/shell/surface_factory.h'
311--- include/server/mir/shell/surface_factory.h 2014-04-02 17:38:24 +0000
312+++ include/server/mir/shell/surface_factory.h 1970-01-01 00:00:00 +0000
313@@ -1,52 +0,0 @@
314-/*
315- * Copyright © 2012-2014 Canonical Ltd.
316- *
317- * This program is free software: you can redistribute it and/or modify it
318- * under the terms of the GNU General Public License version 3,
319- * as published by the Free Software Foundation.
320- *
321- * This program is distributed in the hope that it will be useful,
322- * but WITHOUT ANY WARRANTY; without even the implied warranty of
323- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
324- * GNU General Public License for more details.
325- *
326- * You should have received a copy of the GNU General Public License
327- * along with this program. If not, see <http://www.gnu.org/licenses/>.
328- *
329- * Authored by: Thomas Voss <thomas.voss@canonical.com>
330- */
331-
332-#ifndef MIR_SHELL_SURFACE_FACTORY_H_
333-#define MIR_SHELL_SURFACE_FACTORY_H_
334-
335-#include <memory>
336-
337-namespace mir
338-{
339-namespace scene { class SurfaceObserver; class Surface; }
340-
341-namespace shell
342-{
343-class Session;
344-struct SurfaceCreationParameters;
345-
346-class SurfaceFactory
347-{
348-public:
349- virtual std::shared_ptr<scene::Surface> create_surface(
350- Session* session,
351- SurfaceCreationParameters const& params,
352- std::shared_ptr<scene::SurfaceObserver> const& observer) = 0;
353-
354- virtual void destroy_surface(std::shared_ptr<scene::Surface> const& surface) = 0;
355-
356-protected:
357- virtual ~SurfaceFactory() {}
358- SurfaceFactory() = default;
359- SurfaceFactory(const SurfaceFactory&) = delete;
360- SurfaceFactory& operator=(const SurfaceFactory&) = delete;
361-};
362-}
363-}
364-
365-#endif // MIR_SHELL_SURFACE_FACTORY_H_
366
367=== modified file 'include/test/mir_test_doubles/mock_session_listener.h'
368--- include/test/mir_test_doubles/mock_session_listener.h 2014-03-06 06:05:17 +0000
369+++ include/test/mir_test_doubles/mock_session_listener.h 2014-04-04 08:28:33 +0000
370@@ -39,8 +39,8 @@
371 MOCK_METHOD1(focused, void(std::shared_ptr<shell::Session> const&));
372 MOCK_METHOD0(unfocused, void());
373
374- MOCK_METHOD2(surface_created, void(shell::Session&, std::shared_ptr<shell::Surface> const&));
375- MOCK_METHOD2(destroying_surface, void(shell::Session&, std::shared_ptr<shell::Surface> const&));
376+ MOCK_METHOD2(surface_created, void(shell::Session&, std::shared_ptr<scene::Surface> const&));
377+ MOCK_METHOD2(destroying_surface, void(shell::Session&, std::shared_ptr<scene::Surface> const&));
378 };
379
380 }
381
382=== modified file 'include/test/mir_test_doubles/mock_shell_session.h'
383--- include/test/mir_test_doubles/mock_shell_session.h 2014-03-06 06:05:17 +0000
384+++ include/test/mir_test_doubles/mock_shell_session.h 2014-04-04 08:28:33 +0000
385@@ -39,7 +39,7 @@
386 MOCK_CONST_METHOD1(get_surface, std::shared_ptr<frontend::Surface>(frontend::SurfaceId));
387
388 MOCK_METHOD1(take_snapshot, void(shell::SnapshotCallback const&));
389- MOCK_CONST_METHOD0(default_surface, std::shared_ptr<shell::Surface>());
390+ MOCK_CONST_METHOD0(default_surface, std::shared_ptr<scene::Surface>());
391
392 MOCK_CONST_METHOD0(name, std::string());
393 MOCK_CONST_METHOD0(process_id, pid_t());
394
395=== modified file 'include/test/mir_test_doubles/mock_surface.h'
396--- include/test/mir_test_doubles/mock_surface.h 2014-04-02 16:39:12 +0000
397+++ include/test/mir_test_doubles/mock_surface.h 2014-04-04 08:28:33 +0000
398@@ -49,7 +49,6 @@
399
400 MOCK_METHOD0(hide, void());
401 MOCK_METHOD0(show, void());
402- MOCK_METHOD0(visible, bool());
403
404 MOCK_METHOD0(force_requests_to_complete, void());
405 MOCK_METHOD0(advance_client_buffer, std::shared_ptr<graphics::Buffer>());
406
407=== modified file 'include/test/mir_test_doubles/mock_surface_coordinator.h'
408--- include/test/mir_test_doubles/mock_surface_coordinator.h 2014-04-02 16:39:12 +0000
409+++ include/test/mir_test_doubles/mock_surface_coordinator.h 2014-04-04 08:28:33 +0000
410@@ -35,8 +35,9 @@
411 {
412 MOCK_METHOD1(raise, void(std::weak_ptr<scene::Surface> const&));
413
414- MOCK_METHOD2(add_surface, std::shared_ptr<scene::Surface>(
415+ MOCK_METHOD3(add_surface, std::shared_ptr<scene::Surface>(
416 shell::SurfaceCreationParameters const& params,
417+ scene::Session* session,
418 std::shared_ptr<scene::SurfaceObserver> const& observer));
419
420 MOCK_METHOD1(remove_surface, void(std::weak_ptr<scene::Surface> const& surface));
421
422=== removed file 'include/test/mir_test_doubles/mock_surface_factory.h'
423--- include/test/mir_test_doubles/mock_surface_factory.h 2014-04-02 17:38:24 +0000
424+++ include/test/mir_test_doubles/mock_surface_factory.h 1970-01-01 00:00:00 +0000
425@@ -1,48 +0,0 @@
426-/*
427- * Copyright © 2012 Canonical Ltd.
428- *
429- * This program is free software: you can redistribute it and/or modify it
430- * under the terms of the GNU General Public License version 3,
431- * as published by the Free Software Foundation.
432- *
433- * This program is distributed in the hope that it will be useful,
434- * but WITHOUT ANY WARRANTY; without even the implied warranty of
435- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
436- * GNU General Public License for more details.
437- *
438- * You should have received a copy of the GNU General Public License
439- * along with this program. If not, see <http://www.gnu.org/licenses/>.
440- *
441- * Authored by: Robert Carr <robert.carr@canonical.com>
442- */
443-
444-#ifndef MIR_TEST_DOUBLES_MOCK_SURFACE_FACTORY_H_
445-#define MIR_TEST_DOUBLES_MOCK_SURFACE_FACTORY_H_
446-
447-#include "mir/shell/surface_factory.h"
448-
449-#include <gmock/gmock.h>
450-#include <gtest/gtest.h>
451-
452-namespace mir
453-{
454-namespace test
455-{
456-namespace doubles
457-{
458-
459-struct MockSurfaceFactory : public shell::SurfaceFactory
460-{
461- MOCK_METHOD3(create_surface, std::shared_ptr<scene::Surface>(
462- shell::Session*,
463- const shell::SurfaceCreationParameters&,
464- std::shared_ptr<scene::SurfaceObserver> const&));
465-
466- void destroy_surface(std::shared_ptr<scene::Surface> const& /*surface*/) override {}
467-};
468-
469-}
470-}
471-}
472-
473-#endif // MIR_TEST_DOUBLES_MOCK_SURFACE_FACTORY_H_
474
475=== modified file 'include/test/mir_test_doubles/stub_shell_session.h'
476--- include/test/mir_test_doubles/stub_shell_session.h 2014-04-02 14:37:28 +0000
477+++ include/test/mir_test_doubles/stub_shell_session.h 2014-04-04 08:28:33 +0000
478@@ -68,9 +68,9 @@
479 {
480 }
481
482- std::shared_ptr<shell::Surface> default_surface() const override
483+ std::shared_ptr<scene::Surface> default_surface() const override
484 {
485- return std::shared_ptr<shell::Surface>();
486+ return std::shared_ptr<scene::Surface>();
487 }
488
489 void set_lifecycle_state(MirLifecycleState /*state*/)
490
491=== modified file 'src/server/scene/application_session.cpp'
492--- src/server/scene/application_session.cpp 2014-04-04 00:10:49 +0000
493+++ src/server/scene/application_session.cpp 2014-04-04 08:28:33 +0000
494@@ -19,7 +19,7 @@
495 #include "application_session.h"
496 #include "mir/scene/surface.h"
497 #include "mir/scene/surface_event_source.h"
498-#include "mir/shell/surface_factory.h"
499+#include "mir/scene/surface_coordinator.h"
500 #include "snapshot_strategy.h"
501 #include "mir/shell/session_listener.h"
502 #include "mir/frontend/event_sink.h"
503@@ -37,13 +37,13 @@
504 namespace mg = mir::graphics;
505
506 ms::ApplicationSession::ApplicationSession(
507- std::shared_ptr<msh::SurfaceFactory> const& surface_factory,
508+ std::shared_ptr<ms::SurfaceCoordinator> const& surface_coordinator,
509 pid_t pid,
510 std::string const& session_name,
511 std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
512 std::shared_ptr<msh::SessionListener> const& session_listener,
513 std::shared_ptr<mf::EventSink> const& sink) :
514- surface_factory(surface_factory),
515+ surface_coordinator(surface_coordinator),
516 pid(pid),
517 session_name(session_name),
518 snapshot_strategy(snapshot_strategy),
519@@ -51,7 +51,7 @@
520 event_sink(sink),
521 next_surface_id(0)
522 {
523- assert(surface_factory);
524+ assert(surface_coordinator);
525 }
526
527 ms::ApplicationSession::~ApplicationSession()
528@@ -60,7 +60,7 @@
529 for (auto const& pair_id_surface : surfaces)
530 {
531 session_listener->destroying_surface(*this, pair_id_surface.second);
532- surface_factory->destroy_surface(pair_id_surface.second);
533+ surface_coordinator->remove_surface(pair_id_surface.second);
534 }
535 }
536
537@@ -74,7 +74,7 @@
538 auto const id = next_id();
539
540 auto const observer = std::make_shared<scene::SurfaceEventSource>(id, event_sink);
541- auto surf = surface_factory->create_surface(this, params, observer);
542+ auto surf = surface_coordinator->add_surface(params, this, observer);
543
544 std::unique_lock<std::mutex> lock(surfaces_mutex);
545 surfaces[id] = surf;
546@@ -109,14 +109,14 @@
547 snapshot_taken(msh::Snapshot());
548 }
549
550-std::shared_ptr<msh::Surface> ms::ApplicationSession::default_surface() const
551+std::shared_ptr<ms::Surface> ms::ApplicationSession::default_surface() const
552 {
553 std::unique_lock<std::mutex> lock(surfaces_mutex);
554
555 if (surfaces.size())
556 return surfaces.begin()->second;
557 else
558- return std::shared_ptr<msh::Surface>();
559+ return std::shared_ptr<ms::Surface>();
560 }
561
562 void ms::ApplicationSession::destroy_surface(mf::SurfaceId id)
563@@ -130,7 +130,7 @@
564 surfaces.erase(p);
565 lock.unlock();
566
567- surface_factory->destroy_surface(surface);
568+ surface_coordinator->remove_surface(surface);
569 }
570
571 std::string ms::ApplicationSession::name() const
572
573=== modified file 'src/server/scene/application_session.h'
574--- src/server/scene/application_session.h 2014-04-04 00:10:49 +0000
575+++ src/server/scene/application_session.h 2014-04-04 08:28:33 +0000
576@@ -31,20 +31,20 @@
577 }
578 namespace shell
579 {
580-class SurfaceFactory;
581 class SessionListener;
582 }
583
584 namespace scene
585 {
586 class Surface;
587+class SurfaceCoordinator;
588 class SnapshotStrategy;
589
590 class ApplicationSession : public shell::Session
591 {
592 public:
593 ApplicationSession(
594- std::shared_ptr<shell::SurfaceFactory> const& surface_factory,
595+ std::shared_ptr<SurfaceCoordinator> const& surface_coordinator,
596 pid_t pid,
597 std::string const& session_name,
598 std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
599@@ -58,7 +58,7 @@
600 std::shared_ptr<frontend::Surface> get_surface(frontend::SurfaceId surface) const;
601
602 void take_snapshot(shell::SnapshotCallback const& snapshot_taken);
603- std::shared_ptr<shell::Surface> default_surface() const;
604+ std::shared_ptr<Surface> default_surface() const;
605
606 std::string name() const;
607 pid_t process_id() const override;
608@@ -77,7 +77,7 @@
609 ApplicationSession& operator=(ApplicationSession const&) = delete;
610
611 private:
612- std::shared_ptr<shell::SurfaceFactory> const surface_factory;
613+ std::shared_ptr<SurfaceCoordinator> const surface_coordinator;
614 pid_t const pid;
615 std::string const session_name;
616 std::shared_ptr<SnapshotStrategy> const snapshot_strategy;
617
618=== modified file 'src/server/scene/default_configuration.cpp'
619--- src/server/scene/default_configuration.cpp 2014-04-02 16:39:12 +0000
620+++ src/server/scene/default_configuration.cpp 2014-04-04 08:28:33 +0000
621@@ -99,6 +99,7 @@
622 {
623 return std::make_shared<ms::SurfaceController>(
624 the_surface_factory(),
625+ the_shell_placement_strategy(),
626 the_surface_stack_model());
627 });
628 }
629@@ -183,7 +184,7 @@
630 [this]() -> std::shared_ptr<ms::SessionManager>
631 {
632 return std::make_shared<ms::SessionManager>(
633- the_shell_surface_factory(),
634+ the_surface_coordinator(),
635 the_session_container(),
636 the_shell_focus_setter(),
637 the_snapshot_strategy(),
638
639=== modified file 'src/server/scene/session_manager.cpp'
640--- src/server/scene/session_manager.cpp 2014-03-06 06:05:17 +0000
641+++ src/server/scene/session_manager.cpp 2014-04-04 08:28:33 +0000
642@@ -19,10 +19,9 @@
643 #include "session_manager.h"
644 #include "application_session.h"
645 #include "session_container.h"
646-#include "mir/shell/surface_factory.h"
647+#include "mir/scene/surface_coordinator.h"
648 #include "mir/shell/focus_setter.h"
649 #include "mir/shell/session.h"
650-#include "mir/shell/surface.h"
651 #include "mir/shell/session_listener.h"
652 #include "session_event_sink.h"
653
654@@ -34,13 +33,13 @@
655 namespace ms = mir::scene;
656 namespace msh = mir::shell;
657
658-ms::SessionManager::SessionManager(std::shared_ptr<msh::SurfaceFactory> const& surface_factory,
659+ms::SessionManager::SessionManager(std::shared_ptr<SurfaceCoordinator> const& surface_factory,
660 std::shared_ptr<SessionContainer> const& container,
661 std::shared_ptr<msh::FocusSetter> const& focus_setter,
662 std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
663 std::shared_ptr<SessionEventSink> const& session_event_sink,
664 std::shared_ptr<msh::SessionListener> const& session_listener) :
665- surface_factory(surface_factory),
666+ surface_coordinator(surface_factory),
667 app_container(container),
668 focus_setter(focus_setter),
669 snapshot_strategy(snapshot_strategy),
670@@ -80,7 +79,7 @@
671 {
672 std::shared_ptr<msh::Session> new_session =
673 std::make_shared<ApplicationSession>(
674- surface_factory, client_pid, name, snapshot_strategy, session_listener, sender);
675+ surface_coordinator, client_pid, name, snapshot_strategy, session_listener, sender);
676
677 app_container->insert_session(new_session);
678
679
680=== modified file 'src/server/scene/session_manager.h'
681--- src/server/scene/session_manager.h 2014-03-06 06:05:17 +0000
682+++ src/server/scene/session_manager.h 2014-04-04 08:28:33 +0000
683@@ -32,7 +32,6 @@
684
685 namespace shell
686 {
687-class SurfaceFactory;
688 class FocusSetter;
689 class SessionListener;
690 }
691@@ -42,11 +41,12 @@
692 class SessionEventSink;
693 class SessionContainer;
694 class SnapshotStrategy;
695+class SurfaceCoordinator;
696
697 class SessionManager : public frontend::Shell, public shell::FocusController
698 {
699 public:
700- explicit SessionManager(std::shared_ptr<shell::SurfaceFactory> const& surface_factory,
701+ explicit SessionManager(std::shared_ptr<SurfaceCoordinator> const& surface_coordinator,
702 std::shared_ptr<SessionContainer> const& app_container,
703 std::shared_ptr<shell::FocusSetter> const& focus_setter,
704 std::shared_ptr<SnapshotStrategy> const& snapshot_strategy,
705@@ -75,7 +75,7 @@
706 SessionManager& operator=(const SessionManager&) = delete;
707
708 private:
709- std::shared_ptr<shell::SurfaceFactory> const surface_factory;
710+ std::shared_ptr<SurfaceCoordinator> const surface_coordinator;
711 std::shared_ptr<SessionContainer> const app_container;
712 std::shared_ptr<shell::FocusSetter> const focus_setter;
713 std::shared_ptr<SnapshotStrategy> const snapshot_strategy;
714
715=== modified file 'src/server/scene/surface_controller.cpp'
716--- src/server/scene/surface_controller.cpp 2014-03-31 10:18:49 +0000
717+++ src/server/scene/surface_controller.cpp 2014-04-04 08:28:33 +0000
718@@ -20,25 +20,31 @@
719 #include "surface_stack_model.h"
720 #include "mir/scene/surface_factory.h"
721 #include "mir/scene/surface.h"
722+#include "mir/shell/placement_strategy.h"
723
724 namespace ms = mir::scene;
725 namespace msh = mir::shell;
726
727 ms::SurfaceController::SurfaceController(
728 std::shared_ptr<SurfaceFactory> const& surface_factory,
729+ std::shared_ptr<msh::PlacementStrategy> const& placement_strategy,
730 std::shared_ptr<SurfaceStackModel> const& surface_stack) :
731 surface_factory(surface_factory),
732+ placement_strategy(placement_strategy),
733 surface_stack(surface_stack)
734 {
735 }
736
737 std::shared_ptr<ms::Surface> ms::SurfaceController::add_surface(
738 shell::SurfaceCreationParameters const& params,
739+ Session* session,
740 std::shared_ptr<SurfaceObserver> const& observer)
741 {
742- auto const surface = surface_factory->create_surface(params);
743+ auto placed_params = placement_strategy->place(*session, params);
744+
745+ auto const surface = surface_factory->create_surface(placed_params);
746 surface->add_observer(observer);
747- surface_stack->add_surface(surface, params.depth, params.input_mode);
748+ surface_stack->add_surface(surface, placed_params.depth, placed_params.input_mode);
749 return surface;
750 }
751
752
753=== modified file 'src/server/scene/surface_controller.h'
754--- src/server/scene/surface_controller.h 2014-03-28 17:47:07 +0000
755+++ src/server/scene/surface_controller.h 2014-04-04 08:28:33 +0000
756@@ -24,6 +24,8 @@
757
758 namespace mir
759 {
760+namespace shell { class PlacementStrategy; }
761+
762 namespace scene
763 {
764 class SurfaceStackModel;
765@@ -35,10 +37,12 @@
766 public:
767 SurfaceController(
768 std::shared_ptr<SurfaceFactory> const& surface_factory,
769+ std::shared_ptr<shell::PlacementStrategy> const& placement_strategy,
770 std::shared_ptr<SurfaceStackModel> const& surface_stack);
771
772 std::shared_ptr<Surface> add_surface(
773 shell::SurfaceCreationParameters const& params,
774+ Session* session,
775 std::shared_ptr<SurfaceObserver> const& observer) override;
776
777 void remove_surface(std::weak_ptr<Surface> const& surface) override;
778@@ -47,6 +51,7 @@
779
780 private:
781 std::shared_ptr<SurfaceFactory> const surface_factory;
782+ std::shared_ptr<shell::PlacementStrategy> const placement_strategy;
783 std::shared_ptr<SurfaceStackModel> const surface_stack;
784 };
785
786
787=== modified file 'src/server/shell/CMakeLists.txt'
788--- src/server/shell/CMakeLists.txt 2014-03-06 06:05:17 +0000
789+++ src/server/shell/CMakeLists.txt 2014-04-04 08:28:33 +0000
790@@ -3,7 +3,6 @@
791
792 default_focus_mechanism.cpp
793 consuming_placement_strategy.cpp
794- organising_surface_factory.cpp
795 surface_creation_parameters.cpp
796 graphics_display_layout.cpp
797 default_configuration.cpp
798
799=== modified file 'src/server/shell/default_configuration.cpp'
800--- src/server/shell/default_configuration.cpp 2014-04-02 16:39:12 +0000
801+++ src/server/shell/default_configuration.cpp 2014-04-04 08:28:33 +0000
802@@ -21,24 +21,11 @@
803 #include "consuming_placement_strategy.h"
804 #include "default_focus_mechanism.h"
805 #include "graphics_display_layout.h"
806-#include "organising_surface_factory.h"
807
808 namespace ms = mir::scene;
809 namespace msh = mir::shell;
810 namespace mf = mir::frontend;
811
812-std::shared_ptr<msh::SurfaceFactory>
813-mir::DefaultServerConfiguration::the_shell_surface_factory()
814-{
815- return shell_surface_factory(
816- [this]()
817- {
818- return std::make_shared<msh::OrganisingSurfaceFactory>(
819- the_surface_coordinator(),
820- the_shell_placement_strategy());
821- });
822-}
823-
824 std::shared_ptr<msh::PlacementStrategy>
825 mir::DefaultServerConfiguration::the_shell_placement_strategy()
826 {
827
828=== modified file 'src/server/shell/default_focus_mechanism.cpp'
829--- src/server/shell/default_focus_mechanism.cpp 2014-04-02 16:39:12 +0000
830+++ src/server/shell/default_focus_mechanism.cpp 2014-04-04 08:28:33 +0000
831@@ -22,7 +22,7 @@
832 #include "mir/scene/surface.h"
833 #include "mir/shell/input_targeter.h"
834 #include "mir/shell/session.h"
835-#include "mir/shell/surface.h"
836+#include "mir/scene/surface.h"
837
838 namespace mf = mir::frontend;
839 namespace ms = mir::scene;
840
841=== modified file 'src/server/shell/default_focus_mechanism.h'
842--- src/server/shell/default_focus_mechanism.h 2014-04-02 16:39:12 +0000
843+++ src/server/shell/default_focus_mechanism.h 2014-04-04 08:28:33 +0000
844@@ -26,11 +26,10 @@
845
846 namespace mir
847 {
848-namespace scene { class SurfaceCoordinator; }
849+namespace scene { class SurfaceCoordinator; class Surface; }
850
851 namespace shell
852 {
853-class Surface;
854 class InputTargeter;
855
856 class DefaultFocusMechanism : public FocusSetter
857@@ -51,7 +50,7 @@
858 std::shared_ptr<scene::SurfaceCoordinator> const surface_coordinator;
859
860 std::mutex surface_focus_lock;
861- std::weak_ptr<Surface> currently_focused_surface;
862+ std::weak_ptr<scene::Surface> currently_focused_surface;
863 };
864
865 }
866
867=== removed file 'src/server/shell/organising_surface_factory.cpp'
868--- src/server/shell/organising_surface_factory.cpp 2014-04-02 17:38:24 +0000
869+++ src/server/shell/organising_surface_factory.cpp 1970-01-01 00:00:00 +0000
870@@ -1,56 +0,0 @@
871-/*
872- * Copyright © 2013 Canonical Ltd.
873- *
874- * This program is free software: you can redistribute it and/or modify it
875- * under the terms of the GNU General Public License version 3,
876- * as published by the Free Software Foundation.
877- *
878- * This program is distributed in the hope that it will be useful,
879- * but WITHOUT ANY WARRANTY; without even the implied warranty of
880- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
881- * GNU General Public License for more details.
882- *
883- * You should have received a copy of the GNU General Public License
884- * along with this program. If not, see <http://www.gnu.org/licenses/>.
885- *
886- * Authored by: Robert Carr <robert.carr@canonical.com>
887- */
888-
889-#include "organising_surface_factory.h"
890-#include "mir/shell/placement_strategy.h"
891-#include "mir/shell/surface_creation_parameters.h"
892-#include "mir/scene/surface_coordinator.h"
893-#include "mir/scene/surface.h"
894-
895-#include <cstdlib>
896-
897-namespace mf = mir::frontend;
898-namespace ms = mir::scene;
899-namespace msh = mir::shell;
900-
901-msh::OrganisingSurfaceFactory::OrganisingSurfaceFactory(
902- std::shared_ptr<scene::SurfaceCoordinator> const& surface_coordinator,
903- std::shared_ptr<msh::PlacementStrategy> const& placement_strategy) :
904- surface_coordinator(surface_coordinator),
905- placement_strategy(placement_strategy)
906-{
907-}
908-
909-msh::OrganisingSurfaceFactory::~OrganisingSurfaceFactory()
910-{
911-}
912-
913-std::shared_ptr<ms::Surface> msh::OrganisingSurfaceFactory::create_surface(
914- Session* session,
915- SurfaceCreationParameters const& params,
916- std::shared_ptr<scene::SurfaceObserver> const& observer)
917-{
918- auto placed_params = placement_strategy->place(*session, params);
919-
920- return surface_coordinator->add_surface(placed_params, observer);
921-}
922-
923-void msh::OrganisingSurfaceFactory::destroy_surface(std::shared_ptr<ms::Surface> const& surface)
924-{
925- surface_coordinator->remove_surface(surface);
926-}
927
928=== removed file 'src/server/shell/organising_surface_factory.h'
929--- src/server/shell/organising_surface_factory.h 2014-04-02 17:38:24 +0000
930+++ src/server/shell/organising_surface_factory.h 1970-01-01 00:00:00 +0000
931@@ -1,61 +0,0 @@
932-/*
933- * Copyright © 2013 Canonical Ltd.
934- *
935- * This program is free software: you can redistribute it and/or modify it
936- * under the terms of the GNU General Public License version 3,
937- * as published by the Free Software Foundation.
938- *
939- * This program is distributed in the hope that it will be useful,
940- * but WITHOUT ANY WARRANTY; without even the implied warranty of
941- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
942- * GNU General Public License for more details.
943- *
944- * You should have received a copy of the GNU General Public License
945- * along with this program. If not, see <http://www.gnu.org/licenses/>.
946- *
947- * Authored by: Robert Carr <robert.carr@canonical.com>
948- */
949-
950-#ifndef MIR_SHELL_ORGANISING_SURFACE_FACTORY_H_
951-#define MIR_SHELL_ORGANISING_SURFACE_FACTORY_H_
952-
953-#include "mir/shell/surface_factory.h"
954-
955-#include <memory>
956-
957-namespace mir
958-{
959-namespace scene { class SurfaceCoordinator; }
960-namespace shell
961-{
962-class PlacementStrategy;
963-class Session;
964-
965-class OrganisingSurfaceFactory : public SurfaceFactory
966-{
967-public:
968- OrganisingSurfaceFactory(
969- std::shared_ptr<scene::SurfaceCoordinator> const& surface_coordinator,
970- std::shared_ptr<PlacementStrategy> const& placement_strategy);
971- virtual ~OrganisingSurfaceFactory();
972-
973- std::shared_ptr<scene::Surface> create_surface(
974- Session* session,
975- SurfaceCreationParameters const& params,
976- std::shared_ptr<scene::SurfaceObserver> const& observer) override;
977-
978- void destroy_surface(std::shared_ptr<scene::Surface> const& surface) override;
979-
980-protected:
981- OrganisingSurfaceFactory(OrganisingSurfaceFactory const&) = delete;
982- OrganisingSurfaceFactory& operator=(OrganisingSurfaceFactory const&) = delete;
983-
984-private:
985- std::shared_ptr<scene::SurfaceCoordinator> const surface_coordinator;
986- std::shared_ptr<PlacementStrategy> const placement_strategy;
987-};
988-
989-}
990-} // namespace mir
991-
992-#endif // MIR_SHELL_ORGANISING_SURFACE_FACTORY_H_
993
994=== modified file 'tests/acceptance-tests/test_client_input.cpp'
995--- tests/acceptance-tests/test_client_input.cpp 2014-04-02 17:38:24 +0000
996+++ tests/acceptance-tests/test_client_input.cpp 2014-04-04 08:28:33 +0000
997@@ -19,11 +19,10 @@
998 #include "mir/graphics/display.h"
999 #include "mir/shell/surface_creation_parameters.h"
1000 #include "mir/shell/placement_strategy.h"
1001-#include "mir/shell/surface_factory.h"
1002+#include "mir/scene/surface_coordinator.h"
1003 #include "mir/scene/surface.h"
1004 #include "src/server/scene/session_container.h"
1005 #include "mir/shell/session.h"
1006-#include "src/server/scene/surface_controller.h"
1007 #include "src/server/scene/surface_stack_model.h"
1008
1009 #include "src/server/input/android/android_input_manager.h"
1010@@ -326,33 +325,38 @@
1011
1012 namespace
1013 {
1014-struct RegionApplyingSurfaceFactory : public msh::SurfaceFactory
1015+struct RegionApplyingSurfaceCoordinator : public ms::SurfaceCoordinator
1016 {
1017- RegionApplyingSurfaceFactory(std::shared_ptr<msh::SurfaceFactory> real_factory,
1018+ RegionApplyingSurfaceCoordinator(std::shared_ptr<ms::SurfaceCoordinator> wrapped_coordinator,
1019 std::initializer_list<geom::Rectangle> const& input_rectangles)
1020- : underlying_factory(real_factory),
1021+ : wrapped_coordinator(wrapped_coordinator),
1022 input_rectangles(input_rectangles)
1023 {
1024 }
1025
1026- std::shared_ptr<ms::Surface> create_surface(
1027+ std::shared_ptr<ms::Surface> add_surface(
1028+ msh::SurfaceCreationParameters const& params,
1029 msh::Session* session,
1030- msh::SurfaceCreationParameters const& params,
1031 std::shared_ptr<ms::SurfaceObserver> const& observer) override
1032 {
1033- auto surface = underlying_factory->create_surface(session, params, observer);
1034+ auto surface = wrapped_coordinator->add_surface(params, session, observer);
1035
1036 surface->set_input_region(input_rectangles);
1037
1038 return surface;
1039 }
1040
1041- void destroy_surface(std::shared_ptr<ms::Surface> const& surface) override
1042- {
1043- underlying_factory->destroy_surface(surface);
1044- }
1045-
1046- std::shared_ptr<msh::SurfaceFactory> const underlying_factory;
1047+ void remove_surface(std::weak_ptr<ms::Surface> const& surface) override
1048+ {
1049+ wrapped_coordinator->remove_surface(surface);
1050+ }
1051+
1052+ void raise(std::weak_ptr<ms::Surface> const& surface) override
1053+ {
1054+ wrapped_coordinator->raise(surface);
1055+ }
1056+
1057+ std::shared_ptr<ms::SurfaceCoordinator> const wrapped_coordinator;
1058 std::vector<geom::Rectangle> const input_rectangles;
1059 };
1060 }
1061@@ -391,9 +395,9 @@
1062 return std::make_shared<mtf::DeclarativePlacementStrategy>(
1063 InputTestingServerConfiguration::the_shell_placement_strategy(), positions, mtf::SurfaceDepths());
1064 }
1065- std::shared_ptr<msh::SurfaceFactory> the_shell_surface_factory() override
1066+ std::shared_ptr<ms::SurfaceCoordinator> the_surface_coordinator() override
1067 {
1068- return std::make_shared<RegionApplyingSurfaceFactory>(InputTestingServerConfiguration::the_shell_surface_factory(),
1069+ return std::make_shared<RegionApplyingSurfaceCoordinator>(InputTestingServerConfiguration::the_surface_coordinator(),
1070 client_input_regions);
1071 }
1072
1073
1074=== modified file 'tests/acceptance-tests/test_focus_selection.cpp'
1075--- tests/acceptance-tests/test_focus_selection.cpp 2014-03-06 06:05:17 +0000
1076+++ tests/acceptance-tests/test_focus_selection.cpp 2014-04-04 08:28:33 +0000
1077@@ -20,7 +20,6 @@
1078
1079 #include "src/server/scene/session_container.h"
1080 #include "src/server/shell/consuming_placement_strategy.h"
1081-#include "src/server/shell/organising_surface_factory.h"
1082 #include "src/server/scene/session_manager.h"
1083 #include "mir/graphics/display.h"
1084 #include "mir/shell/input_targeter.h"
1085
1086=== modified file 'tests/integration-tests/graphics/android/test_internal_client.cpp'
1087--- tests/integration-tests/graphics/android/test_internal_client.cpp 2014-03-31 09:02:16 +0000
1088+++ tests/integration-tests/graphics/android/test_internal_client.cpp 2014-04-04 08:28:33 +0000
1089@@ -35,6 +35,7 @@
1090 #include "mir/scene/surface.h"
1091 #include "mir/scene/surface_event_source.h"
1092 #include "mir/shell/surface_creation_parameters.h"
1093+#include "mir/shell/placement_strategy.h"
1094 #include "mir/frontend/surface_id.h"
1095 #include "mir/input/input_channel_factory.h"
1096 #include "mir/options/program_option.h"
1097@@ -77,6 +78,14 @@
1098 return std::shared_ptr<mi::InputChannel>();
1099 }
1100 };
1101+
1102+struct NullSurfacePlacementStrategy : msh::PlacementStrategy
1103+{
1104+ msh::SurfaceCreationParameters place(ms::Session const&, msh::SurfaceCreationParameters const& parameters) override
1105+ {
1106+ return parameters;
1107+ }
1108+};
1109 }
1110
1111 TEST_F(AndroidInternalClient, internal_client_creation_and_use)
1112@@ -96,11 +105,13 @@
1113 auto allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(null_buffer_initializer);
1114 auto buffer_stream_factory = std::make_shared<mc::BufferStreamFactory>(allocator);
1115 auto scene_report = mr::null_scene_report();
1116- auto surface_allocator = std::make_shared<ms::SurfaceAllocator>(buffer_stream_factory, stub_input_factory, std::make_shared<mtd::NullSurfaceConfigurator>(), scene_report);
1117+ auto const surface_configurator = std::make_shared<mtd::NullSurfaceConfigurator>();
1118+ auto surface_allocator = std::make_shared<ms::SurfaceAllocator>(buffer_stream_factory, stub_input_factory, surface_configurator, scene_report);
1119 auto ss = std::make_shared<ms::SurfaceStack>(stub_input_registrar, scene_report);
1120- auto surface_controller = std::make_shared<ms::SurfaceController>(surface_allocator, ss);
1121+ auto const surface_placement = std::make_shared<NullSurfacePlacementStrategy>();
1122+ auto surface_controller = std::make_shared<ms::SurfaceController>(surface_allocator, surface_placement, ss);
1123 auto const observer = std::make_shared<ms::SurfaceEventSource>(id, std::shared_ptr<mf::EventSink>());
1124- auto surface = surface_controller->add_surface(params, observer);
1125+ auto surface = surface_controller->add_surface(params, nullptr, observer);
1126 surface->allow_framedropping(true);
1127 auto mir_surface = as_internal_surface(surface);
1128
1129
1130=== modified file 'tests/integration-tests/test_session.cpp'
1131--- tests/integration-tests/test_session.cpp 2014-03-06 06:05:17 +0000
1132+++ tests/integration-tests/test_session.cpp 2014-04-04 08:28:33 +0000
1133@@ -22,7 +22,7 @@
1134 #include "src/server/scene/application_session.h"
1135 #include "src/server/scene/pixel_buffer.h"
1136 #include "mir/shell/placement_strategy.h"
1137-#include "mir/shell/surface.h"
1138+#include "mir/scene/surface.h"
1139 #include "mir/shell/surface_creation_parameters.h"
1140 #include "mir/shell/null_session_listener.h"
1141 #include "mir/compositor/buffer_stream.h"
1142@@ -154,7 +154,7 @@
1143 TestServerConfiguration conf;
1144
1145 ms::ApplicationSession session{
1146- conf.the_shell_surface_factory(),
1147+ conf.the_surface_coordinator(),
1148 __LINE__,
1149 "stress",
1150 conf.the_snapshot_strategy(),
1151
1152=== modified file 'tests/integration-tests/test_session_manager.cpp'
1153--- tests/integration-tests/test_session_manager.cpp 2014-03-28 17:47:07 +0000
1154+++ tests/integration-tests/test_session_manager.cpp 2014-04-04 08:28:33 +0000
1155@@ -27,7 +27,7 @@
1156
1157 #include "mir_test/gmock_fixes.h"
1158 #include "mir_test/fake_shared.h"
1159-#include "mir_test_doubles/mock_surface_factory.h"
1160+#include "mir_test_doubles/mock_surface_coordinator.h"
1161 #include "mir_test_doubles/mock_focus_setter.h"
1162 #include "mir_test_doubles/null_snapshot_strategy.h"
1163 #include "mir_test_doubles/null_event_sink.h"
1164@@ -50,7 +50,7 @@
1165 {
1166 TestSessionManagerAndFocusSelectionStrategy()
1167 : session_manager(
1168- mt::fake_shared(surface_factory),
1169+ mt::fake_shared(surface_coordinator),
1170 mt::fake_shared(container),
1171 mt::fake_shared(focus_setter),
1172 std::make_shared<mtd::NullSnapshotStrategy>(),
1173@@ -60,7 +60,7 @@
1174
1175 }
1176
1177- mtd::MockSurfaceFactory surface_factory; // TODO this isn't used as a mock
1178+ mtd::MockSurfaceCoordinator surface_coordinator; // TODO this isn't used as a mock
1179 ms::DefaultSessionContainer container;
1180 mtd::MockFocusSetter focus_setter;
1181 std::shared_ptr<mf::Session> new_session;
1182
1183=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
1184--- tests/unit-tests/frontend/test_session_mediator.cpp 2014-03-31 10:59:59 +0000
1185+++ tests/unit-tests/frontend/test_session_mediator.cpp 2014-04-04 08:28:33 +0000
1186@@ -42,7 +42,6 @@
1187 #include "mir_test/display_config_matchers.h"
1188 #include "mir_test/fake_shared.h"
1189 #include "mir/frontend/event_sink.h"
1190-#include "mir/shell/surface.h"
1191
1192 #include "gmock_set_arg.h"
1193 #include <gtest/gtest.h>
1194
1195=== modified file 'tests/unit-tests/scene/test_application_session.cpp'
1196--- tests/unit-tests/scene/test_application_session.cpp 2014-03-28 17:47:07 +0000
1197+++ tests/unit-tests/scene/test_application_session.cpp 2014-04-04 08:28:33 +0000
1198@@ -21,15 +21,13 @@
1199 #include "mir/shell/surface_creation_parameters.h"
1200 #include "mir/shell/null_session_listener.h"
1201 #include "mir_test/fake_shared.h"
1202-#include "mir_test_doubles/mock_surface_factory.h"
1203+#include "mir_test_doubles/mock_surface_coordinator.h"
1204 #include "mir_test_doubles/mock_surface.h"
1205 #include "mir_test_doubles/mock_session_listener.h"
1206 #include "mir_test_doubles/stub_display_configuration.h"
1207 #include "mir_test_doubles/null_snapshot_strategy.h"
1208 #include "mir_test_doubles/null_event_sink.h"
1209
1210-#include "mir/shell/surface.h"
1211-
1212 #include <gmock/gmock.h>
1213 #include <gtest/gtest.h>
1214
1215@@ -82,9 +80,9 @@
1216 auto mock_surface = make_mock_surface();
1217
1218 mtd::NullEventSink sender;
1219- mtd::MockSurfaceFactory surface_factory;
1220+ mtd::MockSurfaceCoordinator surface_coordinator;
1221
1222- EXPECT_CALL(surface_factory, create_surface(_, _, _))
1223+ EXPECT_CALL(surface_coordinator, add_surface(_, _, _))
1224 .WillOnce(Return(mock_surface));
1225
1226 mtd::MockSessionListener listener;
1227@@ -94,7 +92,7 @@
1228 .Times(1);
1229
1230 ms::ApplicationSession session(
1231- mt::fake_shared(surface_factory),
1232+ mt::fake_shared(surface_coordinator),
1233 __LINE__,
1234 "Foo",
1235 std::make_shared<mtd::NullSnapshotStrategy>(),
1236@@ -114,10 +112,10 @@
1237 auto mock_surface = make_mock_surface();
1238
1239 mtd::NullEventSink sender;
1240- mtd::MockSurfaceFactory surface_factory;
1241- ON_CALL(surface_factory, create_surface(_,_,_)).WillByDefault(Return(mock_surface));
1242+ mtd::MockSurfaceCoordinator surface_coordinator;
1243+ ON_CALL(surface_coordinator, add_surface(_,_,_)).WillByDefault(Return(mock_surface));
1244
1245- EXPECT_CALL(surface_factory, create_surface(_, _, _));
1246+ EXPECT_CALL(surface_coordinator, add_surface(_, _, _));
1247
1248 mtd::MockSessionListener listener;
1249 EXPECT_CALL(listener, surface_created(_, _)).Times(1);
1250@@ -125,7 +123,7 @@
1251
1252 {
1253 ms::ApplicationSession session(
1254- mt::fake_shared(surface_factory),
1255+ mt::fake_shared(surface_coordinator),
1256 __LINE__,
1257 "Foo",
1258 std::make_shared<mtd::NullSnapshotStrategy>(),
1259@@ -142,20 +140,20 @@
1260 using namespace ::testing;
1261
1262 mtd::NullEventSink sender;
1263- mtd::MockSurfaceFactory surface_factory;
1264+ mtd::MockSurfaceCoordinator surface_coordinator;
1265
1266 {
1267 InSequence seq;
1268- EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1)
1269- .WillOnce(Return(make_mock_surface()));
1270- EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1)
1271- .WillOnce(Return(make_mock_surface()));
1272- EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1)
1273+ EXPECT_CALL(surface_coordinator, add_surface(_, _, _)).Times(1)
1274+ .WillOnce(Return(make_mock_surface()));
1275+ EXPECT_CALL(surface_coordinator, add_surface(_, _, _)).Times(1)
1276+ .WillOnce(Return(make_mock_surface()));
1277+ EXPECT_CALL(surface_coordinator, add_surface(_, _, _)).Times(1)
1278 .WillOnce(Return(make_mock_surface()));
1279 }
1280
1281 ms::ApplicationSession app_session(
1282- mt::fake_shared(surface_factory),
1283+ mt::fake_shared(surface_coordinator),
1284 __LINE__,
1285 "Foo",
1286 std::make_shared<mtd::NullSnapshotStrategy>(),
1287@@ -188,18 +186,18 @@
1288 mtd::NullEventSink sender;
1289 auto mock_surface = make_mock_surface();
1290
1291- mtd::MockSurfaceFactory surface_factory;
1292- ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(Return(mock_surface));
1293+ mtd::MockSurfaceCoordinator surface_coordinator;
1294+ ON_CALL(surface_coordinator, add_surface(_, _, _)).WillByDefault(Return(mock_surface));
1295
1296 ms::ApplicationSession app_session(
1297- mt::fake_shared(surface_factory),
1298+ mt::fake_shared(surface_coordinator),
1299 __LINE__,
1300 "Foo",
1301 std::make_shared<mtd::NullSnapshotStrategy>(),
1302 std::make_shared<msh::NullSessionListener>(),
1303 mt::fake_shared(sender));
1304
1305- EXPECT_CALL(surface_factory, create_surface(_, _, _));
1306+ EXPECT_CALL(surface_coordinator, add_surface(_, _, _));
1307
1308 {
1309 InSequence seq;
1310@@ -221,9 +219,9 @@
1311 using namespace ::testing;
1312
1313 mtd::NullEventSink sender;
1314- mtd::MockSurfaceFactory surface_factory;
1315+ mtd::MockSurfaceCoordinator surface_coordinator;
1316 ms::ApplicationSession app_session(
1317- mt::fake_shared(surface_factory),
1318+ mt::fake_shared(surface_coordinator),
1319 __LINE__,
1320 "Foo",
1321 std::make_shared<mtd::NullSnapshotStrategy>(),
1322@@ -242,9 +240,9 @@
1323 using namespace ::testing;
1324
1325 mtd::NullEventSink sender;
1326- mtd::MockSurfaceFactory surface_factory;
1327+ mtd::MockSurfaceCoordinator surface_coordinator;
1328 ms::ApplicationSession app_session(
1329- mt::fake_shared(surface_factory),
1330+ mt::fake_shared(surface_coordinator),
1331 __LINE__,
1332 "Foo",
1333 std::make_shared<mtd::NullSnapshotStrategy>(),
1334@@ -262,21 +260,21 @@
1335 {
1336 using namespace ::testing;
1337
1338- mtd::MockSurfaceFactory surface_factory;
1339+ mtd::MockSurfaceCoordinator surface_coordinator;
1340 mtd::NullEventSink sender;
1341 auto const default_surface = make_mock_surface();
1342 auto const default_surface_buffer_access =
1343 std::static_pointer_cast<msh::SurfaceBufferAccess>(default_surface);
1344 auto const snapshot_strategy = std::make_shared<MockSnapshotStrategy>();
1345
1346- EXPECT_CALL(surface_factory, create_surface(_,_,_))
1347+ EXPECT_CALL(surface_coordinator, add_surface(_,_,_))
1348 .WillOnce(Return(default_surface));
1349
1350 EXPECT_CALL(*snapshot_strategy,
1351 take_snapshot_of(default_surface_buffer_access, _));
1352
1353 ms::ApplicationSession app_session(
1354- mt::fake_shared(surface_factory),
1355+ mt::fake_shared(surface_coordinator),
1356 __LINE__,
1357 "Foo",
1358 snapshot_strategy,
1359@@ -293,12 +291,12 @@
1360 using namespace ::testing;
1361
1362 mtd::NullEventSink sender;
1363- mtd::MockSurfaceFactory surface_factory;
1364+ mtd::MockSurfaceCoordinator surface_coordinator;
1365 auto snapshot_strategy = std::make_shared<MockSnapshotStrategy>();
1366 MockSnapshotCallback mock_snapshot_callback;
1367
1368 ms::ApplicationSession app_session(
1369- mt::fake_shared(surface_factory),
1370+ mt::fake_shared(surface_coordinator),
1371 __LINE__,
1372 "Foo",
1373 snapshot_strategy,
1374@@ -326,14 +324,14 @@
1375 using namespace ::testing;
1376
1377 mtd::StubDisplayConfig stub_config;
1378- mtd::MockSurfaceFactory surface_factory;
1379+ mtd::MockSurfaceCoordinator surface_coordinator;
1380 MockEventSink sender;
1381
1382 EXPECT_CALL(sender, handle_display_config_change(testing::Ref(stub_config)))
1383 .Times(1);
1384
1385 ms::ApplicationSession app_session(
1386- mt::fake_shared(surface_factory),
1387+ mt::fake_shared(surface_coordinator),
1388 __LINE__,
1389 "Foo",
1390 std::make_shared<mtd::NullSnapshotStrategy>(),
1391@@ -348,11 +346,11 @@
1392 using namespace ::testing;
1393
1394 MirLifecycleState exp_state = mir_lifecycle_state_will_suspend;
1395- mtd::MockSurfaceFactory surface_factory;
1396+ mtd::MockSurfaceCoordinator surface_coordinator;
1397 MockEventSink sender;
1398
1399 ms::ApplicationSession app_session(
1400- mt::fake_shared(surface_factory),
1401+ mt::fake_shared(surface_coordinator),
1402 __LINE__,
1403 "Foo",
1404 std::make_shared<mtd::NullSnapshotStrategy>(),
1405@@ -370,11 +368,11 @@
1406
1407 pid_t const pid{__LINE__};
1408
1409- mtd::MockSurfaceFactory surface_factory;
1410+ mtd::MockSurfaceCoordinator surface_coordinator;
1411 MockEventSink sender;
1412
1413 ms::ApplicationSession app_session(
1414- mt::fake_shared(surface_factory),
1415+ mt::fake_shared(surface_coordinator),
1416 pid,
1417 "Foo",
1418 std::make_shared<mtd::NullSnapshotStrategy>(),
1419
1420=== modified file 'tests/unit-tests/scene/test_default_focus_mechanism.cpp'
1421--- tests/unit-tests/scene/test_default_focus_mechanism.cpp 2014-04-02 16:39:12 +0000
1422+++ tests/unit-tests/scene/test_default_focus_mechanism.cpp 2014-04-04 08:28:33 +0000
1423@@ -25,7 +25,6 @@
1424
1425 #include "mir_test/fake_shared.h"
1426 #include "mir_test_doubles/mock_buffer_stream.h"
1427-#include "mir_test_doubles/mock_surface_factory.h"
1428 #include "mir_test_doubles/mock_shell_session.h"
1429 #include "mir_test_doubles/mock_surface.h"
1430 #include "mir_test_doubles/mock_surface_coordinator.h"
1431@@ -83,7 +82,7 @@
1432 EXPECT_CALL(app1, default_surface()).Times(1)
1433 .WillOnce(Return(mt::fake_shared(mock_surface)));
1434 EXPECT_CALL(app1, default_surface()).Times(1)
1435- .WillOnce(Return(std::shared_ptr<msh::Surface>()));
1436+ .WillOnce(Return(std::shared_ptr<ms::Surface>()));
1437 }
1438
1439 NiceMock<mtd::MockInputTargeter> targeter;
1440
1441=== modified file 'tests/unit-tests/scene/test_session_manager.cpp'
1442--- tests/unit-tests/scene/test_session_manager.cpp 2014-03-31 09:02:16 +0000
1443+++ tests/unit-tests/scene/test_session_manager.cpp 2014-04-04 08:28:33 +0000
1444@@ -30,7 +30,7 @@
1445
1446 #include "mir_test/fake_shared.h"
1447 #include "mir_test_doubles/mock_buffer_stream.h"
1448-#include "mir_test_doubles/mock_surface_factory.h"
1449+#include "mir_test_doubles/mock_surface_coordinator.h"
1450 #include "mir_test_doubles/mock_focus_setter.h"
1451 #include "mir_test_doubles/mock_session_listener.h"
1452 #include "mir_test_doubles/stub_buffer_stream.h"
1453@@ -73,7 +73,7 @@
1454 struct SessionManagerSetup : public testing::Test
1455 {
1456 SessionManagerSetup()
1457- : session_manager(mt::fake_shared(surface_factory),
1458+ : session_manager(mt::fake_shared(surface_coordinator),
1459 mt::fake_shared(container),
1460 mt::fake_shared(focus_setter),
1461 std::make_shared<mtd::NullSnapshotStrategy>(),
1462@@ -92,7 +92,7 @@
1463 std::shared_ptr<mi::InputChannel>(),
1464 std::shared_ptr<ms::SurfaceConfigurator>(),
1465 mir::report::null_scene_report());
1466- mtd::MockSurfaceFactory surface_factory;
1467+ mtd::MockSurfaceCoordinator surface_coordinator;
1468 testing::NiceMock<MockSessionContainer> container; // Inelegant but some tests need a stub
1469 testing::NiceMock<mtd::MockFocusSetter> focus_setter; // Inelegant but some tests need a stub
1470 msh::NullSessionListener session_listener;
1471@@ -119,9 +119,9 @@
1472 {
1473 using namespace ::testing;
1474
1475- EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1);
1476+ EXPECT_CALL(surface_coordinator, add_surface(_, _, _)).Times(1);
1477
1478- ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(
1479+ ON_CALL(surface_coordinator, add_surface(_, _, _)).WillByDefault(
1480 Return(dummy_surface));
1481
1482 EXPECT_CALL(container, insert_session(_)).Times(1);
1483@@ -151,7 +151,7 @@
1484 TEST_F(SessionManagerSetup, create_surface_for_session_forwards_and_then_focuses_session)
1485 {
1486 using namespace ::testing;
1487- ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(
1488+ ON_CALL(surface_coordinator, add_surface(_, _, _)).WillByDefault(
1489 Return(dummy_surface));
1490
1491 // Once for session creation and once for surface creation
1492@@ -159,7 +159,7 @@
1493 InSequence seq;
1494
1495 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Session creation
1496- EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1);
1497+ EXPECT_CALL(surface_coordinator, add_surface(_, _, _)).Times(1);
1498 EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation
1499 }
1500
1501@@ -173,7 +173,7 @@
1502 struct SessionManagerSessionListenerSetup : public testing::Test
1503 {
1504 SessionManagerSessionListenerSetup()
1505- : session_manager(mt::fake_shared(surface_factory),
1506+ : session_manager(mt::fake_shared(surface_coordinator),
1507 mt::fake_shared(container),
1508 mt::fake_shared(focus_setter),
1509 std::make_shared<mtd::NullSnapshotStrategy>(),
1510@@ -184,7 +184,7 @@
1511 ON_CALL(container, successor_of(_)).WillByDefault(Return((std::shared_ptr<msh::Session>())));
1512 }
1513
1514- mtd::MockSurfaceFactory surface_factory;
1515+ mtd::MockSurfaceCoordinator surface_coordinator;
1516 testing::NiceMock<MockSessionContainer> container; // Inelegant but some tests need a stub
1517 testing::NiceMock<mtd::MockFocusSetter> focus_setter; // Inelegant but some tests need a stub
1518 mtd::MockSessionListener session_listener;
1519@@ -212,7 +212,7 @@
1520 struct SessionManagerSessionEventsSetup : public testing::Test
1521 {
1522 SessionManagerSessionEventsSetup()
1523- : session_manager(mt::fake_shared(surface_factory),
1524+ : session_manager(mt::fake_shared(surface_coordinator),
1525 mt::fake_shared(container),
1526 mt::fake_shared(focus_setter),
1527 std::make_shared<mtd::NullSnapshotStrategy>(),
1528@@ -223,7 +223,7 @@
1529 ON_CALL(container, successor_of(_)).WillByDefault(Return((std::shared_ptr<msh::Session>())));
1530 }
1531
1532- mtd::MockSurfaceFactory surface_factory;
1533+ mtd::MockSurfaceCoordinator surface_coordinator;
1534 testing::NiceMock<MockSessionContainer> container; // Inelegant but some tests need a stub
1535 testing::NiceMock<mtd::MockFocusSetter> focus_setter; // Inelegant but some tests need a stub
1536 MockSessionEventSink session_event_sink;
1537
1538=== modified file 'tests/unit-tests/scene/test_surface_controller.cpp'
1539--- tests/unit-tests/scene/test_surface_controller.cpp 2014-03-31 10:18:49 +0000
1540+++ tests/unit-tests/scene/test_surface_controller.cpp 2014-04-04 08:28:33 +0000
1541@@ -19,7 +19,9 @@
1542 #include "src/server/scene/surface_controller.h"
1543 #include "src/server/scene/surface_stack_model.h"
1544 #include "mir/scene/surface_factory.h"
1545+#include "mir/shell/placement_strategy.h"
1546 #include "mir/shell/surface_creation_parameters.h"
1547+#include "mir_test_doubles/stub_shell_session.h"
1548
1549 #include "mir_test_doubles/mock_surface.h"
1550 #include "mir_test/fake_shared.h"
1551@@ -27,6 +29,7 @@
1552 #include <gtest/gtest.h>
1553 #include <gmock/gmock.h>
1554
1555+namespace geom = mir::geometry;
1556 namespace mf = mir::frontend;
1557 namespace msh = mir::shell;
1558 namespace ms = mir::scene;
1559@@ -41,6 +44,11 @@
1560 msh::SurfaceCreationParameters const&));
1561 };
1562
1563+struct MockPlacementStrategy : public msh::PlacementStrategy
1564+{
1565+ MOCK_METHOD2(place, msh::SurfaceCreationParameters(msh::Session const&, msh::SurfaceCreationParameters const&));
1566+};
1567+
1568 struct MockSurfaceStackModel : public ms::SurfaceStackModel
1569 {
1570 MOCK_METHOD3(add_surface, void(
1571@@ -50,42 +58,98 @@
1572 MOCK_METHOD1(remove_surface, void(std::weak_ptr<ms::Surface> const&));
1573 MOCK_METHOD1(raise, void(std::weak_ptr<ms::Surface> const&));
1574 };
1575-}
1576
1577-TEST(SurfaceController, add_and_remove_surface)
1578+struct SurfaceController : testing::Test
1579 {
1580- using namespace ::testing;
1581-
1582+ MockPlacementStrategy placement_strategy;
1583 mtd::MockSurface mock_surface;
1584 std::shared_ptr<ms::Surface> const expect_surface = mt::fake_shared(mock_surface);
1585- auto const surface = std::make_shared<mtd::MockSurface>();
1586 testing::NiceMock<MockSurfaceAllocator> mock_surface_allocator;
1587 MockSurfaceStackModel model;
1588-
1589- ms::SurfaceController controller(mt::fake_shared(mock_surface_allocator), mt::fake_shared(model));
1590+ mtd::StubShellSession session;
1591+ std::shared_ptr<ms::SurfaceObserver> observer;
1592+
1593+ void SetUp()
1594+ {
1595+ using namespace ::testing;
1596+ ON_CALL(mock_surface_allocator, create_surface(_)).WillByDefault(Return(expect_surface));
1597+ ON_CALL(placement_strategy, place(_, _)).WillByDefault(ReturnArg<1>());
1598+ }
1599+};
1600+}
1601+
1602+TEST_F(SurfaceController, add_and_remove_surface)
1603+{
1604+ using namespace ::testing;
1605+
1606+ ms::SurfaceController controller(
1607+ mt::fake_shared(mock_surface_allocator),
1608+ mt::fake_shared(placement_strategy),
1609+ mt::fake_shared(model));
1610
1611 InSequence seq;
1612+ EXPECT_CALL(placement_strategy, place(_, _)).Times(1);
1613 EXPECT_CALL(mock_surface_allocator, create_surface(_)).Times(1).WillOnce(Return(expect_surface));
1614 EXPECT_CALL(mock_surface, add_observer(_)).Times(1);
1615 EXPECT_CALL(model, add_surface(_,_,_)).Times(1);
1616 EXPECT_CALL(model, remove_surface(_)).Times(1);
1617
1618- auto actual_surface = controller.add_surface(msh::a_surface(), std::shared_ptr<ms::SurfaceObserver>());
1619+ auto actual_surface = controller.add_surface(msh::a_surface(), &session, observer);
1620
1621 EXPECT_THAT(actual_surface, Eq(expect_surface));
1622 controller.remove_surface(actual_surface);
1623 }
1624
1625-TEST(SurfaceController, raise_surface)
1626+TEST_F(SurfaceController, raise_surface)
1627 {
1628 using namespace ::testing;
1629
1630- testing::NiceMock<MockSurfaceAllocator> mock_surface_allocator;
1631- MockSurfaceStackModel model;
1632-
1633- ms::SurfaceController controller(mt::fake_shared(mock_surface_allocator), mt::fake_shared(model));
1634+ ms::SurfaceController controller(
1635+ mt::fake_shared(mock_surface_allocator),
1636+ mt::fake_shared(placement_strategy),
1637+ mt::fake_shared(model));
1638
1639 EXPECT_CALL(model, raise(_)).Times(1);
1640
1641 controller.raise(std::weak_ptr<ms::Surface>());
1642 }
1643+
1644+TEST_F(SurfaceController, offers_create_surface_parameters_to_placement_strategy)
1645+{
1646+ using namespace ::testing;
1647+ EXPECT_CALL(mock_surface, add_observer(_)).Times(AnyNumber());
1648+ EXPECT_CALL(model, add_surface(_,_,_)).Times(AnyNumber());
1649+
1650+ ms::SurfaceController controller(
1651+ mt::fake_shared(mock_surface_allocator),
1652+ mt::fake_shared(placement_strategy),
1653+ mt::fake_shared(model));
1654+
1655+ auto params = msh::a_surface();
1656+ EXPECT_CALL(placement_strategy, place(Ref(session), Ref(params))).Times(1)
1657+ .WillOnce(Return(msh::a_surface()));
1658+
1659+ controller.add_surface(params, &session, observer);
1660+}
1661+
1662+TEST_F(SurfaceController, forwards_create_surface_parameters_from_placement_strategy_to_underlying_factory)
1663+{
1664+ using namespace ::testing;
1665+ EXPECT_CALL(mock_surface, add_observer(_)).Times(AnyNumber());
1666+ EXPECT_CALL(model, add_surface(_,_,_)).Times(AnyNumber());
1667+
1668+ ms::SurfaceController controller(
1669+ mt::fake_shared(mock_surface_allocator),
1670+ mt::fake_shared(placement_strategy),
1671+ mt::fake_shared(model));
1672+
1673+ auto params = msh::a_surface();
1674+ auto placed_params = params;
1675+ placed_params.size.width = geom::Width{100};
1676+
1677+ EXPECT_CALL(placement_strategy, place(_, Ref(params))).Times(1)
1678+ .WillOnce(Return(placed_params));
1679+ EXPECT_CALL(mock_surface_allocator, create_surface(placed_params));
1680+
1681+ controller.add_surface(params, &session, observer);
1682+}
1683
1684=== modified file 'tests/unit-tests/shell/CMakeLists.txt'
1685--- tests/unit-tests/shell/CMakeLists.txt 2014-03-06 06:05:17 +0000
1686+++ tests/unit-tests/shell/CMakeLists.txt 2014-04-04 08:28:33 +0000
1687@@ -1,6 +1,5 @@
1688 list(APPEND UNIT_TEST_SOURCES
1689 ${CMAKE_CURRENT_SOURCE_DIR}/test_consuming_placement_strategy.cpp
1690- ${CMAKE_CURRENT_SOURCE_DIR}/test_organising_surface_factory.cpp
1691 ${CMAKE_CURRENT_SOURCE_DIR}/test_graphics_display_layout.cpp
1692 )
1693
1694
1695=== removed file 'tests/unit-tests/shell/test_organising_surface_factory.cpp'
1696--- tests/unit-tests/shell/test_organising_surface_factory.cpp 2014-03-31 09:02:16 +0000
1697+++ tests/unit-tests/shell/test_organising_surface_factory.cpp 1970-01-01 00:00:00 +0000
1698@@ -1,102 +0,0 @@
1699-/*
1700- * Copyright © 2012 Canonical Ltd.
1701- *
1702- * This program is free software: you can redistribute it and/or modify
1703- * it under the terms of the GNU General Public License version 3 as
1704- * published by the Free Software Foundation.
1705- *
1706- * This program is distributed in the hope that it will be useful,
1707- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1708- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1709- * GNU General Public License for more details.
1710- *
1711- * You should have received a copy of the GNU General Public License
1712- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1713- *
1714- * Authored by: Robert Carr <robert.carr@canonical.com>
1715- */
1716-
1717-#include "src/server/shell/organising_surface_factory.h"
1718-#include "mir/shell/placement_strategy.h"
1719-#include "mir/shell/surface_creation_parameters.h"
1720-#include "mir/shell/session.h"
1721-#include "mir/scene/surface.h"
1722-#include "mir/scene/surface_event_source.h"
1723-#include "mir/scene/surface_coordinator.h"
1724-
1725-#include "mir_test_doubles/stub_shell_session.h"
1726-#include "mir_test_doubles/null_event_sink.h"
1727-
1728-#include <gtest/gtest.h>
1729-#include <gmock/gmock.h>
1730-
1731-namespace mf = mir::frontend;
1732-namespace ms = mir::scene;
1733-namespace msh = mir::shell;
1734-namespace geom = mir::geometry;
1735-namespace mtd = mir::test::doubles;
1736-
1737-namespace
1738-{
1739-struct MockSurfaceCoordinator : public ms::SurfaceCoordinator
1740-{
1741- MOCK_METHOD2(add_surface, std::shared_ptr<ms::Surface>(
1742- msh::SurfaceCreationParameters const&,
1743- std::shared_ptr<ms::SurfaceObserver> const&));
1744-
1745- void remove_surface(std::weak_ptr<ms::Surface> const& /*surface*/) override {}
1746- void raise(std::weak_ptr<ms::Surface> const& /*surface*/) override {}
1747-};
1748-
1749-struct MockPlacementStrategy : public msh::PlacementStrategy
1750-{
1751- MOCK_METHOD2(place, msh::SurfaceCreationParameters(msh::Session const&, msh::SurfaceCreationParameters const&));
1752-};
1753-
1754-struct OrganisingSurfaceFactorySetup : public testing::Test
1755-{
1756- void SetUp()
1757- {
1758- using namespace ::testing;
1759- ON_CALL(*surface_coordinator, add_surface(_, _)).WillByDefault(Return(null_surface));
1760- }
1761- std::shared_ptr<ms::Surface> null_surface;
1762- std::shared_ptr<MockSurfaceCoordinator> surface_coordinator = std::make_shared<MockSurfaceCoordinator>();
1763- std::shared_ptr<ms::SurfaceObserver> const observer = std::make_shared<ms::SurfaceEventSource>(mf::SurfaceId(), std::make_shared<mtd::NullEventSink>());
1764- std::shared_ptr<MockPlacementStrategy> placement_strategy = std::make_shared<MockPlacementStrategy>();
1765-};
1766-
1767-} // namespace
1768-
1769-TEST_F(OrganisingSurfaceFactorySetup, offers_create_surface_parameters_to_placement_strategy)
1770-{
1771- using namespace ::testing;
1772-
1773- msh::OrganisingSurfaceFactory factory(surface_coordinator, placement_strategy);
1774-
1775- mtd::StubShellSession session;
1776- EXPECT_CALL(*surface_coordinator, add_surface(_, _)).Times(1);
1777-
1778- auto params = msh::a_surface();
1779- EXPECT_CALL(*placement_strategy, place(Ref(session), Ref(params))).Times(1)
1780- .WillOnce(Return(msh::a_surface()));
1781-
1782- factory.create_surface(&session, params, observer);
1783-}
1784-
1785-TEST_F(OrganisingSurfaceFactorySetup, forwards_create_surface_parameters_from_placement_strategy_to_underlying_factory)
1786-{
1787- using namespace ::testing;
1788-
1789- msh::OrganisingSurfaceFactory factory(surface_coordinator, placement_strategy);
1790-
1791- auto params = msh::a_surface();
1792- auto placed_params = params;
1793- placed_params.size.width = geom::Width{100};
1794-
1795- EXPECT_CALL(*placement_strategy, place(_, Ref(params))).Times(1)
1796- .WillOnce(Return(placed_params));
1797- EXPECT_CALL(*surface_coordinator, add_surface(placed_params, _));
1798-
1799- factory.create_surface(nullptr, params, observer);
1800-}

Subscribers

People subscribed via source and target branches