Merge lp:~alan-griffiths/mir/introducing-SurfaceObserver into lp:mir
- introducing-SurfaceObserver
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Alan Griffiths |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1520 |
Proposed branch: | lp:~alan-griffiths/mir/introducing-SurfaceObserver |
Merge into: | lp:mir |
Prerequisite: | lp:~alan-griffiths/mir/remove-one-of-the-redundant-surface-factories |
Diff against target: |
1740 lines (+323/-219) 31 files modified
examples/render_surfaces.cpp (+0/-1) include/server/mir/scene/surface.h (+5/-0) include/server/mir/scene/surface_coordinator.h (+2/-4) include/server/mir/scene/surface_event_source.h (+49/-0) include/server/mir/scene/surface_factory.h (+2/-6) include/server/mir/scene/surface_observer.h (+45/-0) include/server/mir/shell/surface_factory.h (+3/-7) include/test/mir_test_doubles/mock_surface.h (+1/-2) include/test/mir_test_doubles/mock_surface_factory.h (+2/-3) src/server/scene/CMakeLists.txt (+1/-0) src/server/scene/application_session.cpp (+4/-1) src/server/scene/basic_surface.cpp (+46/-32) src/server/scene/basic_surface.h (+20/-6) src/server/scene/surface_allocator.cpp (+4/-6) src/server/scene/surface_allocator.h (+1/-3) src/server/scene/surface_controller.cpp (+4/-3) src/server/scene/surface_controller.h (+1/-7) src/server/scene/surface_event_source.cpp (+62/-0) src/server/shell/organising_surface_factory.cpp (+3/-4) src/server/shell/organising_surface_factory.h (+2/-3) tests/acceptance-tests/test_client_input.cpp (+5/-5) tests/integration-tests/graphics/android/test_internal_client.cpp (+3/-1) tests/integration-tests/test_session_manager.cpp (+1/-1) tests/unit-tests/scene/test_application_session.cpp (+11/-11) tests/unit-tests/scene/test_basic_surface.cpp (+0/-23) tests/unit-tests/scene/test_session_manager.cpp (+4/-6) tests/unit-tests/scene/test_surface.cpp (+7/-37) tests/unit-tests/scene/test_surface_controller.cpp (+13/-8) tests/unit-tests/scene/test_surface_impl.cpp (+12/-22) tests/unit-tests/scene/test_surface_stack.cpp (+0/-8) tests/unit-tests/shell/test_organising_surface_factory.cpp (+10/-9) |
To merge this branch: | bzr merge lp:~alan-griffiths/mir/introducing-SurfaceObserver |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andreas Pokorny (community) | Approve | ||
Alexandros Frantzis (community) | Approve | ||
Gerry Boland (community) | api | Approve | |
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+213431@code.launchpad.net |
Commit message
scene: Simplify BasicSurface creation by separating out an initial cut of SurfaceObserver.
Description of the change
scene: Simplify BasicSurface creation by separating out an initial cut of SurfaceObserver.
In this iteration SurfaceObserver is only used to support the MirEvents needed to feed the frontend EventSink. There are other "Observer" requirements that will be rolled into this hierarchy.
Andreas Pokorny (andreas-pokorny) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1523
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
I like this design a lot, +1 from me
Alan Griffiths (alan-griffiths) wrote : | # |
> Approve a part from:
>
> the name SurfaceEventSource is a bit misleading... on second read: was a but
> misleading. Now I am only curious whether we need it inside the public
> headers. Would someone replacing the scene or extending the surfaces need that
> implementation? Or would decorating the surface factory be sufficient?
I thought about it. Making it public ensures that it is easy for users that need to synthesize surface events (rather requiring duplication of our code for populating the MirEvent structure).
Alexandros Frantzis (afrantzis) wrote : | # |
Looks good.
> Making it public ensures that it is easy for users that need to synthesize surface events
I am OK with this, but I guess we could wait until it is actually needed before we promote it to public (unless you have a specific use case in mind for the near future).
Daniel van Vugt (vanvugt) wrote : | # |
I know Observer is a common pattern but that doesn't make it the best solution. Maybe think for a while if there's a better name/design that's less abstract than being based on a verb.
Alan Griffiths (alan-griffiths) wrote : | # |
> I know Observer is a common pattern but that doesn't make it the best
> solution. Maybe think for a while if there's a better name/design that's less
> abstract than being based on a verb.
This design has been under discussion since the end of last year.
The name has been chosen intentionally:
/1/ it matches the discussions about architecture improvements that has been taking place over the last three weeks;
/2/ and, "Observer" is widely understood from the GOF patterns catalog.
I think the fact that our most active user says "I like this design a lot" is more important than any concern you have that there has been too little thought go into it.
Andreas Pokorny (andreas-pokorny) : | # |
Preview Diff
1 | === modified file 'examples/render_surfaces.cpp' | |||
2 | --- examples/render_surfaces.cpp 2014-03-31 11:00:33 +0000 | |||
3 | +++ examples/render_surfaces.cpp 2014-03-31 11:00:33 +0000 | |||
4 | @@ -466,7 +466,6 @@ | |||
5 | 466 | for (auto& m : moveables) | 466 | for (auto& m : moveables) |
6 | 467 | { | 467 | { |
7 | 468 | auto const s = surface_coordinator->add_surface( | 468 | auto const s = surface_coordinator->add_surface( |
8 | 469 | mf::SurfaceId(), | ||
9 | 470 | msh::a_surface().of_size(surface_size) | 469 | msh::a_surface().of_size(surface_size) |
10 | 471 | .of_pixel_format(surface_pf) | 470 | .of_pixel_format(surface_pf) |
11 | 472 | .of_buffer_usage(mg::BufferUsage::hardware), | 471 | .of_buffer_usage(mg::BufferUsage::hardware), |
12 | 473 | 472 | ||
13 | === modified file 'include/server/mir/scene/surface.h' | |||
14 | --- include/server/mir/scene/surface.h 2014-03-25 10:21:00 +0000 | |||
15 | +++ include/server/mir/scene/surface.h 2014-03-31 11:00:33 +0000 | |||
16 | @@ -29,6 +29,8 @@ | |||
17 | 29 | 29 | ||
18 | 30 | namespace scene | 30 | namespace scene |
19 | 31 | { | 31 | { |
20 | 32 | class SurfaceObserver; | ||
21 | 33 | |||
22 | 32 | class Surface : | 34 | class Surface : |
23 | 33 | public graphics::Renderable, | 35 | public graphics::Renderable, |
24 | 34 | public input::Surface, | 36 | public input::Surface, |
25 | @@ -47,6 +49,9 @@ | |||
26 | 47 | // TODO cleanest interface for this. | 49 | // TODO cleanest interface for this. |
27 | 48 | virtual std::shared_ptr<input::InputChannel> input_channel() const = 0; | 50 | virtual std::shared_ptr<input::InputChannel> input_channel() const = 0; |
28 | 49 | virtual void on_change(std::function<void()> change_notification) = 0; | 51 | virtual void on_change(std::function<void()> change_notification) = 0; |
29 | 52 | |||
30 | 53 | virtual void add_observer(std::shared_ptr<SurfaceObserver> const& observer) = 0; | ||
31 | 54 | virtual void remove_observer(std::shared_ptr<SurfaceObserver> const& observer) = 0; | ||
32 | 50 | }; | 55 | }; |
33 | 51 | } | 56 | } |
34 | 52 | } | 57 | } |
35 | 53 | 58 | ||
36 | === modified file 'include/server/mir/scene/surface_coordinator.h' | |||
37 | --- include/server/mir/scene/surface_coordinator.h 2014-03-31 11:00:33 +0000 | |||
38 | +++ include/server/mir/scene/surface_coordinator.h 2014-03-31 11:00:33 +0000 | |||
39 | @@ -21,13 +21,11 @@ | |||
40 | 21 | #define MIR_SCENE_SURFACE_COORDINATOR_H_ | 21 | #define MIR_SCENE_SURFACE_COORDINATOR_H_ |
41 | 22 | 22 | ||
42 | 23 | #include "mir/scene/surface_ranker.h" | 23 | #include "mir/scene/surface_ranker.h" |
43 | 24 | #include "mir/frontend/surface_id.h" | ||
44 | 25 | 24 | ||
45 | 26 | #include <memory> | 25 | #include <memory> |
46 | 27 | 26 | ||
47 | 28 | namespace mir | 27 | namespace mir |
48 | 29 | { | 28 | { |
49 | 30 | namespace frontend { class EventSink; } | ||
50 | 31 | namespace shell | 29 | namespace shell |
51 | 32 | { | 30 | { |
52 | 33 | struct SurfaceCreationParameters; | 31 | struct SurfaceCreationParameters; |
53 | @@ -36,14 +34,14 @@ | |||
54 | 36 | namespace scene | 34 | namespace scene |
55 | 37 | { | 35 | { |
56 | 38 | class Surface; | 36 | class Surface; |
57 | 37 | class SurfaceObserver; | ||
58 | 39 | 38 | ||
59 | 40 | class SurfaceCoordinator : public SurfaceRanker | 39 | class SurfaceCoordinator : public SurfaceRanker |
60 | 41 | { | 40 | { |
61 | 42 | public: | 41 | public: |
62 | 43 | virtual std::shared_ptr<Surface> add_surface( | 42 | virtual std::shared_ptr<Surface> add_surface( |
63 | 44 | frontend::SurfaceId id, | ||
64 | 45 | shell::SurfaceCreationParameters const& params, | 43 | shell::SurfaceCreationParameters const& params, |
66 | 46 | std::shared_ptr<frontend::EventSink> const& event_sink) = 0; | 44 | std::shared_ptr<SurfaceObserver> const& observer) = 0; |
67 | 47 | 45 | ||
68 | 48 | virtual void remove_surface(std::weak_ptr<Surface> const& surface) = 0; | 46 | virtual void remove_surface(std::weak_ptr<Surface> const& surface) = 0; |
69 | 49 | protected: | 47 | protected: |
70 | 50 | 48 | ||
71 | === added file 'include/server/mir/scene/surface_event_source.h' | |||
72 | --- include/server/mir/scene/surface_event_source.h 1970-01-01 00:00:00 +0000 | |||
73 | +++ include/server/mir/scene/surface_event_source.h 2014-03-31 11:00:33 +0000 | |||
74 | @@ -0,0 +1,49 @@ | |||
75 | 1 | /* | ||
76 | 2 | * Copyright © 2014 Canonical Ltd. | ||
77 | 3 | * | ||
78 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
79 | 5 | * under the terms of the GNU General Public License version 3, | ||
80 | 6 | * as published by the Free Software Foundation. | ||
81 | 7 | * | ||
82 | 8 | * This program is distributed in the hope that it will be useful, | ||
83 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
84 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
85 | 11 | * GNU General Public License for more details. | ||
86 | 12 | * | ||
87 | 13 | * You should have received a copy of the GNU General Public License | ||
88 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
89 | 15 | * | ||
90 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | ||
91 | 17 | */ | ||
92 | 18 | |||
93 | 19 | #ifndef MIR_SCENE_SURFACE_EVENT_SOURCE_H_ | ||
94 | 20 | #define MIR_SCENE_SURFACE_EVENT_SOURCE_H_ | ||
95 | 21 | |||
96 | 22 | #include "mir/scene/surface_observer.h" | ||
97 | 23 | #include "mir/frontend/surface_id.h" | ||
98 | 24 | #include "mir/frontend/event_sink.h" | ||
99 | 25 | |||
100 | 26 | #include <memory> | ||
101 | 27 | |||
102 | 28 | namespace mir | ||
103 | 29 | { | ||
104 | 30 | namespace scene | ||
105 | 31 | { | ||
106 | 32 | class SurfaceEventSource : public SurfaceObserver | ||
107 | 33 | { | ||
108 | 34 | public: | ||
109 | 35 | SurfaceEventSource( | ||
110 | 36 | frontend::SurfaceId id, | ||
111 | 37 | std::shared_ptr<frontend::EventSink> const& event_sink); | ||
112 | 38 | |||
113 | 39 | void attrib_change(MirSurfaceAttrib attrib, int value); | ||
114 | 40 | void resize(geometry::Size const& size); | ||
115 | 41 | |||
116 | 42 | private: | ||
117 | 43 | frontend::SurfaceId const id; | ||
118 | 44 | std::shared_ptr<frontend::EventSink> const event_sink; | ||
119 | 45 | }; | ||
120 | 46 | } | ||
121 | 47 | } | ||
122 | 48 | |||
123 | 49 | #endif // MIR_SCENE_SURFACE_EVENT_SOURCE_H_ | ||
124 | 0 | 50 | ||
125 | === modified file 'include/server/mir/scene/surface_factory.h' | |||
126 | --- include/server/mir/scene/surface_factory.h 2014-03-31 11:00:33 +0000 | |||
127 | +++ include/server/mir/scene/surface_factory.h 2014-03-31 11:00:33 +0000 | |||
128 | @@ -19,14 +19,11 @@ | |||
129 | 19 | #ifndef MIR_SCENE_SURFACE_FACTORY_H_ | 19 | #ifndef MIR_SCENE_SURFACE_FACTORY_H_ |
130 | 20 | #define MIR_SCENE_SURFACE_FACTORY_H_ | 20 | #define MIR_SCENE_SURFACE_FACTORY_H_ |
131 | 21 | 21 | ||
132 | 22 | #include "mir/frontend/surface_id.h" | ||
133 | 23 | #include "mir/shell/surface_creation_parameters.h" | 22 | #include "mir/shell/surface_creation_parameters.h" |
134 | 24 | #include <memory> | 23 | #include <memory> |
135 | 25 | #include <functional> | ||
136 | 26 | 24 | ||
137 | 27 | namespace mir | 25 | namespace mir |
138 | 28 | { | 26 | { |
139 | 29 | namespace frontend { class EventSink; } | ||
140 | 30 | namespace scene | 27 | namespace scene |
141 | 31 | { | 28 | { |
142 | 32 | class Surface; | 29 | class Surface; |
143 | @@ -38,9 +35,8 @@ | |||
144 | 38 | virtual ~SurfaceFactory() = default; | 35 | virtual ~SurfaceFactory() = default; |
145 | 39 | 36 | ||
146 | 40 | virtual std::shared_ptr<Surface> create_surface( | 37 | virtual std::shared_ptr<Surface> create_surface( |
150 | 41 | frontend::SurfaceId id, | 38 | shell::SurfaceCreationParameters const& params) = 0; |
151 | 42 | shell::SurfaceCreationParameters const& params, | 39 | |
149 | 43 | std::shared_ptr<frontend::EventSink> const& event_sink) = 0; | ||
152 | 44 | private: | 40 | private: |
153 | 45 | SurfaceFactory(const SurfaceFactory&) = delete; | 41 | SurfaceFactory(const SurfaceFactory&) = delete; |
154 | 46 | SurfaceFactory& operator=(const SurfaceFactory&) = delete; | 42 | SurfaceFactory& operator=(const SurfaceFactory&) = delete; |
155 | 47 | 43 | ||
156 | === added file 'include/server/mir/scene/surface_observer.h' | |||
157 | --- include/server/mir/scene/surface_observer.h 1970-01-01 00:00:00 +0000 | |||
158 | +++ include/server/mir/scene/surface_observer.h 2014-03-31 11:00:33 +0000 | |||
159 | @@ -0,0 +1,45 @@ | |||
160 | 1 | /* | ||
161 | 2 | * Copyright © 2014 Canonical Ltd. | ||
162 | 3 | * | ||
163 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
164 | 5 | * under the terms of the GNU General Public License version 3, | ||
165 | 6 | * as published by the Free Software Foundation. | ||
166 | 7 | * | ||
167 | 8 | * This program is distributed in the hope that it will be useful, | ||
168 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
169 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
170 | 11 | * GNU General Public License for more details. | ||
171 | 12 | * | ||
172 | 13 | * You should have received a copy of the GNU General Public License | ||
173 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
174 | 15 | * | ||
175 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | ||
176 | 17 | */ | ||
177 | 18 | |||
178 | 19 | #ifndef MIR_SCENE_SURFACE_OBSERVER_H_ | ||
179 | 20 | #define MIR_SCENE_SURFACE_OBSERVER_H_ | ||
180 | 21 | |||
181 | 22 | #include "mir/geometry/size.h" | ||
182 | 23 | #include "mir_toolkit/common.h" | ||
183 | 24 | |||
184 | 25 | namespace mir | ||
185 | 26 | { | ||
186 | 27 | namespace scene | ||
187 | 28 | { | ||
188 | 29 | // Initial cut - supporting the frontend requirement, more will follow | ||
189 | 30 | class SurfaceObserver | ||
190 | 31 | { | ||
191 | 32 | public: | ||
192 | 33 | virtual void attrib_change(MirSurfaceAttrib attrib, int value) = 0; | ||
193 | 34 | virtual void resize(geometry::Size const& size) = 0; | ||
194 | 35 | |||
195 | 36 | protected: | ||
196 | 37 | SurfaceObserver() = default; | ||
197 | 38 | virtual ~SurfaceObserver() = default; | ||
198 | 39 | SurfaceObserver(SurfaceObserver const&) = delete; | ||
199 | 40 | SurfaceObserver& operator=(SurfaceObserver const&) = delete; | ||
200 | 41 | }; | ||
201 | 42 | } | ||
202 | 43 | } | ||
203 | 44 | |||
204 | 45 | #endif // MIR_SCENE_SURFACE_OBSERVER_H_ | ||
205 | 0 | 46 | ||
206 | === modified file 'include/server/mir/shell/surface_factory.h' | |||
207 | --- include/server/mir/shell/surface_factory.h 2014-03-25 17:04:27 +0000 | |||
208 | +++ include/server/mir/shell/surface_factory.h 2014-03-31 11:00:33 +0000 | |||
209 | @@ -19,15 +19,12 @@ | |||
210 | 19 | #ifndef MIR_SHELL_SURFACE_FACTORY_H_ | 19 | #ifndef MIR_SHELL_SURFACE_FACTORY_H_ |
211 | 20 | #define MIR_SHELL_SURFACE_FACTORY_H_ | 20 | #define MIR_SHELL_SURFACE_FACTORY_H_ |
212 | 21 | 21 | ||
213 | 22 | #include "mir/frontend/surface_id.h" | ||
214 | 23 | #include <memory> | 22 | #include <memory> |
215 | 24 | 23 | ||
216 | 25 | namespace mir | 24 | namespace mir |
217 | 26 | { | 25 | { |
222 | 27 | namespace frontend | 26 | namespace scene { class SurfaceObserver; } |
223 | 28 | { | 27 | |
220 | 29 | class EventSink; | ||
221 | 30 | } | ||
224 | 31 | namespace shell | 28 | namespace shell |
225 | 32 | { | 29 | { |
226 | 33 | class Session; | 30 | class Session; |
227 | @@ -40,8 +37,7 @@ | |||
228 | 40 | virtual std::shared_ptr<Surface> create_surface( | 37 | virtual std::shared_ptr<Surface> create_surface( |
229 | 41 | Session* session, | 38 | Session* session, |
230 | 42 | SurfaceCreationParameters const& params, | 39 | SurfaceCreationParameters const& params, |
233 | 43 | frontend::SurfaceId id, | 40 | std::shared_ptr<scene::SurfaceObserver> const& observer) = 0; |
232 | 44 | std::shared_ptr<frontend::EventSink> const& sink) = 0; | ||
234 | 45 | 41 | ||
235 | 46 | virtual void destroy_surface(std::shared_ptr<Surface> const& surface) = 0; | 42 | virtual void destroy_surface(std::shared_ptr<Surface> const& surface) = 0; |
236 | 47 | 43 | ||
237 | 48 | 44 | ||
238 | === modified file 'include/test/mir_test_doubles/mock_surface.h' | |||
239 | --- include/test/mir_test_doubles/mock_surface.h 2014-03-26 14:20:14 +0000 | |||
240 | +++ include/test/mir_test_doubles/mock_surface.h 2014-03-31 11:00:33 +0000 | |||
241 | @@ -35,14 +35,12 @@ | |||
242 | 35 | { | 35 | { |
243 | 36 | MockSurface() : | 36 | MockSurface() : |
244 | 37 | scene::BasicSurface( | 37 | scene::BasicSurface( |
245 | 38 | frontend::SurfaceId{}, | ||
246 | 39 | {}, | 38 | {}, |
247 | 40 | {{},{}}, | 39 | {{},{}}, |
248 | 41 | true, | 40 | true, |
249 | 42 | {}, | 41 | {}, |
250 | 43 | {}, | 42 | {}, |
251 | 44 | {}, | 43 | {}, |
252 | 45 | {}, | ||
253 | 46 | mir::report::null_scene_report()) | 44 | mir::report::null_scene_report()) |
254 | 47 | { | 45 | { |
255 | 48 | } | 46 | } |
256 | @@ -65,6 +63,7 @@ | |||
257 | 65 | 63 | ||
258 | 66 | MOCK_METHOD2(configure, int(MirSurfaceAttrib, int)); | 64 | MOCK_METHOD2(configure, int(MirSurfaceAttrib, int)); |
259 | 67 | MOCK_METHOD1(take_input_focus, void(std::shared_ptr<shell::InputTargeter> const&)); | 65 | MOCK_METHOD1(take_input_focus, void(std::shared_ptr<shell::InputTargeter> const&)); |
260 | 66 | MOCK_METHOD1(add_observer, void(std::shared_ptr<scene::SurfaceObserver> const&)); | ||
261 | 68 | }; | 67 | }; |
262 | 69 | 68 | ||
263 | 70 | } | 69 | } |
264 | 71 | 70 | ||
265 | === modified file 'include/test/mir_test_doubles/mock_surface_factory.h' | |||
266 | --- include/test/mir_test_doubles/mock_surface_factory.h 2014-03-24 17:30:12 +0000 | |||
267 | +++ include/test/mir_test_doubles/mock_surface_factory.h 2014-03-31 11:00:33 +0000 | |||
268 | @@ -33,11 +33,10 @@ | |||
269 | 33 | 33 | ||
270 | 34 | struct MockSurfaceFactory : public shell::SurfaceFactory | 34 | struct MockSurfaceFactory : public shell::SurfaceFactory |
271 | 35 | { | 35 | { |
273 | 36 | MOCK_METHOD4(create_surface, std::shared_ptr<shell::Surface>( | 36 | MOCK_METHOD3(create_surface, std::shared_ptr<shell::Surface>( |
274 | 37 | shell::Session*, | 37 | shell::Session*, |
275 | 38 | const shell::SurfaceCreationParameters&, | 38 | const shell::SurfaceCreationParameters&, |
278 | 39 | frontend::SurfaceId, | 39 | std::shared_ptr<scene::SurfaceObserver> const&)); |
277 | 40 | std::shared_ptr<frontend::EventSink> const&)); | ||
279 | 41 | 40 | ||
280 | 42 | void destroy_surface(std::shared_ptr<shell::Surface> const& /*surface*/) override {} | 41 | void destroy_surface(std::shared_ptr<shell::Surface> const& /*surface*/) override {} |
281 | 43 | }; | 42 | }; |
282 | 44 | 43 | ||
283 | === modified file 'src/server/scene/CMakeLists.txt' | |||
284 | --- src/server/scene/CMakeLists.txt 2014-03-31 11:00:33 +0000 | |||
285 | +++ src/server/scene/CMakeLists.txt 2014-03-31 11:00:33 +0000 | |||
286 | @@ -13,5 +13,6 @@ | |||
287 | 13 | surface_allocator.cpp | 13 | surface_allocator.cpp |
288 | 14 | surface_stack.cpp | 14 | surface_stack.cpp |
289 | 15 | surface_controller.cpp | 15 | surface_controller.cpp |
290 | 16 | surface_event_source.cpp | ||
291 | 16 | threaded_snapshot_strategy.cpp | 17 | threaded_snapshot_strategy.cpp |
292 | 17 | ) | 18 | ) |
293 | 18 | 19 | ||
294 | === modified file 'src/server/scene/application_session.cpp' | |||
295 | --- src/server/scene/application_session.cpp 2014-03-26 13:02:43 +0000 | |||
296 | +++ src/server/scene/application_session.cpp 2014-03-31 11:00:33 +0000 | |||
297 | @@ -18,6 +18,7 @@ | |||
298 | 18 | 18 | ||
299 | 19 | #include "application_session.h" | 19 | #include "application_session.h" |
300 | 20 | #include "mir/shell/surface.h" | 20 | #include "mir/shell/surface.h" |
301 | 21 | #include "mir/scene/surface_event_source.h" | ||
302 | 21 | #include "mir/shell/surface_factory.h" | 22 | #include "mir/shell/surface_factory.h" |
303 | 22 | #include "snapshot_strategy.h" | 23 | #include "snapshot_strategy.h" |
304 | 23 | #include "mir/shell/session_listener.h" | 24 | #include "mir/shell/session_listener.h" |
305 | @@ -71,7 +72,9 @@ | |||
306 | 71 | mf::SurfaceId ms::ApplicationSession::create_surface(const msh::SurfaceCreationParameters& params) | 72 | mf::SurfaceId ms::ApplicationSession::create_surface(const msh::SurfaceCreationParameters& params) |
307 | 72 | { | 73 | { |
308 | 73 | auto const id = next_id(); | 74 | auto const id = next_id(); |
310 | 74 | auto surf = surface_factory->create_surface(this, params, id, event_sink); | 75 | |
311 | 76 | auto const observer = std::make_shared<scene::SurfaceEventSource>(id, event_sink); | ||
312 | 77 | auto surf = surface_factory->create_surface(this, params, observer); | ||
313 | 75 | 78 | ||
314 | 76 | std::unique_lock<std::mutex> lock(surfaces_mutex); | 79 | std::unique_lock<std::mutex> lock(surfaces_mutex); |
315 | 77 | surfaces[id] = surf; | 80 | surfaces[id] = surf; |
316 | 78 | 81 | ||
317 | === modified file 'src/server/scene/basic_surface.cpp' | |||
318 | --- src/server/scene/basic_surface.cpp 2014-03-26 14:20:14 +0000 | |||
319 | +++ src/server/scene/basic_surface.cpp 2014-03-31 11:00:33 +0000 | |||
320 | @@ -31,7 +31,7 @@ | |||
321 | 31 | #include <boost/throw_exception.hpp> | 31 | #include <boost/throw_exception.hpp> |
322 | 32 | 32 | ||
323 | 33 | #include <stdexcept> | 33 | #include <stdexcept> |
325 | 34 | #include <cstring> | 34 | #include <algorithm> |
326 | 35 | 35 | ||
327 | 36 | namespace mc = mir::compositor; | 36 | namespace mc = mir::compositor; |
328 | 37 | namespace ms = mir::scene; | 37 | namespace ms = mir::scene; |
329 | @@ -58,17 +58,45 @@ | |||
330 | 58 | notifier(); | 58 | notifier(); |
331 | 59 | } | 59 | } |
332 | 60 | 60 | ||
333 | 61 | void ms::SurfaceObservers::attrib_change(MirSurfaceAttrib attrib, int value) | ||
334 | 62 | { | ||
335 | 63 | std::unique_lock<decltype(mutex)> lock(mutex); | ||
336 | 64 | // TBD Maybe we should copy observers so we can release the lock? | ||
337 | 65 | for (auto const& p : observers) | ||
338 | 66 | p->attrib_change(attrib, value); | ||
339 | 67 | } | ||
340 | 68 | |||
341 | 69 | void ms::SurfaceObservers::resize(geometry::Size const& size) | ||
342 | 70 | { | ||
343 | 71 | std::unique_lock<decltype(mutex)> lock(mutex); | ||
344 | 72 | // TBD Maybe we should copy observers so we can release the lock? | ||
345 | 73 | for (auto const& p : observers) | ||
346 | 74 | p->resize(size); | ||
347 | 75 | } | ||
348 | 76 | |||
349 | 77 | void ms::SurfaceObservers::add(std::shared_ptr<SurfaceObserver> const& observer) | ||
350 | 78 | { | ||
351 | 79 | if (observer) | ||
352 | 80 | { | ||
353 | 81 | std::unique_lock<decltype(mutex)> lock(mutex); | ||
354 | 82 | observers.push_back(observer); | ||
355 | 83 | } | ||
356 | 84 | } | ||
357 | 85 | |||
358 | 86 | void ms::SurfaceObservers::remove(std::shared_ptr<SurfaceObserver> const& observer) | ||
359 | 87 | { | ||
360 | 88 | std::unique_lock<decltype(mutex)> lock(mutex); | ||
361 | 89 | observers.erase(std::remove(observers.begin(),observers.end(), observer), observers.end()); | ||
362 | 90 | } | ||
363 | 91 | |||
364 | 61 | ms::BasicSurface::BasicSurface( | 92 | ms::BasicSurface::BasicSurface( |
365 | 62 | frontend::SurfaceId id, | ||
366 | 63 | std::string const& name, | 93 | std::string const& name, |
367 | 64 | geometry::Rectangle rect, | 94 | geometry::Rectangle rect, |
368 | 65 | bool nonrectangular, | 95 | bool nonrectangular, |
370 | 66 | std::shared_ptr<mc::BufferStream> const& buffer_stream, | 96 | std::shared_ptr<compositor::BufferStream> const& buffer_stream, |
371 | 67 | std::shared_ptr<input::InputChannel> const& input_channel, | 97 | std::shared_ptr<input::InputChannel> const& input_channel, |
372 | 68 | std::shared_ptr<frontend::EventSink> const& event_sink, | ||
373 | 69 | std::shared_ptr<SurfaceConfigurator> const& configurator, | 98 | std::shared_ptr<SurfaceConfigurator> const& configurator, |
374 | 70 | std::shared_ptr<SceneReport> const& report) : | 99 | std::shared_ptr<SceneReport> const& report) : |
375 | 71 | id(id), | ||
376 | 72 | notify_change([](){}), | 100 | notify_change([](){}), |
377 | 73 | surface_name(name), | 101 | surface_name(name), |
378 | 74 | surface_rect(rect), | 102 | surface_rect(rect), |
379 | @@ -79,7 +107,6 @@ | |||
380 | 79 | input_rectangles{surface_rect}, | 107 | input_rectangles{surface_rect}, |
381 | 80 | surface_buffer_stream(buffer_stream), | 108 | surface_buffer_stream(buffer_stream), |
382 | 81 | server_input_channel(input_channel), | 109 | server_input_channel(input_channel), |
383 | 82 | event_sink(event_sink), | ||
384 | 83 | configurator(configurator), | 110 | configurator(configurator), |
385 | 84 | report(report), | 111 | report(report), |
386 | 85 | type_value(mir_surface_type_normal), | 112 | type_value(mir_surface_type_normal), |
387 | @@ -222,13 +249,7 @@ | |||
388 | 222 | surface_rect.size = size; | 249 | surface_rect.size = size; |
389 | 223 | } | 250 | } |
390 | 224 | notify_change(); | 251 | notify_change(); |
398 | 225 | MirEvent e; | 252 | observers.resize(size); |
392 | 226 | memset(&e, 0, sizeof e); | ||
393 | 227 | e.type = mir_event_type_resize; | ||
394 | 228 | e.resize.surface_id = id.as_value(); | ||
395 | 229 | e.resize.width = size.width.as_int(); | ||
396 | 230 | e.resize.height = size.height.as_int(); | ||
397 | 231 | event_sink->handle_event(e); | ||
399 | 232 | } | 253 | } |
400 | 233 | 254 | ||
401 | 234 | geom::Point ms::BasicSurface::top_left() const | 255 | geom::Point ms::BasicSurface::top_left() const |
402 | @@ -363,29 +384,12 @@ | |||
403 | 363 | state_value = s; | 384 | state_value = s; |
404 | 364 | valid = true; | 385 | valid = true; |
405 | 365 | 386 | ||
407 | 366 | notify_attrib_change(mir_surface_attrib_state, s); | 387 | observers.attrib_change(mir_surface_attrib_state, s); |
408 | 367 | } | 388 | } |
409 | 368 | 389 | ||
410 | 369 | return valid; | 390 | return valid; |
411 | 370 | } | 391 | } |
412 | 371 | 392 | ||
413 | 372 | void ms::BasicSurface::notify_attrib_change(MirSurfaceAttrib attrib, int value) | ||
414 | 373 | { | ||
415 | 374 | MirEvent e; | ||
416 | 375 | |||
417 | 376 | // This memset is not really required. However it does avoid some | ||
418 | 377 | // harmless uninitialized memory reads that valgrind will complain | ||
419 | 378 | // about, due to gaps in MirEvent. | ||
420 | 379 | memset(&e, 0, sizeof e); | ||
421 | 380 | |||
422 | 381 | e.type = mir_event_type_surface; | ||
423 | 382 | e.surface.id = id.as_value(); | ||
424 | 383 | e.surface.attrib = attrib; | ||
425 | 384 | e.surface.value = value; | ||
426 | 385 | |||
427 | 386 | event_sink->handle_event(e); | ||
428 | 387 | } | ||
429 | 388 | |||
430 | 389 | void ms::BasicSurface::take_input_focus(std::shared_ptr<msh::InputTargeter> const& targeter) | 393 | void ms::BasicSurface::take_input_focus(std::shared_ptr<msh::InputTargeter> const& targeter) |
431 | 390 | { | 394 | { |
432 | 391 | targeter->focus_changed(input_channel()); | 395 | targeter->focus_changed(input_channel()); |
433 | @@ -415,7 +419,7 @@ | |||
434 | 415 | result = state(); | 419 | result = state(); |
435 | 416 | break; | 420 | break; |
436 | 417 | case mir_surface_attrib_focus: | 421 | case mir_surface_attrib_focus: |
438 | 418 | notify_attrib_change(attrib, value); | 422 | observers.attrib_change(attrib, value); |
439 | 419 | break; | 423 | break; |
440 | 420 | case mir_surface_attrib_swapinterval: | 424 | case mir_surface_attrib_swapinterval: |
441 | 421 | allow_dropping = (value == 0); | 425 | allow_dropping = (value == 0); |
442 | @@ -443,3 +447,13 @@ | |||
443 | 443 | set_hidden(false); | 447 | set_hidden(false); |
444 | 444 | } | 448 | } |
445 | 445 | 449 | ||
446 | 450 | |||
447 | 451 | void ms::BasicSurface::add_observer(std::shared_ptr<SurfaceObserver> const& observer) | ||
448 | 452 | { | ||
449 | 453 | observers.add(observer); | ||
450 | 454 | } | ||
451 | 455 | |||
452 | 456 | void ms::BasicSurface::remove_observer(std::shared_ptr<SurfaceObserver> const& observer) | ||
453 | 457 | { | ||
454 | 458 | observers.remove(observer); | ||
455 | 459 | } | ||
456 | 446 | 460 | ||
457 | === modified file 'src/server/scene/basic_surface.h' | |||
458 | --- src/server/scene/basic_surface.h 2014-03-26 14:20:14 +0000 | |||
459 | +++ src/server/scene/basic_surface.h 2014-03-31 11:00:33 +0000 | |||
460 | @@ -20,8 +20,8 @@ | |||
461 | 20 | #define MIR_SCENE_BASIC_SURFACE_H_ | 20 | #define MIR_SCENE_BASIC_SURFACE_H_ |
462 | 21 | 21 | ||
463 | 22 | #include "mir/scene/surface.h" | 22 | #include "mir/scene/surface.h" |
464 | 23 | #include "mir/scene/surface_observer.h" | ||
465 | 23 | 24 | ||
466 | 24 | #include "mir/frontend/surface_id.h" | ||
467 | 25 | #include "mir/geometry/rectangle.h" | 25 | #include "mir/geometry/rectangle.h" |
468 | 26 | 26 | ||
469 | 27 | #include "mir_toolkit/common.h" | 27 | #include "mir_toolkit/common.h" |
470 | @@ -71,17 +71,30 @@ | |||
471 | 71 | std::function<void()> notify_change; | 71 | std::function<void()> notify_change; |
472 | 72 | }; | 72 | }; |
473 | 73 | 73 | ||
474 | 74 | class SurfaceObservers : public SurfaceObserver | ||
475 | 75 | { | ||
476 | 76 | public: | ||
477 | 77 | |||
478 | 78 | void attrib_change(MirSurfaceAttrib attrib, int value) override; | ||
479 | 79 | void resize(geometry::Size const& size) override; | ||
480 | 80 | |||
481 | 81 | void add(std::shared_ptr<SurfaceObserver> const& observer); | ||
482 | 82 | void remove(std::shared_ptr<SurfaceObserver> const& observer); | ||
483 | 83 | |||
484 | 84 | private: | ||
485 | 85 | std::mutex mutex; | ||
486 | 86 | std::vector<std::shared_ptr<SurfaceObserver>> observers; | ||
487 | 87 | }; | ||
488 | 88 | |||
489 | 74 | class BasicSurface : public Surface | 89 | class BasicSurface : public Surface |
490 | 75 | { | 90 | { |
491 | 76 | public: | 91 | public: |
492 | 77 | BasicSurface( | 92 | BasicSurface( |
493 | 78 | frontend::SurfaceId id, | ||
494 | 79 | std::string const& name, | 93 | std::string const& name, |
495 | 80 | geometry::Rectangle rect, | 94 | geometry::Rectangle rect, |
496 | 81 | bool nonrectangular, | 95 | bool nonrectangular, |
497 | 82 | std::shared_ptr<compositor::BufferStream> const& buffer_stream, | 96 | std::shared_ptr<compositor::BufferStream> const& buffer_stream, |
498 | 83 | std::shared_ptr<input::InputChannel> const& input_channel, | 97 | std::shared_ptr<input::InputChannel> const& input_channel, |
499 | 84 | std::shared_ptr<frontend::EventSink> const& event_sink, | ||
500 | 85 | std::shared_ptr<SurfaceConfigurator> const& configurator, | 98 | std::shared_ptr<SurfaceConfigurator> const& configurator, |
501 | 86 | std::shared_ptr<SceneReport> const& report); | 99 | std::shared_ptr<SceneReport> const& report); |
502 | 87 | 100 | ||
503 | @@ -136,13 +149,15 @@ | |||
504 | 136 | void hide() override; | 149 | void hide() override; |
505 | 137 | void show() override; | 150 | void show() override; |
506 | 138 | 151 | ||
507 | 152 | void add_observer(std::shared_ptr<SurfaceObserver> const& observer) override; | ||
508 | 153 | void remove_observer(std::shared_ptr<SurfaceObserver> const& observer) override; | ||
509 | 154 | |||
510 | 139 | private: | 155 | private: |
511 | 140 | bool set_type(MirSurfaceType t); // Use configure() to make public changes | 156 | bool set_type(MirSurfaceType t); // Use configure() to make public changes |
512 | 141 | bool set_state(MirSurfaceState s); | 157 | bool set_state(MirSurfaceState s); |
513 | 142 | void notify_attrib_change(MirSurfaceAttrib attrib, int value); | ||
514 | 143 | 158 | ||
515 | 159 | SurfaceObservers observers; | ||
516 | 144 | std::mutex mutable guard; | 160 | std::mutex mutable guard; |
517 | 145 | frontend::SurfaceId const id; | ||
518 | 146 | ThreadsafeCallback notify_change; | 161 | ThreadsafeCallback notify_change; |
519 | 147 | std::string const surface_name; | 162 | std::string const surface_name; |
520 | 148 | geometry::Rectangle surface_rect; | 163 | geometry::Rectangle surface_rect; |
521 | @@ -154,7 +169,6 @@ | |||
522 | 154 | std::vector<geometry::Rectangle> input_rectangles; | 169 | std::vector<geometry::Rectangle> input_rectangles; |
523 | 155 | std::shared_ptr<compositor::BufferStream> const surface_buffer_stream; | 170 | std::shared_ptr<compositor::BufferStream> const surface_buffer_stream; |
524 | 156 | std::shared_ptr<input::InputChannel> const server_input_channel; | 171 | std::shared_ptr<input::InputChannel> const server_input_channel; |
525 | 157 | std::shared_ptr<frontend::EventSink> const event_sink; | ||
526 | 158 | std::shared_ptr<SurfaceConfigurator> const configurator; | 172 | std::shared_ptr<SurfaceConfigurator> const configurator; |
527 | 159 | std::shared_ptr<SceneReport> const report; | 173 | std::shared_ptr<SceneReport> const report; |
528 | 160 | 174 | ||
529 | 161 | 175 | ||
530 | === modified file 'src/server/scene/surface_allocator.cpp' | |||
531 | --- src/server/scene/surface_allocator.cpp 2014-03-26 14:20:14 +0000 | |||
532 | +++ src/server/scene/surface_allocator.cpp 2014-03-31 11:00:33 +0000 | |||
533 | @@ -48,9 +48,7 @@ | |||
534 | 48 | } | 48 | } |
535 | 49 | 49 | ||
536 | 50 | std::shared_ptr<ms::Surface> ms::SurfaceAllocator::create_surface( | 50 | std::shared_ptr<ms::Surface> ms::SurfaceAllocator::create_surface( |
540 | 51 | frontend::SurfaceId id, | 51 | shell::SurfaceCreationParameters const& params) |
538 | 52 | msh::SurfaceCreationParameters const& params, | ||
539 | 53 | std::shared_ptr<frontend::EventSink> const& event_sink) | ||
541 | 54 | { | 52 | { |
542 | 55 | mg::BufferProperties buffer_properties{params.size, | 53 | mg::BufferProperties buffer_properties{params.size, |
543 | 56 | params.pixel_format, | 54 | params.pixel_format, |
544 | @@ -60,14 +58,14 @@ | |||
545 | 60 | 58 | ||
546 | 61 | bool nonrectangular = has_alpha(params.pixel_format); | 59 | bool nonrectangular = has_alpha(params.pixel_format); |
547 | 62 | auto input_channel = input_factory->make_input_channel(); | 60 | auto input_channel = input_factory->make_input_channel(); |
550 | 63 | return std::make_shared<BasicSurface>( | 61 | auto const surface = std::make_shared<BasicSurface>( |
549 | 64 | id, | ||
551 | 65 | params.name, | 62 | params.name, |
552 | 66 | actual_size, | 63 | actual_size, |
553 | 67 | nonrectangular, | 64 | nonrectangular, |
554 | 68 | buffer_stream, | 65 | buffer_stream, |
555 | 69 | input_channel, | 66 | input_channel, |
556 | 70 | event_sink, | ||
557 | 71 | configurator, | 67 | configurator, |
558 | 72 | report); | 68 | report); |
559 | 69 | |||
560 | 70 | return surface; | ||
561 | 73 | } | 71 | } |
562 | 74 | 72 | ||
563 | === modified file 'src/server/scene/surface_allocator.h' | |||
564 | --- src/server/scene/surface_allocator.h 2014-03-31 11:00:33 +0000 | |||
565 | +++ src/server/scene/surface_allocator.h 2014-03-31 11:00:33 +0000 | |||
566 | @@ -42,9 +42,7 @@ | |||
567 | 42 | std::shared_ptr<SceneReport> const& report); | 42 | std::shared_ptr<SceneReport> const& report); |
568 | 43 | 43 | ||
569 | 44 | std::shared_ptr<Surface> create_surface( | 44 | std::shared_ptr<Surface> create_surface( |
573 | 45 | frontend::SurfaceId id, | 45 | shell::SurfaceCreationParameters const& params) override; |
571 | 46 | shell::SurfaceCreationParameters const& params, | ||
572 | 47 | std::shared_ptr<frontend::EventSink> const& event_sink) override; | ||
574 | 48 | 46 | ||
575 | 49 | private: | 47 | private: |
576 | 50 | std::shared_ptr<BufferStreamFactory> const buffer_stream_factory; | 48 | std::shared_ptr<BufferStreamFactory> const buffer_stream_factory; |
577 | 51 | 49 | ||
578 | === modified file 'src/server/scene/surface_controller.cpp' | |||
579 | --- src/server/scene/surface_controller.cpp 2014-03-31 11:00:33 +0000 | |||
580 | +++ src/server/scene/surface_controller.cpp 2014-03-31 11:00:33 +0000 | |||
581 | @@ -19,6 +19,7 @@ | |||
582 | 19 | #include "surface_controller.h" | 19 | #include "surface_controller.h" |
583 | 20 | #include "surface_stack_model.h" | 20 | #include "surface_stack_model.h" |
584 | 21 | #include "mir/scene/surface_factory.h" | 21 | #include "mir/scene/surface_factory.h" |
585 | 22 | #include "mir/scene/surface.h" | ||
586 | 22 | 23 | ||
587 | 23 | namespace ms = mir::scene; | 24 | namespace ms = mir::scene; |
588 | 24 | namespace msh = mir::shell; | 25 | namespace msh = mir::shell; |
589 | @@ -32,11 +33,11 @@ | |||
590 | 32 | } | 33 | } |
591 | 33 | 34 | ||
592 | 34 | std::shared_ptr<ms::Surface> ms::SurfaceController::add_surface( | 35 | std::shared_ptr<ms::Surface> ms::SurfaceController::add_surface( |
593 | 35 | frontend::SurfaceId id, | ||
594 | 36 | shell::SurfaceCreationParameters const& params, | 36 | shell::SurfaceCreationParameters const& params, |
596 | 37 | std::shared_ptr<frontend::EventSink> const& event_sink) | 37 | std::shared_ptr<SurfaceObserver> const& observer) |
597 | 38 | { | 38 | { |
599 | 39 | auto const surface = surface_factory->create_surface(id, params, event_sink); | 39 | auto const surface = surface_factory->create_surface(params); |
600 | 40 | surface->add_observer(observer); | ||
601 | 40 | surface_stack->add_surface(surface, params.depth, params.input_mode); | 41 | surface_stack->add_surface(surface, params.depth, params.input_mode); |
602 | 41 | return surface; | 42 | return surface; |
603 | 42 | } | 43 | } |
604 | 43 | 44 | ||
605 | === modified file 'src/server/scene/surface_controller.h' | |||
606 | --- src/server/scene/surface_controller.h 2014-03-31 11:00:33 +0000 | |||
607 | +++ src/server/scene/surface_controller.h 2014-03-31 11:00:33 +0000 | |||
608 | @@ -24,11 +24,6 @@ | |||
609 | 24 | 24 | ||
610 | 25 | namespace mir | 25 | namespace mir |
611 | 26 | { | 26 | { |
612 | 27 | namespace shell | ||
613 | 28 | { | ||
614 | 29 | class Session; | ||
615 | 30 | } | ||
616 | 31 | |||
617 | 32 | namespace scene | 27 | namespace scene |
618 | 33 | { | 28 | { |
619 | 34 | class SurfaceStackModel; | 29 | class SurfaceStackModel; |
620 | @@ -43,9 +38,8 @@ | |||
621 | 43 | std::shared_ptr<SurfaceStackModel> const& surface_stack); | 38 | std::shared_ptr<SurfaceStackModel> const& surface_stack); |
622 | 44 | 39 | ||
623 | 45 | std::shared_ptr<Surface> add_surface( | 40 | std::shared_ptr<Surface> add_surface( |
624 | 46 | frontend::SurfaceId id, | ||
625 | 47 | shell::SurfaceCreationParameters const& params, | 41 | shell::SurfaceCreationParameters const& params, |
627 | 48 | std::shared_ptr<frontend::EventSink> const& event_sink) override; | 42 | std::shared_ptr<SurfaceObserver> const& observer) override; |
628 | 49 | 43 | ||
629 | 50 | void remove_surface(std::weak_ptr<Surface> const& surface) override; | 44 | void remove_surface(std::weak_ptr<Surface> const& surface) override; |
630 | 51 | 45 | ||
631 | 52 | 46 | ||
632 | === added file 'src/server/scene/surface_event_source.cpp' | |||
633 | --- src/server/scene/surface_event_source.cpp 1970-01-01 00:00:00 +0000 | |||
634 | +++ src/server/scene/surface_event_source.cpp 2014-03-31 11:00:33 +0000 | |||
635 | @@ -0,0 +1,62 @@ | |||
636 | 1 | /* | ||
637 | 2 | * Copyright © 2014 Canonical Ltd. | ||
638 | 3 | * | ||
639 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
640 | 5 | * under the terms of the GNU General Public License version 3, | ||
641 | 6 | * as published by the Free Software Foundation. | ||
642 | 7 | * | ||
643 | 8 | * This program is distributed in the hope that it will be useful, | ||
644 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
645 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
646 | 11 | * GNU General Public License for more details. | ||
647 | 12 | * | ||
648 | 13 | * You should have received a copy of the GNU General Public License | ||
649 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
650 | 15 | * | ||
651 | 16 | * Authored by: Alan Griffiths <alan@octopull.co.uk> | ||
652 | 17 | */ | ||
653 | 18 | |||
654 | 19 | #include "mir/scene/surface_event_source.h" | ||
655 | 20 | |||
656 | 21 | #include <cstring> | ||
657 | 22 | #include <algorithm> | ||
658 | 23 | |||
659 | 24 | namespace ms = mir::scene; | ||
660 | 25 | namespace geom = mir::geometry; | ||
661 | 26 | |||
662 | 27 | ms::SurfaceEventSource::SurfaceEventSource( | ||
663 | 28 | frontend::SurfaceId id, | ||
664 | 29 | std::shared_ptr<frontend::EventSink> const& event_sink) : | ||
665 | 30 | id(id), | ||
666 | 31 | event_sink(event_sink) | ||
667 | 32 | { | ||
668 | 33 | } | ||
669 | 34 | |||
670 | 35 | void ms::SurfaceEventSource::resize(geom::Size const& size) | ||
671 | 36 | { | ||
672 | 37 | MirEvent e; | ||
673 | 38 | memset(&e, 0, sizeof e); | ||
674 | 39 | e.type = mir_event_type_resize; | ||
675 | 40 | e.resize.surface_id = id.as_value(); | ||
676 | 41 | e.resize.width = size.width.as_int(); | ||
677 | 42 | e.resize.height = size.height.as_int(); | ||
678 | 43 | event_sink->handle_event(e); | ||
679 | 44 | } | ||
680 | 45 | |||
681 | 46 | |||
682 | 47 | void ms::SurfaceEventSource::attrib_change(MirSurfaceAttrib attrib, int value) | ||
683 | 48 | { | ||
684 | 49 | MirEvent e; | ||
685 | 50 | |||
686 | 51 | // This memset is not really required. However it does avoid some | ||
687 | 52 | // harmless uninitialized memory reads that valgrind will complain | ||
688 | 53 | // about, due to gaps in MirEvent. | ||
689 | 54 | memset(&e, 0, sizeof e); | ||
690 | 55 | |||
691 | 56 | e.type = mir_event_type_surface; | ||
692 | 57 | e.surface.id = id.as_value(); | ||
693 | 58 | e.surface.attrib = attrib; | ||
694 | 59 | e.surface.value = value; | ||
695 | 60 | |||
696 | 61 | event_sink->handle_event(e); | ||
697 | 62 | } | ||
698 | 0 | 63 | ||
699 | === modified file 'src/server/shell/organising_surface_factory.cpp' | |||
700 | --- src/server/shell/organising_surface_factory.cpp 2014-03-31 11:00:33 +0000 | |||
701 | +++ src/server/shell/organising_surface_factory.cpp 2014-03-31 11:00:33 +0000 | |||
702 | @@ -42,13 +42,12 @@ | |||
703 | 42 | 42 | ||
704 | 43 | std::shared_ptr<msh::Surface> msh::OrganisingSurfaceFactory::create_surface( | 43 | std::shared_ptr<msh::Surface> msh::OrganisingSurfaceFactory::create_surface( |
705 | 44 | Session* session, | 44 | Session* session, |
709 | 45 | shell::SurfaceCreationParameters const& params, | 45 | SurfaceCreationParameters const& params, |
710 | 46 | frontend::SurfaceId id, | 46 | std::shared_ptr<scene::SurfaceObserver> const& observer) |
708 | 47 | std::shared_ptr<mf::EventSink> const& sender) | ||
711 | 48 | { | 47 | { |
712 | 49 | auto placed_params = placement_strategy->place(*session, params); | 48 | auto placed_params = placement_strategy->place(*session, params); |
713 | 50 | 49 | ||
715 | 51 | return surface_coordinator->add_surface(id, placed_params, sender); | 50 | return surface_coordinator->add_surface(placed_params, observer); |
716 | 52 | } | 51 | } |
717 | 53 | 52 | ||
718 | 54 | void msh::OrganisingSurfaceFactory::destroy_surface(std::shared_ptr<Surface> const& surface) | 53 | void msh::OrganisingSurfaceFactory::destroy_surface(std::shared_ptr<Surface> const& surface) |
719 | 55 | 54 | ||
720 | === modified file 'src/server/shell/organising_surface_factory.h' | |||
721 | --- src/server/shell/organising_surface_factory.h 2014-03-31 11:00:33 +0000 | |||
722 | +++ src/server/shell/organising_surface_factory.h 2014-03-31 11:00:33 +0000 | |||
723 | @@ -41,9 +41,8 @@ | |||
724 | 41 | 41 | ||
725 | 42 | std::shared_ptr<Surface> create_surface( | 42 | std::shared_ptr<Surface> create_surface( |
726 | 43 | Session* session, | 43 | Session* session, |
730 | 44 | shell::SurfaceCreationParameters const& params, | 44 | SurfaceCreationParameters const& params, |
731 | 45 | frontend::SurfaceId id, | 45 | std::shared_ptr<scene::SurfaceObserver> const& observer) override; |
729 | 46 | std::shared_ptr<frontend::EventSink> const& sink) override; | ||
732 | 47 | 46 | ||
733 | 48 | void destroy_surface(std::shared_ptr<Surface> const& surface) override; | 47 | void destroy_surface(std::shared_ptr<Surface> const& surface) override; |
734 | 49 | 48 | ||
735 | 50 | 49 | ||
736 | === modified file 'tests/acceptance-tests/test_client_input.cpp' | |||
737 | --- tests/acceptance-tests/test_client_input.cpp 2014-03-26 14:20:14 +0000 | |||
738 | +++ tests/acceptance-tests/test_client_input.cpp 2014-03-31 11:00:33 +0000 | |||
739 | @@ -335,12 +335,12 @@ | |||
740 | 335 | { | 335 | { |
741 | 336 | } | 336 | } |
742 | 337 | 337 | ||
747 | 338 | std::shared_ptr<msh::Surface> create_surface(msh::Session* session, | 338 | std::shared_ptr<msh::Surface> create_surface( |
748 | 339 | msh::SurfaceCreationParameters const& params, | 339 | msh::Session* session, |
749 | 340 | mf::SurfaceId id, | 340 | msh::SurfaceCreationParameters const& params, |
750 | 341 | std::shared_ptr<mf::EventSink> const& sink) | 341 | std::shared_ptr<ms::SurfaceObserver> const& observer) override |
751 | 342 | { | 342 | { |
753 | 343 | auto surface = underlying_factory->create_surface(session, params, id, sink); | 343 | auto surface = underlying_factory->create_surface(session, params, observer); |
754 | 344 | 344 | ||
755 | 345 | surface->set_input_region(input_rectangles); | 345 | surface->set_input_region(input_rectangles); |
756 | 346 | 346 | ||
757 | 347 | 347 | ||
758 | === modified file 'tests/integration-tests/graphics/android/test_internal_client.cpp' | |||
759 | --- tests/integration-tests/graphics/android/test_internal_client.cpp 2014-03-31 11:00:33 +0000 | |||
760 | +++ tests/integration-tests/graphics/android/test_internal_client.cpp 2014-03-31 11:00:33 +0000 | |||
761 | @@ -33,6 +33,7 @@ | |||
762 | 33 | #include "mir/scene/scene_report.h" | 33 | #include "mir/scene/scene_report.h" |
763 | 34 | #include "src/server/scene/surface_allocator.h" | 34 | #include "src/server/scene/surface_allocator.h" |
764 | 35 | #include "mir/scene/surface.h" | 35 | #include "mir/scene/surface.h" |
765 | 36 | #include "mir/scene/surface_event_source.h" | ||
766 | 36 | #include "mir/shell/surface_creation_parameters.h" | 37 | #include "mir/shell/surface_creation_parameters.h" |
767 | 37 | #include "mir/frontend/surface_id.h" | 38 | #include "mir/frontend/surface_id.h" |
768 | 38 | #include "mir/input/input_channel_factory.h" | 39 | #include "mir/input/input_channel_factory.h" |
769 | @@ -98,7 +99,8 @@ | |||
770 | 98 | auto surface_allocator = std::make_shared<ms::SurfaceAllocator>(buffer_stream_factory, stub_input_factory, std::make_shared<mtd::NullSurfaceConfigurator>(), scene_report); | 99 | auto surface_allocator = std::make_shared<ms::SurfaceAllocator>(buffer_stream_factory, stub_input_factory, std::make_shared<mtd::NullSurfaceConfigurator>(), scene_report); |
771 | 99 | auto ss = std::make_shared<ms::SurfaceStack>(stub_input_registrar, scene_report); | 100 | auto ss = std::make_shared<ms::SurfaceStack>(stub_input_registrar, scene_report); |
772 | 100 | auto surface_controller = std::make_shared<ms::SurfaceController>(surface_allocator, ss); | 101 | auto surface_controller = std::make_shared<ms::SurfaceController>(surface_allocator, ss); |
774 | 101 | auto surface = surface_controller->add_surface(id, params, std::shared_ptr<mf::EventSink>()); | 102 | auto const observer = std::make_shared<ms::SurfaceEventSource>(id, std::shared_ptr<mf::EventSink>()); |
775 | 103 | auto surface = surface_controller->add_surface(params, observer); | ||
776 | 102 | surface->allow_framedropping(true); | 104 | surface->allow_framedropping(true); |
777 | 103 | auto mir_surface = as_internal_surface(surface); | 105 | auto mir_surface = as_internal_surface(surface); |
778 | 104 | 106 | ||
779 | 105 | 107 | ||
780 | === modified file 'tests/integration-tests/test_session_manager.cpp' | |||
781 | --- tests/integration-tests/test_session_manager.cpp 2014-03-06 06:05:17 +0000 | |||
782 | +++ tests/integration-tests/test_session_manager.cpp 2014-03-31 11:00:33 +0000 | |||
783 | @@ -60,7 +60,7 @@ | |||
784 | 60 | 60 | ||
785 | 61 | } | 61 | } |
786 | 62 | 62 | ||
788 | 63 | mtd::MockSurfaceFactory surface_factory; | 63 | mtd::MockSurfaceFactory surface_factory; // TODO this isn't used as a mock |
789 | 64 | ms::DefaultSessionContainer container; | 64 | ms::DefaultSessionContainer container; |
790 | 65 | mtd::MockFocusSetter focus_setter; | 65 | mtd::MockFocusSetter focus_setter; |
791 | 66 | std::shared_ptr<mf::Session> new_session; | 66 | std::shared_ptr<mf::Session> new_session; |
792 | 67 | 67 | ||
793 | === modified file 'tests/unit-tests/scene/test_application_session.cpp' | |||
794 | --- tests/unit-tests/scene/test_application_session.cpp 2014-03-31 11:00:33 +0000 | |||
795 | +++ tests/unit-tests/scene/test_application_session.cpp 2014-03-31 11:00:33 +0000 | |||
796 | @@ -84,7 +84,7 @@ | |||
797 | 84 | mtd::NullEventSink sender; | 84 | mtd::NullEventSink sender; |
798 | 85 | mtd::MockSurfaceFactory surface_factory; | 85 | mtd::MockSurfaceFactory surface_factory; |
799 | 86 | 86 | ||
801 | 87 | EXPECT_CALL(surface_factory, create_surface(_, _, _, _)) | 87 | EXPECT_CALL(surface_factory, create_surface(_, _, _)) |
802 | 88 | .WillOnce(Return(mock_surface)); | 88 | .WillOnce(Return(mock_surface)); |
803 | 89 | 89 | ||
804 | 90 | mtd::MockSessionListener listener; | 90 | mtd::MockSessionListener listener; |
805 | @@ -115,9 +115,9 @@ | |||
806 | 115 | 115 | ||
807 | 116 | mtd::NullEventSink sender; | 116 | mtd::NullEventSink sender; |
808 | 117 | mtd::MockSurfaceFactory surface_factory; | 117 | mtd::MockSurfaceFactory surface_factory; |
810 | 118 | ON_CALL(surface_factory, create_surface(_,_,_,_)).WillByDefault(Return(mock_surface)); | 118 | ON_CALL(surface_factory, create_surface(_,_,_)).WillByDefault(Return(mock_surface)); |
811 | 119 | 119 | ||
813 | 120 | EXPECT_CALL(surface_factory, create_surface(_, _, _, _)); | 120 | EXPECT_CALL(surface_factory, create_surface(_, _, _)); |
814 | 121 | 121 | ||
815 | 122 | mtd::MockSessionListener listener; | 122 | mtd::MockSessionListener listener; |
816 | 123 | EXPECT_CALL(listener, surface_created(_, _)).Times(1); | 123 | EXPECT_CALL(listener, surface_created(_, _)).Times(1); |
817 | @@ -146,11 +146,11 @@ | |||
818 | 146 | 146 | ||
819 | 147 | { | 147 | { |
820 | 148 | InSequence seq; | 148 | InSequence seq; |
826 | 149 | EXPECT_CALL(surface_factory, create_surface(_, _, _, _)).Times(1) | 149 | EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1) |
827 | 150 | .WillOnce(Return(make_mock_surface())); | 150 | .WillOnce(Return(make_mock_surface())); |
828 | 151 | EXPECT_CALL(surface_factory, create_surface(_, _, _, _)).Times(1) | 151 | EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1) |
829 | 152 | .WillOnce(Return(make_mock_surface())); | 152 | .WillOnce(Return(make_mock_surface())); |
830 | 153 | EXPECT_CALL(surface_factory, create_surface(_, _, _, _)).Times(1) | 153 | EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1) |
831 | 154 | .WillOnce(Return(make_mock_surface())); | 154 | .WillOnce(Return(make_mock_surface())); |
832 | 155 | } | 155 | } |
833 | 156 | 156 | ||
834 | @@ -189,7 +189,7 @@ | |||
835 | 189 | auto mock_surface = make_mock_surface(); | 189 | auto mock_surface = make_mock_surface(); |
836 | 190 | 190 | ||
837 | 191 | mtd::MockSurfaceFactory surface_factory; | 191 | mtd::MockSurfaceFactory surface_factory; |
839 | 192 | ON_CALL(surface_factory, create_surface(_, _, _, _)).WillByDefault(Return(mock_surface)); | 192 | ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault(Return(mock_surface)); |
840 | 193 | 193 | ||
841 | 194 | ms::ApplicationSession app_session( | 194 | ms::ApplicationSession app_session( |
842 | 195 | mt::fake_shared(surface_factory), | 195 | mt::fake_shared(surface_factory), |
843 | @@ -199,7 +199,7 @@ | |||
844 | 199 | std::make_shared<msh::NullSessionListener>(), | 199 | std::make_shared<msh::NullSessionListener>(), |
845 | 200 | mt::fake_shared(sender)); | 200 | mt::fake_shared(sender)); |
846 | 201 | 201 | ||
848 | 202 | EXPECT_CALL(surface_factory, create_surface(_, _, _, _)); | 202 | EXPECT_CALL(surface_factory, create_surface(_, _, _)); |
849 | 203 | 203 | ||
850 | 204 | { | 204 | { |
851 | 205 | InSequence seq; | 205 | InSequence seq; |
852 | @@ -269,7 +269,7 @@ | |||
853 | 269 | std::static_pointer_cast<msh::SurfaceBufferAccess>(default_surface); | 269 | std::static_pointer_cast<msh::SurfaceBufferAccess>(default_surface); |
854 | 270 | auto const snapshot_strategy = std::make_shared<MockSnapshotStrategy>(); | 270 | auto const snapshot_strategy = std::make_shared<MockSnapshotStrategy>(); |
855 | 271 | 271 | ||
857 | 272 | EXPECT_CALL(surface_factory, create_surface(_,_,_,_)) | 272 | EXPECT_CALL(surface_factory, create_surface(_,_,_)) |
858 | 273 | .WillOnce(Return(default_surface)); | 273 | .WillOnce(Return(default_surface)); |
859 | 274 | 274 | ||
860 | 275 | EXPECT_CALL(*snapshot_strategy, | 275 | EXPECT_CALL(*snapshot_strategy, |
861 | 276 | 276 | ||
862 | === modified file 'tests/unit-tests/scene/test_basic_surface.cpp' | |||
863 | --- tests/unit-tests/scene/test_basic_surface.cpp 2014-03-26 14:20:14 +0000 | |||
864 | +++ tests/unit-tests/scene/test_basic_surface.cpp 2014-03-31 11:00:33 +0000 | |||
865 | @@ -85,7 +85,6 @@ | |||
866 | 85 | std::function<void()> mock_change_cb; | 85 | std::function<void()> mock_change_cb; |
867 | 86 | std::shared_ptr<testing::NiceMock<mtd::MockBufferStream>> mock_buffer_stream = | 86 | std::shared_ptr<testing::NiceMock<mtd::MockBufferStream>> mock_buffer_stream = |
868 | 87 | std::make_shared<testing::NiceMock<mtd::MockBufferStream>>(); | 87 | std::make_shared<testing::NiceMock<mtd::MockBufferStream>>(); |
869 | 88 | std::shared_ptr<StubEventSink> const stub_event_sink = std::make_shared<StubEventSink>(); | ||
870 | 89 | std::shared_ptr<StubSurfaceConfigurator> const stub_configurator = std::make_shared<StubSurfaceConfigurator>(); | 88 | std::shared_ptr<StubSurfaceConfigurator> const stub_configurator = std::make_shared<StubSurfaceConfigurator>(); |
871 | 90 | std::shared_ptr<ms::SceneReport> const report = mr::null_scene_report(); | 89 | std::shared_ptr<ms::SceneReport> const report = mr::null_scene_report(); |
872 | 91 | }; | 90 | }; |
873 | @@ -95,13 +94,11 @@ | |||
874 | 95 | TEST_F(BasicSurfaceTest, basics) | 94 | TEST_F(BasicSurfaceTest, basics) |
875 | 96 | { | 95 | { |
876 | 97 | ms::BasicSurface surface{ | 96 | ms::BasicSurface surface{ |
877 | 98 | mf::SurfaceId(), | ||
878 | 99 | name, | 97 | name, |
879 | 100 | rect, | 98 | rect, |
880 | 101 | false, | 99 | false, |
881 | 102 | mock_buffer_stream, | 100 | mock_buffer_stream, |
882 | 103 | std::shared_ptr<mi::InputChannel>(), | 101 | std::shared_ptr<mi::InputChannel>(), |
883 | 104 | stub_event_sink, | ||
884 | 105 | stub_configurator, | 102 | stub_configurator, |
885 | 106 | report}; | 103 | report}; |
886 | 107 | 104 | ||
887 | @@ -117,13 +114,11 @@ | |||
888 | 117 | .Times(1); | 114 | .Times(1); |
889 | 118 | 115 | ||
890 | 119 | ms::BasicSurface surface{ | 116 | ms::BasicSurface surface{ |
891 | 120 | mf::SurfaceId(), | ||
892 | 121 | name, | 117 | name, |
893 | 122 | rect, | 118 | rect, |
894 | 123 | false, | 119 | false, |
895 | 124 | mock_buffer_stream, | 120 | mock_buffer_stream, |
896 | 125 | std::shared_ptr<mi::InputChannel>(), | 121 | std::shared_ptr<mi::InputChannel>(), |
897 | 126 | stub_event_sink, | ||
898 | 127 | stub_configurator, | 122 | stub_configurator, |
899 | 128 | report}; | 123 | report}; |
900 | 129 | 124 | ||
901 | @@ -144,13 +139,11 @@ | |||
902 | 144 | .Times(1); | 139 | .Times(1); |
903 | 145 | 140 | ||
904 | 146 | ms::BasicSurface surface{ | 141 | ms::BasicSurface surface{ |
905 | 147 | mf::SurfaceId(), | ||
906 | 148 | name, | 142 | name, |
907 | 149 | rect, | 143 | rect, |
908 | 150 | false, | 144 | false, |
909 | 151 | mock_buffer_stream, | 145 | mock_buffer_stream, |
910 | 152 | std::shared_ptr<mi::InputChannel>(), | 146 | std::shared_ptr<mi::InputChannel>(), |
911 | 153 | stub_event_sink, | ||
912 | 154 | stub_configurator, | 147 | stub_configurator, |
913 | 155 | report}; | 148 | report}; |
914 | 156 | 149 | ||
915 | @@ -173,13 +166,11 @@ | |||
916 | 173 | .Times(1); | 166 | .Times(1); |
917 | 174 | 167 | ||
918 | 175 | ms::BasicSurface surface{ | 168 | ms::BasicSurface surface{ |
919 | 176 | mf::SurfaceId(), | ||
920 | 177 | name, | 169 | name, |
921 | 178 | rect, | 170 | rect, |
922 | 179 | false, | 171 | false, |
923 | 180 | mock_buffer_stream, | 172 | mock_buffer_stream, |
924 | 181 | std::shared_ptr<mi::InputChannel>(), | 173 | std::shared_ptr<mi::InputChannel>(), |
925 | 182 | stub_event_sink, | ||
926 | 183 | stub_configurator, | 174 | stub_configurator, |
927 | 184 | report}; | 175 | report}; |
928 | 185 | 176 | ||
929 | @@ -204,13 +195,11 @@ | |||
930 | 204 | .Times(1); | 195 | .Times(1); |
931 | 205 | 196 | ||
932 | 206 | ms::BasicSurface surface{ | 197 | ms::BasicSurface surface{ |
933 | 207 | mf::SurfaceId(), | ||
934 | 208 | name, | 198 | name, |
935 | 209 | rect, | 199 | rect, |
936 | 210 | false, | 200 | false, |
937 | 211 | mock_buffer_stream, | 201 | mock_buffer_stream, |
938 | 212 | std::shared_ptr<mi::InputChannel>(), | 202 | std::shared_ptr<mi::InputChannel>(), |
939 | 213 | stub_event_sink, | ||
940 | 214 | stub_configurator, | 203 | stub_configurator, |
941 | 215 | report}; | 204 | report}; |
942 | 216 | 205 | ||
943 | @@ -225,13 +214,11 @@ | |||
944 | 225 | { | 214 | { |
945 | 226 | using namespace testing; | 215 | using namespace testing; |
946 | 227 | ms::BasicSurface surface{ | 216 | ms::BasicSurface surface{ |
947 | 228 | mf::SurfaceId(), | ||
948 | 229 | name, | 217 | name, |
949 | 230 | rect, | 218 | rect, |
950 | 231 | false, | 219 | false, |
951 | 232 | mock_buffer_stream, | 220 | mock_buffer_stream, |
952 | 233 | std::shared_ptr<mi::InputChannel>(), | 221 | std::shared_ptr<mi::InputChannel>(), |
953 | 234 | stub_event_sink, | ||
954 | 235 | stub_configurator, | 222 | stub_configurator, |
955 | 236 | report}; | 223 | report}; |
956 | 237 | 224 | ||
957 | @@ -242,13 +229,11 @@ | |||
958 | 242 | TEST_F(BasicSurfaceTest, test_surface_should_be_rendered_in) | 229 | TEST_F(BasicSurfaceTest, test_surface_should_be_rendered_in) |
959 | 243 | { | 230 | { |
960 | 244 | ms::BasicSurface surface{ | 231 | ms::BasicSurface surface{ |
961 | 245 | mf::SurfaceId(), | ||
962 | 246 | name, | 232 | name, |
963 | 247 | rect, | 233 | rect, |
964 | 248 | false, | 234 | false, |
965 | 249 | mock_buffer_stream, | 235 | mock_buffer_stream, |
966 | 250 | std::shared_ptr<mi::InputChannel>(), | 236 | std::shared_ptr<mi::InputChannel>(), |
967 | 251 | stub_event_sink, | ||
968 | 252 | stub_configurator, | 237 | stub_configurator, |
969 | 253 | report}; | 238 | report}; |
970 | 254 | 239 | ||
971 | @@ -281,13 +266,11 @@ | |||
972 | 281 | .Times(1); | 266 | .Times(1); |
973 | 282 | 267 | ||
974 | 283 | ms::BasicSurface surface{ | 268 | ms::BasicSurface surface{ |
975 | 284 | mf::SurfaceId(), | ||
976 | 285 | name, | 269 | name, |
977 | 286 | rect, | 270 | rect, |
978 | 287 | false, | 271 | false, |
979 | 288 | mock_buffer_stream, | 272 | mock_buffer_stream, |
980 | 289 | std::shared_ptr<mi::InputChannel>(), | 273 | std::shared_ptr<mi::InputChannel>(), |
981 | 290 | stub_event_sink, | ||
982 | 291 | stub_configurator, | 274 | stub_configurator, |
983 | 292 | report}; | 275 | report}; |
984 | 293 | 276 | ||
985 | @@ -303,13 +286,11 @@ | |||
986 | 303 | .Times(1); | 286 | .Times(1); |
987 | 304 | 287 | ||
988 | 305 | ms::BasicSurface surface{ | 288 | ms::BasicSurface surface{ |
989 | 306 | mf::SurfaceId(), | ||
990 | 307 | name, | 289 | name, |
991 | 308 | rect, | 290 | rect, |
992 | 309 | false, | 291 | false, |
993 | 310 | mock_buffer_stream, | 292 | mock_buffer_stream, |
994 | 311 | std::shared_ptr<mi::InputChannel>(), | 293 | std::shared_ptr<mi::InputChannel>(), |
995 | 312 | stub_event_sink, | ||
996 | 313 | stub_configurator, | 294 | stub_configurator, |
997 | 314 | report}; | 295 | report}; |
998 | 315 | 296 | ||
999 | @@ -324,13 +305,11 @@ | |||
1000 | 324 | geom::Point pt(1,1); | 305 | geom::Point pt(1,1); |
1001 | 325 | geom::Size one_by_one{geom::Width{1}, geom::Height{1}}; | 306 | geom::Size one_by_one{geom::Width{1}, geom::Height{1}}; |
1002 | 326 | ms::BasicSurface surface{ | 307 | ms::BasicSurface surface{ |
1003 | 327 | mf::SurfaceId(), | ||
1004 | 328 | name, | 308 | name, |
1005 | 329 | geom::Rectangle{pt, one_by_one}, | 309 | geom::Rectangle{pt, one_by_one}, |
1006 | 330 | false, | 310 | false, |
1007 | 331 | mock_buffer_stream, | 311 | mock_buffer_stream, |
1008 | 332 | std::shared_ptr<mi::InputChannel>(), | 312 | std::shared_ptr<mi::InputChannel>(), |
1009 | 333 | stub_event_sink, | ||
1010 | 334 | stub_configurator, | 313 | stub_configurator, |
1011 | 335 | report}; | 314 | report}; |
1012 | 336 | 315 | ||
1013 | @@ -367,13 +346,11 @@ | |||
1014 | 367 | }; | 346 | }; |
1015 | 368 | 347 | ||
1016 | 369 | ms::BasicSurface surface{ | 348 | ms::BasicSurface surface{ |
1017 | 370 | mf::SurfaceId(), | ||
1018 | 371 | name, | 349 | name, |
1019 | 372 | rect, | 350 | rect, |
1020 | 373 | false, | 351 | false, |
1021 | 374 | mock_buffer_stream, | 352 | mock_buffer_stream, |
1022 | 375 | std::shared_ptr<mi::InputChannel>(), | 353 | std::shared_ptr<mi::InputChannel>(), |
1023 | 376 | stub_event_sink, | ||
1024 | 377 | stub_configurator, | 354 | stub_configurator, |
1025 | 378 | report}; | 355 | report}; |
1026 | 379 | 356 | ||
1027 | 380 | 357 | ||
1028 | === modified file 'tests/unit-tests/scene/test_session_manager.cpp' | |||
1029 | --- tests/unit-tests/scene/test_session_manager.cpp 2014-03-31 11:00:33 +0000 | |||
1030 | +++ tests/unit-tests/scene/test_session_manager.cpp 2014-03-31 11:00:33 +0000 | |||
1031 | @@ -85,13 +85,11 @@ | |||
1032 | 85 | } | 85 | } |
1033 | 86 | 86 | ||
1034 | 87 | std::shared_ptr<ms::Surface> dummy_surface = std::make_shared<ms::BasicSurface>( | 87 | std::shared_ptr<ms::Surface> dummy_surface = std::make_shared<ms::BasicSurface>( |
1035 | 88 | mf::SurfaceId(), | ||
1036 | 89 | std::string("stub"), | 88 | std::string("stub"), |
1037 | 90 | geom::Rectangle{{},{}}, | 89 | geom::Rectangle{{},{}}, |
1038 | 91 | false, | 90 | false, |
1039 | 92 | std::make_shared<mtd::StubBufferStream>(), | 91 | std::make_shared<mtd::StubBufferStream>(), |
1040 | 93 | std::shared_ptr<mi::InputChannel>(), | 92 | std::shared_ptr<mi::InputChannel>(), |
1041 | 94 | std::shared_ptr<mf::EventSink>(), | ||
1042 | 95 | std::shared_ptr<ms::SurfaceConfigurator>(), | 93 | std::shared_ptr<ms::SurfaceConfigurator>(), |
1043 | 96 | mir::report::null_scene_report()); | 94 | mir::report::null_scene_report()); |
1044 | 97 | mtd::MockSurfaceFactory surface_factory; | 95 | mtd::MockSurfaceFactory surface_factory; |
1045 | @@ -121,9 +119,9 @@ | |||
1046 | 121 | { | 119 | { |
1047 | 122 | using namespace ::testing; | 120 | using namespace ::testing; |
1048 | 123 | 121 | ||
1050 | 124 | EXPECT_CALL(surface_factory, create_surface(_, _, _, _)).Times(1); | 122 | EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1); |
1051 | 125 | 123 | ||
1053 | 126 | ON_CALL(surface_factory, create_surface(_, _, _, _)).WillByDefault( | 124 | ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault( |
1054 | 127 | Return(dummy_surface)); | 125 | Return(dummy_surface)); |
1055 | 128 | 126 | ||
1056 | 129 | EXPECT_CALL(container, insert_session(_)).Times(1); | 127 | EXPECT_CALL(container, insert_session(_)).Times(1); |
1057 | @@ -153,7 +151,7 @@ | |||
1058 | 153 | TEST_F(SessionManagerSetup, create_surface_for_session_forwards_and_then_focuses_session) | 151 | TEST_F(SessionManagerSetup, create_surface_for_session_forwards_and_then_focuses_session) |
1059 | 154 | { | 152 | { |
1060 | 155 | using namespace ::testing; | 153 | using namespace ::testing; |
1062 | 156 | ON_CALL(surface_factory, create_surface(_, _, _, _)).WillByDefault( | 154 | ON_CALL(surface_factory, create_surface(_, _, _)).WillByDefault( |
1063 | 157 | Return(dummy_surface)); | 155 | Return(dummy_surface)); |
1064 | 158 | 156 | ||
1065 | 159 | // Once for session creation and once for surface creation | 157 | // Once for session creation and once for surface creation |
1066 | @@ -161,7 +159,7 @@ | |||
1067 | 161 | InSequence seq; | 159 | InSequence seq; |
1068 | 162 | 160 | ||
1069 | 163 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Session creation | 161 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Session creation |
1071 | 164 | EXPECT_CALL(surface_factory, create_surface(_, _, _, _)).Times(1); | 162 | EXPECT_CALL(surface_factory, create_surface(_, _, _)).Times(1); |
1072 | 165 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation | 163 | EXPECT_CALL(focus_setter, set_focus_to(_)).Times(1); // Post Surface creation |
1073 | 166 | } | 164 | } |
1074 | 167 | 165 | ||
1075 | 168 | 166 | ||
1076 | === modified file 'tests/unit-tests/scene/test_surface.cpp' | |||
1077 | --- tests/unit-tests/scene/test_surface.cpp 2014-03-26 14:20:14 +0000 | |||
1078 | +++ tests/unit-tests/scene/test_surface.cpp 2014-03-31 11:00:33 +0000 | |||
1079 | @@ -21,6 +21,7 @@ | |||
1080 | 21 | #include "mir/frontend/event_sink.h" | 21 | #include "mir/frontend/event_sink.h" |
1081 | 22 | #include "mir/shell/surface_creation_parameters.h" | 22 | #include "mir/shell/surface_creation_parameters.h" |
1082 | 23 | #include "mir/scene/surface_configurator.h" | 23 | #include "mir/scene/surface_configurator.h" |
1083 | 24 | #include "mir/scene/surface_event_source.h" | ||
1084 | 24 | #include "mir/input/input_channel.h" | 25 | #include "mir/input/input_channel.h" |
1085 | 25 | 26 | ||
1086 | 26 | #include "mir_test_doubles/mock_buffer_stream.h" | 27 | #include "mir_test_doubles/mock_buffer_stream.h" |
1087 | @@ -209,7 +210,6 @@ | |||
1088 | 209 | std::function<void()> change_notification; | 210 | std::function<void()> change_notification; |
1089 | 210 | int notification_count; | 211 | int notification_count; |
1090 | 211 | mtd::StubBuffer stub_buffer; | 212 | mtd::StubBuffer stub_buffer; |
1091 | 212 | std::shared_ptr<StubEventSink> const stub_event_sink = std::make_shared<StubEventSink>(); | ||
1092 | 213 | std::shared_ptr<StubSurfaceConfigurator> const stub_configurator = std::make_shared<StubSurfaceConfigurator>(); | 213 | std::shared_ptr<StubSurfaceConfigurator> const stub_configurator = std::make_shared<StubSurfaceConfigurator>(); |
1093 | 214 | }; | 214 | }; |
1094 | 215 | 215 | ||
1095 | @@ -219,13 +219,11 @@ | |||
1096 | 219 | { | 219 | { |
1097 | 220 | using namespace testing; | 220 | using namespace testing; |
1098 | 221 | ms::BasicSurface surf( | 221 | ms::BasicSurface surf( |
1099 | 222 | mf::SurfaceId(), | ||
1100 | 223 | surface_name, | 222 | surface_name, |
1101 | 224 | rect, | 223 | rect, |
1102 | 225 | false, | 224 | false, |
1103 | 226 | mock_buffer_stream, | 225 | mock_buffer_stream, |
1104 | 227 | std::shared_ptr<mi::InputChannel>(), | 226 | std::shared_ptr<mi::InputChannel>(), |
1105 | 228 | stub_event_sink, | ||
1106 | 229 | stub_configurator, | 227 | stub_configurator, |
1107 | 230 | report); | 228 | report); |
1108 | 231 | 229 | ||
1109 | @@ -241,13 +239,11 @@ | |||
1110 | 241 | TEST_F(SurfaceCreation, test_surface_gets_right_name) | 239 | TEST_F(SurfaceCreation, test_surface_gets_right_name) |
1111 | 242 | { | 240 | { |
1112 | 243 | ms::BasicSurface surf( | 241 | ms::BasicSurface surf( |
1113 | 244 | mf::SurfaceId(), | ||
1114 | 245 | surface_name, | 242 | surface_name, |
1115 | 246 | rect, | 243 | rect, |
1116 | 247 | false, | 244 | false, |
1117 | 248 | mock_buffer_stream, | 245 | mock_buffer_stream, |
1118 | 249 | std::shared_ptr<mi::InputChannel>(), | 246 | std::shared_ptr<mi::InputChannel>(), |
1119 | 250 | stub_event_sink, | ||
1120 | 251 | stub_configurator, | 247 | stub_configurator, |
1121 | 252 | report); | 248 | report); |
1122 | 253 | 249 | ||
1123 | @@ -257,13 +253,11 @@ | |||
1124 | 257 | TEST_F(SurfaceCreation, test_surface_queries_state_for_size) | 253 | TEST_F(SurfaceCreation, test_surface_queries_state_for_size) |
1125 | 258 | { | 254 | { |
1126 | 259 | ms::BasicSurface surf( | 255 | ms::BasicSurface surf( |
1127 | 260 | mf::SurfaceId(), | ||
1128 | 261 | surface_name, | 256 | surface_name, |
1129 | 262 | rect, | 257 | rect, |
1130 | 263 | false, | 258 | false, |
1131 | 264 | mock_buffer_stream, | 259 | mock_buffer_stream, |
1132 | 265 | std::shared_ptr<mi::InputChannel>(), | 260 | std::shared_ptr<mi::InputChannel>(), |
1133 | 266 | stub_event_sink, | ||
1134 | 267 | stub_configurator, | 261 | stub_configurator, |
1135 | 268 | report); | 262 | report); |
1136 | 269 | 263 | ||
1137 | @@ -274,13 +268,11 @@ | |||
1138 | 274 | { | 268 | { |
1139 | 275 | using namespace testing; | 269 | using namespace testing; |
1140 | 276 | ms::BasicSurface surf( | 270 | ms::BasicSurface surf( |
1141 | 277 | mf::SurfaceId(), | ||
1142 | 278 | surface_name, | 271 | surface_name, |
1143 | 279 | rect, | 272 | rect, |
1144 | 280 | false, | 273 | false, |
1145 | 281 | mock_buffer_stream, | 274 | mock_buffer_stream, |
1146 | 282 | std::shared_ptr<mi::InputChannel>(), | 275 | std::shared_ptr<mi::InputChannel>(), |
1147 | 283 | stub_event_sink, | ||
1148 | 284 | stub_configurator, | 276 | stub_configurator, |
1149 | 285 | report); | 277 | report); |
1150 | 286 | 278 | ||
1151 | @@ -302,13 +294,11 @@ | |||
1152 | 302 | mtd::StubBuffer stub_buffer; | 294 | mtd::StubBuffer stub_buffer; |
1153 | 303 | 295 | ||
1154 | 304 | ms::BasicSurface surf( | 296 | ms::BasicSurface surf( |
1155 | 305 | mf::SurfaceId(), | ||
1156 | 306 | surface_name, | 297 | surface_name, |
1157 | 307 | rect, | 298 | rect, |
1158 | 308 | false, | 299 | false, |
1159 | 309 | mock_buffer_stream, | 300 | mock_buffer_stream, |
1160 | 310 | std::shared_ptr<mi::InputChannel>(), | 301 | std::shared_ptr<mi::InputChannel>(), |
1161 | 311 | stub_event_sink, | ||
1162 | 312 | stub_configurator, | 302 | stub_configurator, |
1163 | 313 | report); | 303 | report); |
1164 | 314 | 304 | ||
1165 | @@ -324,13 +314,11 @@ | |||
1166 | 324 | TEST_F(SurfaceCreation, test_surface_gets_top_left) | 314 | TEST_F(SurfaceCreation, test_surface_gets_top_left) |
1167 | 325 | { | 315 | { |
1168 | 326 | ms::BasicSurface surf( | 316 | ms::BasicSurface surf( |
1169 | 327 | mf::SurfaceId(), | ||
1170 | 328 | surface_name, | 317 | surface_name, |
1171 | 329 | rect, | 318 | rect, |
1172 | 330 | false, | 319 | false, |
1173 | 331 | mock_buffer_stream, | 320 | mock_buffer_stream, |
1174 | 332 | std::shared_ptr<mi::InputChannel>(), | 321 | std::shared_ptr<mi::InputChannel>(), |
1175 | 333 | stub_event_sink, | ||
1176 | 334 | stub_configurator, | 322 | stub_configurator, |
1177 | 335 | report); | 323 | report); |
1178 | 336 | 324 | ||
1179 | @@ -343,13 +331,11 @@ | |||
1180 | 343 | geom::Point p{55, 66}; | 331 | geom::Point p{55, 66}; |
1181 | 344 | 332 | ||
1182 | 345 | ms::BasicSurface surf( | 333 | ms::BasicSurface surf( |
1183 | 346 | mf::SurfaceId(), | ||
1184 | 347 | surface_name, | 334 | surface_name, |
1185 | 348 | rect, | 335 | rect, |
1186 | 349 | false, | 336 | false, |
1187 | 350 | mock_buffer_stream, | 337 | mock_buffer_stream, |
1188 | 351 | std::shared_ptr<mi::InputChannel>(), | 338 | std::shared_ptr<mi::InputChannel>(), |
1189 | 352 | stub_event_sink, | ||
1190 | 353 | stub_configurator, | 339 | stub_configurator, |
1191 | 354 | report); | 340 | report); |
1192 | 355 | 341 | ||
1193 | @@ -366,18 +352,19 @@ | |||
1194 | 366 | .Times(1); | 352 | .Times(1); |
1195 | 367 | 353 | ||
1196 | 368 | auto const mock_event_sink = std::make_shared<MockEventSink>(); | 354 | auto const mock_event_sink = std::make_shared<MockEventSink>(); |
1197 | 355 | auto const observer = std::make_shared<ms::SurfaceEventSource>(mf::SurfaceId(), mock_event_sink); | ||
1198 | 369 | 356 | ||
1199 | 370 | ms::BasicSurface surf( | 357 | ms::BasicSurface surf( |
1200 | 371 | mf::SurfaceId(), | ||
1201 | 372 | surface_name, | 358 | surface_name, |
1202 | 373 | rect, | 359 | rect, |
1203 | 374 | false, | 360 | false, |
1204 | 375 | mock_buffer_stream, | 361 | mock_buffer_stream, |
1205 | 376 | std::shared_ptr<mi::InputChannel>(), | 362 | std::shared_ptr<mi::InputChannel>(), |
1206 | 377 | mock_event_sink, | ||
1207 | 378 | stub_configurator, | 363 | stub_configurator, |
1208 | 379 | report); | 364 | report); |
1209 | 380 | 365 | ||
1210 | 366 | surf.add_observer(observer); | ||
1211 | 367 | |||
1212 | 381 | ASSERT_THAT(surf.size(), Ne(new_size)); | 368 | ASSERT_THAT(surf.size(), Ne(new_size)); |
1213 | 382 | 369 | ||
1214 | 383 | EXPECT_CALL(*mock_event_sink, handle_event(_)).Times(1); | 370 | EXPECT_CALL(*mock_event_sink, handle_event(_)).Times(1); |
1215 | @@ -390,18 +377,19 @@ | |||
1216 | 390 | using namespace testing; | 377 | using namespace testing; |
1217 | 391 | geom::Size const new_size{123, 456}; | 378 | geom::Size const new_size{123, 456}; |
1218 | 392 | auto const mock_event_sink = std::make_shared<MockEventSink>(); | 379 | auto const mock_event_sink = std::make_shared<MockEventSink>(); |
1219 | 380 | auto const observer = std::make_shared<ms::SurfaceEventSource>(mf::SurfaceId(), mock_event_sink); | ||
1220 | 393 | 381 | ||
1221 | 394 | ms::BasicSurface surf( | 382 | ms::BasicSurface surf( |
1222 | 395 | mf::SurfaceId(), | ||
1223 | 396 | surface_name, | 383 | surface_name, |
1224 | 397 | rect, | 384 | rect, |
1225 | 398 | false, | 385 | false, |
1226 | 399 | mock_buffer_stream, | 386 | mock_buffer_stream, |
1227 | 400 | std::shared_ptr<mi::InputChannel>(), | 387 | std::shared_ptr<mi::InputChannel>(), |
1228 | 401 | mock_event_sink, | ||
1229 | 402 | stub_configurator, | 388 | stub_configurator, |
1230 | 403 | report); | 389 | report); |
1231 | 404 | 390 | ||
1232 | 391 | surf.add_observer(observer); | ||
1233 | 392 | |||
1234 | 405 | ASSERT_THAT(surf.size(), Ne(new_size)); | 393 | ASSERT_THAT(surf.size(), Ne(new_size)); |
1235 | 406 | 394 | ||
1236 | 407 | EXPECT_CALL(*mock_buffer_stream, resize(new_size)).Times(1); | 395 | EXPECT_CALL(*mock_buffer_stream, resize(new_size)).Times(1); |
1237 | @@ -428,13 +416,11 @@ | |||
1238 | 428 | .WillOnce(Throw(std::runtime_error("bad resize"))); | 416 | .WillOnce(Throw(std::runtime_error("bad resize"))); |
1239 | 429 | 417 | ||
1240 | 430 | ms::BasicSurface surf( | 418 | ms::BasicSurface surf( |
1241 | 431 | mf::SurfaceId(), | ||
1242 | 432 | surface_name, | 419 | surface_name, |
1243 | 433 | rect, | 420 | rect, |
1244 | 434 | false, | 421 | false, |
1245 | 435 | mock_buffer_stream, | 422 | mock_buffer_stream, |
1246 | 436 | std::shared_ptr<mi::InputChannel>(), | 423 | std::shared_ptr<mi::InputChannel>(), |
1247 | 437 | stub_event_sink, | ||
1248 | 438 | stub_configurator, | 424 | stub_configurator, |
1249 | 439 | report); | 425 | report); |
1250 | 440 | 426 | ||
1251 | @@ -459,13 +445,11 @@ | |||
1252 | 459 | }; | 445 | }; |
1253 | 460 | 446 | ||
1254 | 461 | ms::BasicSurface surf( | 447 | ms::BasicSurface surf( |
1255 | 462 | mf::SurfaceId(), | ||
1256 | 463 | surface_name, | 448 | surface_name, |
1257 | 464 | rect, | 449 | rect, |
1258 | 465 | false, | 450 | false, |
1259 | 466 | mock_buffer_stream, | 451 | mock_buffer_stream, |
1260 | 467 | std::shared_ptr<mi::InputChannel>(), | 452 | std::shared_ptr<mi::InputChannel>(), |
1261 | 468 | stub_event_sink, | ||
1262 | 469 | stub_configurator, | 453 | stub_configurator, |
1263 | 470 | report); | 454 | report); |
1264 | 471 | 455 | ||
1265 | @@ -484,13 +468,11 @@ | |||
1266 | 484 | { | 468 | { |
1267 | 485 | auto mock_channel = std::make_shared<MockInputChannel>(); | 469 | auto mock_channel = std::make_shared<MockInputChannel>(); |
1268 | 486 | ms::BasicSurface surf( | 470 | ms::BasicSurface surf( |
1269 | 487 | mf::SurfaceId(), | ||
1270 | 488 | surface_name, | 471 | surface_name, |
1271 | 489 | rect, | 472 | rect, |
1272 | 490 | false, | 473 | false, |
1273 | 491 | mock_buffer_stream, | 474 | mock_buffer_stream, |
1274 | 492 | mock_channel, | 475 | mock_channel, |
1275 | 493 | stub_event_sink, | ||
1276 | 494 | stub_configurator, | 476 | stub_configurator, |
1277 | 495 | report); | 477 | report); |
1278 | 496 | 478 | ||
1279 | @@ -503,13 +485,11 @@ | |||
1280 | 503 | 485 | ||
1281 | 504 | float alpha = 0.5f; | 486 | float alpha = 0.5f; |
1282 | 505 | ms::BasicSurface surf( | 487 | ms::BasicSurface surf( |
1283 | 506 | mf::SurfaceId(), | ||
1284 | 507 | surface_name, | 488 | surface_name, |
1285 | 508 | rect, | 489 | rect, |
1286 | 509 | false, | 490 | false, |
1287 | 510 | mock_buffer_stream, | 491 | mock_buffer_stream, |
1288 | 511 | std::shared_ptr<mi::InputChannel>(), | 492 | std::shared_ptr<mi::InputChannel>(), |
1289 | 512 | stub_event_sink, | ||
1290 | 513 | stub_configurator, | 493 | stub_configurator, |
1291 | 514 | report); | 494 | report); |
1292 | 515 | 495 | ||
1293 | @@ -524,13 +504,11 @@ | |||
1294 | 524 | EXPECT_CALL(*mock_buffer_stream, force_requests_to_complete()).Times(Exactly(1)); | 504 | EXPECT_CALL(*mock_buffer_stream, force_requests_to_complete()).Times(Exactly(1)); |
1295 | 525 | 505 | ||
1296 | 526 | ms::BasicSurface surf( | 506 | ms::BasicSurface surf( |
1297 | 527 | mf::SurfaceId(), | ||
1298 | 528 | surface_name, | 507 | surface_name, |
1299 | 529 | rect, | 508 | rect, |
1300 | 530 | false, | 509 | false, |
1301 | 531 | mock_buffer_stream, | 510 | mock_buffer_stream, |
1302 | 532 | std::shared_ptr<mi::InputChannel>(), | 511 | std::shared_ptr<mi::InputChannel>(), |
1303 | 533 | stub_event_sink, | ||
1304 | 534 | stub_configurator, | 512 | stub_configurator, |
1305 | 535 | report); | 513 | report); |
1306 | 536 | 514 | ||
1307 | @@ -545,13 +523,11 @@ | |||
1308 | 545 | .Times(1); | 523 | .Times(1); |
1309 | 546 | 524 | ||
1310 | 547 | ms::BasicSurface surf( | 525 | ms::BasicSurface surf( |
1311 | 548 | mf::SurfaceId(), | ||
1312 | 549 | surface_name, | 526 | surface_name, |
1313 | 550 | rect, | 527 | rect, |
1314 | 551 | false, | 528 | false, |
1315 | 552 | mock_buffer_stream, | 529 | mock_buffer_stream, |
1316 | 553 | std::shared_ptr<mi::InputChannel>(), | 530 | std::shared_ptr<mi::InputChannel>(), |
1317 | 554 | stub_event_sink, | ||
1318 | 555 | stub_configurator, | 531 | stub_configurator, |
1319 | 556 | report); | 532 | report); |
1320 | 557 | 533 | ||
1321 | @@ -561,13 +537,11 @@ | |||
1322 | 561 | TEST_F(SurfaceCreation, test_surface_next_buffer_tells_state_on_first_frame) | 537 | TEST_F(SurfaceCreation, test_surface_next_buffer_tells_state_on_first_frame) |
1323 | 562 | { | 538 | { |
1324 | 563 | ms::BasicSurface surf( | 539 | ms::BasicSurface surf( |
1325 | 564 | mf::SurfaceId(), | ||
1326 | 565 | surface_name, | 540 | surface_name, |
1327 | 566 | rect, | 541 | rect, |
1328 | 567 | false, | 542 | false, |
1329 | 568 | mock_buffer_stream, | 543 | mock_buffer_stream, |
1330 | 569 | std::shared_ptr<mi::InputChannel>(), | 544 | std::shared_ptr<mi::InputChannel>(), |
1331 | 570 | stub_event_sink, | ||
1332 | 571 | stub_configurator, | 545 | stub_configurator, |
1333 | 572 | report); | 546 | report); |
1334 | 573 | 547 | ||
1335 | @@ -589,13 +563,11 @@ | |||
1336 | 589 | using namespace testing; | 563 | using namespace testing; |
1337 | 590 | 564 | ||
1338 | 591 | ms::BasicSurface surf( | 565 | ms::BasicSurface surf( |
1339 | 592 | mf::SurfaceId(), | ||
1340 | 593 | surface_name, | 566 | surface_name, |
1341 | 594 | rect, | 567 | rect, |
1342 | 595 | false, | 568 | false, |
1343 | 596 | mock_buffer_stream, | 569 | mock_buffer_stream, |
1344 | 597 | std::shared_ptr<mi::InputChannel>(), | 570 | std::shared_ptr<mi::InputChannel>(), |
1345 | 598 | stub_event_sink, | ||
1346 | 599 | stub_configurator, | 571 | stub_configurator, |
1347 | 600 | report); | 572 | report); |
1348 | 601 | 573 | ||
1349 | @@ -608,12 +580,10 @@ | |||
1350 | 608 | EXPECT_CALL(channel, client_fd()).Times(1).WillOnce(Return(client_fd)); | 580 | EXPECT_CALL(channel, client_fd()).Times(1).WillOnce(Return(client_fd)); |
1351 | 609 | 581 | ||
1352 | 610 | ms::BasicSurface input_surf( | 582 | ms::BasicSurface input_surf( |
1353 | 611 | mf::SurfaceId(), | ||
1354 | 612 | surface_name, | 583 | surface_name, |
1355 | 613 | rect, | 584 | rect, |
1356 | 614 | false, | 585 | false, |
1357 | 615 | mock_buffer_stream,mt::fake_shared(channel), | 586 | mock_buffer_stream,mt::fake_shared(channel), |
1358 | 616 | stub_event_sink, | ||
1359 | 617 | stub_configurator, | 587 | stub_configurator, |
1360 | 618 | report); | 588 | report); |
1361 | 619 | 589 | ||
1362 | 620 | 590 | ||
1363 | === modified file 'tests/unit-tests/scene/test_surface_controller.cpp' | |||
1364 | --- tests/unit-tests/scene/test_surface_controller.cpp 2014-03-31 11:00:33 +0000 | |||
1365 | +++ tests/unit-tests/scene/test_surface_controller.cpp 2014-03-31 11:00:33 +0000 | |||
1366 | @@ -21,6 +21,7 @@ | |||
1367 | 21 | #include "mir/scene/surface_factory.h" | 21 | #include "mir/scene/surface_factory.h" |
1368 | 22 | #include "mir/shell/surface_creation_parameters.h" | 22 | #include "mir/shell/surface_creation_parameters.h" |
1369 | 23 | 23 | ||
1370 | 24 | #include "mir_test_doubles/mock_surface.h" | ||
1371 | 24 | #include "mir_test/fake_shared.h" | 25 | #include "mir_test/fake_shared.h" |
1372 | 25 | 26 | ||
1373 | 26 | #include <gtest/gtest.h> | 27 | #include <gtest/gtest.h> |
1374 | @@ -30,15 +31,14 @@ | |||
1375 | 30 | namespace msh = mir::shell; | 31 | namespace msh = mir::shell; |
1376 | 31 | namespace ms = mir::scene; | 32 | namespace ms = mir::scene; |
1377 | 32 | namespace mt = mir::test; | 33 | namespace mt = mir::test; |
1378 | 34 | namespace mtd = mir::test::doubles; | ||
1379 | 33 | 35 | ||
1380 | 34 | namespace | 36 | namespace |
1381 | 35 | { | 37 | { |
1382 | 36 | struct MockSurfaceAllocator : public ms::SurfaceFactory | 38 | struct MockSurfaceAllocator : public ms::SurfaceFactory |
1383 | 37 | { | 39 | { |
1388 | 38 | MOCK_METHOD3(create_surface, std::shared_ptr<ms::Surface>( | 40 | MOCK_METHOD1(create_surface, std::shared_ptr<ms::Surface>( |
1389 | 39 | mf::SurfaceId id, | 41 | msh::SurfaceCreationParameters const&)); |
1386 | 40 | msh::SurfaceCreationParameters const&, | ||
1387 | 41 | std::shared_ptr<mf::EventSink> const&)); | ||
1390 | 42 | }; | 42 | }; |
1391 | 43 | 43 | ||
1392 | 44 | struct MockSurfaceStackModel : public ms::SurfaceStackModel | 44 | struct MockSurfaceStackModel : public ms::SurfaceStackModel |
1393 | @@ -56,19 +56,24 @@ | |||
1394 | 56 | { | 56 | { |
1395 | 57 | using namespace ::testing; | 57 | using namespace ::testing; |
1396 | 58 | 58 | ||
1398 | 59 | std::shared_ptr<ms::Surface> null_surface; | 59 | mtd::MockSurface mock_surface; |
1399 | 60 | std::shared_ptr<ms::Surface> const expect_surface = mt::fake_shared(mock_surface); | ||
1400 | 61 | auto const surface = std::make_shared<mtd::MockSurface>(); | ||
1401 | 60 | testing::NiceMock<MockSurfaceAllocator> mock_surface_allocator; | 62 | testing::NiceMock<MockSurfaceAllocator> mock_surface_allocator; |
1402 | 61 | MockSurfaceStackModel model; | 63 | MockSurfaceStackModel model; |
1403 | 62 | 64 | ||
1404 | 63 | ms::SurfaceController controller(mt::fake_shared(mock_surface_allocator), mt::fake_shared(model)); | 65 | ms::SurfaceController controller(mt::fake_shared(mock_surface_allocator), mt::fake_shared(model)); |
1405 | 64 | 66 | ||
1406 | 65 | InSequence seq; | 67 | InSequence seq; |
1408 | 66 | EXPECT_CALL(mock_surface_allocator, create_surface(_,_,_)).Times(1).WillOnce(Return(null_surface)); | 68 | EXPECT_CALL(mock_surface_allocator, create_surface(_)).Times(1).WillOnce(Return(expect_surface)); |
1409 | 69 | EXPECT_CALL(mock_surface, add_observer(_)).Times(1); | ||
1410 | 67 | EXPECT_CALL(model, add_surface(_,_,_)).Times(1); | 70 | EXPECT_CALL(model, add_surface(_,_,_)).Times(1); |
1411 | 68 | EXPECT_CALL(model, remove_surface(_)).Times(1); | 71 | EXPECT_CALL(model, remove_surface(_)).Times(1); |
1412 | 69 | 72 | ||
1415 | 70 | auto surface = controller.add_surface(mf::SurfaceId(), msh::a_surface(), {}); | 73 | auto actual_surface = controller.add_surface(msh::a_surface(), std::shared_ptr<ms::SurfaceObserver>()); |
1416 | 71 | controller.remove_surface(surface); | 74 | |
1417 | 75 | EXPECT_THAT(actual_surface, Eq(expect_surface)); | ||
1418 | 76 | controller.remove_surface(actual_surface); | ||
1419 | 72 | } | 77 | } |
1420 | 73 | 78 | ||
1421 | 74 | TEST(SurfaceController, raise_surface) | 79 | TEST(SurfaceController, raise_surface) |
1422 | 75 | 80 | ||
1423 | === modified file 'tests/unit-tests/scene/test_surface_impl.cpp' | |||
1424 | --- tests/unit-tests/scene/test_surface_impl.cpp 2014-03-31 11:00:33 +0000 | |||
1425 | +++ tests/unit-tests/scene/test_surface_impl.cpp 2014-03-31 11:00:33 +0000 | |||
1426 | @@ -17,6 +17,8 @@ | |||
1427 | 17 | */ | 17 | */ |
1428 | 18 | 18 | ||
1429 | 19 | #include "src/server/scene/basic_surface.h" | 19 | #include "src/server/scene/basic_surface.h" |
1430 | 20 | #include "mir/scene/surface_observer.h" | ||
1431 | 21 | #include "mir/scene/surface_event_source.h" | ||
1432 | 20 | #include "src/server/report/null_report_factory.h" | 22 | #include "src/server/report/null_report_factory.h" |
1433 | 21 | #include "mir/frontend/event_sink.h" | 23 | #include "mir/frontend/event_sink.h" |
1434 | 22 | #include "mir/graphics/display_configuration.h" | 24 | #include "mir/graphics/display_configuration.h" |
1435 | @@ -65,7 +67,6 @@ | |||
1436 | 65 | 67 | ||
1437 | 66 | Surface() : | 68 | Surface() : |
1438 | 67 | buffer_stream(std::make_shared<StubBufferStream>()), | 69 | buffer_stream(std::make_shared<StubBufferStream>()), |
1439 | 68 | stub_sender(std::make_shared<mtd::NullEventSink>()), | ||
1440 | 69 | null_configurator(std::make_shared<mtd::NullSurfaceConfigurator>()) | 70 | null_configurator(std::make_shared<mtd::NullSurfaceConfigurator>()) |
1441 | 70 | { | 71 | { |
1442 | 71 | using namespace testing; | 72 | using namespace testing; |
1443 | @@ -76,7 +77,6 @@ | |||
1444 | 76 | .WillByDefault(InvokeArgument<1>(nullptr)); | 77 | .WillByDefault(InvokeArgument<1>(nullptr)); |
1445 | 77 | } | 78 | } |
1446 | 78 | mf::SurfaceId stub_id; | 79 | mf::SurfaceId stub_id; |
1447 | 79 | std::shared_ptr<mf::EventSink> stub_sender; | ||
1448 | 80 | std::shared_ptr<ms::SurfaceConfigurator> null_configurator; | 80 | std::shared_ptr<ms::SurfaceConfigurator> null_configurator; |
1449 | 81 | std::shared_ptr<ms::SceneReport> const report = mr::null_scene_report(); | 81 | std::shared_ptr<ms::SceneReport> const report = mr::null_scene_report(); |
1450 | 82 | }; | 82 | }; |
1451 | @@ -87,13 +87,11 @@ | |||
1452 | 87 | using namespace testing; | 87 | using namespace testing; |
1453 | 88 | 88 | ||
1454 | 89 | ms::BasicSurface surf( | 89 | ms::BasicSurface surf( |
1455 | 90 | stub_id, | ||
1456 | 91 | std::string("stub"), | 90 | std::string("stub"), |
1457 | 92 | geom::Rectangle{{},{}}, | 91 | geom::Rectangle{{},{}}, |
1458 | 93 | false, | 92 | false, |
1459 | 94 | buffer_stream, | 93 | buffer_stream, |
1460 | 95 | std::shared_ptr<mi::InputChannel>(), | 94 | std::shared_ptr<mi::InputChannel>(), |
1461 | 96 | stub_sender, | ||
1462 | 97 | null_configurator, | 95 | null_configurator, |
1463 | 98 | report); | 96 | report); |
1464 | 99 | 97 | ||
1465 | @@ -107,13 +105,11 @@ | |||
1466 | 107 | using namespace testing; | 105 | using namespace testing; |
1467 | 108 | 106 | ||
1468 | 109 | ms::BasicSurface surf( | 107 | ms::BasicSurface surf( |
1469 | 110 | stub_id, | ||
1470 | 111 | std::string("stub"), | 108 | std::string("stub"), |
1471 | 112 | geom::Rectangle{{},{}}, | 109 | geom::Rectangle{{},{}}, |
1472 | 113 | false, | 110 | false, |
1473 | 114 | buffer_stream, | 111 | buffer_stream, |
1474 | 115 | std::shared_ptr<mi::InputChannel>(), | 112 | std::shared_ptr<mi::InputChannel>(), |
1475 | 116 | stub_sender, | ||
1476 | 117 | null_configurator, | 113 | null_configurator, |
1477 | 118 | report); | 114 | report); |
1478 | 119 | 115 | ||
1479 | @@ -148,13 +144,11 @@ | |||
1480 | 148 | using namespace testing; | 144 | using namespace testing; |
1481 | 149 | 145 | ||
1482 | 150 | ms::BasicSurface surf( | 146 | ms::BasicSurface surf( |
1483 | 151 | stub_id, | ||
1484 | 152 | std::string("stub"), | 147 | std::string("stub"), |
1485 | 153 | geom::Rectangle{{},{}}, | 148 | geom::Rectangle{{},{}}, |
1486 | 154 | false, | 149 | false, |
1487 | 155 | buffer_stream, | 150 | buffer_stream, |
1488 | 156 | std::shared_ptr<mi::InputChannel>(), | 151 | std::shared_ptr<mi::InputChannel>(), |
1489 | 157 | stub_sender, | ||
1490 | 158 | null_configurator, | 152 | null_configurator, |
1491 | 159 | report); | 153 | report); |
1492 | 160 | 154 | ||
1493 | @@ -196,18 +190,19 @@ | |||
1494 | 196 | 190 | ||
1495 | 197 | geom::Size const new_size{123, 456}; | 191 | geom::Size const new_size{123, 456}; |
1496 | 198 | auto sink = std::make_shared<MockEventSink>(); | 192 | auto sink = std::make_shared<MockEventSink>(); |
1497 | 193 | auto const observer = std::make_shared<ms::SurfaceEventSource>(stub_id, sink); | ||
1498 | 199 | 194 | ||
1499 | 200 | ms::BasicSurface surf( | 195 | ms::BasicSurface surf( |
1500 | 201 | stub_id, | ||
1501 | 202 | std::string("stub"), | 196 | std::string("stub"), |
1502 | 203 | geom::Rectangle{{},{}}, | 197 | geom::Rectangle{{},{}}, |
1503 | 204 | false, | 198 | false, |
1504 | 205 | buffer_stream, | 199 | buffer_stream, |
1505 | 206 | std::shared_ptr<mi::InputChannel>(), | 200 | std::shared_ptr<mi::InputChannel>(), |
1506 | 207 | sink, | ||
1507 | 208 | null_configurator, | 201 | null_configurator, |
1508 | 209 | report); | 202 | report); |
1509 | 210 | 203 | ||
1510 | 204 | surf.add_observer(observer); | ||
1511 | 205 | |||
1512 | 211 | MirEvent e; | 206 | MirEvent e; |
1513 | 212 | memset(&e, 0, sizeof e); | 207 | memset(&e, 0, sizeof e); |
1514 | 213 | e.type = mir_event_type_resize; | 208 | e.type = mir_event_type_resize; |
1515 | @@ -228,18 +223,19 @@ | |||
1516 | 228 | geom::Size const new_size{123, 456}; | 223 | geom::Size const new_size{123, 456}; |
1517 | 229 | geom::Size const new_size2{789, 1011}; | 224 | geom::Size const new_size2{789, 1011}; |
1518 | 230 | auto sink = std::make_shared<MockEventSink>(); | 225 | auto sink = std::make_shared<MockEventSink>(); |
1519 | 226 | auto const observer = std::make_shared<ms::SurfaceEventSource>(stub_id, sink); | ||
1520 | 231 | 227 | ||
1521 | 232 | ms::BasicSurface surf( | 228 | ms::BasicSurface surf( |
1522 | 233 | stub_id, | ||
1523 | 234 | std::string("stub"), | 229 | std::string("stub"), |
1524 | 235 | geom::Rectangle{{},{}}, | 230 | geom::Rectangle{{},{}}, |
1525 | 236 | false, | 231 | false, |
1526 | 237 | buffer_stream, | 232 | buffer_stream, |
1527 | 238 | std::shared_ptr<mi::InputChannel>(), | 233 | std::shared_ptr<mi::InputChannel>(), |
1528 | 239 | sink, | ||
1529 | 240 | null_configurator, | 234 | null_configurator, |
1530 | 241 | report); | 235 | report); |
1531 | 242 | 236 | ||
1532 | 237 | surf.add_observer(observer); | ||
1533 | 238 | |||
1534 | 243 | MirEvent e; | 239 | MirEvent e; |
1535 | 244 | memset(&e, 0, sizeof e); | 240 | memset(&e, 0, sizeof e); |
1536 | 245 | e.type = mir_event_type_resize; | 241 | e.type = mir_event_type_resize; |
1537 | @@ -272,13 +268,11 @@ | |||
1538 | 272 | TEST_F(Surface, remembers_alpha) | 268 | TEST_F(Surface, remembers_alpha) |
1539 | 273 | { | 269 | { |
1540 | 274 | ms::BasicSurface surf( | 270 | ms::BasicSurface surf( |
1541 | 275 | stub_id, | ||
1542 | 276 | std::string("stub"), | 271 | std::string("stub"), |
1543 | 277 | geom::Rectangle{{},{}}, | 272 | geom::Rectangle{{},{}}, |
1544 | 278 | false, | 273 | false, |
1545 | 279 | buffer_stream, | 274 | buffer_stream, |
1546 | 280 | std::shared_ptr<mi::InputChannel>(), | 275 | std::shared_ptr<mi::InputChannel>(), |
1547 | 281 | stub_sender, | ||
1548 | 282 | null_configurator, | 276 | null_configurator, |
1549 | 283 | report); | 277 | report); |
1550 | 284 | 278 | ||
1551 | @@ -311,17 +305,19 @@ | |||
1552 | 311 | .Times(1); | 305 | .Times(1); |
1553 | 312 | } | 306 | } |
1554 | 313 | 307 | ||
1555 | 308 | auto const observer = std::make_shared<ms::SurfaceEventSource>(stub_id, mt::fake_shared(sink)); | ||
1556 | 309 | |||
1557 | 314 | ms::BasicSurface surf( | 310 | ms::BasicSurface surf( |
1558 | 315 | stub_id, | ||
1559 | 316 | std::string("stub"), | 311 | std::string("stub"), |
1560 | 317 | geom::Rectangle{{},{}}, | 312 | geom::Rectangle{{},{}}, |
1561 | 318 | false, | 313 | false, |
1562 | 319 | buffer_stream, | 314 | buffer_stream, |
1563 | 320 | std::shared_ptr<mi::InputChannel>(), | 315 | std::shared_ptr<mi::InputChannel>(), |
1564 | 321 | mt::fake_shared(sink), | ||
1565 | 322 | null_configurator, | 316 | null_configurator, |
1566 | 323 | report); | 317 | report); |
1567 | 324 | 318 | ||
1568 | 319 | surf.add_observer(observer); | ||
1569 | 320 | |||
1570 | 325 | surf.configure(mir_surface_attrib_focus, mir_surface_focused); | 321 | surf.configure(mir_surface_attrib_focus, mir_surface_focused); |
1571 | 326 | surf.configure(mir_surface_attrib_focus, mir_surface_unfocused); | 322 | surf.configure(mir_surface_attrib_focus, mir_surface_unfocused); |
1572 | 327 | } | 323 | } |
1573 | @@ -337,13 +333,11 @@ | |||
1574 | 337 | EXPECT_CALL(configurator, attribute_set(_, mir_surface_attrib_state, mir_surface_state_minimized)).Times(1); | 333 | EXPECT_CALL(configurator, attribute_set(_, mir_surface_attrib_state, mir_surface_state_minimized)).Times(1); |
1575 | 338 | 334 | ||
1576 | 339 | ms::BasicSurface surf( | 335 | ms::BasicSurface surf( |
1577 | 340 | stub_id, | ||
1578 | 341 | std::string("stub"), | 336 | std::string("stub"), |
1579 | 342 | geom::Rectangle{{},{}}, | 337 | geom::Rectangle{{},{}}, |
1580 | 343 | false, | 338 | false, |
1581 | 344 | buffer_stream, | 339 | buffer_stream, |
1582 | 345 | std::shared_ptr<mi::InputChannel>(), | 340 | std::shared_ptr<mi::InputChannel>(), |
1583 | 346 | stub_sender, | ||
1584 | 347 | mt::fake_shared(configurator), | 341 | mt::fake_shared(configurator), |
1585 | 348 | report); | 342 | report); |
1586 | 349 | 343 | ||
1587 | @@ -355,13 +349,11 @@ | |||
1588 | 355 | using namespace ::testing; | 349 | using namespace ::testing; |
1589 | 356 | 350 | ||
1590 | 357 | ms::BasicSurface surf( | 351 | ms::BasicSurface surf( |
1591 | 358 | stub_id, | ||
1592 | 359 | std::string("stub"), | 352 | std::string("stub"), |
1593 | 360 | geom::Rectangle{{},{}}, | 353 | geom::Rectangle{{},{}}, |
1594 | 361 | false, | 354 | false, |
1595 | 362 | buffer_stream, | 355 | buffer_stream, |
1596 | 363 | std::shared_ptr<mi::InputChannel>(), | 356 | std::shared_ptr<mi::InputChannel>(), |
1597 | 364 | stub_sender, | ||
1598 | 365 | null_configurator, | 357 | null_configurator, |
1599 | 366 | report); | 358 | report); |
1600 | 367 | 359 | ||
1601 | @@ -376,13 +368,11 @@ | |||
1602 | 376 | auto stub_buffer_stream = std::make_shared<mtd::StubBufferStream>(); | 368 | auto stub_buffer_stream = std::make_shared<mtd::StubBufferStream>(); |
1603 | 377 | 369 | ||
1604 | 378 | ms::BasicSurface surf( | 370 | ms::BasicSurface surf( |
1605 | 379 | stub_id, | ||
1606 | 380 | std::string("stub"), | 371 | std::string("stub"), |
1607 | 381 | geom::Rectangle{{},{}}, | 372 | geom::Rectangle{{},{}}, |
1608 | 382 | false, | 373 | false, |
1609 | 383 | stub_buffer_stream, | 374 | stub_buffer_stream, |
1610 | 384 | std::shared_ptr<mi::InputChannel>(), | 375 | std::shared_ptr<mi::InputChannel>(), |
1611 | 385 | stub_sender, | ||
1612 | 386 | null_configurator, | 376 | null_configurator, |
1613 | 387 | report); | 377 | report); |
1614 | 388 | 378 | ||
1615 | 389 | 379 | ||
1616 | === modified file 'tests/unit-tests/scene/test_surface_stack.cpp' | |||
1617 | --- tests/unit-tests/scene/test_surface_stack.cpp 2014-03-26 14:20:14 +0000 | |||
1618 | +++ tests/unit-tests/scene/test_surface_stack.cpp 2014-03-31 11:00:33 +0000 | |||
1619 | @@ -128,35 +128,29 @@ | |||
1620 | 128 | default_params = msh::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}}); | 128 | default_params = msh::a_surface().of_size(geom::Size{geom::Width{1024}, geom::Height{768}}); |
1621 | 129 | 129 | ||
1622 | 130 | stub_surface1 = std::make_shared<ms::BasicSurface>( | 130 | stub_surface1 = std::make_shared<ms::BasicSurface>( |
1623 | 131 | mf::SurfaceId(__LINE__), | ||
1624 | 132 | std::string("stub"), | 131 | std::string("stub"), |
1625 | 133 | geom::Rectangle{{},{}}, | 132 | geom::Rectangle{{},{}}, |
1626 | 134 | false, | 133 | false, |
1627 | 135 | std::make_shared<mtd::StubBufferStream>(), | 134 | std::make_shared<mtd::StubBufferStream>(), |
1628 | 136 | std::shared_ptr<mir::input::InputChannel>(), | 135 | std::shared_ptr<mir::input::InputChannel>(), |
1629 | 137 | std::shared_ptr<mf::EventSink>(), | ||
1630 | 138 | std::shared_ptr<ms::SurfaceConfigurator>(), | 136 | std::shared_ptr<ms::SurfaceConfigurator>(), |
1631 | 139 | report); | 137 | report); |
1632 | 140 | 138 | ||
1633 | 141 | stub_surface2 = std::make_shared<ms::BasicSurface>( | 139 | stub_surface2 = std::make_shared<ms::BasicSurface>( |
1634 | 142 | mf::SurfaceId(__LINE__), | ||
1635 | 143 | std::string("stub"), | 140 | std::string("stub"), |
1636 | 144 | geom::Rectangle{{},{}}, | 141 | geom::Rectangle{{},{}}, |
1637 | 145 | false, | 142 | false, |
1638 | 146 | std::make_shared<mtd::StubBufferStream>(), | 143 | std::make_shared<mtd::StubBufferStream>(), |
1639 | 147 | std::shared_ptr<mir::input::InputChannel>(), | 144 | std::shared_ptr<mir::input::InputChannel>(), |
1640 | 148 | std::shared_ptr<mf::EventSink>(), | ||
1641 | 149 | std::shared_ptr<ms::SurfaceConfigurator>(), | 145 | std::shared_ptr<ms::SurfaceConfigurator>(), |
1642 | 150 | report); | 146 | report); |
1643 | 151 | 147 | ||
1644 | 152 | stub_surface3 = std::make_shared<ms::BasicSurface>( | 148 | stub_surface3 = std::make_shared<ms::BasicSurface>( |
1645 | 153 | mf::SurfaceId(__LINE__), | ||
1646 | 154 | std::string("stub"), | 149 | std::string("stub"), |
1647 | 155 | geom::Rectangle{{},{}}, | 150 | geom::Rectangle{{},{}}, |
1648 | 156 | false, | 151 | false, |
1649 | 157 | std::make_shared<mtd::StubBufferStream>(), | 152 | std::make_shared<mtd::StubBufferStream>(), |
1650 | 158 | std::shared_ptr<mir::input::InputChannel>(), | 153 | std::shared_ptr<mir::input::InputChannel>(), |
1651 | 159 | std::shared_ptr<mf::EventSink>(), | ||
1652 | 160 | std::shared_ptr<ms::SurfaceConfigurator>(), | 154 | std::shared_ptr<ms::SurfaceConfigurator>(), |
1653 | 161 | report); | 155 | report); |
1654 | 162 | } | 156 | } |
1655 | @@ -568,13 +562,11 @@ | |||
1656 | 568 | for(auto i = 0u; i < num_surfaces; i++) | 562 | for(auto i = 0u; i < num_surfaces; i++) |
1657 | 569 | { | 563 | { |
1658 | 570 | auto const surface = std::make_shared<ms::BasicSurface>( | 564 | auto const surface = std::make_shared<ms::BasicSurface>( |
1659 | 571 | mf::SurfaceId(__LINE__), | ||
1660 | 572 | std::string("stub"), | 565 | std::string("stub"), |
1661 | 573 | geom::Rectangle{geom::Point{3 * i, 4 * i},geom::Size{1 * i, 2 * i}}, | 566 | geom::Rectangle{geom::Point{3 * i, 4 * i},geom::Size{1 * i, 2 * i}}, |
1662 | 574 | true, | 567 | true, |
1663 | 575 | std::make_shared<mtd::StubBufferStream>(), | 568 | std::make_shared<mtd::StubBufferStream>(), |
1664 | 576 | std::shared_ptr<mir::input::InputChannel>(), | 569 | std::shared_ptr<mir::input::InputChannel>(), |
1665 | 577 | std::shared_ptr<mf::EventSink>(), | ||
1666 | 578 | std::shared_ptr<ms::SurfaceConfigurator>(), | 570 | std::shared_ptr<ms::SurfaceConfigurator>(), |
1667 | 579 | report); | 571 | report); |
1668 | 580 | 572 | ||
1669 | 581 | 573 | ||
1670 | === modified file 'tests/unit-tests/shell/test_organising_surface_factory.cpp' | |||
1671 | --- tests/unit-tests/shell/test_organising_surface_factory.cpp 2014-03-31 11:00:33 +0000 | |||
1672 | +++ tests/unit-tests/shell/test_organising_surface_factory.cpp 2014-03-31 11:00:33 +0000 | |||
1673 | @@ -20,6 +20,8 @@ | |||
1674 | 20 | #include "mir/shell/placement_strategy.h" | 20 | #include "mir/shell/placement_strategy.h" |
1675 | 21 | #include "mir/shell/surface_creation_parameters.h" | 21 | #include "mir/shell/surface_creation_parameters.h" |
1676 | 22 | #include "mir/shell/session.h" | 22 | #include "mir/shell/session.h" |
1677 | 23 | #include "mir/scene/surface.h" | ||
1678 | 24 | #include "mir/scene/surface_event_source.h" | ||
1679 | 23 | #include "mir/scene/surface_coordinator.h" | 25 | #include "mir/scene/surface_coordinator.h" |
1680 | 24 | 26 | ||
1681 | 25 | #include "mir_test_doubles/stub_shell_session.h" | 27 | #include "mir_test_doubles/stub_shell_session.h" |
1682 | @@ -38,10 +40,9 @@ | |||
1683 | 38 | { | 40 | { |
1684 | 39 | struct MockSurfaceCoordinator : public ms::SurfaceCoordinator | 41 | struct MockSurfaceCoordinator : public ms::SurfaceCoordinator |
1685 | 40 | { | 42 | { |
1688 | 41 | MOCK_METHOD3(add_surface, std::shared_ptr<ms::Surface>( | 43 | MOCK_METHOD2(add_surface, std::shared_ptr<ms::Surface>( |
1687 | 42 | mf::SurfaceId, | ||
1689 | 43 | msh::SurfaceCreationParameters const&, | 44 | msh::SurfaceCreationParameters const&, |
1691 | 44 | std::shared_ptr<mf::EventSink> const&)); | 45 | std::shared_ptr<ms::SurfaceObserver> const&)); |
1692 | 45 | 46 | ||
1693 | 46 | void remove_surface(std::weak_ptr<ms::Surface> const& /*surface*/) override {} | 47 | void remove_surface(std::weak_ptr<ms::Surface> const& /*surface*/) override {} |
1694 | 47 | void raise(std::weak_ptr<ms::Surface> const& /*surface*/) override {} | 48 | void raise(std::weak_ptr<ms::Surface> const& /*surface*/) override {} |
1695 | @@ -57,10 +58,11 @@ | |||
1696 | 57 | void SetUp() | 58 | void SetUp() |
1697 | 58 | { | 59 | { |
1698 | 59 | using namespace ::testing; | 60 | using namespace ::testing; |
1700 | 60 | ON_CALL(*surface_coordinator, add_surface(_, _, _)).WillByDefault(Return(null_surface)); | 61 | ON_CALL(*surface_coordinator, add_surface(_, _)).WillByDefault(Return(null_surface)); |
1701 | 61 | } | 62 | } |
1702 | 62 | std::shared_ptr<ms::Surface> null_surface; | 63 | std::shared_ptr<ms::Surface> null_surface; |
1703 | 63 | std::shared_ptr<MockSurfaceCoordinator> surface_coordinator = std::make_shared<MockSurfaceCoordinator>(); | 64 | std::shared_ptr<MockSurfaceCoordinator> surface_coordinator = std::make_shared<MockSurfaceCoordinator>(); |
1704 | 65 | std::shared_ptr<ms::SurfaceObserver> const observer = std::make_shared<ms::SurfaceEventSource>(mf::SurfaceId(), std::make_shared<mtd::NullEventSink>()); | ||
1705 | 64 | std::shared_ptr<MockPlacementStrategy> placement_strategy = std::make_shared<MockPlacementStrategy>(); | 66 | std::shared_ptr<MockPlacementStrategy> placement_strategy = std::make_shared<MockPlacementStrategy>(); |
1706 | 65 | }; | 67 | }; |
1707 | 66 | 68 | ||
1708 | @@ -73,13 +75,13 @@ | |||
1709 | 73 | msh::OrganisingSurfaceFactory factory(surface_coordinator, placement_strategy); | 75 | msh::OrganisingSurfaceFactory factory(surface_coordinator, placement_strategy); |
1710 | 74 | 76 | ||
1711 | 75 | mtd::StubShellSession session; | 77 | mtd::StubShellSession session; |
1713 | 76 | EXPECT_CALL(*surface_coordinator, add_surface(_, _, _)).Times(1); | 78 | EXPECT_CALL(*surface_coordinator, add_surface(_, _)).Times(1); |
1714 | 77 | 79 | ||
1715 | 78 | auto params = msh::a_surface(); | 80 | auto params = msh::a_surface(); |
1716 | 79 | EXPECT_CALL(*placement_strategy, place(Ref(session), Ref(params))).Times(1) | 81 | EXPECT_CALL(*placement_strategy, place(Ref(session), Ref(params))).Times(1) |
1717 | 80 | .WillOnce(Return(msh::a_surface())); | 82 | .WillOnce(Return(msh::a_surface())); |
1718 | 81 | 83 | ||
1720 | 82 | factory.create_surface(&session, params, mf::SurfaceId(), std::make_shared<mtd::NullEventSink>()); | 84 | factory.create_surface(&session, params, observer); |
1721 | 83 | } | 85 | } |
1722 | 84 | 86 | ||
1723 | 85 | TEST_F(OrganisingSurfaceFactorySetup, forwards_create_surface_parameters_from_placement_strategy_to_underlying_factory) | 87 | TEST_F(OrganisingSurfaceFactorySetup, forwards_create_surface_parameters_from_placement_strategy_to_underlying_factory) |
1724 | @@ -88,14 +90,13 @@ | |||
1725 | 88 | 90 | ||
1726 | 89 | msh::OrganisingSurfaceFactory factory(surface_coordinator, placement_strategy); | 91 | msh::OrganisingSurfaceFactory factory(surface_coordinator, placement_strategy); |
1727 | 90 | 92 | ||
1728 | 91 | std::shared_ptr<mf::EventSink> sink = std::make_shared<mtd::NullEventSink>(); | ||
1729 | 92 | auto params = msh::a_surface(); | 93 | auto params = msh::a_surface(); |
1730 | 93 | auto placed_params = params; | 94 | auto placed_params = params; |
1731 | 94 | placed_params.size.width = geom::Width{100}; | 95 | placed_params.size.width = geom::Width{100}; |
1732 | 95 | 96 | ||
1733 | 96 | EXPECT_CALL(*placement_strategy, place(_, Ref(params))).Times(1) | 97 | EXPECT_CALL(*placement_strategy, place(_, Ref(params))).Times(1) |
1734 | 97 | .WillOnce(Return(placed_params)); | 98 | .WillOnce(Return(placed_params)); |
1736 | 98 | EXPECT_CALL(*surface_coordinator, add_surface(mf::SurfaceId(), placed_params, sink)); | 99 | EXPECT_CALL(*surface_coordinator, add_surface(placed_params, _)); |
1737 | 99 | 100 | ||
1739 | 100 | factory.create_surface(nullptr, params, mf::SurfaceId(), sink); | 101 | factory.create_surface(nullptr, params, observer); |
1740 | 101 | } | 102 | } |
Approve a part from:
the name SurfaceEventSource is a bit misleading... on second read: was a but misleading. Now I am only curious whether we need it inside the public headers. Would someone replacing the scene or extending the surfaces need that implementation? Or would decorating the surface factory be sufficient?