Mir

Merge lp:~afrantzis/mir/fix-1344024 into lp:mir

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1805
Proposed branch: lp:~afrantzis/mir/fix-1344024
Merge into: lp:mir
Diff against target: 346 lines (+92/-63)
11 files modified
src/server/shell/CMakeLists.txt (+1/-1)
src/server/shell/default_configuration.cpp (+2/-2)
src/server/shell/default_placement_strategy.cpp (+3/-12)
src/server/shell/default_placement_strategy.h (+8/-8)
tests/acceptance-tests/CMakeLists.txt (+1/-0)
tests/acceptance-tests/test_focus_selection.cpp (+0/-1)
tests/acceptance-tests/test_server_without_active_outputs.cpp (+64/-0)
tests/integration-tests/session_management.cpp (+1/-4)
tests/mir_test_framework/stubbed_server_configuration.cpp (+7/-0)
tests/unit-tests/shell/CMakeLists.txt (+1/-1)
tests/unit-tests/shell/test_default_placement_strategy.cpp (+4/-34)
To merge this branch: bzr merge lp:~afrantzis/mir/fix-1344024
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+228484@code.launchpad.net

Commit message

server: Allow clients to create surfaces even when there are no active outputs (LP: #1344024)

This is fixed by removing obsolete placement rules from our default placement
policy. These rules had the side-effect of prohibiting surface creation when
there were no active outputs.

Description of the change

server: Allow clients to create surfaces even when there are no active outputs

This is fixed by removing obsolete placement rules from our default placement
policy. These rules had the side-effect of prohibiting surface creation when
there were no active outputs.

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

Maybe the default could be better, but this will do for now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/shell/CMakeLists.txt'
2--- src/server/shell/CMakeLists.txt 2014-05-26 22:00:52 +0000
3+++ src/server/shell/CMakeLists.txt 2014-07-28 13:50:21 +0000
4@@ -2,7 +2,7 @@
5 SHELL_SOURCES
6
7 default_focus_mechanism.cpp
8- consuming_placement_strategy.cpp
9+ default_placement_strategy.cpp
10 graphics_display_layout.cpp
11 default_configuration.cpp
12 session_coordinator_wrapper.cpp
13
14=== modified file 'src/server/shell/default_configuration.cpp'
15--- src/server/shell/default_configuration.cpp 2014-07-21 03:35:31 +0000
16+++ src/server/shell/default_configuration.cpp 2014-07-28 13:50:21 +0000
17@@ -20,7 +20,7 @@
18 #include "null_host_lifecycle_event_listener.h"
19
20
21-#include "consuming_placement_strategy.h"
22+#include "default_placement_strategy.h"
23 #include "default_focus_mechanism.h"
24 #include "graphics_display_layout.h"
25
26@@ -34,7 +34,7 @@
27 return shell_placement_strategy(
28 [this]
29 {
30- return std::make_shared<msh::ConsumingPlacementStrategy>(
31+ return std::make_shared<msh::DefaultPlacementStrategy>(
32 the_shell_display_layout());
33 });
34 }
35
36=== renamed file 'src/server/shell/consuming_placement_strategy.cpp' => 'src/server/shell/default_placement_strategy.cpp'
37--- src/server/shell/consuming_placement_strategy.cpp 2014-04-15 05:31:19 +0000
38+++ src/server/shell/default_placement_strategy.cpp 2014-07-28 13:50:21 +0000
39@@ -16,7 +16,7 @@
40 * Authored by: Robert Carr <robert.carr@canonical.com>
41 */
42
43-#include "consuming_placement_strategy.h"
44+#include "default_placement_strategy.h"
45 #include "mir/scene/surface_creation_parameters.h"
46 #include "mir/shell/display_layout.h"
47 #include "mir/geometry/rectangle.h"
48@@ -29,13 +29,13 @@
49 namespace msh = mir::shell;
50 namespace geom = mir::geometry;
51
52-msh::ConsumingPlacementStrategy::ConsumingPlacementStrategy(
53+msh::DefaultPlacementStrategy::DefaultPlacementStrategy(
54 std::shared_ptr<msh::DisplayLayout> const& display_layout)
55 : display_layout(display_layout)
56 {
57 }
58
59-ms::SurfaceCreationParameters msh::ConsumingPlacementStrategy::place(
60+ms::SurfaceCreationParameters msh::DefaultPlacementStrategy::place(
61 ms::Session const& /* session */,
62 ms::SurfaceCreationParameters const& request_parameters)
63 {
64@@ -49,15 +49,6 @@
65 {
66 display_layout->place_in_output(request_parameters.output_id, rect);
67 }
68- else if (request_parameters.size.width > geom::Width{0} &&
69- request_parameters.size.height > geom::Height{0})
70- {
71- display_layout->clip_to_output(rect);
72- }
73- else
74- {
75- display_layout->size_to_output(rect);
76- }
77
78 placed_parameters.top_left = rect.top_left;
79 placed_parameters.size = rect.size;
80
81=== renamed file 'src/server/shell/consuming_placement_strategy.h' => 'src/server/shell/default_placement_strategy.h'
82--- src/server/shell/consuming_placement_strategy.h 2014-04-15 05:31:19 +0000
83+++ src/server/shell/default_placement_strategy.h 2014-07-28 13:50:21 +0000
84@@ -16,8 +16,8 @@
85 * Authored by: Robert Carr <robert.carr@canonical.com>
86 */
87
88-#ifndef MIR_SHELL_CONSUMING_PLACEMENT_STRATEGY_H_
89-#define MIR_SHELL_CONSUMING_PLACEMENT_STRATEGY_H_
90+#ifndef MIR_SHELL_DEFAULT_PLACEMENT_STRATEGY_H_
91+#define MIR_SHELL_DEFAULT_PLACEMENT_STRATEGY_H_
92
93 #include "mir/scene/placement_strategy.h"
94
95@@ -29,18 +29,18 @@
96 {
97 class DisplayLayout;
98
99-class ConsumingPlacementStrategy : public scene::PlacementStrategy
100+class DefaultPlacementStrategy : public scene::PlacementStrategy
101 {
102 public:
103- explicit ConsumingPlacementStrategy(
104+ explicit DefaultPlacementStrategy(
105 std::shared_ptr<DisplayLayout> const& display_layout);
106- virtual ~ConsumingPlacementStrategy() {}
107+ virtual ~DefaultPlacementStrategy() {}
108
109 virtual scene::SurfaceCreationParameters place(scene::Session const& session, scene::SurfaceCreationParameters const& request_parameters);
110
111 protected:
112- ConsumingPlacementStrategy(ConsumingPlacementStrategy const&) = delete;
113- ConsumingPlacementStrategy& operator=(ConsumingPlacementStrategy const&) = delete;
114+ DefaultPlacementStrategy(DefaultPlacementStrategy const&) = delete;
115+ DefaultPlacementStrategy& operator=(DefaultPlacementStrategy const&) = delete;
116
117 private:
118 std::shared_ptr<DisplayLayout> const display_layout;
119@@ -49,4 +49,4 @@
120 }
121 } // namespace mir
122
123-#endif // MIR_SHELL_CONSUMING_PLACEMENT_STRATEGY_H_
124+#endif // MIR_SHELL_DEFAULT_PLACEMENT_STRATEGY_H_
125
126=== modified file 'tests/acceptance-tests/CMakeLists.txt'
127--- tests/acceptance-tests/CMakeLists.txt 2014-07-23 17:00:22 +0000
128+++ tests/acceptance-tests/CMakeLists.txt 2014-07-28 13:50:21 +0000
129@@ -41,6 +41,7 @@
130 test_client_with_custom_display_config_deadlock.cpp
131 test_macros.cpp
132 test_stale_frames.cpp
133+ test_server_without_active_outputs.cpp
134 ${GENERATED_PROTOBUF_SRCS}
135 ${GENERATED_PROTOBUF_HDRS}
136 )
137
138=== modified file 'tests/acceptance-tests/test_focus_selection.cpp'
139--- tests/acceptance-tests/test_focus_selection.cpp 2014-06-03 11:04:15 +0000
140+++ tests/acceptance-tests/test_focus_selection.cpp 2014-07-28 13:50:21 +0000
141@@ -19,7 +19,6 @@
142 #include "clients.h"
143
144 #include "src/server/scene/session_container.h"
145-#include "src/server/shell/consuming_placement_strategy.h"
146 #include "src/server/scene/session_manager.h"
147 #include "mir/graphics/display.h"
148 #include "mir/shell/input_targeter.h"
149
150=== added file 'tests/acceptance-tests/test_server_without_active_outputs.cpp'
151--- tests/acceptance-tests/test_server_without_active_outputs.cpp 1970-01-01 00:00:00 +0000
152+++ tests/acceptance-tests/test_server_without_active_outputs.cpp 2014-07-28 13:50:21 +0000
153@@ -0,0 +1,64 @@
154+/*
155+ * Copyright © 2014 Canonical Ltd.
156+ *
157+ * This program is free software: you can redistribute it and/or modify it
158+ * under the terms of the GNU General Public License version 3,
159+ * as published by the Free Software Foundation.
160+ *
161+ * This program is distributed in the hope that it will be useful,
162+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
163+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
164+ * GNU General Public License for more details.
165+ *
166+ * You should have received a copy of the GNU General Public License
167+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
168+ *
169+ * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
170+ */
171+
172+#include "mir_toolkit/mir_client_library.h"
173+
174+#include "mir_test_framework/stubbed_server_configuration.h"
175+#include "mir_test_framework/basic_client_server_fixture.h"
176+
177+#include <gtest/gtest.h>
178+#include <gmock/gmock.h>
179+
180+namespace mtf = mir_test_framework;
181+namespace geom = mir::geometry;
182+
183+namespace
184+{
185+
186+struct NoOutputsServerConfig : mtf::StubbedServerConfiguration
187+{
188+ NoOutputsServerConfig()
189+ : mtf::StubbedServerConfiguration(std::vector<geom::Rectangle>{})
190+ {
191+ }
192+};
193+
194+using ServerWithoutActiveOutputs = mtf::BasicClientServerFixture<NoOutputsServerConfig>;
195+
196+}
197+
198+TEST_F(ServerWithoutActiveOutputs, creates_valid_client_surface)
199+{
200+ using namespace testing;
201+
202+ MirSurfaceParameters const request_params =
203+ {
204+ __PRETTY_FUNCTION__,
205+ 640, 480,
206+ mir_pixel_format_abgr_8888,
207+ mir_buffer_usage_hardware,
208+ mir_display_output_id_invalid
209+ };
210+
211+ auto const surface = mir_connection_create_surface_sync(connection, &request_params);
212+
213+ EXPECT_THAT(mir_surface_is_valid(surface), Eq(mir_true))
214+ << mir_surface_get_error_message(surface);
215+
216+ mir_surface_release_sync(surface);
217+}
218
219=== modified file 'tests/integration-tests/session_management.cpp'
220--- tests/integration-tests/session_management.cpp 2014-06-03 11:04:15 +0000
221+++ tests/integration-tests/session_management.cpp 2014-07-28 13:50:21 +0000
222@@ -98,6 +98,7 @@
223 std::shared_ptr<mf::EventSink> const event_sink = std::make_shared<mtd::NullEventSink>();
224 std::shared_ptr<mf::Shell> const session_manager = builder.the_frontend_shell();
225 std::shared_ptr<TestSurfaceStack> const& test_surface_stack = builder.test_surface_stack;
226+ ms::SurfaceCreationParameters const params = ms::SurfaceCreationParameters().of_size(100,100);
227
228 void SetUp()
229 {
230@@ -117,8 +118,6 @@
231
232 TEST_F(SessionManagement, creating_a_surface_adds_it_to_scene)
233 {
234- ms::SurfaceCreationParameters params;
235-
236 auto const session = session_manager->open_session(0, __PRETTY_FUNCTION__, event_sink);
237
238 EXPECT_CALL(*test_surface_stack, add_surface(_,_,_)).Times(1);
239@@ -129,8 +128,6 @@
240 {
241 EXPECT_CALL(*test_surface_stack, add_surface(_,_,_)).Times(AnyNumber());
242
243- ms::SurfaceCreationParameters params;
244-
245 auto const session1 = session_manager->open_session(0, __PRETTY_FUNCTION__, event_sink);
246 auto const surface1 = session1->create_surface(params);
247
248
249=== modified file 'tests/mir_test_framework/stubbed_server_configuration.cpp'
250--- tests/mir_test_framework/stubbed_server_configuration.cpp 2014-06-23 22:25:17 +0000
251+++ tests/mir_test_framework/stubbed_server_configuration.cpp 2014-07-28 13:50:21 +0000
252@@ -116,6 +116,13 @@
253 public:
254 std::shared_ptr<mg::Buffer> alloc_buffer(mg::BufferProperties const& properties) override
255 {
256+ if (properties.size.width == geom::Width{0} ||
257+ properties.size.height == geom::Height{0})
258+ {
259+ BOOST_THROW_EXCEPTION(
260+ std::runtime_error("Request for allocation of buffer with invalid size"));
261+ }
262+
263 return std::make_shared<StubFDBuffer>(properties);
264 }
265 };
266
267=== modified file 'tests/unit-tests/shell/CMakeLists.txt'
268--- tests/unit-tests/shell/CMakeLists.txt 2014-04-15 05:31:19 +0000
269+++ tests/unit-tests/shell/CMakeLists.txt 2014-07-28 13:50:21 +0000
270@@ -1,5 +1,5 @@
271 list(APPEND UNIT_TEST_SOURCES
272- ${CMAKE_CURRENT_SOURCE_DIR}/test_consuming_placement_strategy.cpp
273+ ${CMAKE_CURRENT_SOURCE_DIR}/test_default_placement_strategy.cpp
274 ${CMAKE_CURRENT_SOURCE_DIR}/test_graphics_display_layout.cpp
275 )
276
277
278=== renamed file 'tests/unit-tests/shell/test_consuming_placement_strategy.cpp' => 'tests/unit-tests/shell/test_default_placement_strategy.cpp'
279--- tests/unit-tests/shell/test_consuming_placement_strategy.cpp 2014-04-15 05:31:19 +0000
280+++ tests/unit-tests/shell/test_default_placement_strategy.cpp 2014-07-28 13:50:21 +0000
281@@ -19,7 +19,7 @@
282 #include "mir_test_doubles/mock_display_layout.h"
283 #include "mir_test_doubles/stub_scene_session.h"
284
285-#include "src/server/shell/consuming_placement_strategy.h"
286+#include "src/server/shell/default_placement_strategy.h"
287 #include "mir/scene/surface_creation_parameters.h"
288
289 #include "mir/geometry/rectangle.h"
290@@ -35,7 +35,7 @@
291 namespace
292 {
293
294-struct ConsumingPlacementStrategySetup : public testing::Test
295+struct DefaultPlacementStrategySetup : public testing::Test
296 {
297 void SetUp()
298 {
299@@ -48,37 +48,7 @@
300 };
301 }
302
303-
304-TEST_F(ConsumingPlacementStrategySetup, parameters_with_no_geometry_are_made_fullscreen)
305-{
306- using namespace ::testing;
307-
308- ms::SurfaceCreationParameters input_params;
309- geom::Rectangle rect{input_params.top_left, input_params.size};
310-
311- EXPECT_CALL(*display_layout, size_to_output(rect)).Times(1);
312-
313- msh::ConsumingPlacementStrategy placement_strategy(display_layout);
314-
315- placement_strategy.place(session, input_params);
316-}
317-
318-TEST_F(ConsumingPlacementStrategySetup, parameters_with_geometry_are_clipped)
319-{
320- using namespace ::testing;
321-
322- ms::SurfaceCreationParameters input_params;
323- input_params.size = geom::Size{100, 200};
324- geom::Rectangle rect{input_params.top_left, input_params.size};
325-
326- EXPECT_CALL(*display_layout, clip_to_output(rect)).Times(1);
327-
328- msh::ConsumingPlacementStrategy placement_strategy(display_layout);
329-
330- placement_strategy.place(session, input_params);
331-}
332-
333-TEST_F(ConsumingPlacementStrategySetup, parameters_with_output_id_are_placed_in_output)
334+TEST_F(DefaultPlacementStrategySetup, parameters_with_output_id_are_placed_in_output)
335 {
336 using namespace ::testing;
337
338@@ -91,7 +61,7 @@
339 place_in_output(input_params.output_id, rect))
340 .Times(1);
341
342- msh::ConsumingPlacementStrategy placement_strategy(display_layout);
343+ msh::DefaultPlacementStrategy placement_strategy(display_layout);
344
345 placement_strategy.place(session, input_params);
346 }

Subscribers

People subscribed via source and target branches