Mir

Merge lp:~alan-griffiths/mir/some-surface-modification-infrastructure into lp:mir

Proposed by Alan Griffiths on 2015-04-09
Status: Merged
Approved by: Alan Griffiths on 2015-04-13
Approved revision: 2474
Merged at revision: 2476
Proposed branch: lp:~alan-griffiths/mir/some-surface-modification-infrastructure
Merge into: lp:mir
Diff against target: 311 lines (+150/-32)
6 files modified
include/common/mir/optional_value.h (+3/-0)
include/server/mir/shell/surface_specification.h (+30/-3)
src/client/mir_surface.cpp (+52/-9)
src/client/mir_surface.h (+11/-5)
src/protobuf/mir_protobuf.proto (+22/-11)
src/server/frontend/session_mediator.cpp (+32/-4)
To merge this branch: bzr merge lp:~alan-griffiths/mir/some-surface-modification-infrastructure
Reviewer Review Type Date Requested Status
Chris Halse Rogers 2015-04-09 Approve on 2015-04-13
PS Jenkins bot continuous-integration Approve on 2015-04-10
Review via email: mp+255648@code.launchpad.net

Commit Message

RPC, frontend: "wiring up" to pass generic surface modification requests from wire to the shell.

Description of the Change

RPC, frontend: "wiring up" to pass generic surface modification requests from wire to the shell.

This needs to be followed up with specific client APIs to make the requests and window manager code to process them. The tests will be written to drive that work.

To post a comment you must log in.
Alan Griffiths (alan-griffiths) wrote :

11: [ FAILED ] SimpleDispatchThreadTest.keeps_dispatching_after_signal_interruption (716 ms)

Oh well, I might as well roll in the nest batch of changes to cause a rebuild.

2470. By Alan Griffiths on 2015-04-09

Client side changes to put surface modification onto the wire

2471. By Alan Griffiths on 2015-04-09

Update a couple of copyright dates

2472. By Alan Griffiths on 2015-04-09

merge lp:mir

Chris Halse Rogers (raof) wrote :

35 + mir::optional_value<geometry::Width> width;
36 + mir::optional_value<geometry::Height> height;
37 + optional_value<MirPixelFormat> pixel_format;
38 + optional_value<graphics::BufferUsage> buffer_usage;
39 optional_value<std::string> name;
40 - // TODO: type/state/size etc (LP: #1422522) (LP: #1420573)
41 - // Once fully populated for surface modification this can probably
42 - // also replace scene::SurfaceCreationParameters in create_surface()
43 + optional_value<graphics::DisplayConfigurationOutputId> output_id;
44 + mir::optional_value<MirSurfaceType> type;

Why is there a mix of mir::optional_value<> and optional_value<> here?

Other than that, looks sensible.

review: Needs Fixing
2473. By Alan Griffiths on 2015-04-10

Be consistent

2474. By Alan Griffiths on 2015-04-10

merge lp:mir

Alan Griffiths (alan-griffiths) wrote :

> Why is there a mix of mir::optional_value<> and optional_value<> here?

Fixed

> Other than that, looks sensible.

Chris Halse Rogers (raof) wrote :

Happy with this now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/common/mir/optional_value.h'
2--- include/common/mir/optional_value.h 2014-12-19 04:37:16 +0000
3+++ include/common/mir/optional_value.h 2015-04-10 08:43:04 +0000
4@@ -25,6 +25,9 @@
5 class optional_value
6 {
7 public:
8+ optional_value() = default;
9+ optional_value(T const& value) : value_{value}, is_set_{true} {}
10+
11 optional_value& operator=(T const& value)
12 {
13 value_ = value;
14
15=== modified file 'include/server/mir/shell/surface_specification.h'
16--- include/server/mir/shell/surface_specification.h 2015-04-02 13:34:15 +0000
17+++ include/server/mir/shell/surface_specification.h 2015-04-10 08:43:04 +0000
18@@ -20,6 +20,12 @@
19 #define MIR_SHELL_SURFACE_SPECIFICATION_H_
20
21 #include "mir/optional_value.h"
22+#include "mir_toolkit/common.h"
23+#include "mir/frontend/surface_id.h"
24+#include "mir/geometry/point.h"
25+#include "mir/graphics/buffer_properties.h"
26+#include "mir/graphics/display_configuration.h"
27+#include "mir/scene/depth_id.h"
28
29 #include <string>
30
31@@ -30,10 +36,31 @@
32 /// Specification of surface properties requested by client
33 struct SurfaceSpecification
34 {
35+ optional_value<geometry::Width> width;
36+ optional_value<geometry::Height> height;
37+ optional_value<MirPixelFormat> pixel_format;
38+ optional_value<graphics::BufferUsage> buffer_usage;
39 optional_value<std::string> name;
40- // TODO: type/state/size etc (LP: #1422522) (LP: #1420573)
41- // Once fully populated for surface modification this can probably
42- // also replace scene::SurfaceCreationParameters in create_surface()
43+ optional_value<graphics::DisplayConfigurationOutputId> output_id;
44+ optional_value<MirSurfaceType> type;
45+ optional_value<MirSurfaceState> state;
46+ optional_value<MirOrientationMode> preferred_orientation;
47+ optional_value<frontend::SurfaceId> parent_id;
48+ optional_value<geometry::Rectangle> aux_rect;
49+ optional_value<MirEdgeAttachment> edge_attachment;
50+ optional_value<geometry::Width> min_width;
51+ optional_value<geometry::Height> min_height;
52+ optional_value<geometry::Width> max_width;
53+ optional_value<geometry::Height> max_height;
54+
55+ // TODO scene::SurfaceCreationParameters overlaps this content but has additional fields:
56+ // geometry::Point top_left;
57+ // scene::DepthId depth;
58+ // input::InputReceptionMode input_mode;
59+ // std::weak_ptr<Surface> parent;
60+ //
61+ // it also has size instead of width + height
62+ // Maybe SurfaceCreationParameters /HasA/ SurfaceSpecification?
63 };
64 }
65 }
66
67=== modified file 'src/client/mir_surface.cpp'
68--- src/client/mir_surface.cpp 2015-04-09 06:20:31 +0000
69+++ src/client/mir_surface.cpp 2015-04-10 08:43:04 +0000
70@@ -1,5 +1,5 @@
71 /*
72- * Copyright © 2012 Canonical Ltd.
73+ * Copyright © 2012, 2015 Canonical Ltd.
74 *
75 * This program is free software: you can redistribute it and/or modify it
76 * under the terms of the GNU Lesser General Public License version 3,
77@@ -54,7 +54,8 @@
78 : connection{connection},
79 width{width},
80 height{height},
81- pixel_format{format}
82+ pixel_format{format},
83+ buffer_usage{mir_buffer_usage_hardware}
84 {
85 }
86
87@@ -81,18 +82,20 @@
88 {
89 mir::protobuf::SurfaceParameters message;
90
91- message.set_width(width);
92- message.set_height(height);
93- message.set_pixel_format(pixel_format);
94- message.set_buffer_usage(buffer_usage);
95-
96+ SERIALIZE_OPTION_IF_SET(width, message);
97+ SERIALIZE_OPTION_IF_SET(height, message);
98+ SERIALIZE_OPTION_IF_SET(pixel_format, message);
99+ SERIALIZE_OPTION_IF_SET(buffer_usage, message);
100 SERIALIZE_OPTION_IF_SET(surface_name, message);
101 SERIALIZE_OPTION_IF_SET(output_id, message);
102 SERIALIZE_OPTION_IF_SET(type, message);
103 SERIALIZE_OPTION_IF_SET(state, message);
104 SERIALIZE_OPTION_IF_SET(pref_orientation, message);
105+ SERIALIZE_OPTION_IF_SET(edge_attachment, message);
106+
107 if (parent.is_set() && parent.value() != nullptr)
108 message.set_parent_id(parent.value()->id());
109+
110 if (aux_rect.is_set())
111 {
112 message.mutable_aux_rect()->set_left(aux_rect.value().left);
113@@ -100,7 +103,7 @@
114 message.mutable_aux_rect()->set_width(aux_rect.value().width);
115 message.mutable_aux_rect()->set_height(aux_rect.value().height);
116 }
117- SERIALIZE_OPTION_IF_SET(edge_attachment, message);
118+
119 return message;
120 }
121
122@@ -534,8 +537,48 @@
123 mods.mutable_surface_id()->set_value(surface.id().value());
124 }
125
126+ auto const surface_specification = mods.mutable_surface_specification();
127+
128+ #define COPY_IF_SET(field)\
129+ if (spec.field.is_set())\
130+ surface_specification->set_##field(spec.field.value())
131+
132+ COPY_IF_SET(width);
133+ COPY_IF_SET(height);
134+ COPY_IF_SET(pixel_format);
135+ COPY_IF_SET(buffer_usage);
136+ // name is a special case (below)
137+ COPY_IF_SET(output_id);
138+ COPY_IF_SET(type);
139+ COPY_IF_SET(state);
140+ // preferred_orientation is a special case (below)
141+ // parent_id is a special case (below)
142+ // aux_rect is a special case (below)
143+ COPY_IF_SET(edge_attachment);
144+ COPY_IF_SET(min_width);
145+ COPY_IF_SET(min_height);
146+ COPY_IF_SET(max_width);
147+ COPY_IF_SET(max_height);
148+ #undef COPY_IF_SET
149+
150 if (spec.surface_name.is_set())
151- mods.set_name(spec.surface_name.value());
152+ surface_specification->set_name(spec.surface_name.value());
153+
154+ if (spec.pref_orientation.is_set())
155+ surface_specification->set_preferred_orientation(spec.pref_orientation.value());
156+
157+ if (spec.parent.is_set() && spec.parent.value())
158+ surface_specification->set_parent_id(spec.parent.value()->id());
159+
160+ if (spec.aux_rect.is_set())
161+ {
162+ auto const rect = surface_specification->mutable_aux_rect();
163+ auto const& value = spec.aux_rect.value();
164+ rect->set_left(value.left);
165+ rect->set_top(value.top);
166+ rect->set_width(value.width);
167+ rect->set_height(value.height);
168+ }
169
170 modify_wait_handle.expect_result();
171 server->modify_surface(0, &mods, &modify_result,
172
173=== modified file 'src/client/mir_surface.h'
174--- src/client/mir_surface.h 2015-04-09 06:20:31 +0000
175+++ src/client/mir_surface.h 2015-04-10 08:43:04 +0000
176@@ -1,5 +1,5 @@
177 /*
178- * Copyright © 2012 Canonical Ltd.
179+ * Copyright © 2012, 2015 Canonical Ltd.
180 *
181 * This program is free software: you can redistribute it and/or modify it
182 * under the terms of the GNU Lesser General Public License version 3,
183@@ -70,12 +70,13 @@
184
185 // Required parameters
186 MirConnection* connection{nullptr};
187- int width{-1};
188- int height{-1};
189- MirPixelFormat pixel_format{mir_pixel_format_invalid};
190- MirBufferUsage buffer_usage{mir_buffer_usage_hardware};
191
192 // Optional parameters
193+ mir::optional_value<int> width;
194+ mir::optional_value<int> height;
195+ mir::optional_value<MirPixelFormat> pixel_format;
196+ mir::optional_value<MirBufferUsage> buffer_usage;
197+
198 mir::optional_value<std::string> surface_name;
199 mir::optional_value<uint32_t> output_id;
200
201@@ -87,6 +88,11 @@
202 mir::optional_value<MirSurface*> parent;
203 mir::optional_value<MirRectangle> aux_rect;
204 mir::optional_value<MirEdgeAttachment> edge_attachment;
205+
206+ mir::optional_value<int> min_width;
207+ mir::optional_value<int> min_height;
208+ mir::optional_value<int> max_width;
209+ mir::optional_value<int> max_height;
210 };
211
212 struct MirSurface
213
214=== modified file 'src/protobuf/mir_protobuf.proto'
215--- src/protobuf/mir_protobuf.proto 2015-04-09 14:09:19 +0000
216+++ src/protobuf/mir_protobuf.proto 2015-04-10 08:43:04 +0000
217@@ -30,19 +30,30 @@
218
219 // If and when we break our protocol backward-compatibility, this could be
220 // merged with SurfaceParameters...
221+message SurfaceSpecification {
222+ optional int32 width = 1;
223+ optional int32 height = 2;
224+ optional int32 pixel_format = 3;
225+ optional int32 buffer_usage = 4;
226+ optional string name = 5;
227+ optional uint32 output_id = 6;
228+ optional int32 type = 7;
229+ optional int32 state = 8;
230+ optional int32 preferred_orientation = 9;
231+ optional int32 parent_id = 10;
232+ optional Rectangle aux_rect = 11;
233+ optional int32 edge_attachment = 12;
234+
235+ optional int32 min_width = 13;
236+ optional int32 min_height = 14;
237+ optional int32 max_width = 15;
238+ optional int32 max_height = 16;
239+}
240+
241+
242 message SurfaceModifications {
243 required SurfaceId surface_id = 1;
244-
245- optional string name = 2;
246-
247- // TODO: Client API for resizing (LP: #1420573)
248- // optional int32 width = 3;
249- // optional int32 height = 4;
250-
251- // TODO: We could use these to replace SurfaceSetting
252- // optional int32 type = 5;
253- // optional int32 state = 6;
254- // ...
255+ required SurfaceSpecification surface_specification = 2;
256 }
257
258 message SurfaceId {
259
260=== modified file 'src/server/frontend/session_mediator.cpp'
261--- src/server/frontend/session_mediator.cpp 2015-04-09 06:20:31 +0000
262+++ src/server/frontend/session_mediator.cpp 2015-04-10 08:43:04 +0000
263@@ -420,17 +420,45 @@
264 mir::protobuf::Void* /*response*/,
265 google::protobuf::Closure* done)
266 {
267+ auto const& surface_specification = request->surface_specification();
268+
269 {
270 std::unique_lock<std::mutex> lock(session_mutex);
271
272- auto session = weak_session.lock();
273+ auto const session = weak_session.lock();
274 if (!session)
275 BOOST_THROW_EXCEPTION(std::logic_error("Invalid application session"));
276
277 msh::SurfaceSpecification mods;
278- if (request->has_name())
279- mods.name = request->name();
280- // TODO: More fields soon (LP: #1422522) (LP: #1420573)
281+
282+ #define COPY_IF_SET(name)\
283+ if (surface_specification.has_##name())\
284+ mods.name = decltype(mods.name.value())(surface_specification.name())
285+
286+ COPY_IF_SET(width);
287+ COPY_IF_SET(height);
288+ COPY_IF_SET(pixel_format);
289+ COPY_IF_SET(buffer_usage);
290+ COPY_IF_SET(name);
291+ COPY_IF_SET(output_id);
292+ COPY_IF_SET(type);
293+ COPY_IF_SET(state);
294+ COPY_IF_SET(preferred_orientation);
295+ COPY_IF_SET(parent_id);
296+ // aux_rect is a special case (below)
297+ COPY_IF_SET(edge_attachment);
298+ COPY_IF_SET(min_width);
299+ COPY_IF_SET(min_height);
300+ COPY_IF_SET(max_width);
301+ COPY_IF_SET(max_height);
302+
303+ #undef COPY_IF_SET
304+
305+ if (surface_specification.has_aux_rect())
306+ {
307+ auto const& rect = surface_specification.aux_rect();
308+ mods.aux_rect = {{rect.left(), rect.top()}, {rect.width(), rect.height()}};
309+ }
310
311 auto const id = mf::SurfaceId(request->surface_id().value());
312

Subscribers

People subscribed via source and target branches