Mir

Merge lp:~vanvugt/mir/remove-callbacks-mir_connect into lp:~mir-team/mir/trunk

Proposed by Daniel van Vugt
Status: Rejected
Rejected by: Daniel van Vugt
Proposed branch: lp:~vanvugt/mir/remove-callbacks-mir_connect
Merge into: lp:~mir-team/mir/trunk
Diff against target: 743 lines (+73/-198)
17 files modified
examples/demo_client.c (+1/-6)
examples/demo_client_accelerated.cpp (+1/-7)
examples/demo_client_unaccelerated.c (+1/-7)
include/mir_client/mir_client_library.h (+3/-14)
include/mir_client/mir_client_library_lightdm.h (+1/-2)
src/client/mir_client_library.cpp (+13/-7)
src/client/mir_connection.cpp (+8/-8)
src/client/mir_connection.h (+3/-5)
tests/acceptance-tests/test_client_library.cpp (+16/-14)
tests/acceptance-tests/test_focus_management_api.cpp (+2/-10)
tests/acceptance-tests/test_surfaceloop.cpp (+6/-31)
tests/integration-tests/test_display_info.cpp (+1/-7)
tests/integration-tests/test_drm_auth_magic.cpp (+2/-8)
tests/integration-tests/test_error_reporting.cpp (+2/-25)
tests/integration-tests/test_surfaceloop.cpp (+8/-34)
tests/unit-tests/client/test_client_mir_surface.cpp (+1/-5)
tests/unit-tests/client/test_mir_connection.cpp (+4/-8)
To merge this branch: bzr merge lp:~vanvugt/mir/remove-callbacks-mir_connect
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Thomas Voß (community) Disapprove
Alan Griffiths Disapprove
Review via email: mp+147056@code.launchpad.net

Commit message

Remove mir_connect callback from the public API.

First pass at simplifying the client API by removing callbacks. This is part
of a greater effort to resolve LP: #1112195, with more proposals to come.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

We were asked to provided a callback based API.

Ignoring the stakeholders (I'm sure Thomas can provide a list) by removing the callbacks they asked is a bad idea.

review: Disapprove
Revision history for this message
Thomas Voß (thomas-voss) wrote :

In our conversations, both our toolkit experts (loicm and kaleo) expressed a requirement for an asynchronous API based on callbacks and added support for that requirement. I will disapprove until we have clarified with the stakeholders.

review: Disapprove
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

The API is still asynchronous. I'm not sure the stakeholders even conceived that it could be so without callbacks. And if callbacks are still required, they should be attached to a MirWaitHandle in the spirit of:
  mir_callback_on_completion(waithandle, callback, data);

I hope we can resolve this. The API is presently so awful that I refuse to use it. And I won't be the only one.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

An alternate solution, as discussed in bug 1112195 is to simply add the synchronous functions that most people will want to use:
  connection = mir_connect(...);
Though that suggests the existing functions like "mir_connect" change to something like "mir_async_connect" or "mir_background_connect".

The approach proposed here however is a nice middle-ground, not requiring duplicate functions to elegantly support both asynchronous and synchronous operation.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Design issues should be discussed in bug 1112195...

But I have many possible compromise solutions in mine. Will propose later.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

*in mind

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

408. By Daniel van Vugt

Remove mir_connect callback from the public API.

First pass at simplifying the client API by removing callbacks. This is part
of a greater effort to resolve LP: #1112195, with more proposals to come.

407. By Alan Griffiths

3rd_party/android-input: remove reliance on hardware_legacy/power.(c|h).

Approved by Alexandros Frantzis, PS Jenkins bot.

406. By Alan Griffiths

3rd_party/android-input: remove reliance on cutils/atomic.(c|h).

Approved by Alexandros Frantzis, PS Jenkins bot.

405. By Alan Griffiths

3rd_party/android-input: move the files we want to keep to "input".

Approved by Thomas Voß, PS Jenkins bot.

404. By Kevin DuBois

remove the wrappers for <thread> and <chrono> that were used to work around poor stdlib support on android, now that we have proper support of these libraries in the chroot.

Approved by Alan Griffiths, PS Jenkins bot.

403. By Alan Griffiths

graphics: Silence "narrowing conversion" with g++ 4.7.

Approved by PS Jenkins bot, Kevin DuBois.

402. By Kevin DuBois

stride was not being put into the native window type correctly. This caused render glitches when client was rendering. Add test that catches this condition

fixes: bug #1111612. Fixes: https://bugs.launchpad.net/bugs/1111612.

Approved by Alexandros Frantzis, Robert Carr, PS Jenkins bot, Alan Griffiths.

401. By Alan Griffiths

various: An assortment of nitpicky tidy-up.

Approved by Alexandros Frantzis, PS Jenkins bot.

400. By Alan Griffiths

3rd_party/android-input: stub our small use of TextOutput.

Approved by Kevin DuBois, PS Jenkins bot.

399. By Daniel van Vugt

mir_client_library.h: Documentation cleanup

1. Make the comments properly C-compatible so that clients written in pure C
   can build. (LP: #1116104)
2. Fix invalid Doxygen syntax which was generating bad docs (LP: #1116120). Fixes: https://bugs.launchpad.net/bugs/1116104, https://bugs.launchpad.net/bugs/1116120.

Approved by PS Jenkins bot, Alan Griffiths.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/demo_client.c'
--- examples/demo_client.c 2012-12-27 14:44:59 +0000
+++ examples/demo_client.c 2013-02-07 10:24:19 +0000
@@ -48,11 +48,6 @@
48/// needs to be accessible both to callbacks and to the control function.48/// needs to be accessible both to callbacks and to the control function.
49/// \snippet demo_client.c Callback_tag49/// \snippet demo_client.c Callback_tag
50///\internal [Callback_tag]50///\internal [Callback_tag]
51// Callback to update MirDemoState on connection
52static void connection_callback(MirConnection *new_connection, void *context)
53{
54 ((MirDemoState*)context)->connection = new_connection;
55}
5651
57// Callback to update MirDemoState on surface_create52// Callback to update MirDemoState on surface_create
58static void surface_create_callback(MirSurface *new_surface, void *context)53static void surface_create_callback(MirSurface *new_surface, void *context)
@@ -93,7 +88,7 @@
93 /// \snippet demo_client.c connect_tag88 /// \snippet demo_client.c connect_tag
94 ///\internal [connect_tag]89 ///\internal [connect_tag]
95 // Call mir_connect and wait for callback to complete.90 // Call mir_connect and wait for callback to complete.
96 mir_wait_for(mir_connect(server, __PRETTY_FUNCTION__, connection_callback, &mcd));91 mir_wait_for(mir_connect(server, __PRETTY_FUNCTION__, &mcd.connection));
97 puts("Connected");92 puts("Connected");
98 ///\internal [connect_tag]93 ///\internal [connect_tag]
9994
10095
=== modified file 'examples/demo_client_accelerated.cpp'
--- examples/demo_client_accelerated.cpp 2013-01-28 21:35:03 +0000
+++ examples/demo_client_accelerated.cpp 2013-02-07 10:24:19 +0000
@@ -32,12 +32,6 @@
32static MirConnection *connection = 0;32static MirConnection *connection = 0;
33static MirSurface *surface = 0;33static MirSurface *surface = 0;
3434
35static void set_connection(MirConnection *new_connection, void * context)
36{
37 (void)context;
38 connection = new_connection;
39}
40
41static void surface_create_callback(MirSurface *new_surface, void *context)35static void surface_create_callback(MirSurface *new_surface, void *context)
42{36{
43 (void)context;37 (void)context;
@@ -76,7 +70,7 @@
7670
77 puts("Starting");71 puts("Starting");
7872
79 mir_wait_for(mir_connect(socket_file, __PRETTY_FUNCTION__, set_connection, 0));73 mir_wait_for(mir_connect(socket_file, __PRETTY_FUNCTION__, &connection));
80 puts("Connected");74 puts("Connected");
8175
82 assert(connection != NULL);76 assert(connection != NULL);
8377
=== modified file 'examples/demo_client_unaccelerated.c'
--- examples/demo_client_unaccelerated.c 2012-12-19 16:01:00 +0000
+++ examples/demo_client_unaccelerated.c 2013-02-07 10:24:19 +0000
@@ -30,12 +30,6 @@
30static MirConnection *connection = 0;30static MirConnection *connection = 0;
31static MirSurface *surface = 0;31static MirSurface *surface = 0;
3232
33static void set_connection(MirConnection *new_connection, void * context)
34{
35 (void)context;
36 connection = new_connection;
37}
38
39static void surface_create_callback(MirSurface *new_surface, void *context)33static void surface_create_callback(MirSurface *new_surface, void *context)
40{34{
41 (void)context;35 (void)context;
@@ -136,7 +130,7 @@
136130
137 puts("Starting");131 puts("Starting");
138132
139 mir_wait_for(mir_connect(socket_file, __PRETTY_FUNCTION__, set_connection, 0));133 mir_wait_for(mir_connect(socket_file, __PRETTY_FUNCTION__, &connection));
140 puts("Connected");134 puts("Connected");
141135
142 assert(connection != NULL);136 assert(connection != NULL);
143137
=== modified file 'include/mir_client/mir_client_library.h'
--- include/mir_client/mir_client_library.h 2013-02-05 10:28:36 +0000
+++ include/mir_client/mir_client_library.h 2013-02-07 10:24:19 +0000
@@ -38,14 +38,6 @@
38typedef struct MirWaitHandle MirWaitHandle;38typedef struct MirWaitHandle MirWaitHandle;
3939
40/**40/**
41 * Callback to be passed when issuing a mir_connect request.
42 * \param [in] connection the new connection
43 * \param [in,out] client_context context provided by client in calling
44 * mir_connect
45 */
46typedef void (*mir_connected_callback)(MirConnection *connection, void *client_context);
47
48/**
49 * Callback to be passed when calling:41 * Callback to be passed when calling:
50 * - mir_surface_create42 * - mir_surface_create
51 * - mir_surface_next_buffer43 * - mir_surface_next_buffer
@@ -146,16 +138,13 @@
146 * wait handle remains valid until the connection has been released.138 * wait handle remains valid until the connection has been released.
147 * \param [in] server a name identifying the server139 * \param [in] server a name identifying the server
148 * \param [in] app_name a name referring to the application140 * \param [in] app_name a name referring to the application
149 * \param [in] callback callback function to be invoked when request141 * \param [out] result where to store the connection handle on
150 * completes142 * completion.
151 * \param [in,out] context passed to the callback function
152 * \return a handle that can be passed to mir_wait_for
153 */143 */
154MirWaitHandle *mir_connect(144MirWaitHandle *mir_connect(
155 char const *server,145 char const *server,
156 char const *app_name,146 char const *app_name,
157 mir_connected_callback callback,147 MirConnection **result);
158 void *client_context);
159148
160/**149/**
161 * Test for a valid connection150 * Test for a valid connection
162151
=== modified file 'include/mir_client/mir_client_library_lightdm.h'
--- include/mir_client/mir_client_library_lightdm.h 2013-02-05 14:50:25 +0000
+++ include/mir_client/mir_client_library_lightdm.h 2013-02-07 10:24:19 +0000
@@ -40,8 +40,7 @@
40 char const *server,40 char const *server,
41 int lightdm_id,41 int lightdm_id,
42 char const *app_name,42 char const *app_name,
43 mir_connected_callback callback,43 MirConnection **result);
44 void *client_context);
4544
4645
47/**46/**
4847
=== modified file 'src/client/mir_client_library.cpp'
--- src/client/mir_client_library.cpp 2013-02-05 18:12:46 +0000
+++ src/client/mir_client_library.cpp 2013-02-07 10:24:19 +0000
@@ -44,7 +44,8 @@
44MirConnection error_connection;44MirConnection error_connection;
45}45}
4646
47MirWaitHandle* mir_connect(char const* socket_file, char const* name, mir_connected_callback callback, void * context)47MirWaitHandle* mir_connect(char const* socket_file, char const* name,
48 MirConnection **result)
48{49{
4950
50 try51 try
@@ -57,12 +58,17 @@
57 log,58 log,
58 client_platform_factory);59 client_platform_factory);
5960
60 return connection->connect(name, callback, context);61 return connection->connect(name, result);
61 }62 }
62 catch (std::exception const& x)63 catch (std::exception const& x)
63 {64 {
64 error_connection.set_error_message(x.what());65 error_connection.set_error_message(x.what());
65 callback(&error_connection, context);66
67 // Test cases expect a non-null error connection but why not null
68 // for simpler error handling?
69 if (result)
70 *result = &error_connection;
71
66 return 0;72 return 0;
67 }73 }
68}74}
@@ -195,8 +201,7 @@
195 char const *server,201 char const *server,
196 int lightdm_id,202 int lightdm_id,
197 char const *app_name,203 char const *app_name,
198 mir_connected_callback callback,204 MirConnection **result)
199 void *client_context)
200try205try
201{206{
202 auto log = std::make_shared<mcl::ConsoleLogger>();207 auto log = std::make_shared<mcl::ConsoleLogger>();
@@ -207,12 +212,13 @@
207 log,212 log,
208 client_platform_factory);213 client_platform_factory);
209214
210 return connection->connect(lightdm_id, app_name, callback, client_context);215 return connection->connect(lightdm_id, app_name, result);
211}216}
212catch (std::exception const& x)217catch (std::exception const& x)
213{218{
214 error_connection.set_error_message(x.what());219 error_connection.set_error_message(x.what());
215 callback(&error_connection, client_context);220 if (result)
221 *result = 0;
216 return 0;222 return 0;
217}223}
218224
219225
=== modified file 'src/client/mir_connection.cpp'
--- src/client/mir_connection.cpp 2013-02-05 18:12:46 +0000
+++ src/client/mir_connection.cpp 2013-02-07 10:24:19 +0000
@@ -126,7 +126,7 @@
126 return new_wait_handle;126 return new_wait_handle;
127}127}
128128
129void MirConnection::connected(mir_connected_callback callback, void * context)129void MirConnection::connected(MirConnection **result)
130{130{
131 /*131 /*
132 * We need to create the client platform after the connection has been132 * We need to create the client platform after the connection has been
@@ -136,14 +136,15 @@
136 platform = client_platform_factory->create_client_platform(this);136 platform = client_platform_factory->create_client_platform(this);
137 native_display = platform->create_egl_native_display();137 native_display = platform->create_egl_native_display();
138138
139 callback(this, context);139 if (result)
140 *result = this;
141
140 connect_wait_handle.result_received();142 connect_wait_handle.result_received();
141}143}
142144
143MirWaitHandle* MirConnection::connect(145MirWaitHandle* MirConnection::connect(
144 const char* app_name,146 const char* app_name,
145 mir_connected_callback callback,147 MirConnection **result)
146 void * context)
147{148{
148 connect_parameters.set_application_name(app_name);149 connect_parameters.set_application_name(app_name);
149 server.connect(150 server.connect(
@@ -151,15 +152,14 @@
151 &connect_parameters,152 &connect_parameters,
152 &connect_result,153 &connect_result,
153 google::protobuf::NewCallback(154 google::protobuf::NewCallback(
154 this, &MirConnection::connected, callback, context));155 this, &MirConnection::connected, result));
155 return &connect_wait_handle;156 return &connect_wait_handle;
156}157}
157158
158MirWaitHandle* MirConnection::connect(159MirWaitHandle* MirConnection::connect(
159 int lightdm_id,160 int lightdm_id,
160 const char* app_name,161 const char* app_name,
161 mir_connected_callback callback,162 MirConnection **result)
162 void * context)
163{163{
164 connect_parameters.set_application_name(app_name);164 connect_parameters.set_application_name(app_name);
165 connect_parameters.set_lightdm_id(lightdm_id);165 connect_parameters.set_lightdm_id(lightdm_id);
@@ -168,7 +168,7 @@
168 &connect_parameters,168 &connect_parameters,
169 &connect_result,169 &connect_result,
170 google::protobuf::NewCallback(170 google::protobuf::NewCallback(
171 this, &MirConnection::connected, callback, context));171 this, &MirConnection::connected, result));
172 return &connect_wait_handle;172 return &connect_wait_handle;
173}173}
174174
175175
=== modified file 'src/client/mir_connection.h'
--- src/client/mir_connection.h 2013-02-05 18:12:46 +0000
+++ src/client/mir_connection.h 2013-02-07 10:24:19 +0000
@@ -71,14 +71,12 @@
7171
72 MirWaitHandle* connect(72 MirWaitHandle* connect(
73 const char* app_name,73 const char* app_name,
74 mir_connected_callback callback,74 MirConnection **result);
75 void * context);
7675
77 MirWaitHandle* connect(76 MirWaitHandle* connect(
78 int lightdm_id,77 int lightdm_id,
79 const char* app_name,78 const char* app_name,
80 mir_connected_callback callback,79 MirConnection **result);
81 void * context);
8280
83 void select_focus_by_lightdm_id(int lightdm_id);81 void select_focus_by_lightdm_id(int lightdm_id);
8482
@@ -128,7 +126,7 @@
128 struct SurfaceRelease;126 struct SurfaceRelease;
129127
130 void done_disconnect();128 void done_disconnect();
131 void connected(mir_connected_callback callback, void * context);129 void connected(MirConnection **result);
132 void released(SurfaceRelease );130 void released(SurfaceRelease );
133 void done_drm_auth_magic(mir_drm_auth_magic_callback callback, void* context);131 void done_drm_auth_magic(mir_drm_auth_magic_callback callback, void* context);
134};132};
135133
=== modified file 'tests/acceptance-tests/test_client_library.cpp'
--- tests/acceptance-tests/test_client_library.cpp 2013-02-05 18:12:46 +0000
+++ tests/acceptance-tests/test_client_library.cpp 2013-02-07 10:24:19 +0000
@@ -53,12 +53,6 @@
53 {53 {
54 }54 }
5555
56 static void connection_callback(MirConnection * connection, void * context)
57 {
58 ClientConfigCommon * config = reinterpret_cast<ClientConfigCommon *>(context);
59 config->connection = connection;
60 }
61
62 static void create_surface_callback(MirSurface * surface, void * context)56 static void create_surface_callback(MirSurface * surface, void * context)
63 {57 {
64 ClientConfigCommon * config = reinterpret_cast<ClientConfigCommon *>(context);58 ClientConfigCommon * config = reinterpret_cast<ClientConfigCommon *>(context);
@@ -109,7 +103,8 @@
109 {103 {
110 void exec()104 void exec()
111 {105 {
112 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));106 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
107 &connection));
113108
114 ASSERT_TRUE(connection != NULL);109 ASSERT_TRUE(connection != NULL);
115 EXPECT_TRUE(mir_connection_is_valid(connection));110 EXPECT_TRUE(mir_connection_is_valid(connection));
@@ -129,7 +124,8 @@
129 void exec()124 void exec()
130 {125 {
131126
132 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));127 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
128 &connection));
133129
134 ASSERT_TRUE(connection != NULL);130 ASSERT_TRUE(connection != NULL);
135 EXPECT_TRUE(mir_connection_is_valid(connection));131 EXPECT_TRUE(mir_connection_is_valid(connection));
@@ -200,7 +196,8 @@
200196
201 void exec()197 void exec()
202 {198 {
203 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));199 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
200 &connection));
204201
205 ASSERT_TRUE(connection != NULL);202 ASSERT_TRUE(connection != NULL);
206 EXPECT_TRUE(mir_connection_is_valid(connection));203 EXPECT_TRUE(mir_connection_is_valid(connection));
@@ -252,7 +249,8 @@
252 void exec()249 void exec()
253 {250 {
254251
255 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));252 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
253 &connection));
256254
257 ASSERT_TRUE(connection != NULL);255 ASSERT_TRUE(connection != NULL);
258 EXPECT_TRUE(mir_connection_is_valid(connection));256 EXPECT_TRUE(mir_connection_is_valid(connection));
@@ -288,7 +286,8 @@
288 {286 {
289 void exec()287 void exec()
290 {288 {
291 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));289 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
290 &connection));
292 ASSERT_TRUE(connection != NULL);291 ASSERT_TRUE(connection != NULL);
293292
294 MirPlatformPackage platform_package;293 MirPlatformPackage platform_package;
@@ -314,7 +313,8 @@
314 {313 {
315 void exec()314 void exec()
316 {315 {
317 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));316 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
317 &connection));
318 ASSERT_TRUE(connection != NULL);318 ASSERT_TRUE(connection != NULL);
319319
320 MirDisplayInfo display_info;320 MirDisplayInfo display_info;
@@ -338,7 +338,8 @@
338 {338 {
339 void exec()339 void exec()
340 {340 {
341 mir_wait_for(mir_connect("garbage", __PRETTY_FUNCTION__, connection_callback, this));341 mir_wait_for(mir_connect("garbage", __PRETTY_FUNCTION__,
342 &connection));
342 ASSERT_TRUE(connection != NULL);343 ASSERT_TRUE(connection != NULL);
343344
344 char const* error = mir_connection_get_error_message(connection);345 char const* error = mir_connection_get_error_message(connection);
@@ -360,7 +361,8 @@
360 {361 {
361 void exec()362 void exec()
362 {363 {
363 mir_wait_for(mir_connect("garbage", __PRETTY_FUNCTION__, connection_callback, this));364 mir_wait_for(mir_connect("garbage", __PRETTY_FUNCTION__,
365 &connection));
364366
365 MirSurfaceParameters const request_params =367 MirSurfaceParameters const request_params =
366 {368 {
367369
=== modified file 'tests/acceptance-tests/test_focus_management_api.cpp'
--- tests/acceptance-tests/test_focus_management_api.cpp 2013-02-05 18:12:46 +0000
+++ tests/acceptance-tests/test_focus_management_api.cpp 2013-02-07 10:24:19 +0000
@@ -56,12 +56,6 @@
56 {56 {
57 }57 }
5858
59 static void connection_callback(MirConnection* connection, void* context)
60 {
61 ClientConfigCommon* config = reinterpret_cast<ClientConfigCommon *>(context);
62 config->connection = connection;
63 }
64
65 static void create_surface_callback(MirSurface* surface, void* context)59 static void create_surface_callback(MirSurface* surface, void* context)
66 {60 {
67 ClientConfigCommon* config = reinterpret_cast<ClientConfigCommon *>(context);61 ClientConfigCommon* config = reinterpret_cast<ClientConfigCommon *>(context);
@@ -200,8 +194,7 @@
200 mir_test_socket,194 mir_test_socket,
201 lightdm_id,195 lightdm_id,
202 __PRETTY_FUNCTION__,196 __PRETTY_FUNCTION__,
203 connection_callback,197 &connection));
204 this));
205198
206 ASSERT_TRUE(connection != NULL);199 ASSERT_TRUE(connection != NULL);
207200
@@ -229,8 +222,7 @@
229 mir_wait_for(mir_connect(222 mir_wait_for(mir_connect(
230 mir_test_socket,223 mir_test_socket,
231 __PRETTY_FUNCTION__,224 __PRETTY_FUNCTION__,
232 connection_callback,225 &connection));
233 this));
234226
235 wait_for(focus_ready);227 wait_for(focus_ready);
236 mir_select_focus_by_lightdm_id(connection, lightdm_id);228 mir_select_focus_by_lightdm_id(connection, lightdm_id);
237229
=== modified file 'tests/acceptance-tests/test_surfaceloop.cpp'
--- tests/acceptance-tests/test_surfaceloop.cpp 2013-01-11 23:47:40 +0000
+++ tests/acceptance-tests/test_surfaceloop.cpp 2013-02-07 10:24:19 +0000
@@ -96,28 +96,6 @@
96 {96 {
97 }97 }
9898
99 static void connection_callback(MirConnection * connection, void * context)
100 {
101 ClientConfigCommon * config = reinterpret_cast<ClientConfigCommon *>(context);
102 config->connected(connection);
103 }
104
105 void connected(MirConnection * new_connection)
106 {
107 std::unique_lock<std::mutex> lock(guard);
108 connection = new_connection;
109 wait_condition.notify_all();
110 }
111
112 void wait_for_connect()
113 {
114 std::unique_lock<std::mutex> lock(guard);
115 while (!connection)
116 wait_condition.wait(lock);
117 }
118
119 std::mutex guard;
120 std::condition_variable wait_condition;
121 MirConnection * connection;99 MirConnection * connection;
122 static const int max_surface_count = 5;100 static const int max_surface_count = 5;
123 SurfaceSync ssync[max_surface_count];101 SurfaceSync ssync[max_surface_count];
@@ -160,9 +138,8 @@
160 {138 {
161 void exec()139 void exec()
162 {140 {
163 mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);141 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
164142 &connection));
165 wait_for_connect();
166143
167 MirSurfaceParameters request_params =144 MirSurfaceParameters request_params =
168 {145 {
@@ -213,9 +190,8 @@
213 {190 {
214 void exec()191 void exec()
215 {192 {
216 mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);193 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
217194 &connection));
218 wait_for_connect();
219195
220 MirSurfaceParameters request_params =196 MirSurfaceParameters request_params =
221 {197 {
@@ -257,9 +233,8 @@
257 {233 {
258 void exec()234 void exec()
259 {235 {
260 mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);236 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
261237 &connection));
262 wait_for_connect();
263238
264 MirSurfaceParameters request_params =239 MirSurfaceParameters request_params =
265 {240 {
266241
=== modified file 'tests/integration-tests/test_display_info.cpp'
--- tests/integration-tests/test_display_info.cpp 2013-01-11 23:47:40 +0000
+++ tests/integration-tests/test_display_info.cpp 2013-02-07 10:24:19 +0000
@@ -106,12 +106,6 @@
106106
107};107};
108108
109void connection_callback(MirConnection* connection, void* context)
110{
111 auto connection_ptr = static_cast<MirConnection**>(context);
112 *connection_ptr = connection;
113}
114
115}109}
116110
117TEST_F(BespokeDisplayServerTestFixture, display_info_reaches_client)111TEST_F(BespokeDisplayServerTestFixture, display_info_reaches_client)
@@ -139,7 +133,7 @@
139 {133 {
140 MirConnection* connection{nullptr};134 MirConnection* connection{nullptr};
141 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,135 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
142 connection_callback, &connection));136 &connection));
143137
144 MirDisplayInfo info;138 MirDisplayInfo info;
145139
146140
=== modified file 'tests/integration-tests/test_drm_auth_magic.cpp'
--- tests/integration-tests/test_drm_auth_magic.cpp 2013-02-05 18:12:46 +0000
+++ tests/integration-tests/test_drm_auth_magic.cpp 2013-02-07 10:24:19 +0000
@@ -83,12 +83,6 @@
83 MOCK_METHOD1(drm_auth_magic, void(unsigned int));83 MOCK_METHOD1(drm_auth_magic, void(unsigned int));
84};84};
8585
86void connection_callback(MirConnection* connection, void* context)
87{
88 auto connection_ptr = static_cast<MirConnection**>(context);
89 *connection_ptr = connection;
90}
91
92void drm_auth_magic_callback(int status, void* client_context)86void drm_auth_magic_callback(int status, void* client_context)
93{87{
94 auto status_ptr = static_cast<int*>(client_context);88 auto status_ptr = static_cast<int*>(client_context);
@@ -127,7 +121,7 @@
127 {121 {
128 MirConnection* connection{nullptr};122 MirConnection* connection{nullptr};
129 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,123 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
130 connection_callback, &connection));124 &connection));
131125
132 int const no_error{0};126 int const no_error{0};
133 int status{67};127 int status{67};
@@ -176,7 +170,7 @@
176 {170 {
177 MirConnection* connection{nullptr};171 MirConnection* connection{nullptr};
178 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,172 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
179 connection_callback, &connection));173 &connection));
180174
181 int status{67};175 int status{67};
182176
183177
=== modified file 'tests/integration-tests/test_error_reporting.cpp'
--- tests/integration-tests/test_error_reporting.cpp 2013-02-05 18:12:46 +0000
+++ tests/integration-tests/test_error_reporting.cpp 2013-02-07 10:24:19 +0000
@@ -151,28 +151,6 @@
151 {151 {
152 }152 }
153153
154 static void connection_callback(MirConnection * connection, void * context)
155 {
156 ClientConfigCommon * config = reinterpret_cast<ClientConfigCommon *>(context);
157 config->connected(connection);
158 }
159
160 void connected(MirConnection * new_connection)
161 {
162 std::unique_lock<std::mutex> lock(guard);
163 connection = new_connection;
164 wait_condition.notify_all();
165 }
166
167 void wait_for_connect()
168 {
169 std::unique_lock<std::mutex> lock(guard);
170 while (!connection)
171 wait_condition.wait(lock);
172 }
173
174 std::mutex guard;
175 std::condition_variable wait_condition;
176 MirConnection * connection;154 MirConnection * connection;
177 static const int max_surface_count = 5;155 static const int max_surface_count = 5;
178 SurfaceSync ssync[max_surface_count];156 SurfaceSync ssync[max_surface_count];
@@ -255,9 +233,8 @@
255 {233 {
256 void exec()234 void exec()
257 {235 {
258 mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);236 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
259237 &connection));
260 wait_for_connect();
261238
262 ASSERT_TRUE(connection != NULL);239 ASSERT_TRUE(connection != NULL);
263 EXPECT_FALSE(mir_connection_is_valid(connection));240 EXPECT_FALSE(mir_connection_is_valid(connection));
264241
=== modified file 'tests/integration-tests/test_surfaceloop.cpp'
--- tests/integration-tests/test_surfaceloop.cpp 2013-02-05 18:12:46 +0000
+++ tests/integration-tests/test_surfaceloop.cpp 2013-02-07 10:24:19 +0000
@@ -183,28 +183,6 @@
183 {183 {
184 }184 }
185185
186 static void connection_callback(MirConnection * connection, void * context)
187 {
188 ClientConfigCommon * config = reinterpret_cast<ClientConfigCommon *>(context);
189 config->connected(connection);
190 }
191
192 void connected(MirConnection * new_connection)
193 {
194 std::unique_lock<std::mutex> lock(guard);
195 connection = new_connection;
196 wait_condition.notify_all();
197 }
198
199 void wait_for_connect()
200 {
201 std::unique_lock<std::mutex> lock(guard);
202 while (!connection)
203 wait_condition.wait(lock);
204 }
205
206 std::mutex guard;
207 std::condition_variable wait_condition;
208 MirConnection * connection;186 MirConnection * connection;
209 static const int max_surface_count = 5;187 static const int max_surface_count = 5;
210 SurfaceSync ssync[max_surface_count];188 SurfaceSync ssync[max_surface_count];
@@ -270,9 +248,8 @@
270 {248 {
271 void exec()249 void exec()
272 {250 {
273 mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);251 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
274252 &connection));
275 wait_for_connect();
276253
277 ASSERT_TRUE(connection != NULL);254 ASSERT_TRUE(connection != NULL);
278 EXPECT_TRUE(mir_connection_is_valid(connection));255 EXPECT_TRUE(mir_connection_is_valid(connection));
@@ -373,9 +350,8 @@
373 {350 {
374 void exec()351 void exec()
375 {352 {
376 mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);353 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
377354 &connection));
378 wait_for_connect();
379355
380 ASSERT_TRUE(connection != NULL);356 ASSERT_TRUE(connection != NULL);
381 EXPECT_TRUE(mir_connection_is_valid(connection));357 EXPECT_TRUE(mir_connection_is_valid(connection));
@@ -512,9 +488,8 @@
512 {488 {
513 void exec()489 void exec()
514 {490 {
515 mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);491 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
516492 &connection));
517 wait_for_connect();
518493
519 MirSurfaceParameters const request_params =494 MirSurfaceParameters const request_params =
520 {495 {
@@ -561,9 +536,8 @@
561 {536 {
562 void exec()537 void exec()
563 {538 {
564 mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);539 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
565540 &connection));
566 wait_for_connect();
567541
568 MirSurfaceParameters const request_params =542 MirSurfaceParameters const request_params =
569 {543 {
570544
=== modified file 'tests/unit-tests/client/test_client_mir_surface.cpp'
--- tests/unit-tests/client/test_client_mir_surface.cpp 2013-01-02 15:57:13 +0000
+++ tests/unit-tests/client/test_client_mir_surface.cpp 2013-02-07 10:24:19 +0000
@@ -201,10 +201,6 @@
201201
202namespace mt = mir::test;202namespace mt = mir::test;
203203
204void connected_callback(MirConnection* /*connection*/, void * /*client_context*/)
205{
206}
207
208struct CallBack204struct CallBack
209{205{
210 void msg() {}206 void msg() {}
@@ -233,7 +229,7 @@
233 channel = mcl::make_rpc_channel("./test_socket_surface", logger);229 channel = mcl::make_rpc_channel("./test_socket_surface", logger);
234 connection = std::make_shared<MirConnection>(channel, logger, platform_factory);230 connection = std::make_shared<MirConnection>(channel, logger, platform_factory);
235 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",231 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",
236 connected_callback, 0);232 nullptr);
237 wait_handle->wait_for_result();233 wait_handle->wait_for_result();
238 client_comm_channel = std::make_shared<mir::protobuf::DisplayServer::Stub>(channel.get());234 client_comm_channel = std::make_shared<mir::protobuf::DisplayServer::Stub>(channel.get());
239 }235 }
240236
=== modified file 'tests/unit-tests/client/test_mir_connection.cpp'
--- tests/unit-tests/client/test_mir_connection.cpp 2013-01-02 15:57:13 +0000
+++ tests/unit-tests/client/test_mir_connection.cpp 2013-02-07 10:24:19 +0000
@@ -98,10 +98,6 @@
98 std::shared_ptr<mcl::ClientPlatform> platform;98 std::shared_ptr<mcl::ClientPlatform> platform;
99};99};
100100
101void connected_callback(MirConnection* /*connection*/, void * /*client_context*/)
102{
103}
104
105void drm_auth_magic_callback(int status, void* client_context)101void drm_auth_magic_callback(int status, void* client_context)
106{102{
107 auto status_ptr = static_cast<int*>(client_context);103 auto status_ptr = static_cast<int*>(client_context);
@@ -144,7 +140,7 @@
144 .WillOnce(Return(native_display));140 .WillOnce(Return(native_display));
145141
146 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",142 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",
147 connected_callback, 0);143 nullptr);
148 wait_handle->wait_for_result();144 wait_handle->wait_for_result();
149145
150 EGLNativeDisplayType connection_native_display = connection->egl_native_display();146 EGLNativeDisplayType connection_native_display = connection->egl_native_display();
@@ -167,7 +163,7 @@
167 .Times(1);163 .Times(1);
168164
169 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",165 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",
170 connected_callback, 0);166 nullptr);
171 wait_handle->wait_for_result();167 wait_handle->wait_for_result();
172168
173 int const no_error{0};169 int const no_error{0};
@@ -211,7 +207,7 @@
211 .WillOnce(Invoke(fill_display_info));207 .WillOnce(Invoke(fill_display_info));
212208
213 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",209 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",
214 connected_callback, 0);210 nullptr);
215 wait_handle->wait_for_result();211 wait_handle->wait_for_result();
216212
217 MirDisplayInfo info;213 MirDisplayInfo info;
@@ -236,7 +232,7 @@
236 .WillOnce(Invoke(fill_display_info_100));232 .WillOnce(Invoke(fill_display_info_100));
237233
238 MirWaitHandle* wait_handle = connection->connect("MirConnectionTest",234 MirWaitHandle* wait_handle = connection->connect("MirConnectionTest",
239 connected_callback, 0);235 nullptr);
240 wait_handle->wait_for_result();236 wait_handle->wait_for_result();
241237
242 MirDisplayInfo info;238 MirDisplayInfo info;

Subscribers

People subscribed via source and target branches