Status: | Merged |
---|---|
Approved by: | Alberto Aguirre |
Approved revision: | 2555 |
Merged at revision: | 1233 |
Proposed branch: | lp:mir/0.13 |
Merge into: | lp:mir/ubuntu |
Diff against target: |
1462 lines (+320/-240) 16 files modified
CMakeLists.txt (+1/-1) debian/changelog (+9/-0) debian/control (+1/-1) src/client/buffer_stream.cpp (+41/-40) src/client/buffer_stream.h (+3/-3) src/client/make_protobuf_object.h (+42/-0) src/client/mir_buffer_stream_api.cpp (+7/-6) src/client/mir_connection.cpp (+47/-40) src/client/mir_connection.h (+8/-6) src/client/mir_prompt_session.cpp (+21/-15) src/client/mir_prompt_session.h (+5/-5) src/client/mir_screencast.cpp (+24/-21) src/client/mir_screencast.h (+4/-2) src/client/mir_surface.cpp (+76/-70) src/client/mir_surface.h (+6/-6) src/client/rpc/mir_protobuf_rpc_channel.cpp (+25/-24) |
To merge this branch: | bzr merge lp:mir/0.13 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel van Vugt | Approve | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Kevin DuBois (community) | Approve | ||
Review via email: mp+262262@code.launchpad.net |
Commit message
Mir 0.13.3 release
Description of the change
Mir 0.13.3 release
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2555
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Alberto Aguirre (albaguirre) wrote : | # |
Umm it's always these tests:
[ FAILED ] GLibMainLoopAla
[ FAILED ] SimpleDispatchT
But they don't fail in the silo build...ummm.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2555
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Daniel van Vugt (vanvugt) wrote : | # |
Apparently not landed yet, but is released already (!?) :)
https:/
https:/
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2015-06-02 23:18:42 +0000 | |||
3 | +++ CMakeLists.txt 2015-06-17 19:19:38 +0000 | |||
4 | @@ -28,7 +28,7 @@ | |||
5 | 28 | 28 | ||
6 | 29 | set(MIR_VERSION_MAJOR 0) | 29 | set(MIR_VERSION_MAJOR 0) |
7 | 30 | set(MIR_VERSION_MINOR 13) # This should change at least with every MIRSERVER_ABI | 30 | set(MIR_VERSION_MINOR 13) # This should change at least with every MIRSERVER_ABI |
9 | 31 | set(MIR_VERSION_PATCH 2) | 31 | set(MIR_VERSION_PATCH 3) |
10 | 32 | 32 | ||
11 | 33 | add_definitions(-DMIR_VERSION_MAJOR=${MIR_VERSION_MAJOR}) | 33 | add_definitions(-DMIR_VERSION_MAJOR=${MIR_VERSION_MAJOR}) |
12 | 34 | add_definitions(-DMIR_VERSION_MINOR=${MIR_VERSION_MINOR}) | 34 | add_definitions(-DMIR_VERSION_MINOR=${MIR_VERSION_MINOR}) |
13 | 35 | 35 | ||
14 | === modified file 'debian/changelog' | |||
15 | --- debian/changelog 2015-06-05 17:51:41 +0000 | |||
16 | +++ debian/changelog 2015-06-17 19:19:38 +0000 | |||
17 | @@ -1,3 +1,12 @@ | |||
18 | 1 | mir (0.13.3) UNRELEASED; urgency=medium | ||
19 | 2 | |||
20 | 3 | * New upstream release 0.13.3 (https://launchpad.net/mir/+milestone/0.13.3) | ||
21 | 4 | - Bug fixes: | ||
22 | 5 | . mir-client-platform-mesa-dev package dep is incorrect (LP: #1465642) | ||
23 | 6 | . Avoid allocating mir protobuf message objects on stack (LP: #1465883) | ||
24 | 7 | |||
25 | 8 | -- Alberto Aguirre <alberto.aguirre@canonical.com> Wed, 17 Jun 2015 14:11:53 -0500 | ||
26 | 9 | |||
27 | 1 | mir (0.13.2+15.10.20150605-0ubuntu1) wily; urgency=medium | 10 | mir (0.13.2+15.10.20150605-0ubuntu1) wily; urgency=medium |
28 | 2 | 11 | ||
29 | 3 | [ Alberto Aguirre ] | 12 | [ Alberto Aguirre ] |
30 | 4 | 13 | ||
31 | === modified file 'debian/control' | |||
32 | --- debian/control 2015-06-05 17:48:17 +0000 | |||
33 | +++ debian/control 2015-06-17 19:19:38 +0000 | |||
34 | @@ -317,7 +317,7 @@ | |||
35 | 317 | Architecture: i386 amd64 armhf arm64 powerpc ppc64el | 317 | Architecture: i386 amd64 armhf arm64 powerpc ppc64el |
36 | 318 | Multi-Arch: same | 318 | Multi-Arch: same |
37 | 319 | Pre-Depends: ${misc:Pre-Depends} | 319 | Pre-Depends: ${misc:Pre-Depends} |
39 | 320 | Depends: libmircommon-dev, | 320 | Depends: libmirclient-dev, |
40 | 321 | ${misc:Depends}, | 321 | ${misc:Depends}, |
41 | 322 | Description: Display server for Ubuntu - client platform library for Mesa development files | 322 | Description: Display server for Ubuntu - client platform library for Mesa development files |
42 | 323 | Mir is a display server running on linux systems, with a focus on efficiency, | 323 | Mir is a display server running on linux systems, with a focus on efficiency, |
43 | 324 | 324 | ||
44 | === modified file 'src/client/buffer_stream.cpp' | |||
45 | --- src/client/buffer_stream.cpp 2015-04-23 14:09:57 +0000 | |||
46 | +++ src/client/buffer_stream.cpp 2015-06-17 19:19:38 +0000 | |||
47 | @@ -19,6 +19,7 @@ | |||
48 | 19 | #define MIR_LOG_COMPONENT "MirBufferStream" | 19 | #define MIR_LOG_COMPONENT "MirBufferStream" |
49 | 20 | 20 | ||
50 | 21 | #include "buffer_stream.h" | 21 | #include "buffer_stream.h" |
51 | 22 | #include "make_protobuf_object.h" | ||
52 | 22 | 23 | ||
53 | 23 | #include "mir/frontend/client_constants.h" | 24 | #include "mir/frontend/client_constants.h" |
54 | 24 | 25 | ||
55 | @@ -96,11 +97,11 @@ | |||
56 | 96 | : display_server(server), | 97 | : display_server(server), |
57 | 97 | mode(mode), | 98 | mode(mode), |
58 | 98 | client_platform(client_platform), | 99 | client_platform(client_platform), |
60 | 99 | protobuf_bs(protobuf_bs), | 100 | protobuf_bs{mcl::make_protobuf_object<mir::protobuf::BufferStream>(protobuf_bs)}, |
61 | 100 | buffer_depository{client_platform->create_buffer_factory(), mir::frontend::client_buffer_cache_size}, | 101 | buffer_depository{client_platform->create_buffer_factory(), mir::frontend::client_buffer_cache_size}, |
62 | 101 | swap_interval_(1), | 102 | swap_interval_(1), |
65 | 102 | perf_report(perf_report) | 103 | perf_report(perf_report), |
66 | 103 | 104 | protobuf_void{mcl::make_protobuf_object<mir::protobuf::Void>()} | |
67 | 104 | { | 105 | { |
68 | 105 | created(nullptr, nullptr); | 106 | created(nullptr, nullptr); |
69 | 106 | perf_report->name_surface(surface_name.c_str()); | 107 | perf_report->name_surface(surface_name.c_str()); |
70 | @@ -115,21 +116,23 @@ | |||
71 | 115 | : display_server(server), | 116 | : display_server(server), |
72 | 116 | mode(BufferStreamMode::Producer), | 117 | mode(BufferStreamMode::Producer), |
73 | 117 | client_platform(client_platform), | 118 | client_platform(client_platform), |
74 | 119 | protobuf_bs{mcl::make_protobuf_object<mir::protobuf::BufferStream>()}, | ||
75 | 118 | buffer_depository{client_platform->create_buffer_factory(), mir::frontend::client_buffer_cache_size}, | 120 | buffer_depository{client_platform->create_buffer_factory(), mir::frontend::client_buffer_cache_size}, |
76 | 119 | swap_interval_(1), | 121 | swap_interval_(1), |
78 | 120 | perf_report(perf_report) | 122 | perf_report(perf_report), |
79 | 123 | protobuf_void{mcl::make_protobuf_object<mir::protobuf::Void>()} | ||
80 | 121 | { | 124 | { |
81 | 122 | perf_report->name_surface(std::to_string(reinterpret_cast<long int>(this)).c_str()); | 125 | perf_report->name_surface(std::to_string(reinterpret_cast<long int>(this)).c_str()); |
82 | 123 | 126 | ||
83 | 124 | create_wait_handle.expect_result(); | 127 | create_wait_handle.expect_result(); |
84 | 125 | try | 128 | try |
85 | 126 | { | 129 | { |
87 | 127 | server.create_buffer_stream(0, ¶meters, &protobuf_bs, gp::NewCallback(this, &mcl::BufferStream::created, callback, | 130 | server.create_buffer_stream(0, ¶meters, protobuf_bs.get(), gp::NewCallback(this, &mcl::BufferStream::created, callback, |
88 | 128 | context)); | 131 | context)); |
89 | 129 | } | 132 | } |
90 | 130 | catch (std::exception const& ex) | 133 | catch (std::exception const& ex) |
91 | 131 | { | 134 | { |
93 | 132 | protobuf_bs.set_error(std::string{"Error invoking create buffer stream: "} + | 135 | protobuf_bs->set_error(std::string{"Error invoking create buffer stream: "} + |
94 | 133 | boost::diagnostic_information(ex)); | 136 | boost::diagnostic_information(ex)); |
95 | 134 | } | 137 | } |
96 | 135 | 138 | ||
97 | @@ -137,12 +140,12 @@ | |||
98 | 137 | 140 | ||
99 | 138 | void mcl::BufferStream::created(mir_buffer_stream_callback callback, void *context) | 141 | void mcl::BufferStream::created(mir_buffer_stream_callback callback, void *context) |
100 | 139 | { | 142 | { |
104 | 140 | if (!protobuf_bs.has_id() || protobuf_bs.has_error()) | 143 | if (!protobuf_bs->has_id() || protobuf_bs->has_error()) |
105 | 141 | BOOST_THROW_EXCEPTION(std::runtime_error("Can not create buffer stream: " + std::string(protobuf_bs.error()))); | 144 | BOOST_THROW_EXCEPTION(std::runtime_error("Can not create buffer stream: " + std::string(protobuf_bs->error()))); |
106 | 142 | if (!protobuf_bs.has_buffer()) | 145 | if (!protobuf_bs->has_buffer()) |
107 | 143 | BOOST_THROW_EXCEPTION(std::runtime_error("Buffer stream did not come with a buffer")); | 146 | BOOST_THROW_EXCEPTION(std::runtime_error("Buffer stream did not come with a buffer")); |
108 | 144 | 147 | ||
110 | 145 | process_buffer(protobuf_bs.buffer()); | 148 | process_buffer(protobuf_bs->buffer()); |
111 | 146 | egl_native_window_ = client_platform->create_egl_native_window(this); | 149 | egl_native_window_ = client_platform->create_egl_native_window(this); |
112 | 147 | 150 | ||
113 | 148 | if (callback) | 151 | if (callback) |
114 | @@ -173,7 +176,7 @@ | |||
115 | 173 | 176 | ||
116 | 174 | try | 177 | try |
117 | 175 | { | 178 | { |
119 | 176 | auto pixel_format = static_cast<MirPixelFormat>(protobuf_bs.pixel_format()); | 179 | auto pixel_format = static_cast<MirPixelFormat>(protobuf_bs->pixel_format()); |
120 | 177 | buffer_depository.deposit_package(buffer_package, | 180 | buffer_depository.deposit_package(buffer_package, |
121 | 178 | buffer.buffer_id(), | 181 | buffer.buffer_id(), |
122 | 179 | cached_buffer_size, pixel_format); | 182 | cached_buffer_size, pixel_format); |
123 | @@ -192,40 +195,37 @@ | |||
124 | 192 | 195 | ||
125 | 193 | secured_region.reset(); | 196 | secured_region.reset(); |
126 | 194 | 197 | ||
132 | 195 | mir::protobuf::BufferStreamId buffer_stream_id; | 198 | // TODO: We can fix the strange "ID casting" used below in the second phase |
133 | 196 | buffer_stream_id.set_value(protobuf_bs.id().value()); | 199 | // of buffer stream which generalizes and clarifies the server side logic. |
129 | 197 | |||
130 | 198 | // TODO: We can fix the strange "ID casting" used below in the second phase | ||
131 | 199 | // of buffer stream which generalizes and clarifies the server side logic. | ||
134 | 200 | if (mode == mcl::BufferStreamMode::Producer) | 200 | if (mode == mcl::BufferStreamMode::Producer) |
135 | 201 | { | 201 | { |
139 | 202 | mp::BufferRequest request; | 202 | auto request = mcl::make_protobuf_object<mp::BufferRequest>(); |
140 | 203 | request.mutable_id()->set_value(protobuf_bs.id().value()); | 203 | request->mutable_id()->set_value(protobuf_bs->id().value()); |
141 | 204 | request.mutable_buffer()->set_buffer_id(protobuf_bs.buffer().buffer_id()); | 204 | request->mutable_buffer()->set_buffer_id(protobuf_bs->buffer().buffer_id()); |
142 | 205 | 205 | ||
143 | 206 | lock.unlock(); | 206 | lock.unlock(); |
144 | 207 | next_buffer_wait_handle.expect_result(); | 207 | next_buffer_wait_handle.expect_result(); |
145 | 208 | 208 | ||
146 | 209 | display_server.exchange_buffer( | 209 | display_server.exchange_buffer( |
147 | 210 | nullptr, | 210 | nullptr, |
150 | 211 | &request, | 211 | request.get(), |
151 | 212 | protobuf_bs.mutable_buffer(), | 212 | protobuf_bs->mutable_buffer(), |
152 | 213 | google::protobuf::NewCallback( | 213 | google::protobuf::NewCallback( |
153 | 214 | this, &mcl::BufferStream::next_buffer_received, | 214 | this, &mcl::BufferStream::next_buffer_received, |
154 | 215 | done)); | 215 | done)); |
155 | 216 | } | 216 | } |
156 | 217 | else | 217 | else |
157 | 218 | { | 218 | { |
160 | 219 | mp::ScreencastId screencast_id; | 219 | auto screencast_id = mcl::make_protobuf_object<mp::ScreencastId>(); |
161 | 220 | screencast_id.set_value(protobuf_bs.id().value()); | 220 | screencast_id->set_value(protobuf_bs->id().value()); |
162 | 221 | 221 | ||
163 | 222 | lock.unlock(); | 222 | lock.unlock(); |
164 | 223 | next_buffer_wait_handle.expect_result(); | 223 | next_buffer_wait_handle.expect_result(); |
165 | 224 | 224 | ||
166 | 225 | display_server.screencast_buffer( | 225 | display_server.screencast_buffer( |
167 | 226 | nullptr, | 226 | nullptr, |
170 | 227 | &screencast_id, | 227 | screencast_id.get(), |
171 | 228 | protobuf_bs.mutable_buffer(), | 228 | protobuf_bs->mutable_buffer(), |
172 | 229 | google::protobuf::NewCallback( | 229 | google::protobuf::NewCallback( |
173 | 230 | this, &mcl::BufferStream::next_buffer_received, | 230 | this, &mcl::BufferStream::next_buffer_received, |
174 | 231 | done)); | 231 | done)); |
175 | @@ -263,7 +263,7 @@ | |||
176 | 263 | void mcl::BufferStream::next_buffer_received( | 263 | void mcl::BufferStream::next_buffer_received( |
177 | 264 | std::function<void()> done) | 264 | std::function<void()> done) |
178 | 265 | { | 265 | { |
180 | 266 | process_buffer(protobuf_bs.buffer()); | 266 | process_buffer(protobuf_bs->buffer()); |
181 | 267 | 267 | ||
182 | 268 | done(); | 268 | done(); |
183 | 269 | 269 | ||
184 | @@ -278,8 +278,8 @@ | |||
185 | 278 | "", | 278 | "", |
186 | 279 | cached_buffer_size.width.as_int(), | 279 | cached_buffer_size.width.as_int(), |
187 | 280 | cached_buffer_size.height.as_int(), | 280 | cached_buffer_size.height.as_int(), |
190 | 281 | static_cast<MirPixelFormat>(protobuf_bs.pixel_format()), | 281 | static_cast<MirPixelFormat>(protobuf_bs->pixel_format()), |
191 | 282 | static_cast<MirBufferUsage>(protobuf_bs.buffer_usage()), | 282 | static_cast<MirBufferUsage>(protobuf_bs->buffer_usage()), |
192 | 283 | mir_display_output_id_invalid}; | 283 | mir_display_output_id_invalid}; |
193 | 284 | } | 284 | } |
194 | 285 | 285 | ||
195 | @@ -311,20 +311,21 @@ | |||
196 | 311 | BOOST_THROW_EXCEPTION(std::logic_error("Attempt to set swap interval on screencast is invalid")); | 311 | BOOST_THROW_EXCEPTION(std::logic_error("Attempt to set swap interval on screencast is invalid")); |
197 | 312 | } | 312 | } |
198 | 313 | 313 | ||
203 | 314 | mp::SurfaceSetting setting, result; | 314 | auto setting = mcl::make_protobuf_object<mp::SurfaceSetting>(); |
204 | 315 | setting.mutable_surfaceid()->set_value(protobuf_bs.id().value()); | 315 | auto result = mcl::make_protobuf_object<mp::SurfaceSetting>(); |
205 | 316 | setting.set_attrib(attrib); | 316 | setting->mutable_surfaceid()->set_value(protobuf_bs->id().value()); |
206 | 317 | setting.set_ivalue(value); | 317 | setting->set_attrib(attrib); |
207 | 318 | setting->set_ivalue(value); | ||
208 | 318 | lock.unlock(); | 319 | lock.unlock(); |
209 | 319 | 320 | ||
210 | 320 | configure_wait_handle.expect_result(); | 321 | configure_wait_handle.expect_result(); |
212 | 321 | display_server.configure_surface(0, &setting, &result, | 322 | display_server.configure_surface(0, setting.get(), result.get(), |
213 | 322 | google::protobuf::NewCallback(this, &mcl::BufferStream::on_configured)); | 323 | google::protobuf::NewCallback(this, &mcl::BufferStream::on_configured)); |
214 | 323 | 324 | ||
215 | 324 | configure_wait_handle.wait_for_all(); | 325 | configure_wait_handle.wait_for_all(); |
216 | 325 | 326 | ||
217 | 326 | lock.lock(); | 327 | lock.lock(); |
219 | 327 | swap_interval_ = result.ivalue(); | 328 | swap_interval_ = result->ivalue(); |
220 | 328 | } | 329 | } |
221 | 329 | 330 | ||
222 | 330 | uint32_t mcl::BufferStream::get_current_buffer_id() | 331 | uint32_t mcl::BufferStream::get_current_buffer_id() |
223 | @@ -364,14 +365,14 @@ | |||
224 | 364 | MirWaitHandle* mcl::BufferStream::release( | 365 | MirWaitHandle* mcl::BufferStream::release( |
225 | 365 | mir_buffer_stream_callback callback, void* context) | 366 | mir_buffer_stream_callback callback, void* context) |
226 | 366 | { | 367 | { |
229 | 367 | mir::protobuf::BufferStreamId buffer_stream_id; | 368 | auto buffer_stream_id = mcl::make_protobuf_object<mir::protobuf::BufferStreamId>(); |
230 | 368 | buffer_stream_id.set_value(protobuf_bs.id().value()); | 369 | buffer_stream_id->set_value(protobuf_bs->id().value()); |
231 | 369 | 370 | ||
232 | 370 | release_wait_handle.expect_result(); | 371 | release_wait_handle.expect_result(); |
233 | 371 | display_server.release_buffer_stream( | 372 | display_server.release_buffer_stream( |
234 | 372 | nullptr, | 373 | nullptr, |
237 | 373 | &buffer_stream_id, | 374 | buffer_stream_id.get(), |
238 | 374 | &protobuf_void, | 375 | protobuf_void.get(), |
239 | 375 | google::protobuf::NewCallback( | 376 | google::protobuf::NewCallback( |
240 | 376 | this, &mcl::BufferStream::released, callback, context)); | 377 | this, &mcl::BufferStream::released, callback, context)); |
241 | 377 | 378 | ||
242 | @@ -390,13 +391,13 @@ | |||
243 | 390 | { | 391 | { |
244 | 391 | std::unique_lock<decltype(mutex)> lock(mutex); | 392 | std::unique_lock<decltype(mutex)> lock(mutex); |
245 | 392 | 393 | ||
247 | 393 | return mf::BufferStreamId(protobuf_bs.id().value()); | 394 | return mf::BufferStreamId(protobuf_bs->id().value()); |
248 | 394 | } | 395 | } |
249 | 395 | 396 | ||
250 | 396 | bool mcl::BufferStream::valid() const | 397 | bool mcl::BufferStream::valid() const |
251 | 397 | { | 398 | { |
252 | 398 | std::unique_lock<decltype(mutex)> lock(mutex); | 399 | std::unique_lock<decltype(mutex)> lock(mutex); |
254 | 399 | return protobuf_bs.has_id() && !protobuf_bs.has_error(); | 400 | return protobuf_bs->has_id() && !protobuf_bs->has_error(); |
255 | 400 | } | 401 | } |
256 | 401 | 402 | ||
257 | 402 | void mcl::BufferStream::set_buffer_cache_size(unsigned int cache_size) | 403 | void mcl::BufferStream::set_buffer_cache_size(unsigned int cache_size) |
258 | 403 | 404 | ||
259 | === modified file 'src/client/buffer_stream.h' | |||
260 | --- src/client/buffer_stream.h 2015-04-23 14:09:57 +0000 | |||
261 | +++ src/client/buffer_stream.h 2015-06-17 19:19:38 +0000 | |||
262 | @@ -60,7 +60,7 @@ | |||
263 | 60 | BufferStream(mir::protobuf::DisplayServer& server, | 60 | BufferStream(mir::protobuf::DisplayServer& server, |
264 | 61 | BufferStreamMode mode, | 61 | BufferStreamMode mode, |
265 | 62 | std::shared_ptr<ClientPlatform> const& native_window_factory, | 62 | std::shared_ptr<ClientPlatform> const& native_window_factory, |
267 | 63 | protobuf::BufferStream const& protobuf_bs, | 63 | mir::protobuf::BufferStream const& protobuf_bs, |
268 | 64 | std::shared_ptr<PerfReport> const& perf_report, | 64 | std::shared_ptr<PerfReport> const& perf_report, |
269 | 65 | std::string const& surface_name); | 65 | std::string const& surface_name); |
270 | 66 | // For surfaceless buffer streams | 66 | // For surfaceless buffer streams |
271 | @@ -121,7 +121,7 @@ | |||
272 | 121 | BufferStreamMode const mode; | 121 | BufferStreamMode const mode; |
273 | 122 | std::shared_ptr<ClientPlatform> const client_platform; | 122 | std::shared_ptr<ClientPlatform> const client_platform; |
274 | 123 | 123 | ||
276 | 124 | mir::protobuf::BufferStream protobuf_bs; | 124 | std::unique_ptr<mir::protobuf::BufferStream> protobuf_bs; |
277 | 125 | mir::client::ClientBufferDepository buffer_depository; | 125 | mir::client::ClientBufferDepository buffer_depository; |
278 | 126 | 126 | ||
279 | 127 | int swap_interval_; | 127 | int swap_interval_; |
280 | @@ -134,7 +134,7 @@ | |||
281 | 134 | MirWaitHandle release_wait_handle; | 134 | MirWaitHandle release_wait_handle; |
282 | 135 | MirWaitHandle next_buffer_wait_handle; | 135 | MirWaitHandle next_buffer_wait_handle; |
283 | 136 | MirWaitHandle configure_wait_handle; | 136 | MirWaitHandle configure_wait_handle; |
285 | 137 | mir::protobuf::Void protobuf_void; | 137 | std::unique_ptr<mir::protobuf::Void> protobuf_void; |
286 | 138 | 138 | ||
287 | 139 | std::shared_ptr<MemoryRegion> secured_region; | 139 | std::shared_ptr<MemoryRegion> secured_region; |
288 | 140 | 140 | ||
289 | 141 | 141 | ||
290 | === added file 'src/client/make_protobuf_object.h' | |||
291 | --- src/client/make_protobuf_object.h 1970-01-01 00:00:00 +0000 | |||
292 | +++ src/client/make_protobuf_object.h 2015-06-17 19:19:38 +0000 | |||
293 | @@ -0,0 +1,42 @@ | |||
294 | 1 | /* | ||
295 | 2 | * Copyright © 2015 Canonical Ltd. | ||
296 | 3 | * | ||
297 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
298 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
299 | 6 | * as published by the Free Software Foundation. | ||
300 | 7 | * | ||
301 | 8 | * This program is distributed in the hope that it will be useful, | ||
302 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
303 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
304 | 11 | * GNU Lesser General Public License for more details. | ||
305 | 12 | * | ||
306 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
307 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
308 | 15 | * | ||
309 | 16 | * Authored by: Alberto Aguirre <alberto.aguirre@canonical.com> | ||
310 | 17 | */ | ||
311 | 18 | |||
312 | 19 | #ifndef MIR_CLIENT_MAKE_PROTOBUF_OBJECT_ | ||
313 | 20 | #define MIR_CLIENT_MAKE_PROTOBUF_OBJECT_ | ||
314 | 21 | |||
315 | 22 | namespace mir | ||
316 | 23 | { | ||
317 | 24 | namespace client | ||
318 | 25 | { | ||
319 | 26 | template <typename ProtobufType> | ||
320 | 27 | auto make_protobuf_object() | ||
321 | 28 | { | ||
322 | 29 | return std::unique_ptr<ProtobufType>{ProtobufType::default_instance().New()}; | ||
323 | 30 | } | ||
324 | 31 | |||
325 | 32 | template <typename ProtobufType> | ||
326 | 33 | auto make_protobuf_object(ProtobufType const& from) | ||
327 | 34 | { | ||
328 | 35 | auto object = make_protobuf_object<ProtobufType>(); | ||
329 | 36 | object->CopyFrom(from); | ||
330 | 37 | return object; | ||
331 | 38 | } | ||
332 | 39 | } | ||
333 | 40 | } | ||
334 | 41 | |||
335 | 42 | #endif | ||
336 | 0 | 43 | ||
337 | === modified file 'src/client/mir_buffer_stream_api.cpp' | |||
338 | --- src/client/mir_buffer_stream_api.cpp 2015-03-31 02:35:42 +0000 | |||
339 | +++ src/client/mir_buffer_stream_api.cpp 2015-06-17 19:19:38 +0000 | |||
340 | @@ -23,6 +23,7 @@ | |||
341 | 23 | #include "mir_connection.h" | 23 | #include "mir_connection.h" |
342 | 24 | #include "buffer_stream.h" | 24 | #include "buffer_stream.h" |
343 | 25 | #include "client_buffer_stream_factory.h" | 25 | #include "client_buffer_stream_factory.h" |
344 | 26 | #include "make_protobuf_object.h" | ||
345 | 26 | 27 | ||
346 | 27 | #include "mir/client_buffer.h" | 28 | #include "mir/client_buffer.h" |
347 | 28 | 29 | ||
348 | @@ -68,13 +69,13 @@ | |||
349 | 68 | void *context) | 69 | void *context) |
350 | 69 | try | 70 | try |
351 | 70 | { | 71 | { |
357 | 71 | mp::BufferStreamParameters params; | 72 | auto params = mcl::make_protobuf_object<mp::BufferStreamParameters>(); |
358 | 72 | params.set_width(width); | 73 | params->set_width(width); |
359 | 73 | params.set_height(height); | 74 | params->set_height(height); |
360 | 74 | params.set_pixel_format(format); | 75 | params->set_pixel_format(format); |
361 | 75 | params.set_buffer_usage(buffer_usage); | 76 | params->set_buffer_usage(buffer_usage); |
362 | 76 | 77 | ||
364 | 77 | return connection->get_client_buffer_stream_factory()->make_producer_stream(connection->display_server(), params, callback, context) | 78 | return connection->get_client_buffer_stream_factory()->make_producer_stream(connection->display_server(), *params, callback, context) |
365 | 78 | ->get_create_wait_handle(); | 79 | ->get_create_wait_handle(); |
366 | 79 | } | 80 | } |
367 | 80 | catch (std::exception const& ex) | 81 | catch (std::exception const& ex) |
368 | 81 | 82 | ||
369 | === modified file 'src/client/mir_connection.cpp' | |||
370 | --- src/client/mir_connection.cpp 2015-04-01 19:39:19 +0000 | |||
371 | +++ src/client/mir_connection.cpp 2015-06-17 19:19:38 +0000 | |||
372 | @@ -20,6 +20,7 @@ | |||
373 | 20 | #include "mir_surface.h" | 20 | #include "mir_surface.h" |
374 | 21 | #include "mir_prompt_session.h" | 21 | #include "mir_prompt_session.h" |
375 | 22 | #include "default_client_buffer_stream_factory.h" | 22 | #include "default_client_buffer_stream_factory.h" |
376 | 23 | #include "make_protobuf_object.h" | ||
377 | 23 | #include "mir_toolkit/mir_platform_message.h" | 24 | #include "mir_toolkit/mir_platform_message.h" |
378 | 24 | #include "mir/client_platform.h" | 25 | #include "mir/client_platform.h" |
379 | 25 | #include "mir/client_platform_factory.h" | 26 | #include "mir/client_platform_factory.h" |
380 | @@ -106,7 +107,13 @@ | |||
381 | 106 | server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL), | 107 | server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL), |
382 | 107 | debug(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL), | 108 | debug(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL), |
383 | 108 | logger(conf.the_logger()), | 109 | logger(conf.the_logger()), |
384 | 110 | void_response{mcl::make_protobuf_object<mir::protobuf::Void>()}, | ||
385 | 111 | connect_result{mcl::make_protobuf_object<mir::protobuf::Connection>()}, | ||
386 | 109 | connect_done{false}, | 112 | connect_done{false}, |
387 | 113 | ignored{mcl::make_protobuf_object<mir::protobuf::Void>()}, | ||
388 | 114 | connect_parameters{mcl::make_protobuf_object<mir::protobuf::ConnectParameters>()}, | ||
389 | 115 | platform_operation_reply{mcl::make_protobuf_object<mir::protobuf::PlatformOperationMessage>()}, | ||
390 | 116 | display_configuration_response{mcl::make_protobuf_object<mir::protobuf::DisplayConfiguration>()}, | ||
391 | 110 | client_platform_factory(conf.the_client_platform_factory()), | 117 | client_platform_factory(conf.the_client_platform_factory()), |
392 | 111 | input_platform(conf.the_input_platform()), | 118 | input_platform(conf.the_input_platform()), |
393 | 112 | display_configuration(conf.the_display_configuration()), | 119 | display_configuration(conf.the_display_configuration()), |
394 | @@ -115,7 +122,7 @@ | |||
395 | 115 | event_handler_register(conf.the_event_handler_register()), | 122 | event_handler_register(conf.the_event_handler_register()), |
396 | 116 | eventloop{new md::SimpleDispatchThread{std::dynamic_pointer_cast<md::Dispatchable>(channel)}} | 123 | eventloop{new md::SimpleDispatchThread{std::dynamic_pointer_cast<md::Dispatchable>(channel)}} |
397 | 117 | { | 124 | { |
399 | 118 | connect_result.set_error("connect not called"); | 125 | connect_result->set_error("connect not called"); |
400 | 119 | { | 126 | { |
401 | 120 | std::lock_guard<std::mutex> lock(connection_guard); | 127 | std::lock_guard<std::mutex> lock(connection_guard); |
402 | 121 | next_valid = valid_connections; | 128 | next_valid = valid_connections; |
403 | @@ -130,9 +137,9 @@ | |||
404 | 130 | connect_wait_handle.wait_for_pending(std::chrono::milliseconds(500)); | 137 | connect_wait_handle.wait_for_pending(std::chrono::milliseconds(500)); |
405 | 131 | 138 | ||
406 | 132 | std::lock_guard<decltype(mutex)> lock(mutex); | 139 | std::lock_guard<decltype(mutex)> lock(mutex); |
408 | 133 | if (connect_result.has_platform()) | 140 | if (connect_result && connect_result->has_platform()) |
409 | 134 | { | 141 | { |
411 | 135 | auto const& platform = connect_result.platform(); | 142 | auto const& platform = connect_result->platform(); |
412 | 136 | for (int i = 0, end = platform.fd_size(); i != end; ++i) | 143 | for (int i = 0, end = platform.fd_size(); i != end; ++i) |
413 | 137 | close(platform.fd(i)); | 144 | close(platform.fd(i)); |
414 | 138 | } | 145 | } |
415 | @@ -153,9 +160,9 @@ | |||
416 | 153 | { | 160 | { |
417 | 154 | std::lock_guard<decltype(mutex)> lock(mutex); | 161 | std::lock_guard<decltype(mutex)> lock(mutex); |
418 | 155 | 162 | ||
420 | 156 | if (connect_result.has_error()) | 163 | if (connect_result && connect_result->has_error()) |
421 | 157 | { | 164 | { |
423 | 158 | return connect_result.error().c_str(); | 165 | return connect_result->error().c_str(); |
424 | 159 | } | 166 | } |
425 | 160 | 167 | ||
426 | 161 | return error_message.c_str(); | 168 | return error_message.c_str(); |
427 | @@ -202,8 +209,8 @@ | |||
428 | 202 | 209 | ||
429 | 203 | SurfaceRelease surf_release{surface, new_wait_handle, callback, context}; | 210 | SurfaceRelease surf_release{surface, new_wait_handle, callback, context}; |
430 | 204 | 211 | ||
433 | 205 | mir::protobuf::SurfaceId message; | 212 | auto message = mcl::make_protobuf_object<mir::protobuf::SurfaceId>(); |
434 | 206 | message.set_value(surface->id()); | 213 | message->set_value(surface->id()); |
435 | 207 | 214 | ||
436 | 208 | { | 215 | { |
437 | 209 | std::lock_guard<decltype(release_wait_handle_guard)> rel_lock(release_wait_handle_guard); | 216 | std::lock_guard<decltype(release_wait_handle_guard)> rel_lock(release_wait_handle_guard); |
438 | @@ -211,7 +218,7 @@ | |||
439 | 211 | } | 218 | } |
440 | 212 | 219 | ||
441 | 213 | new_wait_handle->expect_result(); | 220 | new_wait_handle->expect_result(); |
443 | 214 | server.release_surface(0, &message, &void_response, | 221 | server.release_surface(0, message.get(), void_response.get(), |
444 | 215 | gp::NewCallback(this, &MirConnection::released, surf_release)); | 222 | gp::NewCallback(this, &MirConnection::released, surf_release)); |
445 | 216 | 223 | ||
446 | 217 | 224 | ||
447 | @@ -230,9 +237,9 @@ | |||
448 | 230 | { | 237 | { |
449 | 231 | std::lock_guard<decltype(mutex)> lock(mutex); | 238 | std::lock_guard<decltype(mutex)> lock(mutex); |
450 | 232 | 239 | ||
452 | 233 | if (!connect_result.has_platform() || !connect_result.has_display_configuration()) | 240 | if (!connect_result->has_platform() || !connect_result->has_display_configuration()) |
453 | 234 | { | 241 | { |
455 | 235 | if (!connect_result.has_error()) | 242 | if (!connect_result->has_error()) |
456 | 236 | { | 243 | { |
457 | 237 | // We're handling an error scenario that means we're not sync'd | 244 | // We're handling an error scenario that means we're not sync'd |
458 | 238 | // with the client code - a callback isn't safe (or needed) | 245 | // with the client code - a callback isn't safe (or needed) |
459 | @@ -263,12 +270,12 @@ | |||
460 | 263 | 270 | ||
461 | 264 | platform = client_platform_factory->create_client_platform(this); | 271 | platform = client_platform_factory->create_client_platform(this); |
462 | 265 | native_display = platform->create_egl_native_display(); | 272 | native_display = platform->create_egl_native_display(); |
464 | 266 | display_configuration->set_configuration(connect_result.display_configuration()); | 273 | display_configuration->set_configuration(connect_result->display_configuration()); |
465 | 267 | lifecycle_control->set_lifecycle_event_handler(default_lifecycle_event_handler); | 274 | lifecycle_control->set_lifecycle_event_handler(default_lifecycle_event_handler); |
466 | 268 | } | 275 | } |
467 | 269 | catch (std::exception const& e) | 276 | catch (std::exception const& e) |
468 | 270 | { | 277 | { |
470 | 271 | connect_result.set_error(std::string{"Failed to process connect response: "} + | 278 | connect_result->set_error(std::string{"Failed to process connect response: "} + |
471 | 272 | boost::diagnostic_information(e)); | 279 | boost::diagnostic_information(e)); |
472 | 273 | } | 280 | } |
473 | 274 | 281 | ||
474 | @@ -284,14 +291,14 @@ | |||
475 | 284 | { | 291 | { |
476 | 285 | std::lock_guard<decltype(mutex)> lock(mutex); | 292 | std::lock_guard<decltype(mutex)> lock(mutex); |
477 | 286 | 293 | ||
479 | 287 | connect_parameters.set_application_name(app_name); | 294 | connect_parameters->set_application_name(app_name); |
480 | 288 | connect_wait_handle.expect_result(); | 295 | connect_wait_handle.expect_result(); |
481 | 289 | } | 296 | } |
482 | 290 | 297 | ||
483 | 291 | server.connect( | 298 | server.connect( |
484 | 292 | 0, | 299 | 0, |
487 | 293 | &connect_parameters, | 300 | connect_parameters.get(), |
488 | 294 | &connect_result, | 301 | connect_result.get(), |
489 | 295 | google::protobuf::NewCallback( | 302 | google::protobuf::NewCallback( |
490 | 296 | this, &MirConnection::connected, callback, context)); | 303 | this, &MirConnection::connected, callback, context)); |
491 | 297 | return &connect_wait_handle; | 304 | return &connect_wait_handle; |
492 | @@ -319,7 +326,7 @@ | |||
493 | 319 | disconnecting = true; | 326 | disconnecting = true; |
494 | 320 | } | 327 | } |
495 | 321 | disconnect_wait_handle.expect_result(); | 328 | disconnect_wait_handle.expect_result(); |
497 | 322 | server.disconnect(0, &ignored, &ignored, | 329 | server.disconnect(0, ignored.get(), ignored.get(), |
498 | 323 | google::protobuf::NewCallback(this, &MirConnection::done_disconnect)); | 330 | google::protobuf::NewCallback(this, &MirConnection::done_disconnect)); |
499 | 324 | 331 | ||
500 | 325 | return &disconnect_wait_handle; | 332 | return &disconnect_wait_handle; |
501 | @@ -328,19 +335,19 @@ | |||
502 | 328 | void MirConnection::done_platform_operation( | 335 | void MirConnection::done_platform_operation( |
503 | 329 | mir_platform_operation_callback callback, void* context) | 336 | mir_platform_operation_callback callback, void* context) |
504 | 330 | { | 337 | { |
506 | 331 | auto reply = mir_platform_message_create(platform_operation_reply.opcode()); | 338 | auto reply = mir_platform_message_create(platform_operation_reply->opcode()); |
507 | 332 | 339 | ||
509 | 333 | set_error_message(platform_operation_reply.error()); | 340 | set_error_message(platform_operation_reply->error()); |
510 | 334 | 341 | ||
511 | 335 | mir_platform_message_set_data( | 342 | mir_platform_message_set_data( |
512 | 336 | reply, | 343 | reply, |
515 | 337 | platform_operation_reply.data().data(), | 344 | platform_operation_reply->data().data(), |
516 | 338 | platform_operation_reply.data().size()); | 345 | platform_operation_reply->data().size()); |
517 | 339 | 346 | ||
518 | 340 | mir_platform_message_set_fds( | 347 | mir_platform_message_set_fds( |
519 | 341 | reply, | 348 | reply, |
522 | 342 | platform_operation_reply.fd().data(), | 349 | platform_operation_reply->fd().data(), |
523 | 343 | platform_operation_reply.fd().size()); | 350 | platform_operation_reply->fd().size()); |
524 | 344 | 351 | ||
525 | 345 | callback(this, reply, context); | 352 | callback(this, reply, context); |
526 | 346 | 353 | ||
527 | @@ -359,21 +366,21 @@ | |||
528 | 359 | return nullptr; | 366 | return nullptr; |
529 | 360 | } | 367 | } |
530 | 361 | 368 | ||
532 | 362 | mir::protobuf::PlatformOperationMessage protobuf_request; | 369 | auto protobuf_request = mcl::make_protobuf_object<mir::protobuf::PlatformOperationMessage>(); |
533 | 363 | 370 | ||
535 | 364 | protobuf_request.set_opcode(mir_platform_message_get_opcode(request)); | 371 | protobuf_request->set_opcode(mir_platform_message_get_opcode(request)); |
536 | 365 | auto const request_data = mir_platform_message_get_data(request); | 372 | auto const request_data = mir_platform_message_get_data(request); |
537 | 366 | auto const request_fds = mir_platform_message_get_fds(request); | 373 | auto const request_fds = mir_platform_message_get_fds(request); |
538 | 367 | 374 | ||
540 | 368 | protobuf_request.set_data(request_data.data, request_data.size); | 375 | protobuf_request->set_data(request_data.data, request_data.size); |
541 | 369 | for (size_t i = 0; i != request_fds.num_fds; ++i) | 376 | for (size_t i = 0; i != request_fds.num_fds; ++i) |
543 | 370 | protobuf_request.add_fd(request_fds.fds[i]); | 377 | protobuf_request->add_fd(request_fds.fds[i]); |
544 | 371 | 378 | ||
545 | 372 | platform_operation_wait_handle.expect_result(); | 379 | platform_operation_wait_handle.expect_result(); |
546 | 373 | server.platform_operation( | 380 | server.platform_operation( |
547 | 374 | 0, | 381 | 0, |
550 | 375 | &protobuf_request, | 382 | protobuf_request.get(), |
551 | 376 | &platform_operation_reply, | 383 | platform_operation_reply.get(), |
552 | 377 | google::protobuf::NewCallback(this, &MirConnection::done_platform_operation, | 384 | google::protobuf::NewCallback(this, &MirConnection::done_platform_operation, |
553 | 378 | callback, context)); | 385 | callback, context)); |
554 | 379 | 386 | ||
555 | @@ -391,7 +398,7 @@ | |||
556 | 391 | { | 398 | { |
557 | 392 | lock.unlock(); | 399 | lock.unlock(); |
558 | 393 | std::lock_guard<decltype(connection->mutex)> lock(connection->mutex); | 400 | std::lock_guard<decltype(connection->mutex)> lock(connection->mutex); |
560 | 394 | return !connection->connect_result.has_error(); | 401 | return !connection->connect_result->has_error(); |
561 | 395 | } | 402 | } |
562 | 396 | } | 403 | } |
563 | 397 | } | 404 | } |
564 | @@ -407,9 +414,9 @@ | |||
565 | 407 | { | 414 | { |
566 | 408 | // connect_result is write-once: once it's valid, we don't need to lock | 415 | // connect_result is write-once: once it's valid, we don't need to lock |
567 | 409 | // to use it. | 416 | // to use it. |
569 | 410 | if (connect_done && !connect_result.has_error() && connect_result.has_platform()) | 417 | if (connect_done && !connect_result->has_error() && connect_result->has_platform()) |
570 | 411 | { | 418 | { |
572 | 412 | auto const& platform = connect_result.platform(); | 419 | auto const& platform = connect_result->platform(); |
573 | 413 | 420 | ||
574 | 414 | platform_package.data_items = platform.data_size(); | 421 | platform_package.data_items = platform.data_size(); |
575 | 415 | for (int i = 0; i != platform.data_size(); ++i) | 422 | for (int i = 0; i != platform.data_size(); ++i) |
576 | @@ -440,15 +447,15 @@ | |||
577 | 440 | valid_formats = 0; | 447 | valid_formats = 0; |
578 | 441 | 448 | ||
579 | 442 | std::lock_guard<decltype(mutex)> lock(mutex); | 449 | std::lock_guard<decltype(mutex)> lock(mutex); |
581 | 443 | if (!connect_result.has_error()) | 450 | if (!connect_result->has_error()) |
582 | 444 | { | 451 | { |
583 | 445 | valid_formats = std::min( | 452 | valid_formats = std::min( |
585 | 446 | static_cast<unsigned int>(connect_result.surface_pixel_format_size()), | 453 | static_cast<unsigned int>(connect_result->surface_pixel_format_size()), |
586 | 447 | formats_size); | 454 | formats_size); |
587 | 448 | 455 | ||
588 | 449 | for (auto i = 0u; i < valid_formats; i++) | 456 | for (auto i = 0u; i < valid_formats; i++) |
589 | 450 | { | 457 | { |
591 | 451 | formats[i] = static_cast<MirPixelFormat>(connect_result.surface_pixel_format(i)); | 458 | formats[i] = static_cast<MirPixelFormat>(connect_result->surface_pixel_format(i)); |
592 | 452 | } | 459 | } |
593 | 453 | } | 460 | } |
594 | 454 | } | 461 | } |
595 | @@ -518,10 +525,10 @@ | |||
596 | 518 | { | 525 | { |
597 | 519 | std::lock_guard<decltype(mutex)> lock(mutex); | 526 | std::lock_guard<decltype(mutex)> lock(mutex); |
598 | 520 | 527 | ||
600 | 521 | set_error_message(display_configuration_response.error()); | 528 | set_error_message(display_configuration_response->error()); |
601 | 522 | 529 | ||
604 | 523 | if (!display_configuration_response.has_error()) | 530 | if (!display_configuration_response->has_error()) |
605 | 524 | display_configuration->set_configuration(display_configuration_response); | 531 | display_configuration->set_configuration(*display_configuration_response); |
606 | 525 | 532 | ||
607 | 526 | return configure_display_wait_handle.result_received(); | 533 | return configure_display_wait_handle.result_received(); |
608 | 527 | } | 534 | } |
609 | @@ -533,14 +540,14 @@ | |||
610 | 533 | return NULL; | 540 | return NULL; |
611 | 534 | } | 541 | } |
612 | 535 | 542 | ||
614 | 536 | mir::protobuf::DisplayConfiguration request; | 543 | auto request = mcl::make_protobuf_object<mir::protobuf::DisplayConfiguration>(); |
615 | 537 | { | 544 | { |
616 | 538 | std::lock_guard<decltype(mutex)> lock(mutex); | 545 | std::lock_guard<decltype(mutex)> lock(mutex); |
617 | 539 | 546 | ||
618 | 540 | for (auto i=0u; i < config->num_outputs; i++) | 547 | for (auto i=0u; i < config->num_outputs; i++) |
619 | 541 | { | 548 | { |
620 | 542 | auto output = config->outputs[i]; | 549 | auto output = config->outputs[i]; |
622 | 543 | auto display_request = request.add_display_output(); | 550 | auto display_request = request->add_display_output(); |
623 | 544 | display_request->set_output_id(output.output_id); | 551 | display_request->set_output_id(output.output_id); |
624 | 545 | display_request->set_used(output.used); | 552 | display_request->set_used(output.used); |
625 | 546 | display_request->set_current_mode(output.current_mode); | 553 | display_request->set_current_mode(output.current_mode); |
626 | @@ -553,7 +560,7 @@ | |||
627 | 553 | } | 560 | } |
628 | 554 | 561 | ||
629 | 555 | configure_display_wait_handle.expect_result(); | 562 | configure_display_wait_handle.expect_result(); |
631 | 556 | server.configure_display(0, &request, &display_configuration_response, | 563 | server.configure_display(0, request.get(), display_configuration_response.get(), |
632 | 557 | google::protobuf::NewCallback(this, &MirConnection::done_display_configure)); | 564 | google::protobuf::NewCallback(this, &MirConnection::done_display_configure)); |
633 | 558 | 565 | ||
634 | 559 | return &configure_display_wait_handle; | 566 | return &configure_display_wait_handle; |
635 | 560 | 567 | ||
636 | === modified file 'src/client/mir_connection.h' | |||
637 | --- src/client/mir_connection.h 2015-03-31 02:35:42 +0000 | |||
638 | +++ src/client/mir_connection.h 2015-06-17 19:19:38 +0000 | |||
639 | @@ -36,6 +36,8 @@ | |||
640 | 36 | 36 | ||
641 | 37 | #include "mir_wait_handle.h" | 37 | #include "mir_wait_handle.h" |
642 | 38 | 38 | ||
643 | 39 | #include <memory> | ||
644 | 40 | |||
645 | 39 | namespace mir | 41 | namespace mir |
646 | 40 | { | 42 | { |
647 | 41 | class SharedLibrary; | 43 | class SharedLibrary; |
648 | @@ -156,13 +158,13 @@ | |||
649 | 156 | mir::protobuf::DisplayServer::Stub server; | 158 | mir::protobuf::DisplayServer::Stub server; |
650 | 157 | mir::protobuf::Debug::Stub debug; | 159 | mir::protobuf::Debug::Stub debug; |
651 | 158 | std::shared_ptr<mir::logging::Logger> const logger; | 160 | std::shared_ptr<mir::logging::Logger> const logger; |
654 | 159 | mir::protobuf::Void void_response; | 161 | std::unique_ptr<mir::protobuf::Void> void_response; |
655 | 160 | mir::protobuf::Connection connect_result; | 162 | std::unique_ptr<mir::protobuf::Connection> connect_result; |
656 | 161 | std::atomic<bool> connect_done; | 163 | std::atomic<bool> connect_done; |
661 | 162 | mir::protobuf::Void ignored; | 164 | std::unique_ptr<mir::protobuf::Void> ignored; |
662 | 163 | mir::protobuf::ConnectParameters connect_parameters; | 165 | std::unique_ptr<mir::protobuf::ConnectParameters> connect_parameters; |
663 | 164 | mir::protobuf::PlatformOperationMessage platform_operation_reply; | 166 | std::unique_ptr<mir::protobuf::PlatformOperationMessage> platform_operation_reply; |
664 | 165 | mir::protobuf::DisplayConfiguration display_configuration_response; | 167 | std::unique_ptr<mir::protobuf::DisplayConfiguration> display_configuration_response; |
665 | 166 | std::atomic<bool> disconnecting{false}; | 168 | std::atomic<bool> disconnecting{false}; |
666 | 167 | 169 | ||
667 | 168 | std::shared_ptr<mir::client::ClientPlatformFactory> const client_platform_factory; | 170 | std::shared_ptr<mir::client::ClientPlatformFactory> const client_platform_factory; |
668 | 169 | 171 | ||
669 | === modified file 'src/client/mir_prompt_session.cpp' | |||
670 | --- src/client/mir_prompt_session.cpp 2015-03-31 02:35:42 +0000 | |||
671 | +++ src/client/mir_prompt_session.cpp 2015-06-17 19:19:38 +0000 | |||
672 | @@ -18,6 +18,7 @@ | |||
673 | 18 | 18 | ||
674 | 19 | #include "mir_prompt_session.h" | 19 | #include "mir_prompt_session.h" |
675 | 20 | #include "event_handler_register.h" | 20 | #include "event_handler_register.h" |
676 | 21 | #include "make_protobuf_object.h" | ||
677 | 21 | 22 | ||
678 | 22 | namespace mp = mir::protobuf; | 23 | namespace mp = mir::protobuf; |
679 | 23 | namespace mcl = mir::client; | 24 | namespace mcl = mir::client; |
680 | @@ -26,6 +27,10 @@ | |||
681 | 26 | mp::DisplayServer& server, | 27 | mp::DisplayServer& server, |
682 | 27 | std::shared_ptr<mcl::EventHandlerRegister> const& event_handler_register) : | 28 | std::shared_ptr<mcl::EventHandlerRegister> const& event_handler_register) : |
683 | 28 | server(server), | 29 | server(server), |
684 | 30 | parameters(mcl::make_protobuf_object<mir::protobuf::PromptSessionParameters>()), | ||
685 | 31 | add_result(mcl::make_protobuf_object<mir::protobuf::Void>()), | ||
686 | 32 | protobuf_void(mcl::make_protobuf_object<mir::protobuf::Void>()), | ||
687 | 33 | socket_fd_response(mcl::make_protobuf_object<mir::protobuf::SocketFD>()), | ||
688 | 29 | event_handler_register(event_handler_register), | 34 | event_handler_register(event_handler_register), |
689 | 30 | event_handler_register_id{event_handler_register->register_event_handler( | 35 | event_handler_register_id{event_handler_register->register_event_handler( |
690 | 31 | [this](MirEvent const& event) | 36 | [this](MirEvent const& event) |
691 | @@ -34,6 +39,7 @@ | |||
692 | 34 | set_state(mir_prompt_session_event_get_state(mir_event_get_prompt_session_event(&event))); | 39 | set_state(mir_prompt_session_event_get_state(mir_event_get_prompt_session_event(&event))); |
693 | 35 | })}, | 40 | })}, |
694 | 36 | state(mir_prompt_session_state_stopped), | 41 | state(mir_prompt_session_state_stopped), |
695 | 42 | session(mcl::make_protobuf_object<mir::protobuf::Void>()), | ||
696 | 37 | handle_prompt_session_state_change{[](MirPromptSessionState){}} | 43 | handle_prompt_session_state_change{[](MirPromptSessionState){}} |
697 | 38 | { | 44 | { |
698 | 39 | } | 45 | } |
699 | @@ -64,14 +70,14 @@ | |||
700 | 64 | { | 70 | { |
701 | 65 | { | 71 | { |
702 | 66 | std::lock_guard<decltype(mutex)> lock(mutex); | 72 | std::lock_guard<decltype(mutex)> lock(mutex); |
704 | 67 | parameters.set_application_pid(application_pid); | 73 | parameters->set_application_pid(application_pid); |
705 | 68 | } | 74 | } |
706 | 69 | 75 | ||
707 | 70 | start_wait_handle.expect_result(); | 76 | start_wait_handle.expect_result(); |
708 | 71 | server.start_prompt_session( | 77 | server.start_prompt_session( |
709 | 72 | 0, | 78 | 0, |
712 | 73 | ¶meters, | 79 | parameters.get(), |
713 | 74 | &session, | 80 | session.get(), |
714 | 75 | google::protobuf::NewCallback(this, &MirPromptSession::done_start, | 81 | google::protobuf::NewCallback(this, &MirPromptSession::done_start, |
715 | 76 | callback, context)); | 82 | callback, context)); |
716 | 77 | 83 | ||
717 | @@ -84,8 +90,8 @@ | |||
718 | 84 | 90 | ||
719 | 85 | server.stop_prompt_session( | 91 | server.stop_prompt_session( |
720 | 86 | 0, | 92 | 0, |
723 | 87 | &protobuf_void, | 93 | protobuf_void.get(), |
724 | 88 | &protobuf_void, | 94 | protobuf_void.get(), |
725 | 89 | google::protobuf::NewCallback(this, &MirPromptSession::done_stop, | 95 | google::protobuf::NewCallback(this, &MirPromptSession::done_stop, |
726 | 90 | callback, context)); | 96 | callback, context)); |
727 | 91 | 97 | ||
728 | @@ -110,7 +116,7 @@ | |||
729 | 110 | { | 116 | { |
730 | 111 | std::lock_guard<decltype(session_mutex)> lock(session_mutex); | 117 | std::lock_guard<decltype(session_mutex)> lock(session_mutex); |
731 | 112 | 118 | ||
733 | 113 | state = session.has_error() ? mir_prompt_session_state_stopped : mir_prompt_session_state_started; | 119 | state = session->has_error() ? mir_prompt_session_state_stopped : mir_prompt_session_state_started; |
734 | 114 | } | 120 | } |
735 | 115 | 121 | ||
736 | 116 | callback(this, context); | 122 | callback(this, context); |
737 | @@ -129,10 +135,10 @@ | |||
738 | 129 | { | 135 | { |
739 | 130 | std::lock_guard<decltype(session_mutex)> lock(session_mutex); | 136 | std::lock_guard<decltype(session_mutex)> lock(session_mutex); |
740 | 131 | 137 | ||
743 | 132 | if (!session.has_error()) | 138 | if (!session->has_error()) |
744 | 133 | session.set_error(std::string{}); | 139 | session->set_error(std::string{}); |
745 | 134 | 140 | ||
747 | 135 | return session.error().c_str(); | 141 | return session->error().c_str(); |
748 | 136 | } | 142 | } |
749 | 137 | 143 | ||
750 | 138 | MirWaitHandle* MirPromptSession::new_fds_for_prompt_providers( | 144 | MirWaitHandle* MirPromptSession::new_fds_for_prompt_providers( |
751 | @@ -140,15 +146,15 @@ | |||
752 | 140 | mir_client_fd_callback callback, | 146 | mir_client_fd_callback callback, |
753 | 141 | void * context) | 147 | void * context) |
754 | 142 | { | 148 | { |
757 | 143 | mir::protobuf::SocketFDRequest request; | 149 | auto request = mcl::make_protobuf_object<mir::protobuf::SocketFDRequest>(); |
758 | 144 | request.set_number(no_of_fds); | 150 | request->set_number(no_of_fds); |
759 | 145 | 151 | ||
760 | 146 | fds_for_prompt_providers_wait_handle.expect_result(); | 152 | fds_for_prompt_providers_wait_handle.expect_result(); |
761 | 147 | 153 | ||
762 | 148 | server.new_fds_for_prompt_providers( | 154 | server.new_fds_for_prompt_providers( |
763 | 149 | nullptr, | 155 | nullptr, |
766 | 150 | &request, | 156 | request.get(), |
767 | 151 | &socket_fd_response, | 157 | socket_fd_response.get(), |
768 | 152 | google::protobuf::NewCallback(this, &MirPromptSession::done_fds_for_prompt_providers, | 158 | google::protobuf::NewCallback(this, &MirPromptSession::done_fds_for_prompt_providers, |
769 | 153 | callback, context)); | 159 | callback, context)); |
770 | 154 | 160 | ||
771 | @@ -159,13 +165,13 @@ | |||
772 | 159 | mir_client_fd_callback callback, | 165 | mir_client_fd_callback callback, |
773 | 160 | void* context) | 166 | void* context) |
774 | 161 | { | 167 | { |
776 | 162 | auto const size = socket_fd_response.fd_size(); | 168 | auto const size = socket_fd_response->fd_size(); |
777 | 163 | 169 | ||
778 | 164 | std::vector<int> fds; | 170 | std::vector<int> fds; |
779 | 165 | fds.reserve(size); | 171 | fds.reserve(size); |
780 | 166 | 172 | ||
781 | 167 | for (auto i = 0; i != size; ++i) | 173 | for (auto i = 0; i != size; ++i) |
783 | 168 | fds.push_back(socket_fd_response.fd(i)); | 174 | fds.push_back(socket_fd_response->fd(i)); |
784 | 169 | 175 | ||
785 | 170 | callback(this, size, fds.data(), context); | 176 | callback(this, size, fds.data(), context); |
786 | 171 | fds_for_prompt_providers_wait_handle.result_received(); | 177 | fds_for_prompt_providers_wait_handle.result_received(); |
787 | 172 | 178 | ||
788 | === modified file 'src/client/mir_prompt_session.h' | |||
789 | --- src/client/mir_prompt_session.h 2015-01-21 07:34:50 +0000 | |||
790 | +++ src/client/mir_prompt_session.h 2015-06-17 19:19:38 +0000 | |||
791 | @@ -60,10 +60,10 @@ | |||
792 | 60 | private: | 60 | private: |
793 | 61 | std::mutex mutable mutex; // Protects parameters, wait_handles & results | 61 | std::mutex mutable mutex; // Protects parameters, wait_handles & results |
794 | 62 | mir::protobuf::DisplayServer& server; | 62 | mir::protobuf::DisplayServer& server; |
799 | 63 | mir::protobuf::PromptSessionParameters parameters; | 63 | std::unique_ptr<mir::protobuf::PromptSessionParameters> parameters; |
800 | 64 | mir::protobuf::Void add_result; | 64 | std::unique_ptr<mir::protobuf::Void> add_result; |
801 | 65 | mir::protobuf::Void protobuf_void; | 65 | std::unique_ptr<mir::protobuf::Void> protobuf_void; |
802 | 66 | mir::protobuf::SocketFD socket_fd_response; | 66 | std::unique_ptr<mir::protobuf::SocketFD> socket_fd_response; |
803 | 67 | std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register; | 67 | std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register; |
804 | 68 | int const event_handler_register_id; | 68 | int const event_handler_register_id; |
805 | 69 | 69 | ||
806 | @@ -73,7 +73,7 @@ | |||
807 | 73 | std::atomic<MirPromptSessionState> state; | 73 | std::atomic<MirPromptSessionState> state; |
808 | 74 | 74 | ||
809 | 75 | std::mutex mutable session_mutex; // Protects session | 75 | std::mutex mutable session_mutex; // Protects session |
811 | 76 | mir::protobuf::Void session; | 76 | std::unique_ptr<mir::protobuf::Void> session; |
812 | 77 | 77 | ||
813 | 78 | std::mutex mutable event_handler_mutex; // Need another mutex for callback access to members | 78 | std::mutex mutable event_handler_mutex; // Need another mutex for callback access to members |
814 | 79 | std::function<void(MirPromptSessionState)> handle_prompt_session_state_change; | 79 | std::function<void(MirPromptSessionState)> handle_prompt_session_state_change; |
815 | 80 | 80 | ||
816 | === modified file 'src/client/mir_screencast.cpp' | |||
817 | --- src/client/mir_screencast.cpp 2015-04-25 11:38:31 +0000 | |||
818 | +++ src/client/mir_screencast.cpp 2015-06-17 19:19:38 +0000 | |||
819 | @@ -18,6 +18,7 @@ | |||
820 | 18 | 18 | ||
821 | 19 | #include "mir_screencast.h" | 19 | #include "mir_screencast.h" |
822 | 20 | #include "client_buffer_stream_factory.h" | 20 | #include "client_buffer_stream_factory.h" |
823 | 21 | #include "make_protobuf_object.h" | ||
824 | 21 | #include "client_buffer_stream.h" | 22 | #include "client_buffer_stream.h" |
825 | 22 | #include "mir/frontend/client_constants.h" | 23 | #include "mir/frontend/client_constants.h" |
826 | 23 | #include "mir_toolkit/mir_native_buffer.h" | 24 | #include "mir_toolkit/mir_native_buffer.h" |
827 | @@ -38,7 +39,9 @@ | |||
828 | 38 | mir_screencast_callback callback, void* context) | 39 | mir_screencast_callback callback, void* context) |
829 | 39 | : server(server), | 40 | : server(server), |
830 | 40 | output_size{size}, | 41 | output_size{size}, |
832 | 41 | buffer_stream_factory{buffer_stream_factory} | 42 | buffer_stream_factory{buffer_stream_factory}, |
833 | 43 | protobuf_screencast{mcl::make_protobuf_object<mir::protobuf::Screencast>()}, | ||
834 | 44 | protobuf_void{mcl::make_protobuf_object<mir::protobuf::Void>()} | ||
835 | 42 | { | 45 | { |
836 | 43 | if (output_size.width.as_int() == 0 || | 46 | if (output_size.width.as_int() == 0 || |
837 | 44 | output_size.height.as_int() == 0 || | 47 | output_size.height.as_int() == 0 || |
838 | @@ -48,23 +51,23 @@ | |||
839 | 48 | { | 51 | { |
840 | 49 | BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters")); | 52 | BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters")); |
841 | 50 | } | 53 | } |
853 | 51 | protobuf_screencast.set_error("Not initialized"); | 54 | protobuf_screencast->set_error("Not initialized"); |
854 | 52 | 55 | ||
855 | 53 | mir::protobuf::ScreencastParameters parameters; | 56 | auto parameters = mcl::make_protobuf_object<mir::protobuf::ScreencastParameters>(); |
856 | 54 | 57 | ||
857 | 55 | parameters.mutable_region()->set_left(region.top_left.x.as_int()); | 58 | parameters->mutable_region()->set_left(region.top_left.x.as_int()); |
858 | 56 | parameters.mutable_region()->set_top(region.top_left.y.as_int()); | 59 | parameters->mutable_region()->set_top(region.top_left.y.as_int()); |
859 | 57 | parameters.mutable_region()->set_width(region.size.width.as_uint32_t()); | 60 | parameters->mutable_region()->set_width(region.size.width.as_uint32_t()); |
860 | 58 | parameters.mutable_region()->set_height(region.size.height.as_uint32_t()); | 61 | parameters->mutable_region()->set_height(region.size.height.as_uint32_t()); |
861 | 59 | parameters.set_width(output_size.width.as_uint32_t()); | 62 | parameters->set_width(output_size.width.as_uint32_t()); |
862 | 60 | parameters.set_height(output_size.height.as_uint32_t()); | 63 | parameters->set_height(output_size.height.as_uint32_t()); |
863 | 61 | parameters.set_pixel_format(pixel_format); | 64 | parameters->set_pixel_format(pixel_format); |
864 | 62 | 65 | ||
865 | 63 | create_screencast_wait_handle.expect_result(); | 66 | create_screencast_wait_handle.expect_result(); |
866 | 64 | server.create_screencast( | 67 | server.create_screencast( |
867 | 65 | nullptr, | 68 | nullptr, |
870 | 66 | ¶meters, | 69 | parameters.get(), |
871 | 67 | &protobuf_screencast, | 70 | protobuf_screencast.get(), |
872 | 68 | google::protobuf::NewCallback( | 71 | google::protobuf::NewCallback( |
873 | 69 | this, &MirScreencast::screencast_created, | 72 | this, &MirScreencast::screencast_created, |
874 | 70 | callback, context)); | 73 | callback, context)); |
875 | @@ -77,20 +80,20 @@ | |||
876 | 77 | 80 | ||
877 | 78 | bool MirScreencast::valid() | 81 | bool MirScreencast::valid() |
878 | 79 | { | 82 | { |
880 | 80 | return !protobuf_screencast.has_error(); | 83 | return !protobuf_screencast->has_error(); |
881 | 81 | } | 84 | } |
882 | 82 | 85 | ||
883 | 83 | MirWaitHandle* MirScreencast::release( | 86 | MirWaitHandle* MirScreencast::release( |
884 | 84 | mir_screencast_callback callback, void* context) | 87 | mir_screencast_callback callback, void* context) |
885 | 85 | { | 88 | { |
888 | 86 | mir::protobuf::ScreencastId screencast_id; | 89 | auto screencast_id = mcl::make_protobuf_object<mir::protobuf::ScreencastId>(); |
889 | 87 | screencast_id.set_value(protobuf_screencast.screencast_id().value()); | 90 | screencast_id->set_value(protobuf_screencast->screencast_id().value()); |
890 | 88 | 91 | ||
891 | 89 | release_wait_handle.expect_result(); | 92 | release_wait_handle.expect_result(); |
892 | 90 | server.release_screencast( | 93 | server.release_screencast( |
893 | 91 | nullptr, | 94 | nullptr, |
896 | 92 | &screencast_id, | 95 | screencast_id.get(), |
897 | 93 | &protobuf_void, | 96 | protobuf_void.get(), |
898 | 94 | google::protobuf::NewCallback( | 97 | google::protobuf::NewCallback( |
899 | 95 | this, &MirScreencast::released, callback, context)); | 98 | this, &MirScreencast::released, callback, context)); |
900 | 96 | 99 | ||
901 | @@ -104,10 +107,10 @@ | |||
902 | 104 | void MirScreencast::screencast_created( | 107 | void MirScreencast::screencast_created( |
903 | 105 | mir_screencast_callback callback, void* context) | 108 | mir_screencast_callback callback, void* context) |
904 | 106 | { | 109 | { |
906 | 107 | if (!protobuf_screencast.has_error()) | 110 | if (!protobuf_screencast->has_error()) |
907 | 108 | { | 111 | { |
908 | 109 | buffer_stream = buffer_stream_factory->make_consumer_stream(server, | 112 | buffer_stream = buffer_stream_factory->make_consumer_stream(server, |
910 | 110 | protobuf_screencast.buffer_stream(), "MirScreencast"); | 113 | protobuf_screencast->buffer_stream(), "MirScreencast"); |
911 | 111 | } | 114 | } |
912 | 112 | 115 | ||
913 | 113 | callback(this, context); | 116 | callback(this, context); |
914 | 114 | 117 | ||
915 | === modified file 'src/client/mir_screencast.h' | |||
916 | --- src/client/mir_screencast.h 2015-03-31 02:35:42 +0000 | |||
917 | +++ src/client/mir_screencast.h 2015-06-17 19:19:38 +0000 | |||
918 | @@ -27,6 +27,8 @@ | |||
919 | 27 | 27 | ||
920 | 28 | #include <EGL/eglplatform.h> | 28 | #include <EGL/eglplatform.h> |
921 | 29 | 29 | ||
922 | 30 | #include <memory> | ||
923 | 31 | |||
924 | 30 | namespace mir | 32 | namespace mir |
925 | 31 | { | 33 | { |
926 | 32 | namespace protobuf { class DisplayServer; } | 34 | namespace protobuf { class DisplayServer; } |
927 | @@ -72,8 +74,8 @@ | |||
928 | 72 | 74 | ||
929 | 73 | std::shared_ptr<mir::client::ClientBufferStream> buffer_stream; | 75 | std::shared_ptr<mir::client::ClientBufferStream> buffer_stream; |
930 | 74 | 76 | ||
933 | 75 | mir::protobuf::Screencast protobuf_screencast; | 77 | std::unique_ptr<mir::protobuf::Screencast> protobuf_screencast; |
934 | 76 | mir::protobuf::Void protobuf_void; | 78 | std::unique_ptr<mir::protobuf::Void> protobuf_void; |
935 | 77 | 79 | ||
936 | 78 | MirWaitHandle create_screencast_wait_handle; | 80 | MirWaitHandle create_screencast_wait_handle; |
937 | 79 | MirWaitHandle release_wait_handle; | 81 | MirWaitHandle release_wait_handle; |
938 | 80 | 82 | ||
939 | === modified file 'src/client/mir_surface.cpp' | |||
940 | --- src/client/mir_surface.cpp 2015-04-28 10:30:44 +0000 | |||
941 | +++ src/client/mir_surface.cpp 2015-06-17 19:19:38 +0000 | |||
942 | @@ -16,12 +16,13 @@ | |||
943 | 16 | * Authored by: Thomas Guest <thomas.guest@canonical.com> | 16 | * Authored by: Thomas Guest <thomas.guest@canonical.com> |
944 | 17 | */ | 17 | */ |
945 | 18 | 18 | ||
946 | 19 | #include "mir_surface.h" | ||
947 | 20 | #include "cursor_configuration.h" | ||
948 | 21 | #include "client_buffer_stream_factory.h" | ||
949 | 22 | #include "make_protobuf_object.h" | ||
950 | 19 | #include "mir_toolkit/mir_client_library.h" | 23 | #include "mir_toolkit/mir_client_library.h" |
951 | 20 | #include "mir/frontend/client_constants.h" | 24 | #include "mir/frontend/client_constants.h" |
952 | 21 | #include "mir/client_buffer.h" | 25 | #include "mir/client_buffer.h" |
953 | 22 | #include "mir_surface.h" | ||
954 | 23 | #include "cursor_configuration.h" | ||
955 | 24 | #include "client_buffer_stream_factory.h" | ||
956 | 25 | #include "mir_connection.h" | 26 | #include "mir_connection.h" |
957 | 26 | #include "mir/dispatch/simple_dispatch_thread.h" | 27 | #include "mir/dispatch/simple_dispatch_thread.h" |
958 | 27 | #include "mir/input/input_platform.h" | 28 | #include "mir/input/input_platform.h" |
959 | @@ -41,7 +42,7 @@ | |||
960 | 41 | 42 | ||
961 | 42 | #define SERIALIZE_OPTION_IF_SET(option, message) \ | 43 | #define SERIALIZE_OPTION_IF_SET(option, message) \ |
962 | 43 | if (option.is_set()) \ | 44 | if (option.is_set()) \ |
964 | 44 | message.set_##option(option.value()); | 45 | message->set_##option(option.value()); |
965 | 45 | 46 | ||
966 | 46 | namespace | 47 | namespace |
967 | 47 | { | 48 | { |
968 | @@ -78,9 +79,9 @@ | |||
969 | 78 | { | 79 | { |
970 | 79 | } | 80 | } |
971 | 80 | 81 | ||
973 | 81 | mir::protobuf::SurfaceParameters MirSurfaceSpec::serialize() const | 82 | std::unique_ptr<mir::protobuf::SurfaceParameters> MirSurfaceSpec::serialize() const |
974 | 82 | { | 83 | { |
976 | 83 | mir::protobuf::SurfaceParameters message; | 84 | auto message = mcl::make_protobuf_object<mp::SurfaceParameters>(); |
977 | 84 | 85 | ||
978 | 85 | SERIALIZE_OPTION_IF_SET(width, message); | 86 | SERIALIZE_OPTION_IF_SET(width, message); |
979 | 86 | SERIALIZE_OPTION_IF_SET(height, message); | 87 | SERIALIZE_OPTION_IF_SET(height, message); |
980 | @@ -102,34 +103,35 @@ | |||
981 | 102 | // max_aspect is a special case (below) | 103 | // max_aspect is a special case (below) |
982 | 103 | 104 | ||
983 | 104 | if (parent.is_set() && parent.value() != nullptr) | 105 | if (parent.is_set() && parent.value() != nullptr) |
985 | 105 | message.set_parent_id(parent.value()->id()); | 106 | message->set_parent_id(parent.value()->id()); |
986 | 106 | 107 | ||
987 | 107 | if (aux_rect.is_set()) | 108 | if (aux_rect.is_set()) |
988 | 108 | { | 109 | { |
993 | 109 | message.mutable_aux_rect()->set_left(aux_rect.value().left); | 110 | message->mutable_aux_rect()->set_left(aux_rect.value().left); |
994 | 110 | message.mutable_aux_rect()->set_top(aux_rect.value().top); | 111 | message->mutable_aux_rect()->set_top(aux_rect.value().top); |
995 | 111 | message.mutable_aux_rect()->set_width(aux_rect.value().width); | 112 | message->mutable_aux_rect()->set_width(aux_rect.value().width); |
996 | 112 | message.mutable_aux_rect()->set_height(aux_rect.value().height); | 113 | message->mutable_aux_rect()->set_height(aux_rect.value().height); |
997 | 113 | } | 114 | } |
998 | 114 | 115 | ||
999 | 115 | if (min_aspect.is_set()) | 116 | if (min_aspect.is_set()) |
1000 | 116 | { | 117 | { |
1003 | 117 | message.mutable_min_aspect()->set_width(min_aspect.value().width); | 118 | message->mutable_min_aspect()->set_width(min_aspect.value().width); |
1004 | 118 | message.mutable_min_aspect()->set_height(min_aspect.value().height); | 119 | message->mutable_min_aspect()->set_height(min_aspect.value().height); |
1005 | 119 | } | 120 | } |
1006 | 120 | 121 | ||
1007 | 121 | if (max_aspect.is_set()) | 122 | if (max_aspect.is_set()) |
1008 | 122 | { | 123 | { |
1011 | 123 | message.mutable_max_aspect()->set_width(max_aspect.value().width); | 124 | message->mutable_max_aspect()->set_width(max_aspect.value().width); |
1012 | 124 | message.mutable_max_aspect()->set_height(max_aspect.value().height); | 125 | message->mutable_max_aspect()->set_height(max_aspect.value().height); |
1013 | 125 | } | 126 | } |
1014 | 126 | 127 | ||
1015 | 127 | return message; | 128 | return message; |
1016 | 128 | } | 129 | } |
1017 | 129 | 130 | ||
1018 | 130 | MirSurface::MirSurface(std::string const& error) | 131 | MirSurface::MirSurface(std::string const& error) |
1019 | 132 | : surface{mcl::make_protobuf_object<mir::protobuf::Surface>()} | ||
1020 | 131 | { | 133 | { |
1022 | 132 | surface.set_error(error); | 134 | surface->set_error(error); |
1023 | 133 | 135 | ||
1024 | 134 | std::lock_guard<decltype(handle_mutex)> lock(handle_mutex); | 136 | std::lock_guard<decltype(handle_mutex)> lock(handle_mutex); |
1025 | 135 | valid_surfaces.insert(this); | 137 | valid_surfaces.insert(this); |
1026 | @@ -145,11 +147,16 @@ | |||
1027 | 145 | mir_surface_callback callback, void * context) | 147 | mir_surface_callback callback, void * context) |
1028 | 146 | : server{&the_server}, | 148 | : server{&the_server}, |
1029 | 147 | debug{debug}, | 149 | debug{debug}, |
1030 | 150 | surface{mcl::make_protobuf_object<mir::protobuf::Surface>()}, | ||
1031 | 151 | buffer_request{mcl::make_protobuf_object<mir::protobuf::BufferRequest>()}, | ||
1032 | 148 | name{spec.surface_name.value()}, | 152 | name{spec.surface_name.value()}, |
1033 | 153 | void_response{mcl::make_protobuf_object<mir::protobuf::Void>()}, | ||
1034 | 154 | modify_result{mcl::make_protobuf_object<mir::protobuf::Void>()}, | ||
1035 | 149 | connection(allocating_connection), | 155 | connection(allocating_connection), |
1036 | 150 | buffer_stream_factory(buffer_stream_factory), | 156 | buffer_stream_factory(buffer_stream_factory), |
1037 | 151 | input_platform(input_platform), | 157 | input_platform(input_platform), |
1039 | 152 | keymapper(std::make_shared<mircv::XKBMapper>()) | 158 | keymapper(std::make_shared<mircv::XKBMapper>()), |
1040 | 159 | configure_result{mcl::make_protobuf_object<mir::protobuf::SurfaceSetting>()} | ||
1041 | 153 | { | 160 | { |
1042 | 154 | for (int i = 0; i < mir_surface_attribs; i++) | 161 | for (int i = 0; i < mir_surface_attribs; i++) |
1043 | 155 | attrib_cache[i] = -1; | 162 | attrib_cache[i] = -1; |
1044 | @@ -158,11 +165,11 @@ | |||
1045 | 158 | create_wait_handle.expect_result(); | 165 | create_wait_handle.expect_result(); |
1046 | 159 | try | 166 | try |
1047 | 160 | { | 167 | { |
1049 | 161 | server->create_surface(0, &message, &surface, gp::NewCallback(this, &MirSurface::created, callback, context)); | 168 | server->create_surface(0, message.get(), surface.get(), gp::NewCallback(this, &MirSurface::created, callback, context)); |
1050 | 162 | } | 169 | } |
1051 | 163 | catch (std::exception const& ex) | 170 | catch (std::exception const& ex) |
1052 | 164 | { | 171 | { |
1054 | 165 | surface.set_error(std::string{"Error invoking create surface: "} + | 172 | surface->set_error(std::string{"Error invoking create surface: "} + |
1055 | 166 | boost::diagnostic_information(ex)); | 173 | boost::diagnostic_information(ex)); |
1056 | 167 | } | 174 | } |
1057 | 168 | 175 | ||
1058 | @@ -181,8 +188,8 @@ | |||
1059 | 181 | 188 | ||
1060 | 182 | input_thread.reset(); | 189 | input_thread.reset(); |
1061 | 183 | 190 | ||
1064 | 184 | for (auto i = 0, end = surface.fd_size(); i != end; ++i) | 191 | for (auto i = 0, end = surface->fd_size(); i != end; ++i) |
1065 | 185 | close(surface.fd(i)); | 192 | close(surface->fd(i)); |
1066 | 186 | } | 193 | } |
1067 | 187 | 194 | ||
1068 | 188 | MirSurfaceParameters MirSurface::get_parameters() const | 195 | MirSurfaceParameters MirSurface::get_parameters() const |
1069 | @@ -196,9 +203,9 @@ | |||
1070 | 196 | { | 203 | { |
1071 | 197 | std::lock_guard<decltype(mutex)> lock(mutex); | 204 | std::lock_guard<decltype(mutex)> lock(mutex); |
1072 | 198 | 205 | ||
1074 | 199 | if (surface.has_error()) | 206 | if (surface->has_error()) |
1075 | 200 | { | 207 | { |
1077 | 201 | return surface.error().c_str(); | 208 | return surface->error().c_str(); |
1078 | 202 | } | 209 | } |
1079 | 203 | return error_message.c_str(); | 210 | return error_message.c_str(); |
1080 | 204 | } | 211 | } |
1081 | @@ -207,7 +214,7 @@ | |||
1082 | 207 | { | 214 | { |
1083 | 208 | std::lock_guard<decltype(mutex)> lock(mutex); | 215 | std::lock_guard<decltype(mutex)> lock(mutex); |
1084 | 209 | 216 | ||
1086 | 210 | return surface.id().value(); | 217 | return surface->id().value(); |
1087 | 211 | } | 218 | } |
1088 | 212 | 219 | ||
1089 | 213 | bool MirSurface::is_valid(MirSurface* query) | 220 | bool MirSurface::is_valid(MirSurface* query) |
1090 | @@ -215,7 +222,7 @@ | |||
1091 | 215 | std::lock_guard<decltype(handle_mutex)> lock(handle_mutex); | 222 | std::lock_guard<decltype(handle_mutex)> lock(handle_mutex); |
1092 | 216 | 223 | ||
1093 | 217 | if (valid_surfaces.count(query)) | 224 | if (valid_surfaces.count(query)) |
1095 | 218 | return !query->surface.has_error(); | 225 | return !query->surface->has_error(); |
1096 | 219 | 226 | ||
1097 | 220 | return false; | 227 | return false; |
1098 | 221 | } | 228 | } |
1099 | @@ -236,10 +243,10 @@ | |||
1100 | 236 | { | 243 | { |
1101 | 237 | { | 244 | { |
1102 | 238 | std::lock_guard<decltype(mutex)> lock(mutex); | 245 | std::lock_guard<decltype(mutex)> lock(mutex); |
1104 | 239 | if (!surface.has_id()) | 246 | if (!surface->has_id()) |
1105 | 240 | { | 247 | { |
1108 | 241 | if (!surface.has_error()) | 248 | if (!surface->has_error()) |
1109 | 242 | surface.set_error("Error processing surface create response, no ID (disconnected?)"); | 249 | surface->set_error("Error processing surface create response, no ID (disconnected?)"); |
1110 | 243 | 250 | ||
1111 | 244 | callback(this, context); | 251 | callback(this, context); |
1112 | 245 | create_wait_handle.result_received(); | 252 | create_wait_handle.result_received(); |
1113 | @@ -252,11 +259,11 @@ | |||
1114 | 252 | std::lock_guard<decltype(mutex)> lock(mutex); | 259 | std::lock_guard<decltype(mutex)> lock(mutex); |
1115 | 253 | 260 | ||
1116 | 254 | buffer_stream = buffer_stream_factory-> | 261 | buffer_stream = buffer_stream_factory-> |
1118 | 255 | make_producer_stream(*server, surface.buffer_stream(), name); | 262 | make_producer_stream(*server, surface->buffer_stream(), name); |
1119 | 256 | 263 | ||
1121 | 257 | for(int i = 0; i < surface.attributes_size(); i++) | 264 | for(int i = 0; i < surface->attributes_size(); i++) |
1122 | 258 | { | 265 | { |
1124 | 259 | auto const& attrib = surface.attributes(i); | 266 | auto const& attrib = surface->attributes(i); |
1125 | 260 | attrib_cache[attrib.attrib()] = attrib.ivalue(); | 267 | attrib_cache[attrib.attrib()] = attrib.ivalue(); |
1126 | 261 | } | 268 | } |
1127 | 262 | } | 269 | } |
1128 | @@ -265,7 +272,7 @@ | |||
1129 | 265 | } | 272 | } |
1130 | 266 | catch (std::exception const& error) | 273 | catch (std::exception const& error) |
1131 | 267 | { | 274 | { |
1133 | 268 | surface.set_error(std::string{"Error processing Surface creating response:"} + | 275 | surface->set_error(std::string{"Error processing Surface creating response:"} + |
1134 | 269 | boost::diagnostic_information(error)); | 276 | boost::diagnostic_information(error)); |
1135 | 270 | } | 277 | } |
1136 | 271 | 278 | ||
1137 | @@ -284,7 +291,7 @@ | |||
1138 | 284 | was_valid = true; | 291 | was_valid = true; |
1139 | 285 | valid_surfaces.erase(this); | 292 | valid_surfaces.erase(this); |
1140 | 286 | } | 293 | } |
1142 | 287 | if (this->surface.has_error()) | 294 | if (this->surface->has_error()) |
1143 | 288 | was_valid = false; | 295 | was_valid = false; |
1144 | 289 | 296 | ||
1145 | 290 | MirWaitHandle* wait_handle{nullptr}; | 297 | MirWaitHandle* wait_handle{nullptr}; |
1146 | @@ -303,29 +310,28 @@ | |||
1147 | 303 | 310 | ||
1148 | 304 | MirWaitHandle* MirSurface::configure_cursor(MirCursorConfiguration const* cursor) | 311 | MirWaitHandle* MirSurface::configure_cursor(MirCursorConfiguration const* cursor) |
1149 | 305 | { | 312 | { |
1151 | 306 | mp::CursorSetting setting; | 313 | auto setting = mcl::make_protobuf_object<mp::CursorSetting>(); |
1152 | 307 | 314 | ||
1153 | 308 | { | 315 | { |
1154 | 309 | std::unique_lock<decltype(mutex)> lock(mutex); | 316 | std::unique_lock<decltype(mutex)> lock(mutex); |
1156 | 310 | setting.mutable_surfaceid()->CopyFrom(surface.id()); | 317 | setting->mutable_surfaceid()->CopyFrom(surface->id()); |
1157 | 311 | if (cursor) | 318 | if (cursor) |
1158 | 312 | { | 319 | { |
1159 | 313 | if (cursor->stream != nullptr) | 320 | if (cursor->stream != nullptr) |
1160 | 314 | { | 321 | { |
1164 | 315 | setting.mutable_buffer_stream()->set_value(cursor->stream->rpc_id().as_value()); | 322 | setting->mutable_buffer_stream()->set_value(cursor->stream->rpc_id().as_value()); |
1165 | 316 | setting.set_hotspot_x(cursor->hotspot_x); | 323 | setting->set_hotspot_x(cursor->hotspot_x); |
1166 | 317 | setting.set_hotspot_y(cursor->hotspot_y); | 324 | setting->set_hotspot_y(cursor->hotspot_y); |
1167 | 318 | } | 325 | } |
1168 | 319 | else if (cursor->name != mir_disabled_cursor_name) | 326 | else if (cursor->name != mir_disabled_cursor_name) |
1169 | 320 | { | 327 | { |
1171 | 321 | setting.set_name(cursor->name.c_str()); | 328 | setting->set_name(cursor->name.c_str()); |
1172 | 322 | } | 329 | } |
1173 | 323 | |||
1174 | 324 | } | 330 | } |
1175 | 325 | } | 331 | } |
1176 | 326 | 332 | ||
1177 | 327 | configure_cursor_wait_handle.expect_result(); | 333 | configure_cursor_wait_handle.expect_result(); |
1179 | 328 | server->configure_cursor(0, &setting, &void_response, | 334 | server->configure_cursor(0, setting.get(), void_response.get(), |
1180 | 329 | google::protobuf::NewCallback(this, &MirSurface::on_cursor_configured)); | 335 | google::protobuf::NewCallback(this, &MirSurface::on_cursor_configured)); |
1181 | 330 | 336 | ||
1182 | 331 | return &configure_cursor_wait_handle; | 337 | return &configure_cursor_wait_handle; |
1183 | @@ -345,14 +351,14 @@ | |||
1184 | 345 | 351 | ||
1185 | 346 | std::unique_lock<decltype(mutex)> lock(mutex); | 352 | std::unique_lock<decltype(mutex)> lock(mutex); |
1186 | 347 | 353 | ||
1191 | 348 | mp::SurfaceSetting setting; | 354 | auto setting = mcl::make_protobuf_object<mp::SurfaceSetting>(); |
1192 | 349 | setting.mutable_surfaceid()->CopyFrom(surface.id()); | 355 | setting->mutable_surfaceid()->CopyFrom(surface->id()); |
1193 | 350 | setting.set_attrib(at); | 356 | setting->set_attrib(at); |
1194 | 351 | setting.set_ivalue(value); | 357 | setting->set_ivalue(value); |
1195 | 352 | lock.unlock(); | 358 | lock.unlock(); |
1196 | 353 | 359 | ||
1197 | 354 | configure_wait_handle.expect_result(); | 360 | configure_wait_handle.expect_result(); |
1199 | 355 | server->configure_surface(0, &setting, &configure_result, | 361 | server->configure_surface(0, setting.get(), configure_result.get(), |
1200 | 356 | google::protobuf::NewCallback(this, &MirSurface::on_configured)); | 362 | google::protobuf::NewCallback(this, &MirSurface::on_configured)); |
1201 | 357 | 363 | ||
1202 | 358 | return &configure_wait_handle; | 364 | return &configure_wait_handle; |
1203 | @@ -374,12 +380,12 @@ | |||
1204 | 374 | return false; | 380 | return false; |
1205 | 375 | } | 381 | } |
1206 | 376 | 382 | ||
1208 | 377 | mp::CoordinateTranslationRequest request; | 383 | auto request = mcl::make_protobuf_object<mp::CoordinateTranslationRequest>(); |
1209 | 378 | 384 | ||
1214 | 379 | request.set_x(x); | 385 | request->set_x(x); |
1215 | 380 | request.set_y(y); | 386 | request->set_y(y); |
1216 | 381 | *request.mutable_surfaceid() = surface.id(); | 387 | *request->mutable_surfaceid() = surface->id(); |
1217 | 382 | mp::CoordinateTranslationResponse response; | 388 | auto response = mcl::make_protobuf_object<mp::CoordinateTranslationResponse>(); |
1218 | 383 | 389 | ||
1219 | 384 | MirWaitHandle signal; | 390 | MirWaitHandle signal; |
1220 | 385 | signal.expect_result(); | 391 | signal.expect_result(); |
1221 | @@ -389,27 +395,27 @@ | |||
1222 | 389 | 395 | ||
1223 | 390 | debug->translate_surface_to_screen( | 396 | debug->translate_surface_to_screen( |
1224 | 391 | nullptr, | 397 | nullptr, |
1227 | 392 | &request, | 398 | request.get(), |
1228 | 393 | &response, | 399 | response.get(), |
1229 | 394 | google::protobuf::NewCallback(&signal_response_received, &signal)); | 400 | google::protobuf::NewCallback(&signal_response_received, &signal)); |
1230 | 395 | } | 401 | } |
1231 | 396 | 402 | ||
1232 | 397 | signal.wait_for_one(); | 403 | signal.wait_for_one(); |
1233 | 398 | 404 | ||
1237 | 399 | *screen_x = response.x(); | 405 | *screen_x = response->x(); |
1238 | 400 | *screen_y = response.y(); | 406 | *screen_y = response->y(); |
1239 | 401 | return !response.has_error(); | 407 | return !response->has_error(); |
1240 | 402 | } | 408 | } |
1241 | 403 | 409 | ||
1242 | 404 | void MirSurface::on_configured() | 410 | void MirSurface::on_configured() |
1243 | 405 | { | 411 | { |
1244 | 406 | std::lock_guard<decltype(mutex)> lock(mutex); | 412 | std::lock_guard<decltype(mutex)> lock(mutex); |
1245 | 407 | 413 | ||
1249 | 408 | if (configure_result.has_surfaceid() && | 414 | if (configure_result->has_surfaceid() && |
1250 | 409 | configure_result.surfaceid().value() == surface.id().value() && | 415 | configure_result->surfaceid().value() == surface->id().value() && |
1251 | 410 | configure_result.has_attrib()) | 416 | configure_result->has_attrib()) |
1252 | 411 | { | 417 | { |
1254 | 412 | int a = configure_result.attrib(); | 418 | int a = configure_result->attrib(); |
1255 | 413 | 419 | ||
1256 | 414 | switch (a) | 420 | switch (a) |
1257 | 415 | { | 421 | { |
1258 | @@ -418,10 +424,10 @@ | |||
1259 | 418 | case mir_surface_attrib_focus: | 424 | case mir_surface_attrib_focus: |
1260 | 419 | case mir_surface_attrib_dpi: | 425 | case mir_surface_attrib_dpi: |
1261 | 420 | case mir_surface_attrib_preferred_orientation: | 426 | case mir_surface_attrib_preferred_orientation: |
1264 | 421 | if (configure_result.has_ivalue()) | 427 | if (configure_result->has_ivalue()) |
1265 | 422 | attrib_cache[a] = configure_result.ivalue(); | 428 | attrib_cache[a] = configure_result->ivalue(); |
1266 | 423 | else | 429 | else |
1268 | 424 | assert(configure_result.has_error()); | 430 | assert(configure_result->has_error()); |
1269 | 425 | break; | 431 | break; |
1270 | 426 | default: | 432 | default: |
1271 | 427 | assert(false); | 433 | assert(false); |
1272 | @@ -466,9 +472,9 @@ | |||
1273 | 466 | std::placeholders::_1, | 472 | std::placeholders::_1, |
1274 | 467 | context); | 473 | context); |
1275 | 468 | 474 | ||
1277 | 469 | if (surface.fd_size() > 0 && handle_event_callback) | 475 | if (surface->fd_size() > 0 && handle_event_callback) |
1278 | 470 | { | 476 | { |
1280 | 471 | auto input_dispatcher = input_platform->create_input_receiver(surface.fd(0), | 477 | auto input_dispatcher = input_platform->create_input_receiver(surface->fd(0), |
1281 | 472 | keymapper, | 478 | keymapper, |
1282 | 473 | handle_event_callback); | 479 | handle_event_callback); |
1283 | 474 | input_thread = std::make_shared<md::SimpleDispatchThread>(input_dispatcher); | 480 | input_thread = std::make_shared<md::SimpleDispatchThread>(input_dispatcher); |
1284 | @@ -540,7 +546,7 @@ | |||
1285 | 540 | { | 546 | { |
1286 | 541 | { | 547 | { |
1287 | 542 | std::lock_guard<decltype(mutex)> lock(mutex); | 548 | std::lock_guard<decltype(mutex)> lock(mutex); |
1289 | 543 | if (modify_result.has_error()) | 549 | if (modify_result->has_error()) |
1290 | 544 | { | 550 | { |
1291 | 545 | // TODO return errors like lp:~vanvugt/mir/wait-result | 551 | // TODO return errors like lp:~vanvugt/mir/wait-result |
1292 | 546 | } | 552 | } |
1293 | @@ -550,14 +556,14 @@ | |||
1294 | 550 | 556 | ||
1295 | 551 | MirWaitHandle* MirSurface::modify(MirSurfaceSpec const& spec) | 557 | MirWaitHandle* MirSurface::modify(MirSurfaceSpec const& spec) |
1296 | 552 | { | 558 | { |
1298 | 553 | mp::SurfaceModifications mods; | 559 | auto mods = mcl::make_protobuf_object<mp::SurfaceModifications>(); |
1299 | 554 | 560 | ||
1300 | 555 | { | 561 | { |
1301 | 556 | std::unique_lock<decltype(mutex)> lock(mutex); | 562 | std::unique_lock<decltype(mutex)> lock(mutex); |
1303 | 557 | mods.mutable_surface_id()->set_value(surface.id().value()); | 563 | mods->mutable_surface_id()->set_value(surface->id().value()); |
1304 | 558 | } | 564 | } |
1305 | 559 | 565 | ||
1307 | 560 | auto const surface_specification = mods.mutable_surface_specification(); | 566 | auto const surface_specification = mods->mutable_surface_specification(); |
1308 | 561 | 567 | ||
1309 | 562 | #define COPY_IF_SET(field)\ | 568 | #define COPY_IF_SET(field)\ |
1310 | 563 | if (spec.field.is_set())\ | 569 | if (spec.field.is_set())\ |
1311 | @@ -619,7 +625,7 @@ | |||
1312 | 619 | } | 625 | } |
1313 | 620 | 626 | ||
1314 | 621 | modify_wait_handle.expect_result(); | 627 | modify_wait_handle.expect_result(); |
1316 | 622 | server->modify_surface(0, &mods, &modify_result, | 628 | server->modify_surface(0, mods.get(), modify_result.get(), |
1317 | 623 | google::protobuf::NewCallback(this, &MirSurface::on_modified)); | 629 | google::protobuf::NewCallback(this, &MirSurface::on_modified)); |
1318 | 624 | 630 | ||
1319 | 625 | return &modify_wait_handle; | 631 | return &modify_wait_handle; |
1320 | 626 | 632 | ||
1321 | === modified file 'src/client/mir_surface.h' | |||
1322 | --- src/client/mir_surface.h 2015-04-28 08:59:22 +0000 | |||
1323 | +++ src/client/mir_surface.h 2015-06-17 19:19:38 +0000 | |||
1324 | @@ -65,7 +65,7 @@ | |||
1325 | 65 | MirSurfaceSpec(MirConnection* connection, int width, int height, MirPixelFormat format); | 65 | MirSurfaceSpec(MirConnection* connection, int width, int height, MirPixelFormat format); |
1326 | 66 | MirSurfaceSpec(MirConnection* connection, MirSurfaceParameters const& params); | 66 | MirSurfaceSpec(MirConnection* connection, MirSurfaceParameters const& params); |
1327 | 67 | 67 | ||
1329 | 68 | mir::protobuf::SurfaceParameters serialize() const; | 68 | std::unique_ptr<mir::protobuf::SurfaceParameters> serialize() const; |
1330 | 69 | 69 | ||
1331 | 70 | struct AspectRatio { unsigned width; unsigned height; }; | 70 | struct AspectRatio { unsigned width; unsigned height; }; |
1332 | 71 | 71 | ||
1333 | @@ -163,15 +163,15 @@ | |||
1334 | 163 | 163 | ||
1335 | 164 | mir::protobuf::DisplayServer::Stub* server{nullptr}; | 164 | mir::protobuf::DisplayServer::Stub* server{nullptr}; |
1336 | 165 | mir::protobuf::Debug::Stub* debug{nullptr}; | 165 | mir::protobuf::Debug::Stub* debug{nullptr}; |
1339 | 166 | mir::protobuf::Surface surface; | 166 | std::unique_ptr<mir::protobuf::Surface> surface; |
1340 | 167 | mir::protobuf::BufferRequest buffer_request; | 167 | std::unique_ptr<mir::protobuf::BufferRequest> buffer_request; |
1341 | 168 | std::string error_message; | 168 | std::string error_message; |
1342 | 169 | std::string name; | 169 | std::string name; |
1344 | 170 | mir::protobuf::Void void_response; | 170 | std::unique_ptr<mir::protobuf::Void> void_response; |
1345 | 171 | 171 | ||
1346 | 172 | void on_modified(); | 172 | void on_modified(); |
1347 | 173 | MirWaitHandle modify_wait_handle; | 173 | MirWaitHandle modify_wait_handle; |
1349 | 174 | mir::protobuf::Void modify_result; | 174 | std::unique_ptr<mir::protobuf::Void> modify_result; |
1350 | 175 | 175 | ||
1351 | 176 | MirConnection* const connection{nullptr}; | 176 | MirConnection* const connection{nullptr}; |
1352 | 177 | 177 | ||
1353 | @@ -184,7 +184,7 @@ | |||
1354 | 184 | std::shared_ptr<mir::input::receiver::InputPlatform> const input_platform; | 184 | std::shared_ptr<mir::input::receiver::InputPlatform> const input_platform; |
1355 | 185 | std::shared_ptr<mir::input::receiver::XKBMapper> const keymapper; | 185 | std::shared_ptr<mir::input::receiver::XKBMapper> const keymapper; |
1356 | 186 | 186 | ||
1358 | 187 | mir::protobuf::SurfaceSetting configure_result; | 187 | std::unique_ptr<mir::protobuf::SurfaceSetting> configure_result; |
1359 | 188 | 188 | ||
1360 | 189 | // Cache of latest SurfaceSettings returned from the server | 189 | // Cache of latest SurfaceSettings returned from the server |
1361 | 190 | int attrib_cache[mir_surface_attribs]; | 190 | int attrib_cache[mir_surface_attribs]; |
1362 | 191 | 191 | ||
1363 | === modified file 'src/client/rpc/mir_protobuf_rpc_channel.cpp' | |||
1364 | --- src/client/rpc/mir_protobuf_rpc_channel.cpp 2015-04-25 11:38:31 +0000 | |||
1365 | +++ src/client/rpc/mir_protobuf_rpc_channel.cpp 2015-06-17 19:19:38 +0000 | |||
1366 | @@ -25,6 +25,7 @@ | |||
1367 | 25 | #include "../display_configuration.h" | 25 | #include "../display_configuration.h" |
1368 | 26 | #include "../lifecycle_control.h" | 26 | #include "../lifecycle_control.h" |
1369 | 27 | #include "../event_sink.h" | 27 | #include "../event_sink.h" |
1370 | 28 | #include "../make_protobuf_object.h" | ||
1371 | 28 | #include "mir/variable_length_array.h" | 29 | #include "mir/variable_length_array.h" |
1372 | 29 | #include "mir/events/event_private.h" | 30 | #include "mir/events/event_private.h" |
1373 | 30 | 31 | ||
1374 | @@ -233,24 +234,24 @@ | |||
1375 | 233 | 234 | ||
1376 | 234 | void mclr::MirProtobufRpcChannel::process_event_sequence(std::string const& event) | 235 | void mclr::MirProtobufRpcChannel::process_event_sequence(std::string const& event) |
1377 | 235 | { | 236 | { |
1393 | 236 | mir::protobuf::EventSequence seq; | 237 | auto seq = mcl::make_protobuf_object<mir::protobuf::EventSequence>(); |
1394 | 237 | 238 | ||
1395 | 238 | seq.ParseFromString(event); | 239 | seq->ParseFromString(event); |
1396 | 239 | 240 | ||
1397 | 240 | if (seq.has_display_configuration()) | 241 | if (seq->has_display_configuration()) |
1398 | 241 | { | 242 | { |
1399 | 242 | display_configuration->update_configuration(seq.display_configuration()); | 243 | display_configuration->update_configuration(seq->display_configuration()); |
1400 | 243 | } | 244 | } |
1401 | 244 | 245 | ||
1402 | 245 | if (seq.has_lifecycle_event()) | 246 | if (seq->has_lifecycle_event()) |
1403 | 246 | { | 247 | { |
1404 | 247 | lifecycle_control->call_lifecycle_event_handler(seq.lifecycle_event().new_state()); | 248 | lifecycle_control->call_lifecycle_event_handler(seq->lifecycle_event().new_state()); |
1405 | 248 | } | 249 | } |
1406 | 249 | 250 | ||
1407 | 250 | int const nevents = seq.event_size(); | 251 | int const nevents = seq->event_size(); |
1408 | 251 | for (int i = 0; i != nevents; ++i) | 252 | for (int i = 0; i != nevents; ++i) |
1409 | 252 | { | 253 | { |
1411 | 253 | mir::protobuf::Event const& event = seq.event(i); | 254 | mir::protobuf::Event const& event = seq->event(i); |
1412 | 254 | if (event.has_raw()) | 255 | if (event.has_raw()) |
1413 | 255 | { | 256 | { |
1414 | 256 | std::string const& raw_event = event.raw(); | 257 | std::string const& raw_event = event.raw(); |
1415 | @@ -317,7 +318,7 @@ | |||
1416 | 317 | */ | 318 | */ |
1417 | 318 | std::lock_guard<decltype(read_mutex)> lock(read_mutex); | 319 | std::lock_guard<decltype(read_mutex)> lock(read_mutex); |
1418 | 319 | 320 | ||
1420 | 320 | mir::protobuf::wire::Result result; | 321 | auto result = mcl::make_protobuf_object<mir::protobuf::wire::Result>(); |
1421 | 321 | try | 322 | try |
1422 | 322 | { | 323 | { |
1423 | 323 | uint16_t message_size; | 324 | uint16_t message_size; |
1424 | @@ -327,9 +328,9 @@ | |||
1425 | 327 | body_bytes.resize(message_size); | 328 | body_bytes.resize(message_size); |
1426 | 328 | transport->receive_data(body_bytes.data(), message_size); | 329 | transport->receive_data(body_bytes.data(), message_size); |
1427 | 329 | 330 | ||
1429 | 330 | result.ParseFromArray(body_bytes.data(), message_size); | 331 | result->ParseFromArray(body_bytes.data(), message_size); |
1430 | 331 | 332 | ||
1432 | 332 | rpc_report->result_receipt_succeeded(result); | 333 | rpc_report->result_receipt_succeeded(*result); |
1433 | 333 | } | 334 | } |
1434 | 334 | catch (std::exception const& x) | 335 | catch (std::exception const& x) |
1435 | 335 | { | 336 | { |
1436 | @@ -339,14 +340,14 @@ | |||
1437 | 339 | 340 | ||
1438 | 340 | try | 341 | try |
1439 | 341 | { | 342 | { |
1441 | 342 | for (int i = 0; i != result.events_size(); ++i) | 343 | for (int i = 0; i != result->events_size(); ++i) |
1442 | 343 | { | 344 | { |
1444 | 344 | process_event_sequence(result.events(i)); | 345 | process_event_sequence(result->events(i)); |
1445 | 345 | } | 346 | } |
1446 | 346 | 347 | ||
1448 | 347 | if (result.has_id()) | 348 | if (result->has_id()) |
1449 | 348 | { | 349 | { |
1451 | 349 | pending_calls.complete_response(result); | 350 | pending_calls.complete_response(*result); |
1452 | 350 | } | 351 | } |
1453 | 351 | } | 352 | } |
1454 | 352 | catch (std::exception const& x) | 353 | catch (std::exception const& x) |
1455 | @@ -354,7 +355,7 @@ | |||
1456 | 354 | // TODO: This is dangerous as an error in result processing could cause a wait handle | 355 | // TODO: This is dangerous as an error in result processing could cause a wait handle |
1457 | 355 | // to never fire. Could perhaps fix by catching and setting error on the response before invoking | 356 | // to never fire. Could perhaps fix by catching and setting error on the response before invoking |
1458 | 356 | // callback ~racarr | 357 | // callback ~racarr |
1460 | 357 | rpc_report->result_processing_failed(result, x); | 358 | rpc_report->result_processing_failed(*result, x); |
1461 | 358 | } | 359 | } |
1462 | 359 | } | 360 | } |
1463 | 360 | 361 |
lgtm