Mir

Merge lp:mir/0.13 into lp:mir/ubuntu

Proposed by Alberto Aguirre
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
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

To post a comment you must log in.
Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Umm it's always these tests:

[ FAILED ] GLibMainLoopAlarmTest.propagates_exception_from_alarm
[ FAILED ] SimpleDispatchThreadTest.keeps_dispatching_after_signal_interruption

But they don't fail in the silo build...ummm.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Apparently not landed yet, but is released already (!?) :)

https://launchpad.net/ubuntu/+source/mir
https://launchpad.net/mir/+milestone/0.13.3

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-06-02 23:18:42 +0000
+++ CMakeLists.txt 2015-06-17 19:19:38 +0000
@@ -28,7 +28,7 @@
2828
29set(MIR_VERSION_MAJOR 0)29set(MIR_VERSION_MAJOR 0)
30set(MIR_VERSION_MINOR 13) # This should change at least with every MIRSERVER_ABI30set(MIR_VERSION_MINOR 13) # This should change at least with every MIRSERVER_ABI
31set(MIR_VERSION_PATCH 2)31set(MIR_VERSION_PATCH 3)
3232
33add_definitions(-DMIR_VERSION_MAJOR=${MIR_VERSION_MAJOR})33add_definitions(-DMIR_VERSION_MAJOR=${MIR_VERSION_MAJOR})
34add_definitions(-DMIR_VERSION_MINOR=${MIR_VERSION_MINOR})34add_definitions(-DMIR_VERSION_MINOR=${MIR_VERSION_MINOR})
3535
=== modified file 'debian/changelog'
--- debian/changelog 2015-06-05 17:51:41 +0000
+++ debian/changelog 2015-06-17 19:19:38 +0000
@@ -1,3 +1,12 @@
1mir (0.13.3) UNRELEASED; urgency=medium
2
3 * New upstream release 0.13.3 (https://launchpad.net/mir/+milestone/0.13.3)
4 - Bug fixes:
5 . mir-client-platform-mesa-dev package dep is incorrect (LP: #1465642)
6 . Avoid allocating mir protobuf message objects on stack (LP: #1465883)
7
8 -- Alberto Aguirre <alberto.aguirre@canonical.com> Wed, 17 Jun 2015 14:11:53 -0500
9
1mir (0.13.2+15.10.20150605-0ubuntu1) wily; urgency=medium10mir (0.13.2+15.10.20150605-0ubuntu1) wily; urgency=medium
211
3 [ Alberto Aguirre ]12 [ Alberto Aguirre ]
413
=== modified file 'debian/control'
--- debian/control 2015-06-05 17:48:17 +0000
+++ debian/control 2015-06-17 19:19:38 +0000
@@ -317,7 +317,7 @@
317Architecture: i386 amd64 armhf arm64 powerpc ppc64el317Architecture: i386 amd64 armhf arm64 powerpc ppc64el
318Multi-Arch: same318Multi-Arch: same
319Pre-Depends: ${misc:Pre-Depends}319Pre-Depends: ${misc:Pre-Depends}
320Depends: libmircommon-dev,320Depends: libmirclient-dev,
321 ${misc:Depends},321 ${misc:Depends},
322Description: Display server for Ubuntu - client platform library for Mesa development files322Description: Display server for Ubuntu - client platform library for Mesa development files
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,
324324
=== modified file 'src/client/buffer_stream.cpp'
--- src/client/buffer_stream.cpp 2015-04-23 14:09:57 +0000
+++ src/client/buffer_stream.cpp 2015-06-17 19:19:38 +0000
@@ -19,6 +19,7 @@
19#define MIR_LOG_COMPONENT "MirBufferStream"19#define MIR_LOG_COMPONENT "MirBufferStream"
2020
21#include "buffer_stream.h"21#include "buffer_stream.h"
22#include "make_protobuf_object.h"
2223
23#include "mir/frontend/client_constants.h"24#include "mir/frontend/client_constants.h"
2425
@@ -96,11 +97,11 @@
96 : display_server(server),97 : display_server(server),
97 mode(mode),98 mode(mode),
98 client_platform(client_platform),99 client_platform(client_platform),
99 protobuf_bs(protobuf_bs),100 protobuf_bs{mcl::make_protobuf_object<mir::protobuf::BufferStream>(protobuf_bs)},
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},
101 swap_interval_(1),102 swap_interval_(1),
102 perf_report(perf_report)103 perf_report(perf_report),
103 104 protobuf_void{mcl::make_protobuf_object<mir::protobuf::Void>()}
104{105{
105 created(nullptr, nullptr);106 created(nullptr, nullptr);
106 perf_report->name_surface(surface_name.c_str());107 perf_report->name_surface(surface_name.c_str());
@@ -115,21 +116,23 @@
115 : display_server(server),116 : display_server(server),
116 mode(BufferStreamMode::Producer),117 mode(BufferStreamMode::Producer),
117 client_platform(client_platform),118 client_platform(client_platform),
119 protobuf_bs{mcl::make_protobuf_object<mir::protobuf::BufferStream>()},
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},
119 swap_interval_(1),121 swap_interval_(1),
120 perf_report(perf_report)122 perf_report(perf_report),
123 protobuf_void{mcl::make_protobuf_object<mir::protobuf::Void>()}
121{124{
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());
123126
124 create_wait_handle.expect_result();127 create_wait_handle.expect_result();
125 try128 try
126 {129 {
127 server.create_buffer_stream(0, &parameters, &protobuf_bs, gp::NewCallback(this, &mcl::BufferStream::created, callback,130 server.create_buffer_stream(0, &parameters, protobuf_bs.get(), gp::NewCallback(this, &mcl::BufferStream::created, callback,
128 context));131 context));
129 }132 }
130 catch (std::exception const& ex)133 catch (std::exception const& ex)
131 {134 {
132 protobuf_bs.set_error(std::string{"Error invoking create buffer stream: "} +135 protobuf_bs->set_error(std::string{"Error invoking create buffer stream: "} +
133 boost::diagnostic_information(ex));136 boost::diagnostic_information(ex));
134 }137 }
135 138
@@ -137,12 +140,12 @@
137140
138void mcl::BufferStream::created(mir_buffer_stream_callback callback, void *context)141void mcl::BufferStream::created(mir_buffer_stream_callback callback, void *context)
139{142{
140 if (!protobuf_bs.has_id() || protobuf_bs.has_error())143 if (!protobuf_bs->has_id() || protobuf_bs->has_error())
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())));
142 if (!protobuf_bs.has_buffer())145 if (!protobuf_bs->has_buffer())
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"));
144147
145 process_buffer(protobuf_bs.buffer());148 process_buffer(protobuf_bs->buffer());
146 egl_native_window_ = client_platform->create_egl_native_window(this);149 egl_native_window_ = client_platform->create_egl_native_window(this);
147150
148 if (callback)151 if (callback)
@@ -173,7 +176,7 @@
173176
174 try177 try
175 {178 {
176 auto pixel_format = static_cast<MirPixelFormat>(protobuf_bs.pixel_format());179 auto pixel_format = static_cast<MirPixelFormat>(protobuf_bs->pixel_format());
177 buffer_depository.deposit_package(buffer_package,180 buffer_depository.deposit_package(buffer_package,
178 buffer.buffer_id(),181 buffer.buffer_id(),
179 cached_buffer_size, pixel_format);182 cached_buffer_size, pixel_format);
@@ -192,40 +195,37 @@
192195
193 secured_region.reset();196 secured_region.reset();
194197
195 mir::protobuf::BufferStreamId buffer_stream_id;198 // TODO: We can fix the strange "ID casting" used below in the second phase
196 buffer_stream_id.set_value(protobuf_bs.id().value());199 // of buffer stream which generalizes and clarifies the server side logic.
197
198// TODO: We can fix the strange "ID casting" used below in the second phase
199// of buffer stream which generalizes and clarifies the server side logic.
200 if (mode == mcl::BufferStreamMode::Producer)200 if (mode == mcl::BufferStreamMode::Producer)
201 {201 {
202 mp::BufferRequest request;202 auto request = mcl::make_protobuf_object<mp::BufferRequest>();
203 request.mutable_id()->set_value(protobuf_bs.id().value());203 request->mutable_id()->set_value(protobuf_bs->id().value());
204 request.mutable_buffer()->set_buffer_id(protobuf_bs.buffer().buffer_id());204 request->mutable_buffer()->set_buffer_id(protobuf_bs->buffer().buffer_id());
205205
206 lock.unlock();206 lock.unlock();
207 next_buffer_wait_handle.expect_result();207 next_buffer_wait_handle.expect_result();
208208
209 display_server.exchange_buffer(209 display_server.exchange_buffer(
210 nullptr,210 nullptr,
211 &request,211 request.get(),
212 protobuf_bs.mutable_buffer(),212 protobuf_bs->mutable_buffer(),
213 google::protobuf::NewCallback(213 google::protobuf::NewCallback(
214 this, &mcl::BufferStream::next_buffer_received,214 this, &mcl::BufferStream::next_buffer_received,
215 done));215 done));
216 }216 }
217 else217 else
218 {218 {
219 mp::ScreencastId screencast_id;219 auto screencast_id = mcl::make_protobuf_object<mp::ScreencastId>();
220 screencast_id.set_value(protobuf_bs.id().value());220 screencast_id->set_value(protobuf_bs->id().value());
221221
222 lock.unlock();222 lock.unlock();
223 next_buffer_wait_handle.expect_result();223 next_buffer_wait_handle.expect_result();
224224
225 display_server.screencast_buffer(225 display_server.screencast_buffer(
226 nullptr,226 nullptr,
227 &screencast_id,227 screencast_id.get(),
228 protobuf_bs.mutable_buffer(),228 protobuf_bs->mutable_buffer(),
229 google::protobuf::NewCallback(229 google::protobuf::NewCallback(
230 this, &mcl::BufferStream::next_buffer_received,230 this, &mcl::BufferStream::next_buffer_received,
231 done));231 done));
@@ -263,7 +263,7 @@
263void mcl::BufferStream::next_buffer_received(263void mcl::BufferStream::next_buffer_received(
264 std::function<void()> done) 264 std::function<void()> done)
265{265{
266 process_buffer(protobuf_bs.buffer());266 process_buffer(protobuf_bs->buffer());
267267
268 done();268 done();
269269
@@ -278,8 +278,8 @@
278 "",278 "",
279 cached_buffer_size.width.as_int(),279 cached_buffer_size.width.as_int(),
280 cached_buffer_size.height.as_int(),280 cached_buffer_size.height.as_int(),
281 static_cast<MirPixelFormat>(protobuf_bs.pixel_format()),281 static_cast<MirPixelFormat>(protobuf_bs->pixel_format()),
282 static_cast<MirBufferUsage>(protobuf_bs.buffer_usage()),282 static_cast<MirBufferUsage>(protobuf_bs->buffer_usage()),
283 mir_display_output_id_invalid};283 mir_display_output_id_invalid};
284}284}
285285
@@ -311,20 +311,21 @@
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"));
312 }312 }
313313
314 mp::SurfaceSetting setting, result;314 auto setting = mcl::make_protobuf_object<mp::SurfaceSetting>();
315 setting.mutable_surfaceid()->set_value(protobuf_bs.id().value());315 auto result = mcl::make_protobuf_object<mp::SurfaceSetting>();
316 setting.set_attrib(attrib);316 setting->mutable_surfaceid()->set_value(protobuf_bs->id().value());
317 setting.set_ivalue(value);317 setting->set_attrib(attrib);
318 setting->set_ivalue(value);
318 lock.unlock();319 lock.unlock();
319320
320 configure_wait_handle.expect_result();321 configure_wait_handle.expect_result();
321 display_server.configure_surface(0, &setting, &result,322 display_server.configure_surface(0, setting.get(), result.get(),
322 google::protobuf::NewCallback(this, &mcl::BufferStream::on_configured));323 google::protobuf::NewCallback(this, &mcl::BufferStream::on_configured));
323324
324 configure_wait_handle.wait_for_all();325 configure_wait_handle.wait_for_all();
325326
326 lock.lock();327 lock.lock();
327 swap_interval_ = result.ivalue();328 swap_interval_ = result->ivalue();
328}329}
329330
330uint32_t mcl::BufferStream::get_current_buffer_id()331uint32_t mcl::BufferStream::get_current_buffer_id()
@@ -364,14 +365,14 @@
364MirWaitHandle* mcl::BufferStream::release(365MirWaitHandle* mcl::BufferStream::release(
365 mir_buffer_stream_callback callback, void* context)366 mir_buffer_stream_callback callback, void* context)
366{367{
367 mir::protobuf::BufferStreamId buffer_stream_id;368 auto buffer_stream_id = mcl::make_protobuf_object<mir::protobuf::BufferStreamId>();
368 buffer_stream_id.set_value(protobuf_bs.id().value());369 buffer_stream_id->set_value(protobuf_bs->id().value());
369 370
370 release_wait_handle.expect_result();371 release_wait_handle.expect_result();
371 display_server.release_buffer_stream(372 display_server.release_buffer_stream(
372 nullptr,373 nullptr,
373 &buffer_stream_id,374 buffer_stream_id.get(),
374 &protobuf_void,375 protobuf_void.get(),
375 google::protobuf::NewCallback(376 google::protobuf::NewCallback(
376 this, &mcl::BufferStream::released, callback, context));377 this, &mcl::BufferStream::released, callback, context));
377378
@@ -390,13 +391,13 @@
390{391{
391 std::unique_lock<decltype(mutex)> lock(mutex);392 std::unique_lock<decltype(mutex)> lock(mutex);
392 393
393 return mf::BufferStreamId(protobuf_bs.id().value());394 return mf::BufferStreamId(protobuf_bs->id().value());
394}395}
395396
396bool mcl::BufferStream::valid() const397bool mcl::BufferStream::valid() const
397{398{
398 std::unique_lock<decltype(mutex)> lock(mutex);399 std::unique_lock<decltype(mutex)> lock(mutex);
399 return protobuf_bs.has_id() && !protobuf_bs.has_error();400 return protobuf_bs->has_id() && !protobuf_bs->has_error();
400}401}
401402
402void mcl::BufferStream::set_buffer_cache_size(unsigned int cache_size)403void mcl::BufferStream::set_buffer_cache_size(unsigned int cache_size)
403404
=== modified file 'src/client/buffer_stream.h'
--- src/client/buffer_stream.h 2015-04-23 14:09:57 +0000
+++ src/client/buffer_stream.h 2015-06-17 19:19:38 +0000
@@ -60,7 +60,7 @@
60 BufferStream(mir::protobuf::DisplayServer& server,60 BufferStream(mir::protobuf::DisplayServer& server,
61 BufferStreamMode mode,61 BufferStreamMode mode,
62 std::shared_ptr<ClientPlatform> const& native_window_factory,62 std::shared_ptr<ClientPlatform> const& native_window_factory,
63 protobuf::BufferStream const& protobuf_bs,63 mir::protobuf::BufferStream const& protobuf_bs,
64 std::shared_ptr<PerfReport> const& perf_report,64 std::shared_ptr<PerfReport> const& perf_report,
65 std::string const& surface_name);65 std::string const& surface_name);
66 // For surfaceless buffer streams66 // For surfaceless buffer streams
@@ -121,7 +121,7 @@
121 BufferStreamMode const mode;121 BufferStreamMode const mode;
122 std::shared_ptr<ClientPlatform> const client_platform;122 std::shared_ptr<ClientPlatform> const client_platform;
123123
124 mir::protobuf::BufferStream protobuf_bs;124 std::unique_ptr<mir::protobuf::BufferStream> protobuf_bs;
125 mir::client::ClientBufferDepository buffer_depository;125 mir::client::ClientBufferDepository buffer_depository;
126 126
127 int swap_interval_;127 int swap_interval_;
@@ -134,7 +134,7 @@
134 MirWaitHandle release_wait_handle;134 MirWaitHandle release_wait_handle;
135 MirWaitHandle next_buffer_wait_handle;135 MirWaitHandle next_buffer_wait_handle;
136 MirWaitHandle configure_wait_handle;136 MirWaitHandle configure_wait_handle;
137 mir::protobuf::Void protobuf_void;137 std::unique_ptr<mir::protobuf::Void> protobuf_void;
138 138
139 std::shared_ptr<MemoryRegion> secured_region;139 std::shared_ptr<MemoryRegion> secured_region;
140 140
141141
=== added file 'src/client/make_protobuf_object.h'
--- src/client/make_protobuf_object.h 1970-01-01 00:00:00 +0000
+++ src/client/make_protobuf_object.h 2015-06-17 19:19:38 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alberto Aguirre <alberto.aguirre@canonical.com>
17 */
18
19#ifndef MIR_CLIENT_MAKE_PROTOBUF_OBJECT_
20#define MIR_CLIENT_MAKE_PROTOBUF_OBJECT_
21
22namespace mir
23{
24namespace client
25{
26template <typename ProtobufType>
27auto make_protobuf_object()
28{
29 return std::unique_ptr<ProtobufType>{ProtobufType::default_instance().New()};
30}
31
32template <typename ProtobufType>
33auto make_protobuf_object(ProtobufType const& from)
34{
35 auto object = make_protobuf_object<ProtobufType>();
36 object->CopyFrom(from);
37 return object;
38}
39}
40}
41
42#endif
043
=== modified file 'src/client/mir_buffer_stream_api.cpp'
--- src/client/mir_buffer_stream_api.cpp 2015-03-31 02:35:42 +0000
+++ src/client/mir_buffer_stream_api.cpp 2015-06-17 19:19:38 +0000
@@ -23,6 +23,7 @@
23#include "mir_connection.h"23#include "mir_connection.h"
24#include "buffer_stream.h"24#include "buffer_stream.h"
25#include "client_buffer_stream_factory.h"25#include "client_buffer_stream_factory.h"
26#include "make_protobuf_object.h"
2627
27#include "mir/client_buffer.h"28#include "mir/client_buffer.h"
2829
@@ -68,13 +69,13 @@
68 void *context)69 void *context)
69try70try
70{71{
71 mp::BufferStreamParameters params;72 auto params = mcl::make_protobuf_object<mp::BufferStreamParameters>();
72 params.set_width(width);73 params->set_width(width);
73 params.set_height(height);74 params->set_height(height);
74 params.set_pixel_format(format);75 params->set_pixel_format(format);
75 params.set_buffer_usage(buffer_usage);76 params->set_buffer_usage(buffer_usage);
7677
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)
78 ->get_create_wait_handle();79 ->get_create_wait_handle();
79}80}
80catch (std::exception const& ex)81catch (std::exception const& ex)
8182
=== modified file 'src/client/mir_connection.cpp'
--- src/client/mir_connection.cpp 2015-04-01 19:39:19 +0000
+++ src/client/mir_connection.cpp 2015-06-17 19:19:38 +0000
@@ -20,6 +20,7 @@
20#include "mir_surface.h"20#include "mir_surface.h"
21#include "mir_prompt_session.h"21#include "mir_prompt_session.h"
22#include "default_client_buffer_stream_factory.h"22#include "default_client_buffer_stream_factory.h"
23#include "make_protobuf_object.h"
23#include "mir_toolkit/mir_platform_message.h"24#include "mir_toolkit/mir_platform_message.h"
24#include "mir/client_platform.h"25#include "mir/client_platform.h"
25#include "mir/client_platform_factory.h"26#include "mir/client_platform_factory.h"
@@ -106,7 +107,13 @@
106 server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL),107 server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL),
107 debug(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL),108 debug(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL),
108 logger(conf.the_logger()),109 logger(conf.the_logger()),
110 void_response{mcl::make_protobuf_object<mir::protobuf::Void>()},
111 connect_result{mcl::make_protobuf_object<mir::protobuf::Connection>()},
109 connect_done{false},112 connect_done{false},
113 ignored{mcl::make_protobuf_object<mir::protobuf::Void>()},
114 connect_parameters{mcl::make_protobuf_object<mir::protobuf::ConnectParameters>()},
115 platform_operation_reply{mcl::make_protobuf_object<mir::protobuf::PlatformOperationMessage>()},
116 display_configuration_response{mcl::make_protobuf_object<mir::protobuf::DisplayConfiguration>()},
110 client_platform_factory(conf.the_client_platform_factory()),117 client_platform_factory(conf.the_client_platform_factory()),
111 input_platform(conf.the_input_platform()),118 input_platform(conf.the_input_platform()),
112 display_configuration(conf.the_display_configuration()),119 display_configuration(conf.the_display_configuration()),
@@ -115,7 +122,7 @@
115 event_handler_register(conf.the_event_handler_register()),122 event_handler_register(conf.the_event_handler_register()),
116 eventloop{new md::SimpleDispatchThread{std::dynamic_pointer_cast<md::Dispatchable>(channel)}}123 eventloop{new md::SimpleDispatchThread{std::dynamic_pointer_cast<md::Dispatchable>(channel)}}
117{124{
118 connect_result.set_error("connect not called");125 connect_result->set_error("connect not called");
119 {126 {
120 std::lock_guard<std::mutex> lock(connection_guard);127 std::lock_guard<std::mutex> lock(connection_guard);
121 next_valid = valid_connections;128 next_valid = valid_connections;
@@ -130,9 +137,9 @@
130 connect_wait_handle.wait_for_pending(std::chrono::milliseconds(500));137 connect_wait_handle.wait_for_pending(std::chrono::milliseconds(500));
131138
132 std::lock_guard<decltype(mutex)> lock(mutex);139 std::lock_guard<decltype(mutex)> lock(mutex);
133 if (connect_result.has_platform())140 if (connect_result && connect_result->has_platform())
134 {141 {
135 auto const& platform = connect_result.platform();142 auto const& platform = connect_result->platform();
136 for (int i = 0, end = platform.fd_size(); i != end; ++i)143 for (int i = 0, end = platform.fd_size(); i != end; ++i)
137 close(platform.fd(i));144 close(platform.fd(i));
138 }145 }
@@ -153,9 +160,9 @@
153{160{
154 std::lock_guard<decltype(mutex)> lock(mutex);161 std::lock_guard<decltype(mutex)> lock(mutex);
155162
156 if (connect_result.has_error())163 if (connect_result && connect_result->has_error())
157 {164 {
158 return connect_result.error().c_str();165 return connect_result->error().c_str();
159 }166 }
160167
161 return error_message.c_str();168 return error_message.c_str();
@@ -202,8 +209,8 @@
202209
203 SurfaceRelease surf_release{surface, new_wait_handle, callback, context};210 SurfaceRelease surf_release{surface, new_wait_handle, callback, context};
204211
205 mir::protobuf::SurfaceId message;212 auto message = mcl::make_protobuf_object<mir::protobuf::SurfaceId>();
206 message.set_value(surface->id());213 message->set_value(surface->id());
207214
208 {215 {
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);
@@ -211,7 +218,7 @@
211 }218 }
212219
213 new_wait_handle->expect_result();220 new_wait_handle->expect_result();
214 server.release_surface(0, &message, &void_response,221 server.release_surface(0, message.get(), void_response.get(),
215 gp::NewCallback(this, &MirConnection::released, surf_release));222 gp::NewCallback(this, &MirConnection::released, surf_release));
216223
217224
@@ -230,9 +237,9 @@
230 {237 {
231 std::lock_guard<decltype(mutex)> lock(mutex);238 std::lock_guard<decltype(mutex)> lock(mutex);
232239
233 if (!connect_result.has_platform() || !connect_result.has_display_configuration())240 if (!connect_result->has_platform() || !connect_result->has_display_configuration())
234 {241 {
235 if (!connect_result.has_error())242 if (!connect_result->has_error())
236 {243 {
237 // We're handling an error scenario that means we're not sync'd244 // We're handling an error scenario that means we're not sync'd
238 // with the client code - a callback isn't safe (or needed)245 // with the client code - a callback isn't safe (or needed)
@@ -263,12 +270,12 @@
263270
264 platform = client_platform_factory->create_client_platform(this);271 platform = client_platform_factory->create_client_platform(this);
265 native_display = platform->create_egl_native_display();272 native_display = platform->create_egl_native_display();
266 display_configuration->set_configuration(connect_result.display_configuration());273 display_configuration->set_configuration(connect_result->display_configuration());
267 lifecycle_control->set_lifecycle_event_handler(default_lifecycle_event_handler);274 lifecycle_control->set_lifecycle_event_handler(default_lifecycle_event_handler);
268 }275 }
269 catch (std::exception const& e)276 catch (std::exception const& e)
270 {277 {
271 connect_result.set_error(std::string{"Failed to process connect response: "} +278 connect_result->set_error(std::string{"Failed to process connect response: "} +
272 boost::diagnostic_information(e));279 boost::diagnostic_information(e));
273 }280 }
274281
@@ -284,14 +291,14 @@
284 {291 {
285 std::lock_guard<decltype(mutex)> lock(mutex);292 std::lock_guard<decltype(mutex)> lock(mutex);
286293
287 connect_parameters.set_application_name(app_name);294 connect_parameters->set_application_name(app_name);
288 connect_wait_handle.expect_result();295 connect_wait_handle.expect_result();
289 }296 }
290297
291 server.connect(298 server.connect(
292 0,299 0,
293 &connect_parameters,300 connect_parameters.get(),
294 &connect_result,301 connect_result.get(),
295 google::protobuf::NewCallback(302 google::protobuf::NewCallback(
296 this, &MirConnection::connected, callback, context));303 this, &MirConnection::connected, callback, context));
297 return &connect_wait_handle;304 return &connect_wait_handle;
@@ -319,7 +326,7 @@
319 disconnecting = true;326 disconnecting = true;
320 }327 }
321 disconnect_wait_handle.expect_result();328 disconnect_wait_handle.expect_result();
322 server.disconnect(0, &ignored, &ignored,329 server.disconnect(0, ignored.get(), ignored.get(),
323 google::protobuf::NewCallback(this, &MirConnection::done_disconnect));330 google::protobuf::NewCallback(this, &MirConnection::done_disconnect));
324331
325 return &disconnect_wait_handle;332 return &disconnect_wait_handle;
@@ -328,19 +335,19 @@
328void MirConnection::done_platform_operation(335void MirConnection::done_platform_operation(
329 mir_platform_operation_callback callback, void* context)336 mir_platform_operation_callback callback, void* context)
330{337{
331 auto reply = mir_platform_message_create(platform_operation_reply.opcode());338 auto reply = mir_platform_message_create(platform_operation_reply->opcode());
332339
333 set_error_message(platform_operation_reply.error());340 set_error_message(platform_operation_reply->error());
334341
335 mir_platform_message_set_data(342 mir_platform_message_set_data(
336 reply,343 reply,
337 platform_operation_reply.data().data(),344 platform_operation_reply->data().data(),
338 platform_operation_reply.data().size());345 platform_operation_reply->data().size());
339346
340 mir_platform_message_set_fds(347 mir_platform_message_set_fds(
341 reply,348 reply,
342 platform_operation_reply.fd().data(),349 platform_operation_reply->fd().data(),
343 platform_operation_reply.fd().size());350 platform_operation_reply->fd().size());
344351
345 callback(this, reply, context);352 callback(this, reply, context);
346353
@@ -359,21 +366,21 @@
359 return nullptr;366 return nullptr;
360 }367 }
361368
362 mir::protobuf::PlatformOperationMessage protobuf_request;369 auto protobuf_request = mcl::make_protobuf_object<mir::protobuf::PlatformOperationMessage>();
363370
364 protobuf_request.set_opcode(mir_platform_message_get_opcode(request));371 protobuf_request->set_opcode(mir_platform_message_get_opcode(request));
365 auto const request_data = mir_platform_message_get_data(request);372 auto const request_data = mir_platform_message_get_data(request);
366 auto const request_fds = mir_platform_message_get_fds(request);373 auto const request_fds = mir_platform_message_get_fds(request);
367374
368 protobuf_request.set_data(request_data.data, request_data.size);375 protobuf_request->set_data(request_data.data, request_data.size);
369 for (size_t i = 0; i != request_fds.num_fds; ++i)376 for (size_t i = 0; i != request_fds.num_fds; ++i)
370 protobuf_request.add_fd(request_fds.fds[i]);377 protobuf_request->add_fd(request_fds.fds[i]);
371378
372 platform_operation_wait_handle.expect_result();379 platform_operation_wait_handle.expect_result();
373 server.platform_operation(380 server.platform_operation(
374 0,381 0,
375 &protobuf_request,382 protobuf_request.get(),
376 &platform_operation_reply,383 platform_operation_reply.get(),
377 google::protobuf::NewCallback(this, &MirConnection::done_platform_operation,384 google::protobuf::NewCallback(this, &MirConnection::done_platform_operation,
378 callback, context));385 callback, context));
379386
@@ -391,7 +398,7 @@
391 {398 {
392 lock.unlock();399 lock.unlock();
393 std::lock_guard<decltype(connection->mutex)> lock(connection->mutex);400 std::lock_guard<decltype(connection->mutex)> lock(connection->mutex);
394 return !connection->connect_result.has_error();401 return !connection->connect_result->has_error();
395 }402 }
396 }403 }
397 }404 }
@@ -407,9 +414,9 @@
407{414{
408 // connect_result is write-once: once it's valid, we don't need to lock415 // connect_result is write-once: once it's valid, we don't need to lock
409 // to use it.416 // to use it.
410 if (connect_done && !connect_result.has_error() && connect_result.has_platform())417 if (connect_done && !connect_result->has_error() && connect_result->has_platform())
411 {418 {
412 auto const& platform = connect_result.platform();419 auto const& platform = connect_result->platform();
413420
414 platform_package.data_items = platform.data_size();421 platform_package.data_items = platform.data_size();
415 for (int i = 0; i != platform.data_size(); ++i)422 for (int i = 0; i != platform.data_size(); ++i)
@@ -440,15 +447,15 @@
440 valid_formats = 0;447 valid_formats = 0;
441448
442 std::lock_guard<decltype(mutex)> lock(mutex);449 std::lock_guard<decltype(mutex)> lock(mutex);
443 if (!connect_result.has_error())450 if (!connect_result->has_error())
444 {451 {
445 valid_formats = std::min(452 valid_formats = std::min(
446 static_cast<unsigned int>(connect_result.surface_pixel_format_size()),453 static_cast<unsigned int>(connect_result->surface_pixel_format_size()),
447 formats_size);454 formats_size);
448455
449 for (auto i = 0u; i < valid_formats; i++)456 for (auto i = 0u; i < valid_formats; i++)
450 {457 {
451 formats[i] = static_cast<MirPixelFormat>(connect_result.surface_pixel_format(i));458 formats[i] = static_cast<MirPixelFormat>(connect_result->surface_pixel_format(i));
452 }459 }
453 }460 }
454}461}
@@ -518,10 +525,10 @@
518{525{
519 std::lock_guard<decltype(mutex)> lock(mutex);526 std::lock_guard<decltype(mutex)> lock(mutex);
520527
521 set_error_message(display_configuration_response.error());528 set_error_message(display_configuration_response->error());
522529
523 if (!display_configuration_response.has_error())530 if (!display_configuration_response->has_error())
524 display_configuration->set_configuration(display_configuration_response);531 display_configuration->set_configuration(*display_configuration_response);
525532
526 return configure_display_wait_handle.result_received();533 return configure_display_wait_handle.result_received();
527}534}
@@ -533,14 +540,14 @@
533 return NULL;540 return NULL;
534 }541 }
535542
536 mir::protobuf::DisplayConfiguration request;543 auto request = mcl::make_protobuf_object<mir::protobuf::DisplayConfiguration>();
537 {544 {
538 std::lock_guard<decltype(mutex)> lock(mutex);545 std::lock_guard<decltype(mutex)> lock(mutex);
539546
540 for (auto i=0u; i < config->num_outputs; i++)547 for (auto i=0u; i < config->num_outputs; i++)
541 {548 {
542 auto output = config->outputs[i];549 auto output = config->outputs[i];
543 auto display_request = request.add_display_output();550 auto display_request = request->add_display_output();
544 display_request->set_output_id(output.output_id);551 display_request->set_output_id(output.output_id);
545 display_request->set_used(output.used);552 display_request->set_used(output.used);
546 display_request->set_current_mode(output.current_mode);553 display_request->set_current_mode(output.current_mode);
@@ -553,7 +560,7 @@
553 }560 }
554561
555 configure_display_wait_handle.expect_result();562 configure_display_wait_handle.expect_result();
556 server.configure_display(0, &request, &display_configuration_response,563 server.configure_display(0, request.get(), display_configuration_response.get(),
557 google::protobuf::NewCallback(this, &MirConnection::done_display_configure));564 google::protobuf::NewCallback(this, &MirConnection::done_display_configure));
558565
559 return &configure_display_wait_handle;566 return &configure_display_wait_handle;
560567
=== modified file 'src/client/mir_connection.h'
--- src/client/mir_connection.h 2015-03-31 02:35:42 +0000
+++ src/client/mir_connection.h 2015-06-17 19:19:38 +0000
@@ -36,6 +36,8 @@
3636
37#include "mir_wait_handle.h"37#include "mir_wait_handle.h"
3838
39#include <memory>
40
39namespace mir41namespace mir
40{42{
41class SharedLibrary;43class SharedLibrary;
@@ -156,13 +158,13 @@
156 mir::protobuf::DisplayServer::Stub server;158 mir::protobuf::DisplayServer::Stub server;
157 mir::protobuf::Debug::Stub debug;159 mir::protobuf::Debug::Stub debug;
158 std::shared_ptr<mir::logging::Logger> const logger;160 std::shared_ptr<mir::logging::Logger> const logger;
159 mir::protobuf::Void void_response;161 std::unique_ptr<mir::protobuf::Void> void_response;
160 mir::protobuf::Connection connect_result;162 std::unique_ptr<mir::protobuf::Connection> connect_result;
161 std::atomic<bool> connect_done;163 std::atomic<bool> connect_done;
162 mir::protobuf::Void ignored;164 std::unique_ptr<mir::protobuf::Void> ignored;
163 mir::protobuf::ConnectParameters connect_parameters;165 std::unique_ptr<mir::protobuf::ConnectParameters> connect_parameters;
164 mir::protobuf::PlatformOperationMessage platform_operation_reply;166 std::unique_ptr<mir::protobuf::PlatformOperationMessage> platform_operation_reply;
165 mir::protobuf::DisplayConfiguration display_configuration_response;167 std::unique_ptr<mir::protobuf::DisplayConfiguration> display_configuration_response;
166 std::atomic<bool> disconnecting{false};168 std::atomic<bool> disconnecting{false};
167169
168 std::shared_ptr<mir::client::ClientPlatformFactory> const client_platform_factory;170 std::shared_ptr<mir::client::ClientPlatformFactory> const client_platform_factory;
169171
=== modified file 'src/client/mir_prompt_session.cpp'
--- src/client/mir_prompt_session.cpp 2015-03-31 02:35:42 +0000
+++ src/client/mir_prompt_session.cpp 2015-06-17 19:19:38 +0000
@@ -18,6 +18,7 @@
1818
19#include "mir_prompt_session.h"19#include "mir_prompt_session.h"
20#include "event_handler_register.h"20#include "event_handler_register.h"
21#include "make_protobuf_object.h"
2122
22namespace mp = mir::protobuf;23namespace mp = mir::protobuf;
23namespace mcl = mir::client;24namespace mcl = mir::client;
@@ -26,6 +27,10 @@
26 mp::DisplayServer& server,27 mp::DisplayServer& server,
27 std::shared_ptr<mcl::EventHandlerRegister> const& event_handler_register) :28 std::shared_ptr<mcl::EventHandlerRegister> const& event_handler_register) :
28 server(server),29 server(server),
30 parameters(mcl::make_protobuf_object<mir::protobuf::PromptSessionParameters>()),
31 add_result(mcl::make_protobuf_object<mir::protobuf::Void>()),
32 protobuf_void(mcl::make_protobuf_object<mir::protobuf::Void>()),
33 socket_fd_response(mcl::make_protobuf_object<mir::protobuf::SocketFD>()),
29 event_handler_register(event_handler_register),34 event_handler_register(event_handler_register),
30 event_handler_register_id{event_handler_register->register_event_handler(35 event_handler_register_id{event_handler_register->register_event_handler(
31 [this](MirEvent const& event)36 [this](MirEvent const& event)
@@ -34,6 +39,7 @@
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)));
35 })},40 })},
36 state(mir_prompt_session_state_stopped),41 state(mir_prompt_session_state_stopped),
42 session(mcl::make_protobuf_object<mir::protobuf::Void>()),
37 handle_prompt_session_state_change{[](MirPromptSessionState){}}43 handle_prompt_session_state_change{[](MirPromptSessionState){}}
38{44{
39}45}
@@ -64,14 +70,14 @@
64{70{
65 {71 {
66 std::lock_guard<decltype(mutex)> lock(mutex);72 std::lock_guard<decltype(mutex)> lock(mutex);
67 parameters.set_application_pid(application_pid);73 parameters->set_application_pid(application_pid);
68 }74 }
6975
70 start_wait_handle.expect_result();76 start_wait_handle.expect_result();
71 server.start_prompt_session(77 server.start_prompt_session(
72 0,78 0,
73 &parameters,79 parameters.get(),
74 &session,80 session.get(),
75 google::protobuf::NewCallback(this, &MirPromptSession::done_start,81 google::protobuf::NewCallback(this, &MirPromptSession::done_start,
76 callback, context));82 callback, context));
7783
@@ -84,8 +90,8 @@
8490
85 server.stop_prompt_session(91 server.stop_prompt_session(
86 0,92 0,
87 &protobuf_void,93 protobuf_void.get(),
88 &protobuf_void,94 protobuf_void.get(),
89 google::protobuf::NewCallback(this, &MirPromptSession::done_stop,95 google::protobuf::NewCallback(this, &MirPromptSession::done_stop,
90 callback, context));96 callback, context));
9197
@@ -110,7 +116,7 @@
110 {116 {
111 std::lock_guard<decltype(session_mutex)> lock(session_mutex);117 std::lock_guard<decltype(session_mutex)> lock(session_mutex);
112118
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;
114 }120 }
115121
116 callback(this, context);122 callback(this, context);
@@ -129,10 +135,10 @@
129{135{
130 std::lock_guard<decltype(session_mutex)> lock(session_mutex);136 std::lock_guard<decltype(session_mutex)> lock(session_mutex);
131137
132 if (!session.has_error())138 if (!session->has_error())
133 session.set_error(std::string{});139 session->set_error(std::string{});
134140
135 return session.error().c_str();141 return session->error().c_str();
136}142}
137143
138MirWaitHandle* MirPromptSession::new_fds_for_prompt_providers(144MirWaitHandle* MirPromptSession::new_fds_for_prompt_providers(
@@ -140,15 +146,15 @@
140 mir_client_fd_callback callback,146 mir_client_fd_callback callback,
141 void * context)147 void * context)
142{148{
143 mir::protobuf::SocketFDRequest request;149 auto request = mcl::make_protobuf_object<mir::protobuf::SocketFDRequest>();
144 request.set_number(no_of_fds);150 request->set_number(no_of_fds);
145151
146 fds_for_prompt_providers_wait_handle.expect_result();152 fds_for_prompt_providers_wait_handle.expect_result();
147153
148 server.new_fds_for_prompt_providers(154 server.new_fds_for_prompt_providers(
149 nullptr,155 nullptr,
150 &request,156 request.get(),
151 &socket_fd_response,157 socket_fd_response.get(),
152 google::protobuf::NewCallback(this, &MirPromptSession::done_fds_for_prompt_providers,158 google::protobuf::NewCallback(this, &MirPromptSession::done_fds_for_prompt_providers,
153 callback, context));159 callback, context));
154160
@@ -159,13 +165,13 @@
159 mir_client_fd_callback callback,165 mir_client_fd_callback callback,
160 void* context)166 void* context)
161{167{
162 auto const size = socket_fd_response.fd_size();168 auto const size = socket_fd_response->fd_size();
163169
164 std::vector<int> fds;170 std::vector<int> fds;
165 fds.reserve(size);171 fds.reserve(size);
166172
167 for (auto i = 0; i != size; ++i)173 for (auto i = 0; i != size; ++i)
168 fds.push_back(socket_fd_response.fd(i));174 fds.push_back(socket_fd_response->fd(i));
169175
170 callback(this, size, fds.data(), context);176 callback(this, size, fds.data(), context);
171 fds_for_prompt_providers_wait_handle.result_received();177 fds_for_prompt_providers_wait_handle.result_received();
172178
=== modified file 'src/client/mir_prompt_session.h'
--- src/client/mir_prompt_session.h 2015-01-21 07:34:50 +0000
+++ src/client/mir_prompt_session.h 2015-06-17 19:19:38 +0000
@@ -60,10 +60,10 @@
60private:60private:
61 std::mutex mutable mutex; // Protects parameters, wait_handles & results61 std::mutex mutable mutex; // Protects parameters, wait_handles & results
62 mir::protobuf::DisplayServer& server;62 mir::protobuf::DisplayServer& server;
63 mir::protobuf::PromptSessionParameters parameters;63 std::unique_ptr<mir::protobuf::PromptSessionParameters> parameters;
64 mir::protobuf::Void add_result;64 std::unique_ptr<mir::protobuf::Void> add_result;
65 mir::protobuf::Void protobuf_void;65 std::unique_ptr<mir::protobuf::Void> protobuf_void;
66 mir::protobuf::SocketFD socket_fd_response;66 std::unique_ptr<mir::protobuf::SocketFD> socket_fd_response;
67 std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register;67 std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register;
68 int const event_handler_register_id;68 int const event_handler_register_id;
6969
@@ -73,7 +73,7 @@
73 std::atomic<MirPromptSessionState> state;73 std::atomic<MirPromptSessionState> state;
7474
75 std::mutex mutable session_mutex; // Protects session75 std::mutex mutable session_mutex; // Protects session
76 mir::protobuf::Void session;76 std::unique_ptr<mir::protobuf::Void> session;
7777
78 std::mutex mutable event_handler_mutex; // Need another mutex for callback access to members78 std::mutex mutable event_handler_mutex; // Need another mutex for callback access to members
79 std::function<void(MirPromptSessionState)> handle_prompt_session_state_change;79 std::function<void(MirPromptSessionState)> handle_prompt_session_state_change;
8080
=== modified file 'src/client/mir_screencast.cpp'
--- src/client/mir_screencast.cpp 2015-04-25 11:38:31 +0000
+++ src/client/mir_screencast.cpp 2015-06-17 19:19:38 +0000
@@ -18,6 +18,7 @@
1818
19#include "mir_screencast.h"19#include "mir_screencast.h"
20#include "client_buffer_stream_factory.h"20#include "client_buffer_stream_factory.h"
21#include "make_protobuf_object.h"
21#include "client_buffer_stream.h"22#include "client_buffer_stream.h"
22#include "mir/frontend/client_constants.h"23#include "mir/frontend/client_constants.h"
23#include "mir_toolkit/mir_native_buffer.h"24#include "mir_toolkit/mir_native_buffer.h"
@@ -38,7 +39,9 @@
38 mir_screencast_callback callback, void* context)39 mir_screencast_callback callback, void* context)
39 : server(server),40 : server(server),
40 output_size{size},41 output_size{size},
41 buffer_stream_factory{buffer_stream_factory}42 buffer_stream_factory{buffer_stream_factory},
43 protobuf_screencast{mcl::make_protobuf_object<mir::protobuf::Screencast>()},
44 protobuf_void{mcl::make_protobuf_object<mir::protobuf::Void>()}
42{45{
43 if (output_size.width.as_int() == 0 ||46 if (output_size.width.as_int() == 0 ||
44 output_size.height.as_int() == 0 ||47 output_size.height.as_int() == 0 ||
@@ -48,23 +51,23 @@
48 {51 {
49 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters"));52 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters"));
50 }53 }
51 protobuf_screencast.set_error("Not initialized");54 protobuf_screencast->set_error("Not initialized");
5255
53 mir::protobuf::ScreencastParameters parameters;56 auto parameters = mcl::make_protobuf_object<mir::protobuf::ScreencastParameters>();
5457
55 parameters.mutable_region()->set_left(region.top_left.x.as_int());58 parameters->mutable_region()->set_left(region.top_left.x.as_int());
56 parameters.mutable_region()->set_top(region.top_left.y.as_int());59 parameters->mutable_region()->set_top(region.top_left.y.as_int());
57 parameters.mutable_region()->set_width(region.size.width.as_uint32_t());60 parameters->mutable_region()->set_width(region.size.width.as_uint32_t());
58 parameters.mutable_region()->set_height(region.size.height.as_uint32_t());61 parameters->mutable_region()->set_height(region.size.height.as_uint32_t());
59 parameters.set_width(output_size.width.as_uint32_t());62 parameters->set_width(output_size.width.as_uint32_t());
60 parameters.set_height(output_size.height.as_uint32_t());63 parameters->set_height(output_size.height.as_uint32_t());
61 parameters.set_pixel_format(pixel_format);64 parameters->set_pixel_format(pixel_format);
6265
63 create_screencast_wait_handle.expect_result();66 create_screencast_wait_handle.expect_result();
64 server.create_screencast(67 server.create_screencast(
65 nullptr,68 nullptr,
66 &parameters,69 parameters.get(),
67 &protobuf_screencast,70 protobuf_screencast.get(),
68 google::protobuf::NewCallback(71 google::protobuf::NewCallback(
69 this, &MirScreencast::screencast_created,72 this, &MirScreencast::screencast_created,
70 callback, context));73 callback, context));
@@ -77,20 +80,20 @@
7780
78bool MirScreencast::valid()81bool MirScreencast::valid()
79{82{
80 return !protobuf_screencast.has_error();83 return !protobuf_screencast->has_error();
81}84}
8285
83MirWaitHandle* MirScreencast::release(86MirWaitHandle* MirScreencast::release(
84 mir_screencast_callback callback, void* context)87 mir_screencast_callback callback, void* context)
85{88{
86 mir::protobuf::ScreencastId screencast_id;89 auto screencast_id = mcl::make_protobuf_object<mir::protobuf::ScreencastId>();
87 screencast_id.set_value(protobuf_screencast.screencast_id().value());90 screencast_id->set_value(protobuf_screencast->screencast_id().value());
88 91
89 release_wait_handle.expect_result();92 release_wait_handle.expect_result();
90 server.release_screencast(93 server.release_screencast(
91 nullptr,94 nullptr,
92 &screencast_id,95 screencast_id.get(),
93 &protobuf_void,96 protobuf_void.get(),
94 google::protobuf::NewCallback(97 google::protobuf::NewCallback(
95 this, &MirScreencast::released, callback, context));98 this, &MirScreencast::released, callback, context));
9699
@@ -104,10 +107,10 @@
104void MirScreencast::screencast_created(107void MirScreencast::screencast_created(
105 mir_screencast_callback callback, void* context)108 mir_screencast_callback callback, void* context)
106{109{
107 if (!protobuf_screencast.has_error())110 if (!protobuf_screencast->has_error())
108 {111 {
109 buffer_stream = buffer_stream_factory->make_consumer_stream(server,112 buffer_stream = buffer_stream_factory->make_consumer_stream(server,
110 protobuf_screencast.buffer_stream(), "MirScreencast");113 protobuf_screencast->buffer_stream(), "MirScreencast");
111 }114 }
112115
113 callback(this, context);116 callback(this, context);
114117
=== modified file 'src/client/mir_screencast.h'
--- src/client/mir_screencast.h 2015-03-31 02:35:42 +0000
+++ src/client/mir_screencast.h 2015-06-17 19:19:38 +0000
@@ -27,6 +27,8 @@
2727
28#include <EGL/eglplatform.h>28#include <EGL/eglplatform.h>
2929
30#include <memory>
31
30namespace mir32namespace mir
31{33{
32namespace protobuf { class DisplayServer; }34namespace protobuf { class DisplayServer; }
@@ -72,8 +74,8 @@
72 74
73 std::shared_ptr<mir::client::ClientBufferStream> buffer_stream;75 std::shared_ptr<mir::client::ClientBufferStream> buffer_stream;
7476
75 mir::protobuf::Screencast protobuf_screencast;77 std::unique_ptr<mir::protobuf::Screencast> protobuf_screencast;
76 mir::protobuf::Void protobuf_void;78 std::unique_ptr<mir::protobuf::Void> protobuf_void;
7779
78 MirWaitHandle create_screencast_wait_handle;80 MirWaitHandle create_screencast_wait_handle;
79 MirWaitHandle release_wait_handle;81 MirWaitHandle release_wait_handle;
8082
=== modified file 'src/client/mir_surface.cpp'
--- src/client/mir_surface.cpp 2015-04-28 10:30:44 +0000
+++ src/client/mir_surface.cpp 2015-06-17 19:19:38 +0000
@@ -16,12 +16,13 @@
16 * Authored by: Thomas Guest <thomas.guest@canonical.com>16 * Authored by: Thomas Guest <thomas.guest@canonical.com>
17 */17 */
1818
19#include "mir_surface.h"
20#include "cursor_configuration.h"
21#include "client_buffer_stream_factory.h"
22#include "make_protobuf_object.h"
19#include "mir_toolkit/mir_client_library.h"23#include "mir_toolkit/mir_client_library.h"
20#include "mir/frontend/client_constants.h"24#include "mir/frontend/client_constants.h"
21#include "mir/client_buffer.h"25#include "mir/client_buffer.h"
22#include "mir_surface.h"
23#include "cursor_configuration.h"
24#include "client_buffer_stream_factory.h"
25#include "mir_connection.h"26#include "mir_connection.h"
26#include "mir/dispatch/simple_dispatch_thread.h"27#include "mir/dispatch/simple_dispatch_thread.h"
27#include "mir/input/input_platform.h"28#include "mir/input/input_platform.h"
@@ -41,7 +42,7 @@
4142
42#define SERIALIZE_OPTION_IF_SET(option, message) \43#define SERIALIZE_OPTION_IF_SET(option, message) \
43 if (option.is_set()) \44 if (option.is_set()) \
44 message.set_##option(option.value());45 message->set_##option(option.value());
4546
46namespace47namespace
47{48{
@@ -78,9 +79,9 @@
78{79{
79}80}
8081
81mir::protobuf::SurfaceParameters MirSurfaceSpec::serialize() const82std::unique_ptr<mir::protobuf::SurfaceParameters> MirSurfaceSpec::serialize() const
82{83{
83 mir::protobuf::SurfaceParameters message;84 auto message = mcl::make_protobuf_object<mp::SurfaceParameters>();
8485
85 SERIALIZE_OPTION_IF_SET(width, message);86 SERIALIZE_OPTION_IF_SET(width, message);
86 SERIALIZE_OPTION_IF_SET(height, message);87 SERIALIZE_OPTION_IF_SET(height, message);
@@ -102,34 +103,35 @@
102 // max_aspect is a special case (below)103 // max_aspect is a special case (below)
103104
104 if (parent.is_set() && parent.value() != nullptr)105 if (parent.is_set() && parent.value() != nullptr)
105 message.set_parent_id(parent.value()->id());106 message->set_parent_id(parent.value()->id());
106107
107 if (aux_rect.is_set())108 if (aux_rect.is_set())
108 {109 {
109 message.mutable_aux_rect()->set_left(aux_rect.value().left);110 message->mutable_aux_rect()->set_left(aux_rect.value().left);
110 message.mutable_aux_rect()->set_top(aux_rect.value().top);111 message->mutable_aux_rect()->set_top(aux_rect.value().top);
111 message.mutable_aux_rect()->set_width(aux_rect.value().width);112 message->mutable_aux_rect()->set_width(aux_rect.value().width);
112 message.mutable_aux_rect()->set_height(aux_rect.value().height);113 message->mutable_aux_rect()->set_height(aux_rect.value().height);
113 }114 }
114115
115 if (min_aspect.is_set())116 if (min_aspect.is_set())
116 {117 {
117 message.mutable_min_aspect()->set_width(min_aspect.value().width);118 message->mutable_min_aspect()->set_width(min_aspect.value().width);
118 message.mutable_min_aspect()->set_height(min_aspect.value().height);119 message->mutable_min_aspect()->set_height(min_aspect.value().height);
119 }120 }
120121
121 if (max_aspect.is_set())122 if (max_aspect.is_set())
122 {123 {
123 message.mutable_max_aspect()->set_width(max_aspect.value().width);124 message->mutable_max_aspect()->set_width(max_aspect.value().width);
124 message.mutable_max_aspect()->set_height(max_aspect.value().height);125 message->mutable_max_aspect()->set_height(max_aspect.value().height);
125 }126 }
126127
127 return message;128 return message;
128}129}
129130
130MirSurface::MirSurface(std::string const& error)131MirSurface::MirSurface(std::string const& error)
132 : surface{mcl::make_protobuf_object<mir::protobuf::Surface>()}
131{133{
132 surface.set_error(error);134 surface->set_error(error);
133135
134 std::lock_guard<decltype(handle_mutex)> lock(handle_mutex);136 std::lock_guard<decltype(handle_mutex)> lock(handle_mutex);
135 valid_surfaces.insert(this);137 valid_surfaces.insert(this);
@@ -145,11 +147,16 @@
145 mir_surface_callback callback, void * context)147 mir_surface_callback callback, void * context)
146 : server{&the_server},148 : server{&the_server},
147 debug{debug},149 debug{debug},
150 surface{mcl::make_protobuf_object<mir::protobuf::Surface>()},
151 buffer_request{mcl::make_protobuf_object<mir::protobuf::BufferRequest>()},
148 name{spec.surface_name.value()},152 name{spec.surface_name.value()},
153 void_response{mcl::make_protobuf_object<mir::protobuf::Void>()},
154 modify_result{mcl::make_protobuf_object<mir::protobuf::Void>()},
149 connection(allocating_connection),155 connection(allocating_connection),
150 buffer_stream_factory(buffer_stream_factory),156 buffer_stream_factory(buffer_stream_factory),
151 input_platform(input_platform),157 input_platform(input_platform),
152 keymapper(std::make_shared<mircv::XKBMapper>())158 keymapper(std::make_shared<mircv::XKBMapper>()),
159 configure_result{mcl::make_protobuf_object<mir::protobuf::SurfaceSetting>()}
153{160{
154 for (int i = 0; i < mir_surface_attribs; i++)161 for (int i = 0; i < mir_surface_attribs; i++)
155 attrib_cache[i] = -1;162 attrib_cache[i] = -1;
@@ -158,11 +165,11 @@
158 create_wait_handle.expect_result();165 create_wait_handle.expect_result();
159 try 166 try
160 {167 {
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));
162 }169 }
163 catch (std::exception const& ex)170 catch (std::exception const& ex)
164 {171 {
165 surface.set_error(std::string{"Error invoking create surface: "} +172 surface->set_error(std::string{"Error invoking create surface: "} +
166 boost::diagnostic_information(ex));173 boost::diagnostic_information(ex));
167 }174 }
168175
@@ -181,8 +188,8 @@
181188
182 input_thread.reset();189 input_thread.reset();
183190
184 for (auto i = 0, end = surface.fd_size(); i != end; ++i)191 for (auto i = 0, end = surface->fd_size(); i != end; ++i)
185 close(surface.fd(i));192 close(surface->fd(i));
186}193}
187194
188MirSurfaceParameters MirSurface::get_parameters() const195MirSurfaceParameters MirSurface::get_parameters() const
@@ -196,9 +203,9 @@
196{203{
197 std::lock_guard<decltype(mutex)> lock(mutex);204 std::lock_guard<decltype(mutex)> lock(mutex);
198205
199 if (surface.has_error())206 if (surface->has_error())
200 {207 {
201 return surface.error().c_str();208 return surface->error().c_str();
202 }209 }
203 return error_message.c_str();210 return error_message.c_str();
204}211}
@@ -207,7 +214,7 @@
207{214{
208 std::lock_guard<decltype(mutex)> lock(mutex);215 std::lock_guard<decltype(mutex)> lock(mutex);
209216
210 return surface.id().value();217 return surface->id().value();
211}218}
212219
213bool MirSurface::is_valid(MirSurface* query)220bool MirSurface::is_valid(MirSurface* query)
@@ -215,7 +222,7 @@
215 std::lock_guard<decltype(handle_mutex)> lock(handle_mutex);222 std::lock_guard<decltype(handle_mutex)> lock(handle_mutex);
216223
217 if (valid_surfaces.count(query))224 if (valid_surfaces.count(query))
218 return !query->surface.has_error();225 return !query->surface->has_error();
219226
220 return false;227 return false;
221}228}
@@ -236,10 +243,10 @@
236{243{
237 {244 {
238 std::lock_guard<decltype(mutex)> lock(mutex);245 std::lock_guard<decltype(mutex)> lock(mutex);
239 if (!surface.has_id())246 if (!surface->has_id())
240 {247 {
241 if (!surface.has_error())248 if (!surface->has_error())
242 surface.set_error("Error processing surface create response, no ID (disconnected?)");249 surface->set_error("Error processing surface create response, no ID (disconnected?)");
243250
244 callback(this, context);251 callback(this, context);
245 create_wait_handle.result_received();252 create_wait_handle.result_received();
@@ -252,11 +259,11 @@
252 std::lock_guard<decltype(mutex)> lock(mutex);259 std::lock_guard<decltype(mutex)> lock(mutex);
253260
254 buffer_stream = buffer_stream_factory->261 buffer_stream = buffer_stream_factory->
255 make_producer_stream(*server, surface.buffer_stream(), name);262 make_producer_stream(*server, surface->buffer_stream(), name);
256263
257 for(int i = 0; i < surface.attributes_size(); i++)264 for(int i = 0; i < surface->attributes_size(); i++)
258 {265 {
259 auto const& attrib = surface.attributes(i);266 auto const& attrib = surface->attributes(i);
260 attrib_cache[attrib.attrib()] = attrib.ivalue();267 attrib_cache[attrib.attrib()] = attrib.ivalue();
261 }268 }
262 }269 }
@@ -265,7 +272,7 @@
265 }272 }
266 catch (std::exception const& error)273 catch (std::exception const& error)
267 {274 {
268 surface.set_error(std::string{"Error processing Surface creating response:"} +275 surface->set_error(std::string{"Error processing Surface creating response:"} +
269 boost::diagnostic_information(error));276 boost::diagnostic_information(error));
270 }277 }
271278
@@ -284,7 +291,7 @@
284 was_valid = true;291 was_valid = true;
285 valid_surfaces.erase(this);292 valid_surfaces.erase(this);
286 }293 }
287 if (this->surface.has_error())294 if (this->surface->has_error())
288 was_valid = false;295 was_valid = false;
289296
290 MirWaitHandle* wait_handle{nullptr};297 MirWaitHandle* wait_handle{nullptr};
@@ -303,29 +310,28 @@
303310
304MirWaitHandle* MirSurface::configure_cursor(MirCursorConfiguration const* cursor)311MirWaitHandle* MirSurface::configure_cursor(MirCursorConfiguration const* cursor)
305{312{
306 mp::CursorSetting setting;313 auto setting = mcl::make_protobuf_object<mp::CursorSetting>();
307314
308 {315 {
309 std::unique_lock<decltype(mutex)> lock(mutex);316 std::unique_lock<decltype(mutex)> lock(mutex);
310 setting.mutable_surfaceid()->CopyFrom(surface.id());317 setting->mutable_surfaceid()->CopyFrom(surface->id());
311 if (cursor)318 if (cursor)
312 {319 {
313 if (cursor->stream != nullptr)320 if (cursor->stream != nullptr)
314 {321 {
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());
316 setting.set_hotspot_x(cursor->hotspot_x);323 setting->set_hotspot_x(cursor->hotspot_x);
317 setting.set_hotspot_y(cursor->hotspot_y);324 setting->set_hotspot_y(cursor->hotspot_y);
318 }325 }
319 else if (cursor->name != mir_disabled_cursor_name)326 else if (cursor->name != mir_disabled_cursor_name)
320 {327 {
321 setting.set_name(cursor->name.c_str());328 setting->set_name(cursor->name.c_str());
322 }329 }
323
324 }330 }
325 }331 }
326 332
327 configure_cursor_wait_handle.expect_result();333 configure_cursor_wait_handle.expect_result();
328 server->configure_cursor(0, &setting, &void_response,334 server->configure_cursor(0, setting.get(), void_response.get(),
329 google::protobuf::NewCallback(this, &MirSurface::on_cursor_configured));335 google::protobuf::NewCallback(this, &MirSurface::on_cursor_configured));
330 336
331 return &configure_cursor_wait_handle;337 return &configure_cursor_wait_handle;
@@ -345,14 +351,14 @@
345351
346 std::unique_lock<decltype(mutex)> lock(mutex);352 std::unique_lock<decltype(mutex)> lock(mutex);
347353
348 mp::SurfaceSetting setting;354 auto setting = mcl::make_protobuf_object<mp::SurfaceSetting>();
349 setting.mutable_surfaceid()->CopyFrom(surface.id());355 setting->mutable_surfaceid()->CopyFrom(surface->id());
350 setting.set_attrib(at);356 setting->set_attrib(at);
351 setting.set_ivalue(value);357 setting->set_ivalue(value);
352 lock.unlock();358 lock.unlock();
353359
354 configure_wait_handle.expect_result();360 configure_wait_handle.expect_result();
355 server->configure_surface(0, &setting, &configure_result,361 server->configure_surface(0, setting.get(), configure_result.get(),
356 google::protobuf::NewCallback(this, &MirSurface::on_configured));362 google::protobuf::NewCallback(this, &MirSurface::on_configured));
357363
358 return &configure_wait_handle;364 return &configure_wait_handle;
@@ -374,12 +380,12 @@
374 return false;380 return false;
375 }381 }
376382
377 mp::CoordinateTranslationRequest request;383 auto request = mcl::make_protobuf_object<mp::CoordinateTranslationRequest>();
378384
379 request.set_x(x);385 request->set_x(x);
380 request.set_y(y);386 request->set_y(y);
381 *request.mutable_surfaceid() = surface.id();387 *request->mutable_surfaceid() = surface->id();
382 mp::CoordinateTranslationResponse response;388 auto response = mcl::make_protobuf_object<mp::CoordinateTranslationResponse>();
383389
384 MirWaitHandle signal;390 MirWaitHandle signal;
385 signal.expect_result();391 signal.expect_result();
@@ -389,27 +395,27 @@
389395
390 debug->translate_surface_to_screen(396 debug->translate_surface_to_screen(
391 nullptr,397 nullptr,
392 &request,398 request.get(),
393 &response,399 response.get(),
394 google::protobuf::NewCallback(&signal_response_received, &signal));400 google::protobuf::NewCallback(&signal_response_received, &signal));
395 }401 }
396402
397 signal.wait_for_one();403 signal.wait_for_one();
398404
399 *screen_x = response.x();405 *screen_x = response->x();
400 *screen_y = response.y();406 *screen_y = response->y();
401 return !response.has_error();407 return !response->has_error();
402}408}
403409
404void MirSurface::on_configured()410void MirSurface::on_configured()
405{411{
406 std::lock_guard<decltype(mutex)> lock(mutex);412 std::lock_guard<decltype(mutex)> lock(mutex);
407413
408 if (configure_result.has_surfaceid() &&414 if (configure_result->has_surfaceid() &&
409 configure_result.surfaceid().value() == surface.id().value() &&415 configure_result->surfaceid().value() == surface->id().value() &&
410 configure_result.has_attrib())416 configure_result->has_attrib())
411 {417 {
412 int a = configure_result.attrib();418 int a = configure_result->attrib();
413419
414 switch (a)420 switch (a)
415 {421 {
@@ -418,10 +424,10 @@
418 case mir_surface_attrib_focus:424 case mir_surface_attrib_focus:
419 case mir_surface_attrib_dpi:425 case mir_surface_attrib_dpi:
420 case mir_surface_attrib_preferred_orientation:426 case mir_surface_attrib_preferred_orientation:
421 if (configure_result.has_ivalue())427 if (configure_result->has_ivalue())
422 attrib_cache[a] = configure_result.ivalue();428 attrib_cache[a] = configure_result->ivalue();
423 else429 else
424 assert(configure_result.has_error());430 assert(configure_result->has_error());
425 break;431 break;
426 default:432 default:
427 assert(false);433 assert(false);
@@ -466,9 +472,9 @@
466 std::placeholders::_1,472 std::placeholders::_1,
467 context);473 context);
468474
469 if (surface.fd_size() > 0 && handle_event_callback)475 if (surface->fd_size() > 0 && handle_event_callback)
470 {476 {
471 auto input_dispatcher = input_platform->create_input_receiver(surface.fd(0),477 auto input_dispatcher = input_platform->create_input_receiver(surface->fd(0),
472 keymapper,478 keymapper,
473 handle_event_callback);479 handle_event_callback);
474 input_thread = std::make_shared<md::SimpleDispatchThread>(input_dispatcher);480 input_thread = std::make_shared<md::SimpleDispatchThread>(input_dispatcher);
@@ -540,7 +546,7 @@
540{546{
541 {547 {
542 std::lock_guard<decltype(mutex)> lock(mutex);548 std::lock_guard<decltype(mutex)> lock(mutex);
543 if (modify_result.has_error())549 if (modify_result->has_error())
544 {550 {
545 // TODO return errors like lp:~vanvugt/mir/wait-result551 // TODO return errors like lp:~vanvugt/mir/wait-result
546 }552 }
@@ -550,14 +556,14 @@
550556
551MirWaitHandle* MirSurface::modify(MirSurfaceSpec const& spec)557MirWaitHandle* MirSurface::modify(MirSurfaceSpec const& spec)
552{558{
553 mp::SurfaceModifications mods;559 auto mods = mcl::make_protobuf_object<mp::SurfaceModifications>();
554560
555 {561 {
556 std::unique_lock<decltype(mutex)> lock(mutex);562 std::unique_lock<decltype(mutex)> lock(mutex);
557 mods.mutable_surface_id()->set_value(surface.id().value());563 mods->mutable_surface_id()->set_value(surface->id().value());
558 }564 }
559565
560 auto const surface_specification = mods.mutable_surface_specification();566 auto const surface_specification = mods->mutable_surface_specification();
561567
562 #define COPY_IF_SET(field)\568 #define COPY_IF_SET(field)\
563 if (spec.field.is_set())\569 if (spec.field.is_set())\
@@ -619,7 +625,7 @@
619 }625 }
620626
621 modify_wait_handle.expect_result();627 modify_wait_handle.expect_result();
622 server->modify_surface(0, &mods, &modify_result,628 server->modify_surface(0, mods.get(), modify_result.get(),
623 google::protobuf::NewCallback(this, &MirSurface::on_modified));629 google::protobuf::NewCallback(this, &MirSurface::on_modified));
624630
625 return &modify_wait_handle;631 return &modify_wait_handle;
626632
=== modified file 'src/client/mir_surface.h'
--- src/client/mir_surface.h 2015-04-28 08:59:22 +0000
+++ src/client/mir_surface.h 2015-06-17 19:19:38 +0000
@@ -65,7 +65,7 @@
65 MirSurfaceSpec(MirConnection* connection, int width, int height, MirPixelFormat format);65 MirSurfaceSpec(MirConnection* connection, int width, int height, MirPixelFormat format);
66 MirSurfaceSpec(MirConnection* connection, MirSurfaceParameters const& params);66 MirSurfaceSpec(MirConnection* connection, MirSurfaceParameters const& params);
6767
68 mir::protobuf::SurfaceParameters serialize() const;68 std::unique_ptr<mir::protobuf::SurfaceParameters> serialize() const;
6969
70 struct AspectRatio { unsigned width; unsigned height; };70 struct AspectRatio { unsigned width; unsigned height; };
7171
@@ -163,15 +163,15 @@
163163
164 mir::protobuf::DisplayServer::Stub* server{nullptr};164 mir::protobuf::DisplayServer::Stub* server{nullptr};
165 mir::protobuf::Debug::Stub* debug{nullptr};165 mir::protobuf::Debug::Stub* debug{nullptr};
166 mir::protobuf::Surface surface;166 std::unique_ptr<mir::protobuf::Surface> surface;
167 mir::protobuf::BufferRequest buffer_request;167 std::unique_ptr<mir::protobuf::BufferRequest> buffer_request;
168 std::string error_message;168 std::string error_message;
169 std::string name;169 std::string name;
170 mir::protobuf::Void void_response;170 std::unique_ptr<mir::protobuf::Void> void_response;
171171
172 void on_modified();172 void on_modified();
173 MirWaitHandle modify_wait_handle;173 MirWaitHandle modify_wait_handle;
174 mir::protobuf::Void modify_result;174 std::unique_ptr<mir::protobuf::Void> modify_result;
175175
176 MirConnection* const connection{nullptr};176 MirConnection* const connection{nullptr};
177177
@@ -184,7 +184,7 @@
184 std::shared_ptr<mir::input::receiver::InputPlatform> const input_platform;184 std::shared_ptr<mir::input::receiver::InputPlatform> const input_platform;
185 std::shared_ptr<mir::input::receiver::XKBMapper> const keymapper;185 std::shared_ptr<mir::input::receiver::XKBMapper> const keymapper;
186186
187 mir::protobuf::SurfaceSetting configure_result;187 std::unique_ptr<mir::protobuf::SurfaceSetting> configure_result;
188188
189 // Cache of latest SurfaceSettings returned from the server189 // Cache of latest SurfaceSettings returned from the server
190 int attrib_cache[mir_surface_attribs];190 int attrib_cache[mir_surface_attribs];
191191
=== modified file 'src/client/rpc/mir_protobuf_rpc_channel.cpp'
--- src/client/rpc/mir_protobuf_rpc_channel.cpp 2015-04-25 11:38:31 +0000
+++ src/client/rpc/mir_protobuf_rpc_channel.cpp 2015-06-17 19:19:38 +0000
@@ -25,6 +25,7 @@
25#include "../display_configuration.h"25#include "../display_configuration.h"
26#include "../lifecycle_control.h"26#include "../lifecycle_control.h"
27#include "../event_sink.h"27#include "../event_sink.h"
28#include "../make_protobuf_object.h"
28#include "mir/variable_length_array.h"29#include "mir/variable_length_array.h"
29#include "mir/events/event_private.h"30#include "mir/events/event_private.h"
3031
@@ -233,24 +234,24 @@
233234
234void mclr::MirProtobufRpcChannel::process_event_sequence(std::string const& event)235void mclr::MirProtobufRpcChannel::process_event_sequence(std::string const& event)
235{236{
236 mir::protobuf::EventSequence seq;237 auto seq = mcl::make_protobuf_object<mir::protobuf::EventSequence>();
237238
238 seq.ParseFromString(event);239 seq->ParseFromString(event);
239240
240 if (seq.has_display_configuration())241 if (seq->has_display_configuration())
241 {242 {
242 display_configuration->update_configuration(seq.display_configuration());243 display_configuration->update_configuration(seq->display_configuration());
243 }244 }
244245
245 if (seq.has_lifecycle_event())246 if (seq->has_lifecycle_event())
246 {247 {
247 lifecycle_control->call_lifecycle_event_handler(seq.lifecycle_event().new_state());248 lifecycle_control->call_lifecycle_event_handler(seq->lifecycle_event().new_state());
248 }249 }
249250
250 int const nevents = seq.event_size();251 int const nevents = seq->event_size();
251 for (int i = 0; i != nevents; ++i)252 for (int i = 0; i != nevents; ++i)
252 {253 {
253 mir::protobuf::Event const& event = seq.event(i);254 mir::protobuf::Event const& event = seq->event(i);
254 if (event.has_raw())255 if (event.has_raw())
255 {256 {
256 std::string const& raw_event = event.raw();257 std::string const& raw_event = event.raw();
@@ -317,7 +318,7 @@
317 */318 */
318 std::lock_guard<decltype(read_mutex)> lock(read_mutex);319 std::lock_guard<decltype(read_mutex)> lock(read_mutex);
319320
320 mir::protobuf::wire::Result result;321 auto result = mcl::make_protobuf_object<mir::protobuf::wire::Result>();
321 try322 try
322 {323 {
323 uint16_t message_size;324 uint16_t message_size;
@@ -327,9 +328,9 @@
327 body_bytes.resize(message_size);328 body_bytes.resize(message_size);
328 transport->receive_data(body_bytes.data(), message_size);329 transport->receive_data(body_bytes.data(), message_size);
329330
330 result.ParseFromArray(body_bytes.data(), message_size);331 result->ParseFromArray(body_bytes.data(), message_size);
331332
332 rpc_report->result_receipt_succeeded(result);333 rpc_report->result_receipt_succeeded(*result);
333 }334 }
334 catch (std::exception const& x)335 catch (std::exception const& x)
335 {336 {
@@ -339,14 +340,14 @@
339340
340 try341 try
341 {342 {
342 for (int i = 0; i != result.events_size(); ++i)343 for (int i = 0; i != result->events_size(); ++i)
343 {344 {
344 process_event_sequence(result.events(i));345 process_event_sequence(result->events(i));
345 }346 }
346347
347 if (result.has_id())348 if (result->has_id())
348 {349 {
349 pending_calls.complete_response(result);350 pending_calls.complete_response(*result);
350 }351 }
351 }352 }
352 catch (std::exception const& x)353 catch (std::exception const& x)
@@ -354,7 +355,7 @@
354 // TODO: This is dangerous as an error in result processing could cause a wait handle355 // TODO: This is dangerous as an error in result processing could cause a wait handle
355 // to never fire. Could perhaps fix by catching and setting error on the response before invoking356 // to never fire. Could perhaps fix by catching and setting error on the response before invoking
356 // callback ~racarr357 // callback ~racarr
357 rpc_report->result_processing_failed(result, x);358 rpc_report->result_processing_failed(*result, x);
358 }359 }
359}360}
360361

Subscribers

People subscribed via source and target branches

to all changes: