Mir

Merge lp:~robertcarr/mir/enable-and-demonstrate-inprocess-input into lp:~mir-team/mir/trunk

Proposed by Robert Carr
Status: Merged
Approved by: Robert Carr
Approved revision: no longer in the source branch.
Merged at revision: 682
Proposed branch: lp:~robertcarr/mir/enable-and-demonstrate-inprocess-input
Merge into: lp:~mir-team/mir/trunk
Diff against target: 1066 lines (+215/-143)
28 files modified
examples/CMakeLists.txt (+1/-1)
examples/demo-inprocess-surface-client/CMakeLists.txt (+1/-1)
examples/demo-inprocess-surface-client/demo_inprocess_surface_client.cpp (+1/-1)
examples/demo-inprocess-surface-client/inprocess_egl_client.cpp (+35/-4)
examples/demo-inprocess-surface-client/inprocess_egl_client.h (+19/-4)
include/server/mir/default_server_configuration.h (+2/-1)
include/shared/mir/input/input_platform.h (+5/-5)
include/shared/mir/input/input_receiver_thread.h (+5/-5)
include/shared/mir/input/xkb_mapper.h (+5/-5)
src/client/CMakeLists.txt (+0/-1)
src/client/input/CMakeLists.txt (+0/-13)
src/client/mir_connection.cpp (+3/-3)
src/client/mir_connection.h (+4/-1)
src/client/mir_surface.cpp (+4/-4)
src/client/mir_surface.h (+9/-6)
src/shared/input/CMakeLists.txt (+4/-1)
src/shared/input/android/CMakeLists.txt (+29/-0)
src/shared/input/android/android_input_platform.cpp (+16/-16)
src/shared/input/android/android_input_platform.h (+3/-3)
src/shared/input/android/android_input_receiver.cpp (+18/-18)
src/shared/input/android/android_input_receiver.h (+5/-5)
src/shared/input/android/android_input_receiver_thread.cpp (+8/-8)
src/shared/input/android/android_input_receiver_thread.h (+7/-7)
src/shared/input/xkb_mapper.cpp (+5/-5)
tests/unit-tests/client/input/test_android_input_receiver.cpp (+6/-6)
tests/unit-tests/client/input/test_android_input_receiver_thread.cpp (+7/-7)
tests/unit-tests/client/input/test_xkb_mapper.cpp (+3/-3)
tests/unit-tests/client/test_client_mir_surface.cpp (+10/-9)
To merge this branch: bzr merge lp:~robertcarr/mir/enable-and-demonstrate-inprocess-input
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Kevin DuBois (community) Approve
Review via email: mp+163615@code.launchpad.net

Commit message

Enable usage of in-process input (i.e. reorganize headers), and demonstrate usage in examples/.

Description of the change

Enable usage of in-process input (i.e. reorganize headers), and demonstrate usage in examples/.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

overall, looks ok... a few needs fixings though

should we have mir::client::input in shared/ ? I'd rather just have mir::input in shared, usable on both the server side and client side

106/107: reinterpret_cast not needed here

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote :

I think we're quickly converging on an interface for our internal clients that makes sense. I also think we're suffering from name overloading, specifically on what we want to call the interfaces that provide internal renderloops to the shell. put another way, me::InprocessEGLClient::InprocessEGLClient is quickly converging on something elegant, but I think if I had not wrestled with that code last week, it would be a strange abstraction.
maybe i'll send out a mail or something to discuss

Revision history for this message
Kevin DuBois (kdub) wrote :

> I think we're quickly converging on an interface for our internal clients that
> makes sense. I also think we're suffering from name overloading, specifically
> on what we want to call the interfaces that provide internal renderloops to
> the shell. put another way, me::InprocessEGLClient::InprocessEGLClient is
> quickly converging on something elegant, but I think if I had not wrestled
> with that code last week, it would be a strange abstraction.
> maybe i'll send out a mail or something to discuss

oh, and this branch can land without having that interface, just want to make sure we get to that clean naming and interface for this part of mir :)

Revision history for this message
Robert Carr (robertcarr) wrote :

After discussion on IRC moved the machinery to mir::input::receiver.

Removed reinterpret cast.

r652 and 653

Revision history for this message
Kevin DuBois (kdub) wrote :

seems ok, pending the decision on the rename for 'not over ipc clients'

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/CMakeLists.txt'
2--- examples/CMakeLists.txt 2013-05-07 20:24:11 +0000
3+++ examples/CMakeLists.txt 2013-05-14 00:10:31 +0000
4@@ -120,7 +120,7 @@
5 mir_eglplasma
6 )
7
8-add_subdirectory(demo-inprocess-egl)
9+add_subdirectory(demo-inprocess-surface-client)
10 add_subdirectory(demo-shell)
11
12 install(TARGETS ${DEMO_CLIENTS} RUNTIME DESTINATION bin)
13
14=== renamed directory 'examples/demo-inprocess-egl' => 'examples/demo-inprocess-surface-client'
15=== modified file 'examples/demo-inprocess-surface-client/CMakeLists.txt'
16--- examples/demo-inprocess-egl/CMakeLists.txt 2013-04-24 05:22:20 +0000
17+++ examples/demo-inprocess-surface-client/CMakeLists.txt 2013-05-14 00:10:31 +0000
18@@ -1,7 +1,7 @@
19 include_directories(..)
20
21 add_executable(mir_demo_inprocess_egl
22- demo_inprocess_egl.cpp
23+ demo_inprocess_surface_client.cpp
24 inprocess_egl_client.cpp
25 example_egl_helper.cpp
26 )
27
28=== renamed file 'examples/demo-inprocess-egl/demo_inprocess_egl.cpp' => 'examples/demo-inprocess-surface-client/demo_inprocess_surface_client.cpp'
29--- examples/demo-inprocess-egl/demo_inprocess_egl.cpp 2013-05-09 01:17:23 +0000
30+++ examples/demo-inprocess-surface-client/demo_inprocess_surface_client.cpp 2013-05-14 00:10:31 +0000
31@@ -48,7 +48,7 @@
32 client = std::make_shared<me::InprocessEGLClient>(
33 config.the_main_loop(),
34 config.the_graphics_platform(),
35- config.the_shell_surface_factory());
36+ config.the_session_manager());
37 });
38 ///\internal [main_tag]
39
40
41=== modified file 'examples/demo-inprocess-surface-client/inprocess_egl_client.cpp'
42--- examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-05-09 01:17:23 +0000
43+++ examples/demo-inprocess-surface-client/inprocess_egl_client.cpp 2013-05-14 00:10:31 +0000
44@@ -20,18 +20,23 @@
45 #include "example_egl_helper.h"
46
47 #include "mir/main_loop.h"
48-#include "mir/shell/surface_factory.h"
49+#include "mir/shell/session_manager.h"
50 #include "mir/shell/surface.h"
51 #include "mir/frontend/surface_creation_parameters.h"
52+#include "mir/frontend/session.h"
53 #include "mir/geometry/size.h"
54 #include "mir/compositor/buffer_properties.h"
55 #include "mir/graphics/platform.h"
56+#include "mir/input/input_receiver_thread.h"
57+#include "mir/input/input_platform.h"
58 #include "mir/graphics/internal_client.h"
59
60 #include "graphics.h"
61
62 #include <EGL/egl.h>
63
64+#include <xkbcommon/xkbcommon-keysyms.h>
65+
66 #include <functional>
67
68 #include <assert.h>
69@@ -43,13 +48,16 @@
70 namespace msh = mir::shell;
71 namespace mg = mir::graphics;
72 namespace me = mir::examples;
73+namespace mircv = mir::input::receiver;
74 namespace geom = mir::geometry;
75
76+
77 me::InprocessEGLClient::InprocessEGLClient(std::shared_ptr<mir::MainLoop> const& main_loop,
78 std::shared_ptr<mg::Platform> const& graphics_platform,
79- std::shared_ptr<msh::SurfaceFactory> const& surface_factory)
80+ std::shared_ptr<msh::SessionManager> const& session_manager)
81 : graphics_platform(graphics_platform),
82- surface_factory(surface_factory),
83+
84+ session_manager(session_manager),
85 client_thread(std::mem_fn(&InprocessEGLClient::thread_loop), this),
86 terminate(false)
87 {
88@@ -72,7 +80,17 @@
89 .of_size(surface_size)
90 .of_buffer_usage(mc::BufferUsage::hardware)
91 .of_pixel_format(geom::PixelFormat::argb_8888);
92- auto surface = surface_factory->create_surface(params, mf::SurfaceId(), std::shared_ptr<events::EventSink>());
93+ auto session = session_manager->open_session("Inprocess client",
94+ std::shared_ptr<mir::events::EventSink>());
95+ // TODO: Why do we get an ID? ~racarr
96+ auto surface = session->get_surface(session_manager->create_surface_for(session, params));
97+
98+ auto input_platform = mircv::InputPlatform::create();
99+ input_thread = input_platform->create_input_thread(
100+ surface->client_input_fd(),
101+ std::bind(std::mem_fn(&me::InprocessEGLClient::handle_event), this, std::placeholders::_1));
102+ input_thread->start();
103+
104 auto internal_client = graphics_platform->create_internal_client(surface);
105 me::EGLHelper helper(internal_client->egl_native_display(), internal_client->egl_native_window());
106
107@@ -92,5 +110,18 @@
108
109 gl_animation.step();
110 }
111+
112+ input_thread->stop();
113 ///\internal [loop_tag]
114 }
115+
116+void me::InprocessEGLClient::handle_event(MirEvent *event)
117+{
118+ if (event->type != mir_event_type_key)
119+ return;
120+ if (event->key.action != mir_key_action_down)
121+ return;
122+ if (event->key.key_code != XKB_KEY_Escape)
123+ return;
124+ terminate = true;
125+}
126
127=== modified file 'examples/demo-inprocess-surface-client/inprocess_egl_client.h'
128--- examples/demo-inprocess-egl/inprocess_egl_client.h 2013-05-09 01:17:23 +0000
129+++ examples/demo-inprocess-surface-client/inprocess_egl_client.h 2013-05-14 00:10:31 +0000
130@@ -19,19 +19,29 @@
131 #ifndef MIR_EXAMPLES_INPROCESS_EGL_CLIENT_H_
132 #define MIR_EXAMPLES_INPROCESS_EGL_CLIENT_H_
133
134+#include "mir_toolkit/event.h"
135+
136 #include <thread>
137 #include <memory>
138+#include <atomic>
139
140 namespace mir
141 {
142 class MainLoop;
143+namespace input
144+{
145+namespace receiver
146+{
147+class InputReceiverThread;
148+}
149+}
150 namespace graphics
151 {
152 class Platform;
153 }
154 namespace shell
155 {
156-class SurfaceFactory;
157+class SessionManager;
158 }
159
160 namespace examples
161@@ -43,7 +53,7 @@
162 public:
163 InprocessEGLClient(std::shared_ptr<mir::MainLoop> const& main_loop,
164 std::shared_ptr<graphics::Platform> const& graphics_platform,
165- std::shared_ptr<shell::SurfaceFactory> const& surface_factory);
166+ std::shared_ptr<shell::SessionManager> const& session_manager);
167
168 protected:
169 InprocessEGLClient(InprocessEGLClient const&) = delete;
170@@ -51,11 +61,16 @@
171
172 private:
173 std::shared_ptr<graphics::Platform> const graphics_platform;
174- std::shared_ptr<shell::SurfaceFactory> const surface_factory;
175+ std::shared_ptr<shell::SessionManager> const session_manager;
176
177 std::thread client_thread;
178+
179+ std::shared_ptr<input::receiver::InputReceiverThread> input_thread;
180+
181 void thread_loop();
182- bool terminate;
183+ void handle_event(MirEvent *event);
184+
185+ std::atomic<bool> terminate;
186 };
187
188 }
189
190=== modified file 'include/server/mir/default_server_configuration.h'
191--- include/server/mir/default_server_configuration.h 2013-05-09 14:54:22 +0000
192+++ include/server/mir/default_server_configuration.h 2013-05-14 00:10:31 +0000
193@@ -197,6 +197,8 @@
194 virtual std::shared_ptr<graphics::Platform> the_graphics_platform();
195 virtual std::shared_ptr<time::TimeSource> the_time_source();
196
197+ virtual std::shared_ptr<shell::SessionManager> the_session_manager();
198+
199 protected:
200 // add_options() allows configuration specializations to add their
201 // own options. This MUST be called before the first invocation of
202@@ -205,7 +207,6 @@
203 virtual std::shared_ptr<options::Option> the_options() const;
204
205 virtual std::shared_ptr<input::InputChannelFactory> the_input_channel_factory();
206- virtual std::shared_ptr<shell::SessionManager> the_session_manager();
207
208 CachedPtr<frontend::Communicator> communicator;
209 CachedPtr<shell::SessionManager> session_manager;
210
211=== renamed file 'src/client/input/input_platform.h' => 'include/shared/mir/input/input_platform.h'
212--- src/client/input/input_platform.h 2013-04-24 05:22:20 +0000
213+++ include/shared/mir/input/input_platform.h 2013-05-14 00:10:31 +0000
214@@ -16,8 +16,8 @@
215 * Authored by: Robert Carr <robert.carr@canonical.com>
216 */
217
218-#ifndef MIR_CLIENT_INPUT_PLATFORM_H_
219-#define MIR_CLIENT_INPUT_PLATFORM_H_
220+#ifndef MIR_INPUT_RECEIVER_PLATFORM_H_
221+#define MIR_INPUT_RECEIVER_PLATFORM_H_
222
223 #include "mir_toolkit/event.h"
224
225@@ -26,10 +26,10 @@
226
227 namespace mir
228 {
229-namespace client
230-{
231 namespace input
232 {
233+namespace receiver
234+{
235 class InputReceiverThread;
236
237 // Interface for MirSurface to construct input dispatcher threads.
238@@ -52,4 +52,4 @@
239 }
240 } // namespace mir
241
242-#endif // MIR_CLIENT_INPUT_PLATFORM_H_
243+#endif // MIR_INPUT_RECEIVER_PLATFORM_H_
244
245=== renamed file 'src/client/input/input_receiver_thread.h' => 'include/shared/mir/input/input_receiver_thread.h'
246--- src/client/input/input_receiver_thread.h 2013-04-24 05:22:20 +0000
247+++ include/shared/mir/input/input_receiver_thread.h 2013-05-14 00:10:31 +0000
248@@ -16,15 +16,15 @@
249 * Authored by: Robert Carr <robert.carr@canonical.com>
250 */
251
252-#ifndef MIR_CLIENT_INPUT_RECEIVER_THREAD_H_
253-#define MIR_CLIENT_INPUT_RECEIVER_THREAD_H_
254+#ifndef MIR_INPUT_RECEIVER_RECEIVER_THREAD_H_
255+#define MIR_INPUT_RECEIVER_RECEIVER_THREAD_H_
256
257 namespace mir
258 {
259-namespace client
260-{
261 namespace input
262 {
263+namespace receiver
264+{
265
266 class InputReceiverThread
267 {
268@@ -45,4 +45,4 @@
269 }
270 } // namespace mir
271
272-#endif // MIR_CLIENT_INPUT_RECEIVER_THREAD_H_
273+#endif // MIR_INPUT_RECEIVER_RECEIVER_THREAD_H_
274
275=== renamed file 'src/client/input/xkb_mapper.h' => 'include/shared/mir/input/xkb_mapper.h'
276--- src/client/input/xkb_mapper.h 2013-04-12 17:33:05 +0000
277+++ include/shared/mir/input/xkb_mapper.h 2013-05-14 00:10:31 +0000
278@@ -16,8 +16,8 @@
279 * Authored by: Robert Carr <robert.carr@canonical.com>
280 */
281
282-#ifndef MIR_CLIENT_INPUT_XKB_MAPPER_H_
283-#define MIR_CLIENT_INPUT_XKB_MAPPER_H_
284+#ifndef MIR_INPUT_RECEIVER_XKB_MAPPER_H_
285+#define MIR_INPUT_RECEIVER_XKB_MAPPER_H_
286
287 #include <xkbcommon/xkbcommon.h>
288
289@@ -25,10 +25,10 @@
290
291 namespace mir
292 {
293-namespace client
294-{
295 namespace input
296 {
297+namespace receiver
298+{
299
300 class XKBMapper
301 {
302@@ -53,4 +53,4 @@
303 }
304 }
305
306-#endif // MIR_CLIENT_INPUT_XKB_MAPPER_H_
307+#endif // MIR_INPUT_RECEIVER_XKB_MAPPER_H_
308
309=== modified file 'src/client/CMakeLists.txt'
310--- src/client/CMakeLists.txt 2013-04-24 05:22:20 +0000
311+++ src/client/CMakeLists.txt 2013-05-14 00:10:31 +0000
312@@ -35,7 +35,6 @@
313 mir_basic_rpc_channel.cpp
314 ${PROTO_SRCS}
315 )
316-add_subdirectory(input)
317
318 list(APPEND CLIENT_SOURCES
319 mir_socket_rpc_channel.cpp
320
321=== removed directory 'src/client/input'
322=== removed file 'src/client/input/CMakeLists.txt'
323--- src/client/input/CMakeLists.txt 2013-04-24 05:22:20 +0000
324+++ src/client/input/CMakeLists.txt 1970-01-01 00:00:00 +0000
325@@ -1,13 +0,0 @@
326-list(
327- APPEND CLIENT_SOURCES
328- ${CMAKE_CURRENT_SOURCE_DIR}/android_input_receiver.cpp
329- ${CMAKE_CURRENT_SOURCE_DIR}/android_input_receiver_thread.cpp
330- ${CMAKE_CURRENT_SOURCE_DIR}/android_input_platform.cpp
331- ${CMAKE_CURRENT_SOURCE_DIR}/xkb_mapper.cpp
332-)
333-
334-set(
335- CLIENT_SOURCES
336- ${CLIENT_SOURCES}
337- PARENT_SCOPE
338-)
339
340=== modified file 'src/client/mir_connection.cpp'
341--- src/client/mir_connection.cpp 2013-04-29 23:21:58 +0000
342+++ src/client/mir_connection.cpp 2013-05-14 00:10:31 +0000
343@@ -25,13 +25,13 @@
344 #include "client_buffer_depository.h"
345 #include "make_rpc_channel.h"
346
347-#include "input/input_platform.h"
348+#include "mir/input/input_platform.h"
349
350 #include <thread>
351 #include <cstddef>
352
353 namespace mcl = mir::client;
354-namespace mcli = mcl::input;
355+namespace mircv = mir::input::receiver;
356 namespace mp = mir::protobuf;
357 namespace gp = google::protobuf;
358
359@@ -50,7 +50,7 @@
360 server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL),
361 log(log),
362 client_platform_factory(client_platform_factory),
363- input_platform(mcli::InputPlatform::create())
364+ input_platform(mircv::InputPlatform::create())
365 {
366 channel->set_event_handler(this);
367 {
368
369=== modified file 'src/client/mir_connection.h'
370--- src/client/mir_connection.h 2013-04-29 23:21:58 +0000
371+++ src/client/mir_connection.h 2013-05-14 00:10:31 +0000
372@@ -45,9 +45,12 @@
373 class ClientBufferDepository;
374 class ClientPlatformFactory;
375 class MirBasicRpcChannel;
376+}
377
378 namespace input
379 {
380+namespace receiver
381+{
382 class InputPlatform;
383 }
384 }
385@@ -117,7 +120,7 @@
386 std::shared_ptr<mir::client::ClientPlatform> platform;
387 std::shared_ptr<EGLNativeDisplayType> native_display;
388
389- std::shared_ptr<mir::client::input::InputPlatform> const input_platform;
390+ std::shared_ptr<mir::input::receiver::InputPlatform> const input_platform;
391
392 std::string error_message;
393
394
395=== modified file 'src/client/mir_surface.cpp'
396--- src/client/mir_surface.cpp 2013-05-03 18:39:57 +0000
397+++ src/client/mir_surface.cpp 2013-05-14 00:10:31 +0000
398@@ -22,14 +22,14 @@
399 #include "client_buffer.h"
400 #include "mir_surface.h"
401 #include "mir_connection.h"
402-#include "input/input_receiver_thread.h"
403-#include "input/input_platform.h"
404+#include "mir/input/input_receiver_thread.h"
405+#include "mir/input/input_platform.h"
406
407 #include <cassert>
408
409 namespace geom = mir::geometry;
410 namespace mcl = mir::client;
411-namespace mcli = mir::client::input;
412+namespace mircv = mir::input::receiver;
413 namespace mp = mir::protobuf;
414 namespace gp = google::protobuf;
415
416@@ -38,7 +38,7 @@
417 mp::DisplayServer::Stub & server,
418 std::shared_ptr<mir::client::Logger> const& logger,
419 std::shared_ptr<mcl::ClientBufferFactory> const& factory,
420- std::shared_ptr<mcli::InputPlatform> const& input_platform,
421+ std::shared_ptr<mircv::InputPlatform> const& input_platform,
422 MirSurfaceParameters const & params,
423 mir_surface_lifecycle_callback callback, void * context)
424 : server(server),
425
426=== modified file 'src/client/mir_surface.h'
427--- src/client/mir_surface.h 2013-05-03 22:53:42 +0000
428+++ src/client/mir_surface.h 2013-05-14 00:10:31 +0000
429@@ -35,14 +35,17 @@
430
431 namespace mir
432 {
433-namespace client
434-{
435-class ClientBuffer;
436 namespace input
437 {
438+namespace receiver
439+{
440 class InputPlatform;
441 class InputReceiverThread;
442 }
443+}
444+namespace client
445+{
446+class ClientBuffer;
447
448 struct MemoryRegion;
449 }
450@@ -59,7 +62,7 @@
451 mir::protobuf::DisplayServer::Stub & server,
452 std::shared_ptr<mir::client::Logger> const& logger,
453 std::shared_ptr<mir::client::ClientBufferFactory> const& buffer_factory,
454- std::shared_ptr<mir::client::input::InputPlatform> const& input_platform,
455+ std::shared_ptr<mir::input::receiver::InputPlatform> const& input_platform,
456 MirSurfaceParameters const& params,
457 mir_surface_lifecycle_callback callback, void * context);
458
459@@ -110,7 +113,7 @@
460
461 std::shared_ptr<mir::client::MemoryRegion> secured_region;
462 std::shared_ptr<mir::client::ClientBufferDepository> buffer_depository;
463- std::shared_ptr<mir::client::input::InputPlatform> const input_platform;
464+ std::shared_ptr<mir::input::receiver::InputPlatform> const input_platform;
465
466 std::shared_ptr<mir::client::Logger> logger;
467 std::shared_ptr<EGLNativeWindowType> accelerated_window;
468@@ -121,7 +124,7 @@
469 int attrib_cache[mir_surface_attrib_arraysize_];
470
471 std::function<void(MirEvent const*)> handle_event_callback;
472- std::shared_ptr<mir::client::input::InputReceiverThread> input_thread;
473+ std::shared_ptr<mir::input::receiver::InputReceiverThread> input_thread;
474 };
475
476 #endif /* MIR_CLIENT_PRIVATE_MIR_WAIT_HANDLE_H_ */
477
478=== modified file 'src/shared/input/CMakeLists.txt'
479--- src/shared/input/CMakeLists.txt 2013-04-24 05:22:20 +0000
480+++ src/shared/input/CMakeLists.txt 2013-05-14 00:10:31 +0000
481@@ -16,9 +16,11 @@
482
483 set(
484 ANDROID_SHARED_INPUT_SOURCES
485- ${CMAKE_CURRENT_SOURCE_DIR}/android_input_lexicon.cpp
486+ ${CMAKE_CURRENT_SOURCE_DIR}/xkb_mapper.cpp
487 )
488
489+add_subdirectory(android)
490+
491 add_library(
492 mirsharedinput STATIC
493 ${ANDROID_SHARED_INPUT_SOURCES}
494@@ -28,4 +30,5 @@
495 mirsharedinput
496
497 android-input
498+ ${XKBCOMMON_LIBRARIES}
499 )
500
501=== added directory 'src/shared/input/android'
502=== added file 'src/shared/input/android/CMakeLists.txt'
503--- src/shared/input/android/CMakeLists.txt 1970-01-01 00:00:00 +0000
504+++ src/shared/input/android/CMakeLists.txt 2013-05-14 00:10:31 +0000
505@@ -0,0 +1,29 @@
506+# Copyright © 2012 Canonical Ltd.
507+#
508+# This program is free software: you can redistribute it and/or modify
509+# it under the terms of the GNU Lesser General Public License version 3 as
510+# published by the Free Software Foundation.
511+#
512+# This program is distributed in the hope that it will be useful,
513+# but WITHOUT ANY WARRANTY; without even the implied warranty of
514+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
515+# GNU Lesser General Public License for more details.
516+#
517+# You should have received a copy of the GNU Lesser General Public License
518+# along with this program. If not, see <http://www.gnu.org/licenses/>.
519+#
520+# Authored by: Robert Carr <robert.carr@canonical.com>
521+
522+list(
523+ APPEND ANDROID_SHARED_INPUT_SOURCES
524+ ${CMAKE_CURRENT_SOURCE_DIR}/android_input_lexicon.cpp
525+ ${CMAKE_CURRENT_SOURCE_DIR}/android_input_receiver.cpp
526+ ${CMAKE_CURRENT_SOURCE_DIR}/android_input_receiver_thread.cpp
527+ ${CMAKE_CURRENT_SOURCE_DIR}/android_input_platform.cpp
528+)
529+
530+set(
531+ ANDROID_SHARED_INPUT_SOURCES
532+ ${ANDROID_SHARED_INPUT_SOURCES}
533+ PARENT_SCOPE
534+)
535
536=== renamed file 'src/shared/input/android_input_lexicon.cpp' => 'src/shared/input/android/android_input_lexicon.cpp'
537=== renamed file 'src/client/input/android_input_platform.cpp' => 'src/shared/input/android/android_input_platform.cpp'
538--- src/client/input/android_input_platform.cpp 2013-04-24 05:22:20 +0000
539+++ src/shared/input/android/android_input_platform.cpp 2013-05-14 00:10:31 +0000
540@@ -20,25 +20,25 @@
541 #include "android_input_receiver.h"
542 #include "android_input_receiver_thread.h"
543
544-namespace mcli = mir::client::input;
545-namespace mclia = mcli::android;
546-
547-mclia::AndroidInputPlatform::AndroidInputPlatform()
548-{
549-}
550-
551-mclia::AndroidInputPlatform::~AndroidInputPlatform()
552-{
553-}
554-
555-std::shared_ptr<mcli::InputReceiverThread> mclia::AndroidInputPlatform::create_input_thread(
556+namespace mircv = mir::input::receiver;
557+namespace mircva = mircv::android;
558+
559+mircva::AndroidInputPlatform::AndroidInputPlatform()
560+{
561+}
562+
563+mircva::AndroidInputPlatform::~AndroidInputPlatform()
564+{
565+}
566+
567+std::shared_ptr<mircv::InputReceiverThread> mircva::AndroidInputPlatform::create_input_thread(
568 int fd, std::function<void(MirEvent*)> const& callback)
569 {
570- auto receiver = std::make_shared<mclia::InputReceiver>(fd);
571- return std::make_shared<mclia::InputReceiverThread>(receiver, callback);
572+ auto receiver = std::make_shared<mircva::InputReceiver>(fd);
573+ return std::make_shared<mircva::InputReceiverThread>(receiver, callback);
574 }
575
576-std::shared_ptr<mcli::InputPlatform> mcli::InputPlatform::create()
577+std::shared_ptr<mircv::InputPlatform> mircv::InputPlatform::create()
578 {
579- return std::make_shared<mclia::AndroidInputPlatform>();
580+ return std::make_shared<mircva::AndroidInputPlatform>();
581 }
582
583=== renamed file 'src/client/input/android_input_platform.h' => 'src/shared/input/android/android_input_platform.h'
584--- src/client/input/android_input_platform.h 2013-04-24 05:22:20 +0000
585+++ src/shared/input/android/android_input_platform.h 2013-05-14 00:10:31 +0000
586@@ -19,14 +19,14 @@
587 #ifndef MIR_CLIENT_ANDROID_INPUT_PLATFORM_H_
588 #define MIR_CLIENT_ANDROID_INPUT_PLATFORM_H_
589
590-#include "input_platform.h"
591+#include "mir/input/input_platform.h"
592
593 namespace mir
594 {
595-namespace client
596-{
597 namespace input
598 {
599+namespace receiver
600+{
601 namespace android
602 {
603
604
605=== renamed file 'src/client/input/android_input_receiver.cpp' => 'src/shared/input/android/android_input_receiver.cpp'
606--- src/client/input/android_input_receiver.cpp 2013-04-24 05:22:20 +0000
607+++ src/shared/input/android/android_input_receiver.cpp 2013-05-14 00:10:31 +0000
608@@ -17,41 +17,41 @@
609 */
610
611 #include "android_input_receiver.h"
612-#include "xkb_mapper.h"
613
614+#include "mir/input/xkb_mapper.h"
615 #include "mir/input/android/android_input_lexicon.h"
616
617 #include <androidfw/InputTransport.h>
618 #include <utils/Looper.h>
619
620-namespace mcli = mir::client::input;
621-namespace mclia = mcli::android;
622+namespace mircv = mir::input::receiver;
623+namespace mircva = mircv::android;
624
625 namespace mia = mir::input::android;
626
627-mclia::InputReceiver::InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel)
628+mircva::InputReceiver::InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel)
629 : input_channel(input_channel),
630 input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel)),
631 looper(new droidinput::Looper(true)),
632 fd_added(false),
633- xkb_mapper(std::make_shared<mcli::XKBMapper>())
634+ xkb_mapper(std::make_shared<mircv::XKBMapper>())
635 {
636 }
637
638-mclia::InputReceiver::InputReceiver(int fd)
639+mircva::InputReceiver::InputReceiver(int fd)
640 : input_channel(new droidinput::InputChannel(droidinput::String8(""), fd)),
641 input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel)),
642 looper(new droidinput::Looper(true)),
643 fd_added(false),
644- xkb_mapper(std::make_shared<mcli::XKBMapper>())
645-{
646-}
647-
648-mclia::InputReceiver::~InputReceiver()
649-{
650-}
651-
652-int mclia::InputReceiver::fd() const
653+ xkb_mapper(std::make_shared<mircv::XKBMapper>())
654+{
655+}
656+
657+mircva::InputReceiver::~InputReceiver()
658+{
659+}
660+
661+int mircva::InputReceiver::fd() const
662 {
663 return input_channel->getFd();
664 }
665@@ -59,7 +59,7 @@
666 namespace
667 {
668
669-static void map_key_event(std::shared_ptr<mcli::XKBMapper> const& xkb_mapper, MirEvent &ev)
670+static void map_key_event(std::shared_ptr<mircv::XKBMapper> const& xkb_mapper, MirEvent &ev)
671 {
672 // TODO: As XKBMapper is used to track modifier state we need to use a seperate instance
673 // of XKBMapper per device id (or modify XKBMapper semantics)
674@@ -77,7 +77,7 @@
675
676 // TODO: We use a droidinput::Looper here for polling functionality but it might be nice to integrate
677 // with the existing client io_service ~racarr ~tvoss
678-bool mclia::InputReceiver::next_event(std::chrono::milliseconds const& timeout, MirEvent &ev)
679+bool mircva::InputReceiver::next_event(std::chrono::milliseconds const& timeout, MirEvent &ev)
680 {
681 droidinput::InputEvent *android_event;
682 uint32_t event_sequence_id;
683@@ -113,7 +113,7 @@
684 return handled_event;
685 }
686
687-void mclia::InputReceiver::wake()
688+void mircva::InputReceiver::wake()
689 {
690 looper->wake();
691 }
692
693=== renamed file 'src/client/input/android_input_receiver.h' => 'src/shared/input/android/android_input_receiver.h'
694--- src/client/input/android_input_receiver.h 2013-04-24 05:22:20 +0000
695+++ src/shared/input/android/android_input_receiver.h 2013-05-14 00:10:31 +0000
696@@ -16,8 +16,8 @@
697 * Authored by: Robert Carr <robert.carr@canonical.com>
698 */
699
700-#ifndef MIR_INPUT_ANDROID_INPUT_RECEIVER_H_
701-#define MIR_INPUT_ANDROID_INPUT_RECEIVER_H_
702+#ifndef MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_H_
703+#define MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_H_
704
705 #include "mir_toolkit/event.h"
706
707@@ -38,10 +38,10 @@
708
709 namespace mir
710 {
711-namespace client
712-{
713 namespace input
714 {
715+namespace receiver
716+{
717 class XKBMapper;
718
719 namespace android
720@@ -85,4 +85,4 @@
721 }
722 } // namespace mir
723
724-#endif // MIR_INPUT_ANDROID_INPUT_RECEIVER_H_
725+#endif // MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_H_
726
727=== renamed file 'src/client/input/android_input_receiver_thread.cpp' => 'src/shared/input/android/android_input_receiver_thread.cpp'
728--- src/client/input/android_input_receiver_thread.cpp 2013-04-24 05:22:20 +0000
729+++ src/shared/input/android/android_input_receiver_thread.cpp 2013-05-14 00:10:31 +0000
730@@ -21,9 +21,9 @@
731
732 #include <thread>
733
734-namespace mclia = mir::client::input::android;
735+namespace mircva = mir::input::receiver::android;
736
737-mclia::InputReceiverThread::InputReceiverThread(std::shared_ptr<mclia::InputReceiver> const& receiver,
738+mircva::InputReceiverThread::InputReceiverThread(std::shared_ptr<mircva::InputReceiver> const& receiver,
739 std::function<void(MirEvent*)> const& event_handling_callback)
740 : receiver(receiver),
741 handler(event_handling_callback),
742@@ -31,7 +31,7 @@
743 {
744 }
745
746-mclia::InputReceiverThread::~InputReceiverThread()
747+mircva::InputReceiverThread::~InputReceiverThread()
748 {
749 if (running)
750 stop();
751@@ -39,24 +39,24 @@
752 join();
753 }
754
755-void mclia::InputReceiverThread::start()
756+void mircva::InputReceiverThread::start()
757 {
758 running = true;
759- thread = std::thread(std::mem_fn(&mclia::InputReceiverThread::thread_loop), this);
760+ thread = std::thread(std::mem_fn(&mircva::InputReceiverThread::thread_loop), this);
761 }
762
763-void mclia::InputReceiverThread::stop()
764+void mircva::InputReceiverThread::stop()
765 {
766 running = false;
767 receiver->wake();
768 }
769
770-void mclia::InputReceiverThread::join()
771+void mircva::InputReceiverThread::join()
772 {
773 thread.join();
774 }
775
776-void mclia::InputReceiverThread::thread_loop()
777+void mircva::InputReceiverThread::thread_loop()
778 {
779 while (running)
780 {
781
782=== renamed file 'src/client/input/android_input_receiver_thread.h' => 'src/shared/input/android/android_input_receiver_thread.h'
783--- src/client/input/android_input_receiver_thread.h 2013-04-24 05:22:20 +0000
784+++ src/shared/input/android/android_input_receiver_thread.h 2013-05-14 00:10:31 +0000
785@@ -16,10 +16,10 @@
786 * Authored by: Robert Carr <robert.carr@canonical.com>
787 */
788
789-#ifndef MIR_INPUT_ANDROID_INPUT_RECEIVER_THREAD_H_
790-#define MIR_INPUT_ANDROID_INPUT_RECEIVER_THREAD_H_
791+#ifndef MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_THREAD_H_
792+#define MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_THREAD_H_
793
794-#include "input_receiver_thread.h"
795+#include "mir/input/input_receiver_thread.h"
796
797 #include "mir_toolkit/event.h"
798
799@@ -30,16 +30,16 @@
800
801 namespace mir
802 {
803-namespace client
804-{
805 namespace input
806 {
807+namespace receiver
808+{
809 namespace android
810 {
811 class InputReceiver;
812
813 /// Responsible for polling an InputReceiver to read and dispatch events when appropriate.
814-class InputReceiverThread : public input::InputReceiverThread
815+class InputReceiverThread : public receiver::InputReceiverThread
816 {
817 public:
818 InputReceiverThread(std::shared_ptr<InputReceiver> const& receiver,
819@@ -68,4 +68,4 @@
820 }
821 } // namespace mir
822
823-#endif // MIR_INPUT_ANDROID_INPUT_RECEIVER_THREAD_H_
824+#endif // MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_THREAD_H_
825
826=== renamed file 'src/client/input/xkb_mapper.cpp' => 'src/shared/input/xkb_mapper.cpp'
827--- src/client/input/xkb_mapper.cpp 2013-04-15 14:47:44 +0000
828+++ src/shared/input/xkb_mapper.cpp 2013-05-14 00:10:31 +0000
829@@ -16,11 +16,11 @@
830 * Authored by: Robert Carr <robert.carr@canonical.com>
831 */
832
833-#include "xkb_mapper.h"
834+#include "mir/input/xkb_mapper.h"
835
836 #include <string.h>
837
838-namespace mcli = mir::client::input;
839+namespace mircv = mir::input::receiver;
840
841 namespace
842 {
843@@ -47,7 +47,7 @@
844 };
845 }
846
847-mcli::XKBMapper::XKBMapper()
848+mircv::XKBMapper::XKBMapper()
849 {
850 xkb_rule_names names;
851 names.rules = "evdev";
852@@ -85,7 +85,7 @@
853
854 }
855
856-xkb_keysym_t mcli::XKBMapper::press_and_map_key(int scan_code)
857+xkb_keysym_t mircv::XKBMapper::press_and_map_key(int scan_code)
858 {
859 uint32_t xkb_scan_code = to_xkb_scan_code(scan_code);
860 xkb_state_update_key(state.get(), xkb_scan_code, XKB_KEY_DOWN);
861@@ -93,7 +93,7 @@
862 return keysym_for_scan_code(state.get(), xkb_scan_code);
863 }
864
865-xkb_keysym_t mcli::XKBMapper::release_and_map_key(int scan_code)
866+xkb_keysym_t mircv::XKBMapper::release_and_map_key(int scan_code)
867 {
868 uint32_t xkb_scan_code = to_xkb_scan_code(scan_code);
869 xkb_state_update_key(state.get(), xkb_scan_code, XKB_KEY_UP);
870
871=== modified file 'tests/unit-tests/client/input/test_android_input_receiver.cpp'
872--- tests/unit-tests/client/input/test_android_input_receiver.cpp 2013-04-24 05:22:20 +0000
873+++ tests/unit-tests/client/input/test_android_input_receiver.cpp 2013-05-14 00:10:31 +0000
874@@ -16,7 +16,7 @@
875 * Authored by: Robert Carr <robert.carr@canonical.com>
876 */
877
878-#include "src/client/input/android_input_receiver.h"
879+#include "src/shared/input/android/android_input_receiver.h"
880 #include "mir_toolkit/event.h"
881
882 #include <androidfw/InputTransport.h>
883@@ -27,7 +27,7 @@
884 #include <unistd.h>
885 #include <memory>
886
887-namespace mclia = mir::client::input::android;
888+namespace mircva = mir::input::receiver::android;
889
890 namespace droidinput = android;
891
892@@ -141,14 +141,14 @@
893
894 TEST_F(AndroidInputReceiverSetup, receiever_takes_channel_fd)
895 {
896- mclia::InputReceiver receiver(android_client_channel);
897+ mircva::InputReceiver receiver(android_client_channel);
898
899 EXPECT_EQ(android_client_channel->getFd(), receiver.fd());
900 }
901
902 TEST_F(AndroidInputReceiverSetup, receiver_receives_key_events)
903 {
904- mclia::InputReceiver receiver(android_client_channel);
905+ mircva::InputReceiver receiver(android_client_channel);
906 TestingInputProducer producer(android_server_channel);
907
908 producer.produce_a_key_event();
909@@ -164,7 +164,7 @@
910
911 TEST_F(AndroidInputReceiverSetup, receiver_handles_events)
912 {
913- mclia::InputReceiver receiver(android_client_channel);
914+ mircva::InputReceiver receiver(android_client_channel);
915 TestingInputProducer producer(android_server_channel);
916
917 producer.produce_a_key_event();
918@@ -180,7 +180,7 @@
919
920 TEST_F(AndroidInputReceiverSetup, receiver_consumes_batched_motion_events)
921 {
922- mclia::InputReceiver receiver(android_client_channel);
923+ mircva::InputReceiver receiver(android_client_channel);
924 TestingInputProducer producer(android_server_channel);
925
926 // Produce 3 motion events before client handles any.
927
928=== modified file 'tests/unit-tests/client/input/test_android_input_receiver_thread.cpp'
929--- tests/unit-tests/client/input/test_android_input_receiver_thread.cpp 2013-04-24 05:22:20 +0000
930+++ tests/unit-tests/client/input/test_android_input_receiver_thread.cpp 2013-05-14 00:10:31 +0000
931@@ -16,8 +16,8 @@
932 * Authored by: Robert Carr <robert.carr@canonical.com>
933 */
934
935-#include "src/client/input/android_input_receiver_thread.h"
936-#include "src/client/input/android_input_receiver.h"
937+#include "src/shared/input/android/android_input_receiver_thread.h"
938+#include "src/shared/input/android/android_input_receiver.h"
939
940 #include "mir_toolkit/mir_client_library.h"
941
942@@ -30,7 +30,7 @@
943
944 #include <fcntl.h>
945
946-namespace mclia = mir::client::input::android;
947+namespace mircva = mir::input::receiver::android;
948
949 namespace
950 {
951@@ -40,7 +40,7 @@
952 MOCK_METHOD1(handle_event, void(MirEvent*));
953 };
954
955-struct MockInputReceiver : public mclia::InputReceiver
956+struct MockInputReceiver : public mircva::InputReceiver
957 {
958 MockInputReceiver(int fd)
959 : InputReceiver(fd)
960@@ -77,7 +77,7 @@
961 {
962 using namespace ::testing;
963
964- mclia::InputReceiverThread input_thread(input_receiver,
965+ mircva::InputReceiverThread input_thread(input_receiver,
966 std::function<void(MirEvent*)>());
967 {
968 InSequence seq;
969@@ -105,7 +105,7 @@
970 MockEventHandler &handler;
971 } input_delegate(mock_handler);
972
973- mclia::InputReceiverThread input_thread(input_receiver, input_delegate);
974+ mircva::InputReceiverThread input_thread(input_receiver, input_delegate);
975 {
976 InSequence seq;
977
978@@ -138,7 +138,7 @@
979 std::atomic<bool> &handled;
980 } input_delegate(handled);
981
982- mclia::InputReceiverThread input_thread(input_receiver, input_delegate);
983+ mircva::InputReceiverThread input_thread(input_receiver, input_delegate);
984 {
985 InSequence seq;
986
987
988=== modified file 'tests/unit-tests/client/input/test_xkb_mapper.cpp'
989--- tests/unit-tests/client/input/test_xkb_mapper.cpp 2013-04-08 22:50:00 +0000
990+++ tests/unit-tests/client/input/test_xkb_mapper.cpp 2013-05-14 00:10:31 +0000
991@@ -16,7 +16,7 @@
992 * Authored by: Robert Carr <robert.carr@canonical.com>
993 */
994
995-#include "src/client/input/xkb_mapper.h"
996+#include "mir/input/xkb_mapper.h"
997
998 #include <xkbcommon/xkbcommon-keysyms.h>
999 #include <xkbcommon/xkbcommon.h>
1000@@ -25,11 +25,11 @@
1001
1002 #include <gtest/gtest.h>
1003
1004-namespace mcli = mir::client::input;
1005+namespace mircv = mir::input::receiver;
1006
1007 TEST(XKBMapper, maps_generic_us_english_keys)
1008 {
1009- mcli::XKBMapper mapper;
1010+ mircv::XKBMapper mapper;
1011
1012 EXPECT_EQ(static_cast<xkb_keysym_t>(XKB_KEY_4), mapper.press_and_map_key(KEY_4));
1013 EXPECT_EQ(static_cast<xkb_keysym_t>(XKB_KEY_Shift_L), mapper.press_and_map_key(KEY_LEFTSHIFT));
1014
1015=== modified file 'tests/unit-tests/client/test_client_mir_surface.cpp'
1016--- tests/unit-tests/client/test_client_mir_surface.cpp 2013-05-09 15:23:09 +0000
1017+++ tests/unit-tests/client/test_client_mir_surface.cpp 2013-05-14 00:10:31 +0000
1018@@ -25,9 +25,10 @@
1019 #include "src/client/client_platform_factory.h"
1020 #include "src/client/mir_surface.h"
1021 #include "src/client/mir_connection.h"
1022-#include "src/client/input/input_platform.h"
1023-#include "src/client/input/input_receiver_thread.h"
1024+
1025 #include "mir/frontend/resource_cache.h"
1026+#include "mir/input/input_platform.h"
1027+#include "mir/input/input_receiver_thread.h"
1028
1029 #include "mir_test/test_protobuf_server.h"
1030 #include "mir_test/stub_server_tool.h"
1031@@ -43,7 +44,7 @@
1032 #include <fcntl.h>
1033
1034 namespace mcl = mir::client;
1035-namespace mcli = mcl::input;
1036+namespace mircv = mir::input::receiver;
1037 namespace mp = mir::protobuf;
1038 namespace geom = mir::geometry;
1039
1040@@ -230,20 +231,20 @@
1041 }
1042 };
1043
1044-struct StubClientInputPlatform : public mcli::InputPlatform
1045+struct StubClientInputPlatform : public mircv::InputPlatform
1046 {
1047- std::shared_ptr<mcli::InputReceiverThread> create_input_thread(int /* fd */, std::function<void(MirEvent*)> const& /* callback */)
1048+ std::shared_ptr<mircv::InputReceiverThread> create_input_thread(int /* fd */, std::function<void(MirEvent*)> const& /* callback */)
1049 {
1050- return std::shared_ptr<mcli::InputReceiverThread>();
1051+ return std::shared_ptr<mircv::InputReceiverThread>();
1052 }
1053 };
1054
1055-struct MockClientInputPlatform : public mcli::InputPlatform
1056+struct MockClientInputPlatform : public mircv::InputPlatform
1057 {
1058- MOCK_METHOD2(create_input_thread, std::shared_ptr<mcli::InputReceiverThread>(int, std::function<void(MirEvent*)> const&));
1059+ MOCK_METHOD2(create_input_thread, std::shared_ptr<mircv::InputReceiverThread>(int, std::function<void(MirEvent*)> const&));
1060 };
1061
1062-struct MockInputReceiverThread : public mcli::InputReceiverThread
1063+struct MockInputReceiverThread : public mircv::InputReceiverThread
1064 {
1065 MOCK_METHOD0(start, void());
1066 MOCK_METHOD0(stop, void());

Subscribers

People subscribed via source and target branches