Mir

Merge lp:mir/0.3 into lp:mir/ubuntu

Proposed by Cemil Azizoglu
Status: Merged
Merged at revision: 1189
Proposed branch: lp:mir/0.3
Merge into: lp:mir/ubuntu
Diff against target: 22111 lines (+9848/-3603)
336 files modified
3rd_party/android-deps/std/Thread.h (+5/-2)
CMakeLists.txt (+1/-1)
debian/changelog (+43/-0)
debian/control (+2/-2)
debian/libmirserver21.install (+1/-1)
examples/CMakeLists.txt (+6/-2)
examples/buffer_render_target.cpp (+1/-1)
examples/demo-inprocess-surface-client/inprocess_egl_client.cpp (+1/-1)
examples/demo-shell/demo_renderer.cpp (+25/-13)
examples/demo-shell/demo_renderer.h (+2/-1)
examples/demo-shell/demo_shell.cpp (+3/-2)
examples/demo-shell/window_manager.cpp (+7/-0)
examples/eglcounter.cpp (+3/-2)
examples/eglflash.c (+21/-11)
examples/egltriangle.c (+3/-2)
examples/prompt_session.c (+231/-0)
examples/render_surfaces.cpp (+1/-2)
include/client/mir_toolkit/mir_connection.h (+0/-20)
include/client/mir_toolkit/mir_prompt_session.h (+87/-0)
include/platform/mir/graphics/buffer.h (+2/-1)
include/platform/mir/graphics/buffer_id.h (+1/-1)
include/platform/mir/graphics/display_buffer.h (+6/-4)
include/platform/mir/graphics/platform.h (+11/-2)
include/server/mir/asio_main_loop.h (+2/-0)
include/server/mir/compositor/buffer_stream.h (+3/-1)
include/server/mir/compositor/destination_alpha.h (+36/-0)
include/server/mir/compositor/display_buffer_compositor.h (+1/-3)
include/server/mir/compositor/frame_dropping_policy.h (+69/-0)
include/server/mir/compositor/frame_dropping_policy_factory.h (+57/-0)
include/server/mir/compositor/gl_renderer.h (+8/-2)
include/server/mir/compositor/renderer_factory.h (+3/-1)
include/server/mir/default_server_configuration.h (+9/-0)
include/server/mir/frontend/prompt_session.h (+48/-0)
include/server/mir/frontend/session_mediator_report.h (+11/-1)
include/server/mir/frontend/shell.h (+10/-0)
include/server/mir/frontend/surface.h (+4/-10)
include/server/mir/graphics/cursor_images.h (+2/-0)
include/server/mir/scene/null_prompt_session_listener.h (+40/-0)
include/server/mir/scene/null_surface_observer.h (+1/-0)
include/server/mir/scene/prompt_session.h (+37/-0)
include/server/mir/scene/prompt_session_creation_parameters.h (+36/-0)
include/server/mir/scene/prompt_session_listener.h (+52/-0)
include/server/mir/scene/prompt_session_manager.h (+110/-0)
include/server/mir/scene/session.h (+3/-0)
include/server/mir/scene/surface.h (+4/-0)
include/server/mir/scene/surface_observer.h (+5/-0)
include/server/mir/shell/session_coordinator_wrapper.h (+14/-0)
include/server/mir/time/timer.h (+8/-1)
include/shared/mir/thread_name.h (+29/-0)
include/shared/mir_toolkit/client_types.h (+28/-2)
include/shared/mir_toolkit/common.h (+6/-0)
include/shared/mir_toolkit/event.h (+10/-1)
include/test/mir_test/barrier.h (+61/-0)
include/test/mir_test/current_thread_name.h (+34/-0)
include/test/mir_test/fake_clock.h (+72/-0)
include/test/mir_test/signal.h (+63/-0)
include/test/mir_test/test_protobuf_client.h (+17/-0)
include/test/mir_test_doubles/fake_ipc_factory.h (+10/-8)
include/test/mir_test_doubles/fake_renderable.h (+31/-6)
include/test/mir_test_doubles/mock_buffer.h (+1/-1)
include/test/mir_test_doubles/mock_buffer_stream.h (+2/-1)
include/test/mir_test_doubles/mock_display_buffer.h (+2/-4)
include/test/mir_test_doubles/mock_display_device.h (+2/-3)
include/test/mir_test_doubles/mock_frame_dropping_policy_factory.h (+83/-0)
include/test/mir_test_doubles/mock_frontend_surface.h (+2/-0)
include/test/mir_test_doubles/mock_gl.h (+1/-0)
include/test/mir_test_doubles/mock_prompt_session_listener.h (+48/-0)
include/test/mir_test_doubles/mock_scene_session.h (+3/-0)
include/test/mir_test_doubles/mock_shell.h (+12/-0)
include/test/mir_test_doubles/mock_surface.h (+1/-0)
include/test/mir_test_doubles/mock_swapping_gl_context.h (+1/-0)
include/test/mir_test_doubles/mock_timer.h (+52/-0)
include/test/mir_test_doubles/mock_virtual_terminal.h (+48/-0)
include/test/mir_test_doubles/null_client_event_sink.h (+42/-0)
include/test/mir_test_doubles/null_display_buffer.h (+1/-1)
include/test/mir_test_doubles/null_display_buffer_compositor_factory.h (+1/-1)
include/test/mir_test_doubles/null_pixel_buffer.h (+43/-0)
include/test/mir_test_doubles/null_prompt_session.h (+37/-0)
include/test/mir_test_doubles/null_prompt_session_manager.h (+82/-0)
include/test/mir_test_doubles/null_virtual_terminal.h (+4/-2)
include/test/mir_test_doubles/platform_factory.h (+46/-0)
include/test/mir_test_doubles/stub_buffer.h (+17/-12)
include/test/mir_test_doubles/stub_buffer_stream.h (+8/-1)
include/test/mir_test_doubles/stub_display_builder.h (+1/-1)
include/test/mir_test_doubles/stub_frame_dropping_policy_factory.h (+58/-0)
include/test/mir_test_doubles/stub_renderable.h (+51/-4)
include/test/mir_test_doubles/stub_scene_session.h (+14/-1)
include/test/mir_test_doubles/stub_scene_surface.h (+4/-0)
include/test/mir_test_doubles/stub_shell.h (+19/-0)
include/test/mir_test_doubles/stub_swapping_gl_context.h (+5/-0)
include/test/mir_test_framework/in_process_server.h (+7/-16)
include/test/mir_test_framework/input_testing_client_configuration.h (+4/-4)
include/test/mir_test_framework/server_runner.h (+60/-0)
src/client/CMakeLists.txt (+4/-1)
src/client/connection_configuration.h (+4/-0)
src/client/connection_surface_map.h (+1/-0)
src/client/default_connection_configuration.cpp (+20/-1)
src/client/default_connection_configuration.h (+4/-0)
src/client/event_distributor.h (+37/-0)
src/client/event_handler_register.h (+47/-0)
src/client/event_sink.h (+44/-0)
src/client/logging/input_receiver_report.cpp (+1/-0)
src/client/mir_connection.cpp (+13/-36)
src/client/mir_connection.h (+5/-8)
src/client/mir_connection_api.cpp (+0/-18)
src/client/mir_event_distributor.cpp (+56/-0)
src/client/mir_event_distributor.h (+43/-0)
src/client/mir_prompt_session.cpp (+203/-0)
src/client/mir_prompt_session.h (+94/-0)
src/client/mir_prompt_session_api.cpp (+118/-0)
src/client/mir_screencast.cpp (+3/-0)
src/client/mir_surface.cpp (+18/-3)
src/client/mir_surface.h (+1/-0)
src/client/mir_wait_handle.cpp (+8/-16)
src/client/rpc/make_rpc_channel.h (+3/-1)
src/client/rpc/make_socket_rpc_channel.cpp (+4/-3)
src/client/rpc/mir_socket_rpc_channel.cpp (+26/-7)
src/client/rpc/mir_socket_rpc_channel.h (+6/-2)
src/client/surface_map.cpp (+19/-4)
src/platform/graphics/android/CMakeLists.txt (+1/-1)
src/platform/graphics/android/android_display.cpp (+1/-2)
src/platform/graphics/android/android_display.h (+1/-1)
src/platform/graphics/android/android_platform.cpp (+33/-8)
src/platform/graphics/android/buffer.cpp (+1/-1)
src/platform/graphics/android/buffer.h (+1/-1)
src/platform/graphics/android/display_buffer.cpp (+12/-41)
src/platform/graphics/android/display_buffer.h (+7/-6)
src/platform/graphics/android/display_device.h (+5/-3)
src/platform/graphics/android/fb_device.cpp (+10/-16)
src/platform/graphics/android/fb_device.h (+2/-3)
src/platform/graphics/android/gl_context.cpp (+83/-45)
src/platform/graphics/android/gl_context.h (+45/-28)
src/platform/graphics/android/hwc_device.cpp (+36/-15)
src/platform/graphics/android/hwc_device.h (+7/-4)
src/platform/graphics/android/hwc_fallback_gl_renderer.cpp (+1/-1)
src/platform/graphics/android/hwc_fb_device.cpp (+14/-56)
src/platform/graphics/android/hwc_fb_device.h (+2/-6)
src/platform/graphics/android/hwc_logger.h (+2/-0)
src/platform/graphics/android/hwc_loggers.cpp (+30/-1)
src/platform/graphics/android/hwc_loggers.h (+18/-7)
src/platform/graphics/android/output_builder.cpp (+11/-4)
src/platform/graphics/android/output_builder.h (+4/-1)
src/platform/graphics/android/overlay_optimization.h (+37/-0)
src/platform/graphics/android/resource_factory.cpp (+4/-31)
src/platform/graphics/android/resource_factory.h (+3/-2)
src/platform/graphics/android/swapping_gl_context.h (+47/-0)
src/platform/graphics/mesa/CMakeLists.txt (+1/-0)
src/platform/graphics/mesa/buffer_allocator.cpp (+1/-1)
src/platform/graphics/mesa/buffer_texture_binder.h (+1/-1)
src/platform/graphics/mesa/bypass.cpp (+6/-7)
src/platform/graphics/mesa/bypass.h (+9/-11)
src/platform/graphics/mesa/display.cpp (+5/-5)
src/platform/graphics/mesa/display_buffer.cpp (+25/-9)
src/platform/graphics/mesa/display_buffer.h (+4/-3)
src/platform/graphics/mesa/gbm_buffer.cpp (+2/-2)
src/platform/graphics/mesa/gbm_buffer.h (+1/-1)
src/platform/graphics/mesa/linux_virtual_terminal.cpp (+23/-17)
src/platform/graphics/mesa/linux_virtual_terminal.h (+3/-2)
src/platform/graphics/mesa/platform.cpp (+26/-7)
src/platform/graphics/mesa/platform.h (+3/-1)
src/platform/graphics/mesa/shm_buffer.cpp (+1/-1)
src/platform/graphics/mesa/shm_buffer.h (+1/-1)
src/platform/graphics/mesa/virtual_terminal.h (+1/-0)
src/server/CMakeLists.txt (+2/-1)
src/server/asio_main_loop.cpp (+20/-6)
src/server/compositor/CMakeLists.txt (+1/-1)
src/server/compositor/buffer_queue.cpp (+54/-3)
src/server/compositor/buffer_queue.h (+6/-1)
src/server/compositor/buffer_stream_factory.cpp (+6/-4)
src/server/compositor/buffer_stream_factory.h (+4/-4)
src/server/compositor/buffer_stream_surfaces.cpp (+7/-6)
src/server/compositor/buffer_stream_surfaces.h (+2/-1)
src/server/compositor/default_configuration.cpp (+15/-1)
src/server/compositor/default_display_buffer_compositor.cpp (+8/-37)
src/server/compositor/default_display_buffer_compositor.h (+1/-3)
src/server/compositor/default_display_buffer_compositor_factory.cpp (+4/-1)
src/server/compositor/gl_renderer.cpp (+21/-4)
src/server/compositor/gl_renderer_factory.cpp (+5/-2)
src/server/compositor/gl_renderer_factory.h (+2/-1)
src/server/compositor/multi_threaded_compositor.cpp (+74/-152)
src/server/compositor/multi_threaded_compositor.h (+1/-1)
src/server/compositor/recently_used_cache.cpp (+1/-1)
src/server/compositor/screencast_display_buffer.cpp (+6/-6)
src/server/compositor/screencast_display_buffer.h (+2/-2)
src/server/compositor/temporary_buffers.cpp (+2/-2)
src/server/compositor/temporary_buffers.h (+1/-1)
src/server/compositor/timeout_frame_dropping_policy_factory.cpp (+92/-0)
src/server/compositor/timeout_frame_dropping_policy_factory.h (+56/-0)
src/server/default_server_configuration.cpp (+11/-0)
src/server/frontend/default_configuration.cpp (+2/-1)
src/server/frontend/default_ipc_factory.cpp (+9/-5)
src/server/frontend/default_ipc_factory.h (+8/-4)
src/server/frontend/protobuf_message_processor.cpp (+15/-3)
src/server/frontend/published_socket_connector.cpp (+2/-0)
src/server/frontend/session_mediator.cpp (+121/-11)
src/server/frontend/session_mediator.h (+28/-9)
src/server/graphics/default_configuration.cpp (+2/-1)
src/server/graphics/nested/nested_output.cpp (+7/-6)
src/server/graphics/nested/nested_output.h (+2/-1)
src/server/graphics/offscreen/display_buffer.cpp (+5/-5)
src/server/graphics/offscreen/display_buffer.h (+1/-1)
src/server/input/android/android_input_window_handle.cpp (+1/-0)
src/server/input/android/default_android_input_configuration.cpp (+1/-1)
src/server/input/default_configuration.cpp (+1/-1)
src/server/report/logging/session_mediator_report.cpp (+20/-0)
src/server/report/logging/session_mediator_report.h (+8/-0)
src/server/report/lttng/session_mediator_report.cpp (+12/-0)
src/server/report/lttng/session_mediator_report.h (+4/-0)
src/server/report/lttng/session_mediator_report_tp.h (+22/-0)
src/server/report/null/session_mediator_report.cpp (+16/-0)
src/server/report/null/session_mediator_report.h (+8/-0)
src/server/scene/CMakeLists.txt (+2/-0)
src/server/scene/application_session.cpp (+21/-0)
src/server/scene/application_session.h (+3/-0)
src/server/scene/basic_surface.cpp (+44/-13)
src/server/scene/basic_surface.h (+6/-0)
src/server/scene/default_configuration.cpp (+16/-1)
src/server/scene/gl_pixel_buffer.cpp (+1/-1)
src/server/scene/legacy_surface_change_notification.cpp (+6/-0)
src/server/scene/legacy_surface_change_notification.h (+1/-0)
src/server/scene/null_surface_observer.cpp (+2/-0)
src/server/scene/prompt_session_container.cpp (+189/-0)
src/server/scene/prompt_session_container.h (+158/-0)
src/server/scene/prompt_session_manager_impl.cpp (+232/-0)
src/server/scene/prompt_session_manager_impl.h (+96/-0)
src/server/scene/session_manager.cpp (+47/-3)
src/server/scene/session_manager.h (+14/-2)
src/server/scene/surface_allocator.cpp (+3/-0)
src/server/scene/surface_allocator.h (+6/-0)
src/server/scene/threaded_snapshot_strategy.cpp (+2/-0)
src/server/shell/session_coordinator_wrapper.cpp (+28/-2)
src/shared/CMakeLists.txt (+1/-0)
src/shared/protobuf/mir_protobuf.proto (+15/-4)
src/shared/threadname/CMakeLists.txt (+23/-0)
src/shared/threadname/thread_name.cpp (+32/-0)
tests/acceptance-tests/CMakeLists.txt (+3/-2)
tests/acceptance-tests/test_client_cursor_api.cpp (+76/-2)
tests/acceptance-tests/test_client_input.cpp (+32/-36)
tests/acceptance-tests/test_client_library.cpp (+752/-0)
tests/acceptance-tests/test_client_library_drm.cpp (+16/-33)
tests/acceptance-tests/test_client_library_old.cpp (+14/-1054)
tests/acceptance-tests/test_client_surface_swap_buffers.cpp (+8/-13)
tests/acceptance-tests/test_client_surfaces.cpp (+108/-226)
tests/acceptance-tests/test_nested_mir.cpp (+4/-0)
tests/acceptance-tests/test_prompt_session_client_api.cpp (+421/-0)
tests/acceptance-tests/test_server_shutdown.cpp (+2/-2)
tests/acceptance-tests/test_trust_session_helper.cpp (+0/-215)
tests/integration-tests/compositor/test_buffer_stream.cpp (+49/-16)
tests/integration-tests/compositor/test_swapping_swappers.cpp (+3/-1)
tests/integration-tests/frontend/test_application_mediator_report.cpp (+182/-0)
tests/integration-tests/graphics/android/test_buffer_integration.cpp (+4/-1)
tests/integration-tests/graphics/android/test_display_integration.cpp (+4/-2)
tests/integration-tests/graphics/android/test_internal_client.cpp (+3/-2)
tests/integration-tests/graphics/mesa/test_buffer_integration.cpp (+12/-4)
tests/integration-tests/test_session.cpp (+4/-10)
tests/integration-tests/test_session_manager.cpp (+3/-1)
tests/integration-tests/test_surface_first_frame_sync.cpp (+2/-1)
tests/integration-tests/test_surface_stack_with_compositor.cpp (+17/-35)
tests/integration-tests/test_swapinterval.cpp (+9/-2)
tests/mir_test/CMakeLists.txt (+3/-0)
tests/mir_test/current_thread_name.cpp (+34/-0)
tests/mir_test/fake_clock.cpp (+53/-0)
tests/mir_test/signal.cpp (+46/-0)
tests/mir_test_doubles/CMakeLists.txt (+3/-0)
tests/mir_test_doubles/mock_frame_dropping_policy_factory.cpp (+70/-0)
tests/mir_test_doubles/mock_gl.cpp (+6/-0)
tests/mir_test_doubles/mock_timer.cpp (+149/-0)
tests/mir_test_doubles/platform_factory.cpp (+60/-0)
tests/mir_test_doubles/test_protobuf_client.cpp (+27/-1)
tests/mir_test_framework/CMakeLists.txt (+1/-1)
tests/mir_test_framework/input_testing_client_configuration.cpp (+6/-10)
tests/mir_test_framework/server_runner.cpp (+13/-19)
tests/mir_test_framework/stubbed_server_configuration.cpp (+1/-1)
tests/performance-tests/test_glmark2-es2-mir.cpp (+4/-4)
tests/unit-tests/CMakeLists.txt (+1/-0)
tests/unit-tests/client/CMakeLists.txt (+2/-0)
tests/unit-tests/client/test_client_mir_surface.cpp (+95/-78)
tests/unit-tests/client/test_event_distributor.cpp (+152/-0)
tests/unit-tests/client/test_mir_prompt_session.cpp (+233/-0)
tests/unit-tests/client/test_wait_handle.cpp (+17/-3)
tests/unit-tests/compositor/CMakeLists.txt (+1/-1)
tests/unit-tests/compositor/test_buffer_queue.cpp (+142/-49)
tests/unit-tests/compositor/test_buffer_stream.cpp (+4/-2)
tests/unit-tests/compositor/test_compositing_screencast.cpp (+3/-3)
tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp (+40/-195)
tests/unit-tests/compositor/test_gl_renderer.cpp (+36/-6)
tests/unit-tests/compositor/test_gl_texture_cache.cpp (+4/-4)
tests/unit-tests/compositor/test_multi_threaded_compositor.cpp (+71/-84)
tests/unit-tests/compositor/test_occlusion.cpp (+5/-5)
tests/unit-tests/compositor/test_screencast_display_buffer.cpp (+11/-1)
tests/unit-tests/compositor/test_temporary_buffers.cpp (+3/-3)
tests/unit-tests/compositor/test_timeout_frame_dropping_policy.cpp (+186/-0)
tests/unit-tests/frontend/CMakeLists.txt (+1/-0)
tests/unit-tests/frontend/stress_protobuf_communicator.cpp (+4/-1)
tests/unit-tests/frontend/test_basic_connector.cpp (+57/-0)
tests/unit-tests/frontend/test_session_mediator.cpp (+9/-8)
tests/unit-tests/frontend/test_session_mediator_android.cpp (+1/-2)
tests/unit-tests/frontend/test_session_mediator_mesa.cpp (+1/-2)
tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp (+33/-33)
tests/unit-tests/graphics/android/test_fb_device.cpp (+10/-12)
tests/unit-tests/graphics/android/test_hwc_device.cpp (+114/-97)
tests/unit-tests/graphics/android/test_hwc_display.cpp (+49/-106)
tests/unit-tests/graphics/android/test_hwc_fb_device.cpp (+11/-26)
tests/unit-tests/graphics/android/test_hwc_logger.cpp (+17/-1)
tests/unit-tests/graphics/android/test_hwc_wrapper.cpp (+1/-0)
tests/unit-tests/graphics/android/test_output_builder.cpp (+10/-7)
tests/unit-tests/graphics/android/test_resource_factory.cpp (+10/-5)
tests/unit-tests/graphics/mesa/CMakeLists.txt (+1/-0)
tests/unit-tests/graphics/mesa/test_buffer_allocator.cpp (+2/-7)
tests/unit-tests/graphics/mesa/test_bypass.cpp (+41/-41)
tests/unit-tests/graphics/mesa/test_display.cpp (+10/-18)
tests/unit-tests/graphics/mesa/test_display_buffer.cpp (+85/-51)
tests/unit-tests/graphics/mesa/test_display_configuration.cpp (+3/-8)
tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp (+4/-10)
tests/unit-tests/graphics/mesa/test_gbm_buffer.cpp (+8/-14)
tests/unit-tests/graphics/mesa/test_linux_virtual_terminal.cpp (+36/-3)
tests/unit-tests/graphics/mesa/test_platform.cpp (+79/-8)
tests/unit-tests/graphics/mesa/test_shm_buffer.cpp (+1/-1)
tests/unit-tests/graphics/nested/CMakeLists.txt (+1/-0)
tests/unit-tests/graphics/nested/test_nested_display_buffer.cpp (+82/-0)
tests/unit-tests/graphics/test_display.cpp (+3/-15)
tests/unit-tests/graphics/test_graphics_platform.cpp (+2/-13)
tests/unit-tests/graphics/test_program_factory.cpp (+6/-5)
tests/unit-tests/scene/CMakeLists.txt (+2/-0)
tests/unit-tests/scene/test_application_session.cpp (+45/-0)
tests/unit-tests/scene/test_basic_surface.cpp (+25/-9)
tests/unit-tests/scene/test_gl_pixel_buffer.cpp (+2/-2)
tests/unit-tests/scene/test_prompt_session_container.cpp (+273/-0)
tests/unit-tests/scene/test_prompt_session_manager.cpp (+217/-0)
tests/unit-tests/scene/test_session_manager.cpp (+14/-5)
tests/unit-tests/scene/test_surface.cpp (+24/-6)
tests/unit-tests/scene/test_surface_impl.cpp (+15/-2)
tests/unit-tests/scene/test_surface_stack.cpp (+7/-0)
tests/unit-tests/scene/test_threaded_snapshot_strategy.cpp (+41/-6)
tests/unit-tests/test_asio_main_loop.cpp (+62/-23)
tests/unit-tests/test_thread_name.cpp (+100/-0)
To merge this branch: bzr merge lp:mir/0.3
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
Review via email: mp+223101@code.launchpad.net

Commit message

Mir 0.3.0 release.

Description of the change

Mir 0.3.0 release. Please see the changelog for a list of changes.

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

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '3rd_party/android-deps/std/Thread.h'
2--- 3rd_party/android-deps/std/Thread.h 2014-05-22 11:31:21 +0000
3+++ 3rd_party/android-deps/std/Thread.h 2014-06-18 12:52:17 +0000
4@@ -35,6 +35,7 @@
5 namespace mir
6 {
7 void terminate_with_current_exception();
8+void set_thread_name(std::string const&);
9 }
10
11 namespace mir_input
12@@ -54,13 +55,15 @@
13 int32_t priority = PRIORITY_DEFAULT,
14 size_t stack = 0)
15 {
16- (void)name; (void)priority; (void)stack;
17+ (void)priority; (void)stack;
18+ std::string const name_str{name};
19
20 status.store(NO_ERROR);
21 exit_pending.store(false);
22
23- thread = std::thread([this]() -> void
24+ thread = std::thread([name_str,this]() -> void
25 {
26+ mir::set_thread_name(name_str);
27 try
28 {
29 if (auto result = readyToRun()) status.store(result);
30
31=== modified file 'CMakeLists.txt'
32--- CMakeLists.txt 2014-06-05 12:55:18 +0000
33+++ CMakeLists.txt 2014-06-18 12:52:17 +0000
34@@ -27,7 +27,7 @@
35 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
36
37 set(MIR_VERSION_MAJOR 0)
38-set(MIR_VERSION_MINOR 2) # This should change at least with every MIRSERVER_ABI
39+set(MIR_VERSION_MINOR 3) # This should change at least with every MIRSERVER_ABI
40 set(MIR_VERSION_PATCH 0)
41
42 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
43
44=== modified file 'debian/changelog'
45--- debian/changelog 2014-06-05 14:02:57 +0000
46+++ debian/changelog 2014-06-18 12:52:17 +0000
47@@ -1,3 +1,46 @@
48+mir (0.3.0-0ubuntu1) UNRELEASED; urgency=medium
49+
50+ * New upstream release 0.3.0 (https://launchpad.net/mir/+milestone/0.3.0)
51+ - mirclient ABI unchanged, still at 7. Clients do not need rebuilding.
52+ - mirserver ABI bumped to 21. Shells need rebuilding.
53+ . Divide swap_client_buffers into separate functions.
54+ . Allow buffer swapping even when compositor is turned off or blocked.
55+ (LP: #1308843, 1308844)
56+ . Wire the cursor client API through the session mediator to the surface
57+ observer.
58+ . Generate destination alpha for alpha enabled display buffers.
59+ . Named threads.
60+ . Support for prompt sessions :
61+ https://wiki.ubuntu.com/Security/TrustStoreAndSessions.
62+
63+ - mirscreencast screenshots now produce images with correct color instead
64+ of transparency.
65+ - Rename bind_to_texture->gl_bind_to_texture.
66+ - Refinements in test infrastructure.
67+ - Phablet: allow disabling the overlays via a command line switch.
68+ - Unify the DisplayBuffer interface's optimization functions
69+ behind post_renderables_if_optimizable.
70+ - Clean up the DisplayDevice interface so that it doesn't require the
71+ functions are called in any particular order.
72+ - Phablet: graphics: android: preserve buffer ownership for onscreen
73+ overlay layers until the subsequent display posting.
74+ - Allow the platform to register emergency cleanup handlers in order to
75+ restore the graphics system to a sane state when the server fails
76+ abruptly.
77+
78+ - Bugs fixed:
79+ . Mirscreencast outputs translucency instead of shadows, producing
80+ incorrect images. (LP: #1301210)
81+ . JSON formatting. (LP: #1324902)
82+ . Fix input_area_contains to work properly in global coordinates even
83+ when input_rectangles is updated. (LP: #1261647)
84+ . Allow a moment for clients to acquire a buffer. (LP: #1317370)
85+ . Generate correct alpha by changing blending equation to assume
86+ pre-multiplied alpha sources. (LP: #1318852)
87+ . Rework the recomposition messaging so that the DisplayBufferCompositor
88+ is no longer involved. (LP: #1319907)
89+ -- Cemil Azizoglu <cemil.azizoglu@canonical.com> Thu, 12 Jun 2014 20:15:39 +0800
90+
91 mir (0.2.0+14.10.20140605-0ubuntu1) utopic; urgency=medium
92
93 [ Daniel van Vugt ]
94
95=== modified file 'debian/control'
96--- debian/control 2014-05-28 07:43:51 +0000
97+++ debian/control 2014-06-18 12:52:17 +0000
98@@ -72,7 +72,7 @@
99 .
100 Contains the protocol's definition files.
101
102-Package: libmirserver20
103+Package: libmirserver21
104 Section: libs
105 Architecture: i386 amd64 armhf arm64
106 Multi-Arch: same
107@@ -150,7 +150,7 @@
108 Architecture: i386 amd64 armhf arm64
109 Multi-Arch: same
110 Pre-Depends: ${misc:Pre-Depends}
111-Depends: libmirserver20 (= ${binary:Version}),
112+Depends: libmirserver21 (= ${binary:Version}),
113 libmirprotobuf-dev (= ${binary:Version}),
114 mircommon-dev (= ${binary:Version}),
115 libglm-dev,
116
117=== renamed file 'debian/libmirserver20.install' => 'debian/libmirserver21.install'
118--- debian/libmirserver20.install 2014-05-07 02:56:33 +0000
119+++ debian/libmirserver21.install 2014-06-18 12:52:17 +0000
120@@ -1,1 +1,1 @@
121-usr/lib/*/libmirserver.so.20
122+usr/lib/*/libmirserver.so.21
123
124=== modified file 'examples/CMakeLists.txt'
125--- examples/CMakeLists.txt 2014-05-28 07:43:51 +0000
126+++ examples/CMakeLists.txt 2014-06-18 12:52:17 +0000
127@@ -92,6 +92,9 @@
128
129 )
130
131+add_executable(mir_demo_client_prompt_session prompt_session.c)
132+target_link_libraries(mir_demo_client_prompt_session mirclient)
133+
134 add_library(mirdraw STATIC graphics_utils.cpp)
135 target_link_libraries(mirdraw ${GLESv2_LIBRARIES})
136
137@@ -143,7 +146,7 @@
138 server_configuration.cpp
139 )
140
141-target_link_libraries(mir_demo_standalone_input_filter
142+target_link_libraries(mir_demo_standalone_input_filter
143 mirserver
144 )
145
146@@ -158,8 +161,9 @@
147 mir_demo_client_multiwin
148 mir_demo_client_display_config
149 mir_demo_client_progressbar
150+ mir_demo_client_prompt_session
151 mir_demo_standalone_input_filter
152- mir_demo_standalone_render_to_fb
153+ mir_demo_standalone_render_to_fb
154 mir_demo_standalone_render_surfaces
155 )
156
157
158=== modified file 'examples/buffer_render_target.cpp'
159--- examples/buffer_render_target.cpp 2014-03-06 06:05:17 +0000
160+++ examples/buffer_render_target.cpp 2014-06-18 12:52:17 +0000
161@@ -77,7 +77,7 @@
162 /* Set up color buffer... */
163 glGenTextures(1, &color_tex);
164 glBindTexture(GL_TEXTURE_2D, color_tex);
165- buffer.bind_to_texture();
166+ buffer.gl_bind_to_texture();
167 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
168 GL_TEXTURE_2D, color_tex, 0);
169
170
171=== modified file 'examples/demo-inprocess-surface-client/inprocess_egl_client.cpp'
172--- examples/demo-inprocess-surface-client/inprocess_egl_client.cpp 2014-04-15 05:31:19 +0000
173+++ examples/demo-inprocess-surface-client/inprocess_egl_client.cpp 2014-06-18 12:52:17 +0000
174@@ -102,7 +102,7 @@
175
176 auto input_platform = mircv::InputPlatform::create();
177 input_thread = input_platform->create_input_thread(
178- surface->client_input_fd(),
179+ surface->client_input_fd(),
180 std::bind(std::mem_fn(&me::InprocessEGLClient::handle_event), this, std::placeholders::_1));
181 input_thread->start();
182
183
184=== modified file 'examples/demo-shell/demo_renderer.cpp'
185--- examples/demo-shell/demo_renderer.cpp 2014-06-03 17:20:17 +0000
186+++ examples/demo-shell/demo_renderer.cpp 2014-06-18 12:52:17 +0000
187@@ -18,6 +18,7 @@
188
189 #include "demo_renderer.h"
190 #include <mir/graphics/renderable.h>
191+#include <mir/compositor/destination_alpha.h>
192 #include <mir/compositor/recently_used_cache.h>
193 #include <cmath>
194
195@@ -93,15 +94,6 @@
196 {
197 Color col = color;
198
199- // Cut out the corner in a circular shape.
200- if (x < cx && y < cy)
201- {
202- int dx = cx - x;
203- int dy = cy - y;
204- if (dx * dx + dy * dy >= radius_sqr)
205- col.a = 0;
206- }
207-
208 // Set gradient
209 if (y < cy)
210 {
211@@ -113,6 +105,15 @@
212 col.b += (highlight - col.b) * brighten;
213 }
214
215+ // Cut out the corner in a circular shape.
216+ if (x < cx && y < cy)
217+ {
218+ int dx = cx - x;
219+ int dy = cy - y;
220+ if (dx * dx + dy * dy >= radius_sqr)
221+ col = {0, 0, 0, 0};
222+ }
223+
224 image[y * width + x] = col;
225 }
226 }
227@@ -137,10 +138,12 @@
228
229 DemoRenderer::DemoRenderer(
230 graphics::GLProgramFactory const& program_factory,
231- geometry::Rectangle const& display_area)
232+ geometry::Rectangle const& display_area,
233+ compositor::DestinationAlpha dest_alpha)
234 : GLRenderer(program_factory,
235 std::unique_ptr<graphics::GLTextureCache>(new compositor::RecentlyUsedCache()),
236- display_area)
237+ display_area,
238+ dest_alpha)
239 , corner_radius(0.5f)
240 {
241 shadow_corner_tex = generate_shadow_corner_texture(0.4f);
242@@ -157,8 +160,17 @@
243
244 void DemoRenderer::begin() const
245 {
246- glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
247+ bool const opaque = destination_alpha() == compositor::DestinationAlpha::opaque;
248+ if (opaque)
249+ glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
250+ else
251+ glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
252+
253+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
254 glClear(GL_COLOR_BUFFER_BIT);
255+
256+ if (opaque)
257+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
258 }
259
260 void DemoRenderer::tessellate(std::vector<graphics::GLPrimitive>& primitives,
261@@ -261,7 +273,7 @@
262
263 // Shadows always need blending...
264 glEnable(GL_BLEND);
265- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
266+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
267 }
268
269 void DemoRenderer::tessellate_frame(std::vector<graphics::GLPrimitive>& primitives,
270
271=== modified file 'examples/demo-shell/demo_renderer.h'
272--- examples/demo-shell/demo_renderer.h 2014-05-19 02:55:29 +0000
273+++ examples/demo-shell/demo_renderer.h 2014-06-18 12:52:17 +0000
274@@ -29,7 +29,8 @@
275 class DemoRenderer : public compositor::GLRenderer
276 {
277 public:
278- DemoRenderer(graphics::GLProgramFactory const& factory, geometry::Rectangle const& display_area);
279+ DemoRenderer(graphics::GLProgramFactory const& factory, geometry::Rectangle const& display_area,
280+ compositor::DestinationAlpha dest_alpha);
281 ~DemoRenderer();
282
283 void begin() const override;
284
285=== modified file 'examples/demo-shell/demo_shell.cpp'
286--- examples/demo-shell/demo_shell.cpp 2014-04-24 08:42:12 +0000
287+++ examples/demo-shell/demo_shell.cpp 2014-06-18 12:52:17 +0000
288@@ -53,9 +53,10 @@
289 }
290
291 std::unique_ptr<compositor::Renderer> create_renderer_for(
292- geometry::Rectangle const& rect) override
293+ geometry::Rectangle const& rect,
294+ mir::compositor::DestinationAlpha dest_alpha) override
295 {
296- return std::unique_ptr<compositor::Renderer>(new DemoRenderer(*gl_program_factory, rect));
297+ return std::unique_ptr<compositor::Renderer>(new DemoRenderer(*gl_program_factory, rect, dest_alpha));
298 }
299 private:
300 std::shared_ptr<graphics::GLProgramFactory> const gl_program_factory;
301
302=== modified file 'examples/demo-shell/window_manager.cpp'
303--- examples/demo-shell/window_manager.cpp 2014-05-22 11:31:21 +0000
304+++ examples/demo-shell/window_manager.cpp 2014-06-18 12:52:17 +0000
305@@ -156,6 +156,13 @@
306 return true;
307 }
308 else if ((event.key.modifiers & mir_key_modifier_alt) &&
309+ (event.key.modifiers & mir_key_modifier_ctrl) &&
310+ (event.key.scan_code == KEY_ESC))
311+ {
312+ std::abort();
313+ return true;
314+ }
315+ else if ((event.key.modifiers & mir_key_modifier_alt) &&
316 (event.key.modifiers & mir_key_modifier_ctrl))
317 {
318 MirOrientation orientation = mir_orientation_normal;
319
320=== modified file 'examples/eglcounter.cpp'
321--- examples/eglcounter.cpp 2014-05-07 02:56:33 +0000
322+++ examples/eglcounter.cpp 2014-06-18 12:52:17 +0000
323@@ -201,7 +201,7 @@
324 };
325
326 /* Colours from http://design.ubuntu.com/brand/colour-palette */
327-#define MID_AUBERGINE 0.368627451f, 0.152941176f, 0.31372549f
328+#define MID_AUBERGINE(x) x*0.368627451f, x*0.152941176f, x*0.31372549f
329 #define ORANGE 0.866666667f, 0.282352941f, 0.141414141f
330
331 int main(int argc, char *argv[])
332@@ -254,7 +254,8 @@
333 return 2;
334 }
335
336- glClearColor(MID_AUBERGINE, mir_eglapp_background_opacity);
337+ float const opacity = mir_eglapp_background_opacity;
338+ glClearColor(MID_AUBERGINE(opacity), opacity);
339 glViewport(0, 0, width, height);
340
341 glUseProgram(prog);
342
343=== modified file 'examples/eglflash.c'
344--- examples/eglflash.c 2013-10-07 09:21:27 +0000
345+++ examples/eglflash.c 2014-06-18 12:52:17 +0000
346@@ -23,6 +23,11 @@
347 #include <unistd.h>
348 #include <GLES2/gl2.h>
349
350+typedef struct Color
351+{
352+ GLfloat r, g, b, a;
353+} Color;
354+
355 int main(int argc, char *argv[])
356 {
357 unsigned int width = 0, height = 0;
358@@ -30,20 +35,25 @@
359 if (!mir_eglapp_init(argc, argv, &width, &height))
360 return 1;
361
362+ float const opacity = mir_eglapp_background_opacity;
363+ Color red = {opacity, 0.0f, 0.0f, opacity};
364+ Color green = {0.0f, opacity, 0.0f, opacity};
365+ Color blue = {0.0f, 0.0f, opacity, opacity};
366+
367 /* This is probably the simplest GL you can do */
368 while (mir_eglapp_running())
369 {
370- glClearColor(1.0f, 0.0f, 0.0f, mir_eglapp_background_opacity);
371- glClear(GL_COLOR_BUFFER_BIT);
372- mir_eglapp_swap_buffers();
373- sleep(1);
374-
375- glClearColor(0.0f, 1.0f, 0.0f, mir_eglapp_background_opacity);
376- glClear(GL_COLOR_BUFFER_BIT);
377- mir_eglapp_swap_buffers();
378- sleep(1);
379-
380- glClearColor(0.0f, 0.0f, 1.0f, mir_eglapp_background_opacity);
381+ glClearColor(red.r, red.g, red.b, red.a);
382+ glClear(GL_COLOR_BUFFER_BIT);
383+ mir_eglapp_swap_buffers();
384+ sleep(1);
385+
386+ glClearColor(green.r, green.g, green.b, green.a);
387+ glClear(GL_COLOR_BUFFER_BIT);
388+ mir_eglapp_swap_buffers();
389+ sleep(1);
390+
391+ glClearColor(blue.r, blue.g, blue.b, blue.a);
392 glClear(GL_COLOR_BUFFER_BIT);
393 mir_eglapp_swap_buffers();
394 sleep(1);
395
396=== modified file 'examples/egltriangle.c'
397--- examples/egltriangle.c 2013-10-07 09:21:27 +0000
398+++ examples/egltriangle.c 2014-06-18 12:52:17 +0000
399@@ -44,7 +44,7 @@
400 }
401
402 /* Colours from http://design.ubuntu.com/brand/colour-palette */
403-#define MID_AUBERGINE 0.368627451f, 0.152941176f, 0.31372549f
404+#define MID_AUBERGINE(x) x*0.368627451f, x*0.152941176f, x*0.31372549f
405 #define ORANGE 0.866666667f, 0.282352941f, 0.141414141f
406
407 int main(int argc, char *argv[])
408@@ -105,7 +105,8 @@
409 return 2;
410 }
411
412- glClearColor(MID_AUBERGINE, mir_eglapp_background_opacity);
413+ float const opacity = mir_eglapp_background_opacity;
414+ glClearColor(MID_AUBERGINE(opacity), opacity);
415 glViewport(0, 0, width, height);
416
417 glUseProgram(prog);
418
419=== added file 'examples/prompt_session.c'
420--- examples/prompt_session.c 1970-01-01 00:00:00 +0000
421+++ examples/prompt_session.c 2014-06-18 12:52:17 +0000
422@@ -0,0 +1,231 @@
423+/*
424+ * Copyright © 2014 Canonical Ltd.
425+ *
426+ * This program is free software: you can redistribute it and/or modify
427+ * it under the terms of the GNU General Public License version 3 as
428+ * published by the Free Software Foundation.
429+ *
430+ * This program is distributed in the hope that it will be useful,
431+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
432+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
433+ * GNU General Public License for more details.
434+ *
435+ * You should have received a copy of the GNU General Public License
436+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
437+ *
438+ * Authored by: Nick Dedekind <nick.dedekind <nick.dedekind@canonical.com>
439+ */
440+
441+#define _POSIX_SOURCE
442+
443+#include "mir_toolkit/mir_client_library.h"
444+#include "mir_toolkit/mir_prompt_session.h"
445+
446+#undef NDEBUG
447+#include <assert.h>
448+#include <string.h>
449+#include <stdio.h>
450+#include <stdlib.h>
451+#include <getopt.h>
452+#include <unistd.h>
453+#include <errno.h>
454+#include <sys/wait.h>
455+#include <sys/types.h>
456+#include <signal.h>
457+
458+///\page prompt_session.c prompt_session.c: A mir client which starts a prompt session and prompt client app.
459+/// mir_demo_client_prompt_session shows the use of mir prompt session API.
460+/// This program opens a mir connection and creates a prompt session.
461+///\section helper helper()
462+/// Opens a mir connection and creates a prompt session
463+/// before closing the prompt session and connection.
464+///\section prompt_session_app prompt_session_app()
465+/// Opens a mir connection and creates a surface
466+/// before releasing the surface and closing the connection.
467+///\example prompt_session.c A mir client demonstrating prompt sessions.
468+///\section MirDemoState MirDemoState
469+/// The handles needs to be accessible both to callbacks and to the control function.
470+///\snippet prompt_session.c MirDemoState_tag
471+///\section Callbacks Callbacks
472+///\snippet prompt_session.c Callback_tag
473+/// This program creates two processes, both opening a mir connection, one starting
474+/// a prompt session with the other process.
475+
476+///\internal [MirDemoState_tag]
477+// Utility structure for the state of a single session.
478+typedef struct MirDemoState
479+{
480+ MirConnection *connection;
481+ MirSurface *surface;
482+ MirPromptSession *prompt_session;
483+ pid_t child_pid;
484+ MirPromptSessionState state;
485+
486+ int* client_fds;
487+ unsigned int client_fd_count;
488+} MirDemoState;
489+///\internal [MirDemoState_tag]
490+
491+
492+///\internal [Callback_tag]
493+// Callback to update MirDemoState on prompt_session_event
494+static void prompt_session_event_callback(MirPromptSession* prompt_session,
495+ MirPromptSessionState state,
496+ void* context)
497+{
498+ (void)prompt_session;
499+ MirDemoState* demo_state = (MirDemoState*)context;
500+ demo_state->state = state;
501+
502+ printf("helper: Prompt Session state updated to %d\n", state);
503+ if (state == mir_prompt_session_state_stopped)
504+ {
505+ kill(demo_state->child_pid, SIGINT);
506+ }
507+}
508+
509+static void client_fd_callback(MirPromptSession* prompt_session, size_t count, int const* fds, void* context)
510+{
511+ (void)prompt_session;
512+ ((MirDemoState*)context)->client_fds = malloc(sizeof(int)*count);
513+ unsigned int i = 0;
514+ for (; i < count; i++)
515+ {
516+ ((MirDemoState*)context)->client_fds[i] = fds[i];
517+ }
518+ ((MirDemoState*)context)->client_fd_count = count;
519+}
520+///\internal [Callback_tag]
521+
522+void start_session(const char* server, const char* name, MirDemoState* mcd)
523+{
524+ // Call mir_connect synchronously
525+ mcd->connection = mir_connect_sync(server, name);
526+
527+ // We expect a connection handle;
528+ // we expect it to be valid; and,
529+ // we don't expect an error description
530+ assert(mcd->connection != NULL);
531+ assert(mir_connection_is_valid(mcd->connection));
532+ assert(strcmp(mir_connection_get_error_message(mcd->connection), "") == 0);
533+ printf("%s: Connected\n", name);
534+
535+ // We can query information about the platform we're running on
536+ {
537+ MirPlatformPackage platform_package;
538+ platform_package.data_items = -1;
539+ platform_package.fd_items = -1;
540+
541+ mir_connection_get_platform(mcd->connection, &platform_package);
542+ assert(0 <= platform_package.data_items);
543+ assert(0 <= platform_package.fd_items);
544+ }
545+}
546+
547+void stop_session(MirDemoState* mcd, const char* name)
548+{
549+ if (mcd->surface)
550+ {
551+ // We should release our surface
552+ mir_surface_release_sync(mcd->surface);
553+ mcd->surface = 0;
554+ printf("%s: Surface released\n", name);
555+ }
556+
557+ // We should release our connection
558+ mir_connection_release(mcd->connection);
559+ printf("%s: Connection released\n", name);
560+}
561+
562+void helper(const char* server)
563+{
564+ MirDemoState mcd;
565+ mcd.connection = 0;
566+ mcd.surface = 0;
567+ mcd.prompt_session = 0;
568+ mcd.state = mir_prompt_session_state_stopped;
569+ mcd.client_fd_count = 0;
570+ start_session(server, "helper", &mcd);
571+
572+ // We create a prompt session
573+ mcd.prompt_session = mir_connection_create_prompt_session_sync(mcd.connection, getpid(), prompt_session_event_callback, &mcd);
574+ assert(mcd.prompt_session != NULL);
575+
576+ assert(mcd.state == mir_prompt_session_state_started);
577+ puts("helper: Started prompt session");
578+
579+ mir_wait_for(mir_prompt_session_new_fds_for_prompt_providers(mcd.prompt_session, 1, client_fd_callback, &mcd));
580+ assert(mcd.client_fd_count == 1);
581+ puts("helper: Added waiting FD");
582+
583+ printf("helper: Starting child application 'mir_demo_client_basic' with fd://%d\n", mcd.client_fds[0]);
584+ mcd.child_pid = fork();
585+
586+ if (mcd.child_pid == 0)
587+ {
588+ char buffer[128] = {0};
589+ sprintf(buffer, "fd://%d", mcd.client_fds[0]);
590+
591+ char* args[4];
592+ args[0] = "mir_demo_client_basic";
593+ args[1] = "-m";
594+ args[2] = &buffer[0];
595+ args[3] = NULL;
596+
597+ errno = 0;
598+ execvp("mir_demo_client_basic", args);
599+ return;
600+ }
601+
602+ int status;
603+ printf("helper: Waiting on child application: %d\n", mcd.child_pid);
604+ waitpid(mcd.child_pid, &status, 0);
605+
606+ if (mcd.state == mir_prompt_session_state_started)
607+ {
608+ mir_prompt_session_release_sync(mcd.prompt_session);
609+ mcd.prompt_session = NULL;
610+ puts("helper: Stopped prompt session");
611+ }
612+ else
613+ {
614+ puts("helper: Prompt session stopped by server");
615+ }
616+ puts("helper: Done");
617+
618+ stop_session(&mcd, "helper");
619+}
620+
621+// The main() function deals with parsing arguments and defaults
622+int main(int argc, char* argv[])
623+{
624+ // Some variables for holding command line options
625+ char const *server = NULL;
626+
627+ // Parse the command line
628+ {
629+ int arg;
630+ opterr = 0;
631+ while ((arg = getopt (argc, argv, "c:hm:")) != -1)
632+ {
633+ switch (arg)
634+ {
635+ case 'm':
636+ server = optarg;
637+ break;
638+
639+ case '?':
640+ case 'h':
641+ default:
642+ puts(argv[0]);
643+ puts("Usage:");
644+ puts(" -m <Mir server socket>");
645+ puts(" -h: this help text");
646+ return -1;
647+ }
648+ }
649+ }
650+
651+ helper(server);
652+ return 0;
653+}
654
655=== modified file 'examples/render_surfaces.cpp'
656--- examples/render_surfaces.cpp 2014-05-28 07:56:16 +0000
657+++ examples/render_surfaces.cpp 2014-06-18 12:52:17 +0000
658@@ -324,7 +324,7 @@
659 {
660 }
661
662- bool composite()
663+ void composite()
664 {
665 while (!created) std::this_thread::yield();
666 stop_watch.stop();
667@@ -342,7 +342,6 @@
668 m.step();
669
670 frames++;
671- return false;
672 }
673
674 private:
675
676=== modified file 'include/client/mir_toolkit/mir_connection.h'
677--- include/client/mir_toolkit/mir_connection.h 2014-05-22 11:31:21 +0000
678+++ include/client/mir_toolkit/mir_connection.h 2014-06-18 12:52:17 +0000
679@@ -169,26 +169,6 @@
680 MirConnection* connection, MirPixelFormat* formats,
681 unsigned const int format_size, unsigned int *num_valid_formats);
682
683-/**
684- * Allocate some FDs for trusted clients to connect on
685- *
686- * Trust session helpers need to allocate connection FDs it will pass to
687- * trusted clients to use when connecting to the server. The server can
688- * then associate them with the trust session.
689- *
690- * \warning This API is tentative until the implementation of trust sessions is complete
691- * \param [in] connection The connection
692- * \param [in] no_of_fds The number of fds to allocate
693- * \param [in] callback Callback invoked when request completes
694- * \param [in,out] context User data passed to the callback function
695- * \return A handle that can be passed to mir_wait_for
696- */
697-MirWaitHandle* mir_connection_new_fds_for_trusted_clients(
698- MirConnection* connection,
699- unsigned int no_of_fds,
700- mir_client_fd_callback callback,
701- void * context);
702-
703 #ifdef __cplusplus
704 }
705 /**@}*/
706
707=== added file 'include/client/mir_toolkit/mir_prompt_session.h'
708--- include/client/mir_toolkit/mir_prompt_session.h 1970-01-01 00:00:00 +0000
709+++ include/client/mir_toolkit/mir_prompt_session.h 2014-06-18 12:52:17 +0000
710@@ -0,0 +1,87 @@
711+/*
712+ * Copyright © 2014 Canonical Ltd.
713+ *
714+ * This program is free software: you can redistribute it and/or modify it
715+ * under the terms of the GNU Lesser General Public License version 3,
716+ * as published by the Free Software Foundation.
717+ *
718+ * This program is distributed in the hope that it will be useful,
719+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
720+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
721+ * GNU Lesser General Public License for more details.
722+ *
723+ * You should have received a copy of the GNU Lesser General Public License
724+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
725+ */
726+
727+#ifndef MIR_TOOLKIT_MIR_PROMPT_SESSION_H_
728+#define MIR_TOOLKIT_MIR_PROMPT_SESSION_H_
729+
730+#include "mir_toolkit/mir_client_library.h"
731+
732+#include <sys/types.h>
733+
734+#ifdef __cplusplus
735+/**
736+ * \addtogroup mir_toolkit
737+ * @{
738+ */
739+extern "C" {
740+#endif
741+
742+/**
743+ * Create and start a new prompt session
744+ * \param [in] connection The connection
745+ * \param [in] application_pid The process id of the initiating application
746+ * \param [in] state_change_callback The function to be called when a prompt session state change occurs
747+ * \param [in,out] context User data passed to the callback functions
748+ * \return A handle that can be passed to mir_wait_for
749+ */
750+MirPromptSession *mir_connection_create_prompt_session_sync(
751+ MirConnection* connection,
752+ pid_t application_pid,
753+ mir_prompt_session_state_change_callback state_change_callback,
754+ void *context);
755+
756+/**
757+ * Add a prompt provider process id to the prompt session
758+ * \param [in] prompt_session The prompt session
759+ * \param [in] provider_pid The process id of the prompt provider to add
760+ * \return True if the process id was added, false otherwise
761+ */
762+MirBool mir_prompt_session_add_prompt_provider_sync(
763+ MirPromptSession *prompt_session,
764+ pid_t provider_pid);
765+
766+/**
767+ * Allocate some FDs for prompt providers to connect on
768+ *
769+ * Prompt helpers need to allocate connection FDs it will pass to
770+ * prompt providers to use when connecting to the server. The server can
771+ * then associate them with the prompt session.
772+ *
773+ * \warning This API is tentative until the implementation of prompt sessions is complete
774+ * \param [in] prompt_session The prompt session
775+ * \param [in] no_of_fds The number of fds to allocate
776+ * \param [in] callback Callback invoked when request completes
777+ * \param [in,out] context User data passed to the callback function
778+ * \return A handle that can be passed to mir_wait_for
779+ */
780+MirWaitHandle* mir_prompt_session_new_fds_for_prompt_providers(
781+ MirPromptSession *prompt_session,
782+ unsigned int no_of_fds,
783+ mir_client_fd_callback callback,
784+ void * context);
785+
786+/**
787+ * Stop and release the specified prompt session
788+ * \param [in] prompt_session The prompt session
789+ */
790+void mir_prompt_session_release_sync(MirPromptSession *prompt_session);
791+
792+#ifdef __cplusplus
793+}
794+/**@}*/
795+#endif
796+
797+#endif /* MIR_TOOLKIT_MIR_PROMPT_SESSION_H_ */
798
799=== modified file 'include/platform/mir/graphics/buffer.h'
800--- include/platform/mir/graphics/buffer.h 2014-03-06 06:05:17 +0000
801+++ include/platform/mir/graphics/buffer.h 2014-06-18 12:52:17 +0000
802@@ -41,7 +41,8 @@
803 virtual geometry::Size size() const = 0;
804 virtual geometry::Stride stride() const = 0;
805 virtual MirPixelFormat pixel_format() const = 0;
806- virtual void bind_to_texture() = 0;
807+ virtual void gl_bind_to_texture() = 0;
808+ /* TODO: remove this function, as it is specific to the mesa platform */
809 virtual bool can_bypass() const = 0;
810
811 protected:
812
813=== modified file 'include/platform/mir/graphics/buffer_id.h'
814--- include/platform/mir/graphics/buffer_id.h 2014-05-22 09:56:17 +0000
815+++ include/platform/mir/graphics/buffer_id.h 2014-06-18 12:52:17 +0000
816@@ -27,7 +27,7 @@
817 class BufferID
818 {
819 public:
820- BufferID() : value(id_invalid){}
821+ BufferID() noexcept: value(id_invalid){}
822 explicit BufferID(uint32_t val) : value(val) {}
823 bool is_valid() const { return (id_invalid != value); }
824 uint32_t as_uint32_t() const { return value; };
825
826=== modified file 'include/platform/mir/graphics/display_buffer.h'
827--- include/platform/mir/graphics/display_buffer.h 2014-05-22 09:56:17 +0000
828+++ include/platform/mir/graphics/display_buffer.h 2014-06-18 12:52:17 +0000
829@@ -67,10 +67,6 @@
830 **/
831 virtual bool post_renderables_if_optimizable(RenderableList const& renderlist) = 0;
832
833- /** to be deprecated */
834- virtual bool can_bypass() const = 0;
835- virtual void post_update(std::shared_ptr<Buffer> /* bypass_buf */) {}
836-
837 /** Returns the orientation of the display buffer relative to how the
838 * user should see it (the orientation of the output).
839 * This tells us how much (if any) rotation the renderer needs to do.
840@@ -81,6 +77,12 @@
841 */
842 virtual MirOrientation orientation() const = 0;
843
844+ /** Returns true if the display buffer has an alpha channel and the alpha
845+ * channel will be read from at some point - in which case the renderer
846+ * must produce valid alpha channel content
847+ */
848+ virtual bool uses_alpha() const = 0;
849+
850 protected:
851 DisplayBuffer() = default;
852 DisplayBuffer(DisplayBuffer const& c) = delete;
853
854=== modified file 'include/platform/mir/graphics/platform.h'
855--- include/platform/mir/graphics/platform.h 2014-05-07 02:56:33 +0000
856+++ include/platform/mir/graphics/platform.h 2014-06-18 12:52:17 +0000
857@@ -27,6 +27,8 @@
858
859 namespace mir
860 {
861+class EmergencyCleanupRegistry;
862+
863 namespace frontend
864 {
865 class Surface;
866@@ -116,14 +118,21 @@
867 * Function prototype used to return a new graphics platform.
868 *
869 * \param [in] options options to use for this platform
870+ * \param [in] emergency_cleanup_registry object to register emergency shutdown handlers with
871 * \param [in] report the object to use to report interesting events from the display subsystem
872 *
873 * This factory function needs to be implemented by each platform.
874 *
875 * \ingroup platform_enablement
876 */
877-extern "C" typedef std::shared_ptr<Platform>(*CreatePlatform)(std::shared_ptr<options::Option> const& options, std::shared_ptr<DisplayReport> const& report);
878-extern "C" std::shared_ptr<Platform> create_platform (std::shared_ptr<options::Option> const& options, std::shared_ptr<DisplayReport> const& report);
879+extern "C" typedef std::shared_ptr<Platform>(*CreatePlatform)(
880+ std::shared_ptr<options::Option> const& options,
881+ std::shared_ptr<EmergencyCleanupRegistry> const& emergency_cleanup_registry,
882+ std::shared_ptr<DisplayReport> const& report);
883+extern "C" std::shared_ptr<Platform> create_platform(
884+ std::shared_ptr<options::Option> const& options,
885+ std::shared_ptr<EmergencyCleanupRegistry> const& emergency_cleanup_registry,
886+ std::shared_ptr<DisplayReport> const& report);
887 extern "C" typedef void(*AddPlatformOptions)(
888 boost::program_options::options_description& config);
889 extern "C" void add_platform_options(
890
891=== modified file 'include/server/mir/asio_main_loop.h'
892--- include/server/mir/asio_main_loop.h 2014-05-28 07:43:51 +0000
893+++ include/server/mir/asio_main_loop.h 2014-06-18 12:52:17 +0000
894@@ -58,6 +58,8 @@
895 std::function<void()> callback) override;
896 std::unique_ptr<time::Alarm> notify_at(mir::time::Timestamp time_point,
897 std::function<void()> callback) override;
898+ std::unique_ptr<time::Alarm> create_alarm(std::function<void()> callback) override;
899+
900 void enqueue(void const* owner, ServerAction const& action);
901 void pause_processing_for(void const* owner);
902 void resume_processing_for(void const* owner);
903
904=== modified file 'include/server/mir/compositor/buffer_stream.h'
905--- include/server/mir/compositor/buffer_stream.h 2014-03-26 05:48:59 +0000
906+++ include/server/mir/compositor/buffer_stream.h 2014-06-18 12:52:17 +0000
907@@ -41,7 +41,9 @@
908 public:
909 virtual ~BufferStream() = default;
910
911- virtual void swap_client_buffers(graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) = 0;
912+ virtual void acquire_client_buffer(
913+ std::function<void(graphics::Buffer* buffer)> complete) = 0;
914+ virtual void release_client_buffer(graphics::Buffer* buf) = 0;
915 virtual std::shared_ptr<graphics::Buffer>
916 lock_compositor_buffer(void const* user_id) = 0;
917 virtual std::shared_ptr<graphics::Buffer> lock_snapshot_buffer() = 0;
918
919=== added file 'include/server/mir/compositor/destination_alpha.h'
920--- include/server/mir/compositor/destination_alpha.h 1970-01-01 00:00:00 +0000
921+++ include/server/mir/compositor/destination_alpha.h 2014-06-18 12:52:17 +0000
922@@ -0,0 +1,36 @@
923+/*
924+ * Copyright © 2014 Canonical Ltd.
925+ *
926+ * This program is free software: you can redistribute it and/or modify it
927+ * under the terms of the GNU General Public License version 3,
928+ * as published by the Free Software Foundation.
929+ *
930+ * This program is distributed in the hope that it will be useful,
931+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
932+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
933+ * GNU General Public License for more details.
934+ *
935+ * You should have received a copy of the GNU General Public License
936+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
937+ *
938+ * Authored by: Alberto Aguirre <alberto.aguirre@canonical.com>
939+ */
940+
941+#ifndef MIR_COMPOSITOR_DESTINATION_ALPHA_H_
942+#define MIR_COMPOSITOR_DESTINATION_ALPHA_H_
943+
944+namespace mir
945+{
946+namespace compositor
947+{
948+
949+enum class DestinationAlpha
950+{
951+ generate_from_source,
952+ opaque
953+};
954+
955+}
956+}
957+
958+#endif
959
960=== modified file 'include/server/mir/compositor/display_buffer_compositor.h'
961--- include/server/mir/compositor/display_buffer_compositor.h 2014-03-05 07:31:06 +0000
962+++ include/server/mir/compositor/display_buffer_compositor.h 2014-06-18 12:52:17 +0000
963@@ -30,9 +30,7 @@
964 public:
965 virtual ~DisplayBufferCompositor() = default;
966
967- /// Returns true if there is additional work to do. E.g. a composited surface
968- /// has additional buffers ready to composite or during animation
969- virtual bool composite() = 0;
970+ virtual void composite() = 0;
971
972 protected:
973 DisplayBufferCompositor() = default;
974
975=== added file 'include/server/mir/compositor/frame_dropping_policy.h'
976--- include/server/mir/compositor/frame_dropping_policy.h 1970-01-01 00:00:00 +0000
977+++ include/server/mir/compositor/frame_dropping_policy.h 2014-06-18 12:52:17 +0000
978@@ -0,0 +1,69 @@
979+/*
980+ * Copyright © 2014 Canonical Ltd.
981+ *
982+ * This program is free software: you can redistribute it and/or modify it
983+ * under the terms of the GNU General Public License version 3,
984+ * as published by the Free Software Foundation.
985+ *
986+ * This program is distributed in the hope that it will be useful,
987+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
988+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
989+ * GNU General Public License for more details.
990+ *
991+ * You should have received a copy of the GNU General Public License
992+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
993+ *
994+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
995+ */
996+
997+#ifndef MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_
998+#define MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_
999+
1000+#include <functional>
1001+
1002+namespace mir
1003+{
1004+namespace compositor
1005+{
1006+/**
1007+ * \brief Policy to determine when to drop a frame from a client
1008+ *
1009+ * The FrameDroppingPolicy objects are constructed from a
1010+ * \ref FrameDroppingPolicyFactory
1011+ *
1012+ * The frame dropping mechanism is provided as the
1013+ * \a drop_frames argument of \ref FrameDroppingPolicyFactory::create_policy
1014+ *
1015+ * The policy may decide to drop a frame any time that there is an outstanding
1016+ * swap - namely, when there have been more calls to \ref swap_now_blocking
1017+ * than to \ref swap_unblocked
1018+ */
1019+class FrameDroppingPolicy
1020+{
1021+public:
1022+ virtual ~FrameDroppingPolicy() = default;
1023+
1024+ FrameDroppingPolicy(FrameDroppingPolicy const&) = delete;
1025+ FrameDroppingPolicy& operator=(FrameDroppingPolicy const&) = delete;
1026+
1027+ /**
1028+ * \brief Notify that a swap is now blocking
1029+ */
1030+ virtual void swap_now_blocking() = 0;
1031+ /**
1032+ * \brief Notify that previous swap is no longer blocking
1033+ */
1034+ virtual void swap_unblocked() = 0;
1035+
1036+protected:
1037+ /**
1038+ * \note FrameDroppingPolicies should not be constructed directly;
1039+ * use a \ref FrameDroppingPolicyFactory
1040+ */
1041+ FrameDroppingPolicy() = default;
1042+};
1043+
1044+}
1045+}
1046+
1047+#endif // MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_
1048
1049=== added file 'include/server/mir/compositor/frame_dropping_policy_factory.h'
1050--- include/server/mir/compositor/frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000
1051+++ include/server/mir/compositor/frame_dropping_policy_factory.h 2014-06-18 12:52:17 +0000
1052@@ -0,0 +1,57 @@
1053+/*
1054+ * Copyright © 2014 Canonical Ltd.
1055+ *
1056+ * This program is free software: you can redistribute it and/or modify it
1057+ * under the terms of the GNU General Public License version 3,
1058+ * as published by the Free Software Foundation.
1059+ *
1060+ * This program is distributed in the hope that it will be useful,
1061+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1062+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1063+ * GNU General Public License for more details.
1064+ *
1065+ * You should have received a copy of the GNU General Public License
1066+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1067+ *
1068+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
1069+ */
1070+
1071+#ifndef MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_
1072+#define MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_
1073+
1074+#include <memory>
1075+
1076+namespace mir
1077+{
1078+namespace compositor
1079+{
1080+class FrameDroppingPolicy;
1081+
1082+/**
1083+ * \brief Creator of FrameDroppingPolicies
1084+ *
1085+ * The FrameDroppingPolicyFactory is how you go from a means of dropping frames -
1086+ * the \a drop_frames parameter of \ref create_policy -
1087+ * to a \ref FrameDroppingPolicy
1088+ */
1089+class FrameDroppingPolicyFactory
1090+{
1091+public:
1092+ FrameDroppingPolicyFactory() = default;
1093+ virtual ~FrameDroppingPolicyFactory() = default;
1094+
1095+ FrameDroppingPolicyFactory(FrameDroppingPolicyFactory const&) = delete;
1096+ FrameDroppingPolicyFactory& operator=(FrameDroppingPolicyFactory const&) = delete;
1097+
1098+ /**
1099+ * \brief Create a FrameDroppingPolicy that will call \a drop_frame when it decides to drop a frame
1100+ * \param drop_frame Function to call when a frame needs to be dropped
1101+ * \return The policy object.
1102+ */
1103+ virtual std::unique_ptr<FrameDroppingPolicy> create_policy(std::function<void(void)> drop_frame) const = 0;
1104+};
1105+
1106+}
1107+}
1108+
1109+#endif // MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_
1110
1111=== modified file 'include/server/mir/compositor/gl_renderer.h'
1112--- include/server/mir/compositor/gl_renderer.h 2014-05-28 07:43:51 +0000
1113+++ include/server/mir/compositor/gl_renderer.h 2014-06-18 12:52:17 +0000
1114@@ -37,13 +37,16 @@
1115 namespace compositor
1116 {
1117
1118+enum class DestinationAlpha;
1119+
1120 class GLRenderer : public Renderer
1121 {
1122 public:
1123 GLRenderer(
1124 graphics::GLProgramFactory const& program_factory,
1125 std::unique_ptr<graphics::GLTextureCache> && texture_cache,
1126- geometry::Rectangle const& display_area);
1127+ geometry::Rectangle const& display_area,
1128+ DestinationAlpha dest_alpha);
1129
1130 // These are called with a valid GL context:
1131 void set_viewport(geometry::Rectangle const& rect) override;
1132@@ -75,6 +78,9 @@
1133 graphics::Renderable const& renderable) const;
1134
1135 virtual void render(graphics::Renderable const& renderable) const;
1136+
1137+ DestinationAlpha destination_alpha() const;
1138+
1139 private:
1140 std::unique_ptr<graphics::GLProgram> program;
1141 std::unique_ptr<graphics::GLTextureCache> mutable texture_cache;
1142@@ -85,7 +91,7 @@
1143 GLuint transform_uniform_loc;
1144 GLuint alpha_uniform_loc;
1145 float rotation;
1146-
1147+ DestinationAlpha const dest_alpha;
1148 geometry::Rectangle viewport;
1149 };
1150
1151
1152=== modified file 'include/server/mir/compositor/renderer_factory.h'
1153--- include/server/mir/compositor/renderer_factory.h 2014-03-06 06:05:17 +0000
1154+++ include/server/mir/compositor/renderer_factory.h 2014-06-18 12:52:17 +0000
1155@@ -31,13 +31,15 @@
1156 {
1157
1158 class Renderer;
1159+enum class DestinationAlpha;
1160
1161 class RendererFactory
1162 {
1163 public:
1164 virtual ~RendererFactory() = default;
1165
1166- virtual std::unique_ptr<Renderer> create_renderer_for(geometry::Rectangle const& rect) = 0;
1167+ virtual std::unique_ptr<Renderer> create_renderer_for(geometry::Rectangle const& rect,
1168+ DestinationAlpha dest_alpha) = 0;
1169
1170 protected:
1171 RendererFactory() = default;
1172
1173=== modified file 'include/server/mir/default_server_configuration.h'
1174--- include/server/mir/default_server_configuration.h 2014-05-28 07:56:16 +0000
1175+++ include/server/mir/default_server_configuration.h 2014-06-18 12:52:17 +0000
1176@@ -46,6 +46,7 @@
1177 class Compositor;
1178 class RendererFactory;
1179 class CompositorReport;
1180+class FrameDroppingPolicyFactory;
1181 }
1182 namespace frontend
1183 {
1184@@ -92,6 +93,8 @@
1185 class SurfaceStackModel;
1186 class SurfaceStack;
1187 class SceneReport;
1188+class PromptSessionListener;
1189+class PromptSessionManager;
1190 }
1191 namespace graphics
1192 {
1193@@ -196,6 +199,7 @@
1194 * @{ */
1195 virtual std::shared_ptr<graphics::GraphicBufferAllocator> the_buffer_allocator();
1196 virtual std::shared_ptr<compositor::Scene> the_scene();
1197+ virtual std::shared_ptr<compositor::FrameDroppingPolicyFactory> the_frame_dropping_policy_factory();
1198 /** @} */
1199
1200 /** @name frontend configuration - dependencies
1201@@ -229,6 +233,8 @@
1202 virtual std::shared_ptr<scene::PlacementStrategy> the_placement_strategy();
1203 virtual std::shared_ptr<scene::SessionListener> the_session_listener();
1204 virtual std::shared_ptr<shell::DisplayLayout> the_shell_display_layout();
1205+ virtual std::shared_ptr<scene::PromptSessionListener> the_prompt_session_listener();
1206+ virtual std::shared_ptr<scene::PromptSessionManager> the_prompt_session_manager();
1207 /** @} */
1208
1209 /** @name internal scene configuration
1210@@ -336,6 +342,7 @@
1211 CachedPtr<frontend::Screencast> screencast;
1212 CachedPtr<compositor::RendererFactory> renderer_factory;
1213 CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory;
1214+ CachedPtr<compositor::FrameDroppingPolicyFactory> frame_dropping_policy_factory;
1215 CachedPtr<scene::SurfaceStack> surface_stack;
1216 CachedPtr<scene::SceneReport> scene_report;
1217
1218@@ -362,6 +369,8 @@
1219 CachedPtr<scene::MediatingDisplayChanger> mediating_display_changer;
1220 CachedPtr<graphics::GLProgramFactory> gl_program_factory;
1221 CachedPtr<graphics::GLConfig> gl_config;
1222+ CachedPtr<scene::PromptSessionListener> prompt_session_listener;
1223+ CachedPtr<scene::PromptSessionManager> prompt_session_manager;
1224 CachedPtr<scene::SessionCoordinator> session_coordinator;
1225 CachedPtr<EmergencyCleanup> emergency_cleanup;
1226
1227
1228=== added file 'include/server/mir/frontend/prompt_session.h'
1229--- include/server/mir/frontend/prompt_session.h 1970-01-01 00:00:00 +0000
1230+++ include/server/mir/frontend/prompt_session.h 2014-06-18 12:52:17 +0000
1231@@ -0,0 +1,48 @@
1232+/*
1233+ * Copyright © 2014 Canonical Ltd.
1234+ *
1235+ * This program is free software: you can redistribute it and/or modify it
1236+ * under the terms of the GNU General Public License version 3,
1237+ * as published by the Free Software Foundation.
1238+ *
1239+ * This program is distributed in the hope that it will be useful,
1240+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1241+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1242+ * GNU General Public License for more details.
1243+ *
1244+ * You should have received a copy of the GNU General Public License
1245+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1246+ *
1247+ * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
1248+ */
1249+
1250+#ifndef MIR_FRONTEND_PROMPT_SESSION_H_
1251+#define MIR_FRONTEND_PROMPT_SESSION_H_
1252+
1253+#include "mir_toolkit/common.h"
1254+
1255+#include <sys/types.h>
1256+#include <vector>
1257+#include <string>
1258+#include <memory>
1259+
1260+namespace mir
1261+{
1262+
1263+namespace frontend
1264+{
1265+class PromptSession
1266+{
1267+public:
1268+ virtual ~PromptSession() = default;
1269+
1270+protected:
1271+ PromptSession() = default;
1272+ PromptSession(const PromptSession&) = delete;
1273+ PromptSession& operator=(const PromptSession&) = delete;
1274+};
1275+
1276+}
1277+}
1278+
1279+#endif // MIR_FRONTEND_PROMPT_SESSION_H_
1280
1281=== modified file 'include/server/mir/frontend/session_mediator_report.h'
1282--- include/server/mir/frontend/session_mediator_report.h 2014-03-06 06:05:17 +0000
1283+++ include/server/mir/frontend/session_mediator_report.h 2014-06-18 12:52:17 +0000
1284@@ -1,5 +1,5 @@
1285 /*
1286- * Copyright © 2012 Canonical Ltd.
1287+ * Copyright © 2012-2014 Canonical Ltd.
1288 *
1289 * This program is free software: you can redistribute it and/or modify it
1290 * under the terms of the GNU General Public License version 3,
1291@@ -22,6 +22,8 @@
1292
1293 #include <string>
1294
1295+#include <sys/types.h>
1296+
1297 namespace mir
1298 {
1299 namespace frontend
1300@@ -46,8 +48,16 @@
1301
1302 virtual void session_configure_surface_called(std::string const& app_name) = 0;
1303
1304+ virtual void session_configure_surface_cursor_called(std::string const& app_name) = 0;
1305+
1306 virtual void session_configure_display_called(std::string const& app_name) = 0;
1307
1308+ virtual void session_start_prompt_session_called(std::string const& app_name, pid_t application_process) = 0;
1309+
1310+ virtual void session_add_prompt_provider_called(std::string const& app_name, pid_t provider_process) = 0;
1311+
1312+ virtual void session_stop_prompt_session_called(std::string const& app_name) = 0;
1313+
1314 virtual void session_error(
1315 std::string const& app_name,
1316 char const* method,
1317
1318=== modified file 'include/server/mir/frontend/shell.h'
1319--- include/server/mir/frontend/shell.h 2014-04-15 05:31:19 +0000
1320+++ include/server/mir/frontend/shell.h 2014-06-18 12:52:17 +0000
1321@@ -30,11 +30,13 @@
1322 namespace scene
1323 {
1324 struct SurfaceCreationParameters;
1325+struct PromptSessionCreationParameters;
1326 }
1327 namespace frontend
1328 {
1329 class EventSink;
1330 class Session;
1331+class PromptSession;
1332
1333 class Shell
1334 {
1335@@ -54,6 +56,14 @@
1336
1337 virtual void handle_surface_created(std::shared_ptr<Session> const& session) = 0;
1338
1339+ virtual std::shared_ptr<PromptSession> start_prompt_session_for(std::shared_ptr<Session> const& session,
1340+ scene::PromptSessionCreationParameters const& params) = 0;
1341+ virtual void add_prompt_provider_process_for(std::shared_ptr<PromptSession> const& prompt_session,
1342+ pid_t process_id) = 0;
1343+ virtual void add_prompt_provider_for(std::shared_ptr<PromptSession> const& prompt_session,
1344+ std::shared_ptr<Session> const& session) = 0;
1345+ virtual void stop_prompt_session(std::shared_ptr<PromptSession> const& prompt_session) = 0;
1346+
1347 protected:
1348 Shell() = default;
1349 Shell(const Shell&) = delete;
1350
1351=== modified file 'include/server/mir/frontend/surface.h'
1352--- include/server/mir/frontend/surface.h 2014-05-22 11:31:21 +0000
1353+++ include/server/mir/frontend/surface.h 2014-06-18 12:52:17 +0000
1354@@ -20,12 +20,9 @@
1355 #ifndef MIR_FRONTEND_SURFACE_H_
1356 #define MIR_FRONTEND_SURFACE_H_
1357
1358-#include "mir/geometry/point.h"
1359 #include "mir/geometry/size.h"
1360 #include "mir_toolkit/common.h"
1361
1362-#include <glm/glm.hpp>
1363-
1364 #include <memory>
1365
1366 namespace mir
1367@@ -34,22 +31,17 @@
1368 {
1369 class Buffer;
1370 class InternalSurface;
1371-}
1372-namespace input
1373-{
1374-class InputChannel;
1375+class CursorImage;
1376 }
1377
1378 namespace frontend
1379 {
1380-
1381 class ClientBufferTracker;
1382
1383 class Surface
1384 {
1385 public:
1386-
1387- virtual ~Surface() {}
1388+ virtual ~Surface() = default;
1389
1390 /// Size of the client area of the surface (excluding any decorations)
1391 virtual geometry::Size client_size() const = 0;
1392@@ -62,6 +54,8 @@
1393
1394 virtual int configure(MirSurfaceAttrib attrib, int value) = 0;
1395
1396+ virtual void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& image) = 0;
1397+
1398 /**
1399 * swap_buffers_blocking() is a convenience wrapper around swap_buffers()
1400 * it forces the current thread to block until complete() is called.
1401
1402=== modified file 'include/server/mir/graphics/cursor_images.h'
1403--- include/server/mir/graphics/cursor_images.h 2014-04-28 23:15:05 +0000
1404+++ include/server/mir/graphics/cursor_images.h 2014-06-18 12:52:17 +0000
1405@@ -31,6 +31,8 @@
1406 {
1407 class CursorImage;
1408
1409+geometry::Size const default_cursor_size{geometry::Width{64}, geometry::Height{64}};
1410+
1411 /// CursorImages is used to lookup cursor images.
1412 class CursorImages
1413 {
1414
1415=== added file 'include/server/mir/scene/null_prompt_session_listener.h'
1416--- include/server/mir/scene/null_prompt_session_listener.h 1970-01-01 00:00:00 +0000
1417+++ include/server/mir/scene/null_prompt_session_listener.h 2014-06-18 12:52:17 +0000
1418@@ -0,0 +1,40 @@
1419+/*
1420+ * Copyright © 2014 Canonical Ltd.
1421+ *
1422+ * This program is free software: you can redistribute it and/or modify it
1423+ * under the terms of the GNU General Public License version 3,
1424+ * as published by the Free Software Foundation.
1425+ *
1426+ * This program is distributed in the hope that it will be useful,
1427+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1428+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1429+ * GNU General Public License for more details.
1430+ *
1431+ * You should have received a copy of the GNU General Public License
1432+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1433+ *
1434+ * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
1435+ */
1436+
1437+#ifndef MIR_SCENE_NULL_PROMPT_SESSION_LISTENER_H_
1438+#define MIR_SCENE_NULL_PROMPT_SESSION_LISTENER_H_
1439+
1440+#include "mir/scene/prompt_session_listener.h"
1441+
1442+namespace mir
1443+{
1444+namespace scene
1445+{
1446+class NullPromptSessionListener : public PromptSessionListener
1447+{
1448+public:
1449+ void starting(std::shared_ptr<PromptSession> const&) override {}
1450+ void stopping(std::shared_ptr<PromptSession> const&) override {}
1451+
1452+ void prompt_provider_added(PromptSession const&, std::shared_ptr<Session> const&) override {}
1453+ void prompt_provider_removed(PromptSession const&, std::shared_ptr<Session> const&) override {}
1454+};
1455+}
1456+}
1457+
1458+#endif // MIR_SHELL_NULL_PROMPT_SESSION_LISTENER_H_
1459
1460=== modified file 'include/server/mir/scene/null_surface_observer.h'
1461--- include/server/mir/scene/null_surface_observer.h 2014-05-22 22:44:19 +0000
1462+++ include/server/mir/scene/null_surface_observer.h 2014-06-18 12:52:17 +0000
1463@@ -38,6 +38,7 @@
1464 void frame_posted(int frames_available);
1465 void alpha_set_to(float alpha);
1466 void transformation_set_to(glm::mat4 const& t);
1467+ void cursor_image_set_to(graphics::CursorImage const& image);
1468 void reception_mode_set_to(input::InputReceptionMode mode);
1469
1470 protected:
1471
1472=== added file 'include/server/mir/scene/prompt_session.h'
1473--- include/server/mir/scene/prompt_session.h 1970-01-01 00:00:00 +0000
1474+++ include/server/mir/scene/prompt_session.h 2014-06-18 12:52:17 +0000
1475@@ -0,0 +1,37 @@
1476+/*
1477+ * Copyright © 2014 Canonical Ltd.
1478+ *
1479+ * This program is free software: you can redistribute it and/or modify it
1480+ * under the terms of the GNU General Public License version 3,
1481+ * as published by the Free Software Foundation.
1482+ *
1483+ * This program is distributed in the hope that it will be useful,
1484+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1485+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1486+ * GNU General Public License for more details.
1487+ *
1488+ * You should have received a copy of the GNU General Public License
1489+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1490+ *
1491+ * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
1492+ */
1493+
1494+#ifndef MIR_SCENE_PROMPT_SESSION_H_
1495+#define MIR_SCENE_PROMPT_SESSION_H_
1496+
1497+#include "mir/frontend/prompt_session.h"
1498+
1499+namespace mir
1500+{
1501+namespace scene
1502+{
1503+class Session;
1504+
1505+class PromptSession : public frontend::PromptSession
1506+{
1507+};
1508+
1509+}
1510+}
1511+
1512+#endif // MIR_SHELL_PROMPT_SESSION_H_
1513
1514=== added file 'include/server/mir/scene/prompt_session_creation_parameters.h'
1515--- include/server/mir/scene/prompt_session_creation_parameters.h 1970-01-01 00:00:00 +0000
1516+++ include/server/mir/scene/prompt_session_creation_parameters.h 2014-06-18 12:52:17 +0000
1517@@ -0,0 +1,36 @@
1518+/*
1519+ * Copyright © 2014 Canonical Ltd.
1520+ *
1521+ * This program is free software: you can redistribute it and/or modify it
1522+ * under the terms of the GNU General Public License version 3,
1523+ * as published by the Free Software Foundation.
1524+ *
1525+ * This program is distributed in the hope that it will be useful,
1526+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1527+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1528+ * GNU General Public License for more details.
1529+ *
1530+ * You should have received a copy of the GNU General Public License
1531+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1532+ *
1533+ * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
1534+ */
1535+
1536+#ifndef MIR_SCENE_PROMPT_SESSION_CREATION_PARAMETERS_H_
1537+#define MIR_SCENE_PROMPT_SESSION_CREATION_PARAMETERS_H_
1538+
1539+#include <sys/types.h>
1540+
1541+namespace mir
1542+{
1543+namespace scene
1544+{
1545+
1546+struct PromptSessionCreationParameters
1547+{
1548+ pid_t application_pid = 0;
1549+};
1550+}
1551+}
1552+
1553+#endif /* MIR_SCENE_PROMPT_SESSION_CREATION_PARAMETERS_H_ */
1554
1555=== added file 'include/server/mir/scene/prompt_session_listener.h'
1556--- include/server/mir/scene/prompt_session_listener.h 1970-01-01 00:00:00 +0000
1557+++ include/server/mir/scene/prompt_session_listener.h 2014-06-18 12:52:17 +0000
1558@@ -0,0 +1,52 @@
1559+/*
1560+ * Copyright © 2014 Canonical Ltd.
1561+ *
1562+ * This program is free software: you can redistribute it and/or modify it
1563+ * under the terms of the GNU General Public License version 3,
1564+ * as published by the Free Software Foundation.
1565+ *
1566+ * This program is distributed in the hope that it will be useful,
1567+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1568+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1569+ * GNU General Public License for more details.
1570+ *
1571+ * You should have received a copy of the GNU General Public License
1572+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1573+ *
1574+ * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
1575+ */
1576+
1577+#ifndef MIR_SCENE_PROMPT_SESSION_LISTENER_H_
1578+#define MIR_SCENE_PROMPT_SESSION_LISTENER_H_
1579+
1580+#include <memory>
1581+
1582+namespace mir
1583+{
1584+namespace scene
1585+{
1586+class Session;
1587+class PromptSession;
1588+
1589+class PromptSessionListener
1590+{
1591+public:
1592+ virtual void starting(std::shared_ptr<PromptSession> const& prompt_session) = 0;
1593+ virtual void stopping(std::shared_ptr<PromptSession> const& prompt_session) = 0;
1594+
1595+ virtual void prompt_provider_added(PromptSession const& prompt_session, std::shared_ptr<Session> const& prompt_provider) = 0;
1596+ virtual void prompt_provider_removed(PromptSession const& prompt_session, std::shared_ptr<Session> const& prompt_provider) = 0;
1597+
1598+protected:
1599+ PromptSessionListener() = default;
1600+ virtual ~PromptSessionListener() = default;
1601+
1602+ PromptSessionListener(const PromptSessionListener&) = delete;
1603+ PromptSessionListener& operator=(const PromptSessionListener&) = delete;
1604+};
1605+
1606+}
1607+}
1608+
1609+
1610+#endif // MIR_SCENE_PROMPT_SESSION_LISTENER_H_
1611
1612=== added file 'include/server/mir/scene/prompt_session_manager.h'
1613--- include/server/mir/scene/prompt_session_manager.h 1970-01-01 00:00:00 +0000
1614+++ include/server/mir/scene/prompt_session_manager.h 2014-06-18 12:52:17 +0000
1615@@ -0,0 +1,110 @@
1616+/*
1617+ * Copyright © 2014 Canonical Ltd.
1618+ *
1619+ * This program is free software: you can redistribute it and/or modify it
1620+ * under the terms of the GNU General Public License version 3,
1621+ * as published by the Free Software Foundation.
1622+ *
1623+ * This program is distributed in the hope that it will be useful,
1624+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1625+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1626+ * GNU General Public License for more details.
1627+ *
1628+ * You should have received a copy of the GNU General Public License
1629+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1630+ *
1631+ * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
1632+ */
1633+
1634+#ifndef MIR_SCENE_PROMPT_SESSION_MANAGER_H_
1635+#define MIR_SCENE_PROMPT_SESSION_MANAGER_H_
1636+
1637+#include <sys/types.h>
1638+#include <memory>
1639+#include <functional>
1640+
1641+namespace mir
1642+{
1643+namespace scene
1644+{
1645+class Session;
1646+class PromptSession;
1647+struct PromptSessionCreationParameters;
1648+
1649+class PromptSessionManager
1650+{
1651+public:
1652+ virtual ~PromptSessionManager() = default;
1653+
1654+ /**
1655+ * Start a new prompt session
1656+ * \param [in] session The prompt helper session
1657+ * \param [in] params The creation parameters for constructing the prompt session
1658+ */
1659+ virtual std::shared_ptr<PromptSession> start_prompt_session_for(std::shared_ptr<Session> const& session,
1660+ PromptSessionCreationParameters const& params) const = 0;
1661+
1662+ /**
1663+ * Stop a started prompt session
1664+ * \param [in] prompt_session The prompt session
1665+ */
1666+ virtual void stop_prompt_session(std::shared_ptr<PromptSession> const& prompt_session) const = 0;
1667+
1668+ /**
1669+ * Add a prompt provider to an existing prompt session
1670+ * \param [in] prompt_session The prompt session
1671+ * \param [in] prompt_provider The prompt provider to add to the prompt session
1672+ */
1673+ virtual void add_prompt_provider(std::shared_ptr<PromptSession> const& prompt_session,
1674+ std::shared_ptr<Session> const& prompt_provider) const = 0;
1675+
1676+ /**
1677+ * Add a process id to wait for to the prompt session
1678+ * \param [in] prompt_session The prompt session
1679+ * \param [in] process_id The process id to wait for
1680+ */
1681+ virtual void add_prompt_provider_by_pid(std::shared_ptr<PromptSession> const& prompt_session,
1682+ pid_t process_id) const = 0;
1683+
1684+ /**
1685+ * Add a session that may have been expected by a prompt session.
1686+ * \param [in] session The new session that was being expected
1687+ */
1688+ virtual void add_expected_session(std::shared_ptr<Session> const& new_session) const = 0;
1689+
1690+ /**
1691+ * Remove a session from all associated prompt sessions
1692+ * \param [in] session The new session that is to be removed
1693+ */
1694+ virtual void remove_session(std::shared_ptr<Session> const& session) const = 0;
1695+
1696+ /**
1697+ * Retrieve the application session for a prompt session
1698+ * \param [in] prompt_session The prompt session
1699+ */
1700+ virtual std::shared_ptr<Session> application_for(std::shared_ptr<PromptSession> const& prompt_session) const = 0;
1701+
1702+ /**
1703+ * Retrieve the helper session for a prompt session
1704+ * \param [in] prompt_session The prompt session
1705+ */
1706+ virtual std::shared_ptr<Session> helper_for(std::shared_ptr<PromptSession> const& prompt_session) const = 0;
1707+
1708+ /**
1709+ * Iterate over all the prompt providers associated with a prompt session
1710+ * \param [in] prompt_session The prompt session
1711+ * \param [in] f The callback function to call for each provider
1712+ */
1713+ virtual void for_each_provider_in(std::shared_ptr<PromptSession> const& prompt_session,
1714+ std::function<void(std::shared_ptr<Session> const& prompt_provider)> const& f) const = 0;
1715+
1716+protected:
1717+ PromptSessionManager() = default;
1718+ PromptSessionManager(const PromptSessionManager&) = delete;
1719+ PromptSessionManager& operator=(const PromptSessionManager&) = delete;
1720+};
1721+
1722+}
1723+}
1724+
1725+#endif // MIR_SCENE_PROMPT_SESSION_MANAGER_H_
1726
1727=== modified file 'include/server/mir/scene/session.h'
1728--- include/server/mir/scene/session.h 2014-04-15 05:31:19 +0000
1729+++ include/server/mir/scene/session.h 2014-06-18 12:52:17 +0000
1730@@ -40,6 +40,9 @@
1731 virtual std::shared_ptr<Surface> default_surface() const = 0;
1732 virtual void set_lifecycle_state(MirLifecycleState state) = 0;
1733 virtual void send_display_config(graphics::DisplayConfiguration const&) = 0;
1734+
1735+ virtual void start_prompt_session() = 0;
1736+ virtual void stop_prompt_session() = 0;
1737 };
1738 }
1739 }
1740
1741=== modified file 'include/server/mir/scene/surface.h'
1742--- include/server/mir/scene/surface.h 2014-05-22 11:31:21 +0000
1743+++ include/server/mir/scene/surface.h 2014-06-18 12:52:17 +0000
1744@@ -31,6 +31,7 @@
1745 namespace input { class InputChannel; }
1746 namespace shell { class InputTargeter; }
1747 namespace geometry { class Rectangle; }
1748+namespace graphics { class CursorImage; }
1749
1750 namespace scene
1751 {
1752@@ -70,6 +71,9 @@
1753 virtual void set_transformation(glm::mat4 const& t) = 0;
1754 virtual void set_alpha(float alpha) = 0;
1755 virtual void force_requests_to_complete() = 0;
1756+
1757+ virtual void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& image) = 0;
1758+ virtual std::shared_ptr<graphics::CursorImage> cursor_image() = 0;
1759
1760 virtual void add_observer(std::shared_ptr<SurfaceObserver> const& observer) = 0;
1761 virtual void remove_observer(std::weak_ptr<SurfaceObserver> const& observer) = 0;
1762
1763=== modified file 'include/server/mir/scene/surface_observer.h'
1764--- include/server/mir/scene/surface_observer.h 2014-05-22 22:44:19 +0000
1765+++ include/server/mir/scene/surface_observer.h 2014-06-18 12:52:17 +0000
1766@@ -32,6 +32,10 @@
1767 struct Size;
1768 struct Point;
1769 }
1770+namespace graphics
1771+{
1772+class CursorImage;
1773+}
1774
1775 namespace scene
1776 {
1777@@ -46,6 +50,7 @@
1778 virtual void alpha_set_to(float alpha) = 0;
1779 virtual void transformation_set_to(glm::mat4 const& t) = 0;
1780 virtual void reception_mode_set_to(input::InputReceptionMode mode) = 0;
1781+ virtual void cursor_image_set_to(graphics::CursorImage const& image) = 0;
1782
1783 protected:
1784 SurfaceObserver() = default;
1785
1786=== modified file 'include/server/mir/shell/session_coordinator_wrapper.h'
1787--- include/server/mir/shell/session_coordinator_wrapper.h 2014-05-23 12:59:00 +0000
1788+++ include/server/mir/shell/session_coordinator_wrapper.h 2014-06-18 12:52:17 +0000
1789@@ -48,6 +48,20 @@
1790
1791 void handle_surface_created(std::shared_ptr<frontend::Session> const& session) override;
1792
1793+ std::shared_ptr<frontend::PromptSession> start_prompt_session_for(
1794+ std::shared_ptr<frontend::Session> const& session,
1795+ scene::PromptSessionCreationParameters const& params) override;
1796+
1797+ void add_prompt_provider_process_for(
1798+ std::shared_ptr<frontend::PromptSession> const& prompt_session,
1799+ pid_t process_id) override;
1800+
1801+ void add_prompt_provider_for(
1802+ std::shared_ptr<frontend::PromptSession> const& prompt_session,
1803+ std::shared_ptr<frontend::Session> const& session) override;
1804+
1805+ void stop_prompt_session(std::shared_ptr<frontend::PromptSession> const& prompt_session) override;
1806+
1807 protected:
1808 std::shared_ptr<scene::SessionCoordinator> const wrapped;
1809 };
1810
1811=== modified file 'include/server/mir/time/timer.h'
1812--- include/server/mir/time/timer.h 2014-05-22 09:56:17 +0000
1813+++ include/server/mir/time/timer.h 2014-06-18 12:52:17 +0000
1814@@ -58,7 +58,14 @@
1815 */
1816 virtual std::unique_ptr<Alarm> notify_at(Timestamp time_point,
1817 std::function<void()> callback) = 0;
1818-
1819+ /**
1820+ * \brief Create an Alarm that will not fire until scheduled
1821+ *
1822+ * \param callback Function to call when the Alarm signals
1823+ *
1824+ * \return A handle to an Alarm that can later be scheduled
1825+ */
1826+ virtual std::unique_ptr<Alarm> create_alarm(std::function<void()> callback) = 0;
1827
1828 Timer(Timer const&) = delete;
1829 Timer& operator=(Timer const&) = delete;
1830
1831=== added file 'include/shared/mir/thread_name.h'
1832--- include/shared/mir/thread_name.h 1970-01-01 00:00:00 +0000
1833+++ include/shared/mir/thread_name.h 2014-06-18 12:52:17 +0000
1834@@ -0,0 +1,29 @@
1835+/*
1836+ * Copyright © 2014 Canonical Ltd.
1837+ *
1838+ * This program is free software: you can redistribute it and/or modify
1839+ * it under the terms of the GNU Lesser General Public License version 3 as
1840+ * published by the Free Software Foundation.
1841+ *
1842+ * This program is distributed in the hope that it will be useful,
1843+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1844+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1845+ * GNU Lesser General Public License for more details.
1846+ *
1847+ * You should have received a copy of the GNU Lesser General Public License
1848+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1849+ *
1850+ * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
1851+ */
1852+
1853+#ifndef MIR_THREAD_NAME_H_
1854+#define MIR_THREAD_NAME_H_
1855+
1856+#include <string>
1857+
1858+namespace mir
1859+{
1860+void set_thread_name(std::string const& name);
1861+}
1862+
1863+#endif /* MIR_THREAD_NAME_H_ */
1864
1865=== modified file 'include/shared/mir_toolkit/client_types.h'
1866--- include/shared/mir_toolkit/client_types.h 2014-05-22 11:31:21 +0000
1867+++ include/shared/mir_toolkit/client_types.h 2014-06-18 12:52:17 +0000
1868@@ -46,6 +46,7 @@
1869 typedef struct MirConnection MirConnection;
1870 typedef struct MirSurface MirSurface;
1871 typedef struct MirScreencast MirScreencast;
1872+typedef struct MirPromptSession MirPromptSession;
1873
1874 /**
1875 * Returned by asynchronous functions. Must not be free'd by
1876@@ -105,7 +106,7 @@
1877
1878 /**
1879 * Callback called when a request for client file descriptors completes
1880- * \param [in] connection The connection associated with the display change
1881+ * \param [in] prompt_session The prompt session
1882 * \param [in] count The number of FDs allocated
1883 * \param [in] fds Array of FDs
1884 * \param [in,out] context The context provided by client
1885@@ -114,7 +115,7 @@
1886 */
1887
1888 typedef void (*mir_client_fd_callback)(
1889- MirConnection* connection, size_t count, int const* fds, void* context);
1890+ MirPromptSession *prompt_session, size_t count, int const* fds, void* context);
1891
1892 /**
1893 * MirBufferUsage specifies how a surface can and will be used. A "hardware"
1894@@ -319,6 +320,31 @@
1895 */
1896 typedef void (*mir_screencast_callback)(MirScreencast *screencast, void *client_context);
1897
1898+/**
1899+ * Callback member of MirPromptSession for handling of prompt sessions.
1900+ * \param [in] prompt_provider The prompt session associated with the callback
1901+ * \param [in,out] context The context provided by the client
1902+ */
1903+typedef void (*mir_prompt_session_callback)(MirPromptSession* prompt_provider, void* context);
1904+
1905+/**
1906+ * Callback member of MirPromptSession for adding prompt providers
1907+ * \param [in] prompt_provider The prompt session associated with the callback
1908+ * \param [in] added True if the session was added, false otherwise
1909+ * \param [in,out] context The context provided by the client
1910+ */
1911+typedef void (*mir_prompt_session_add_prompt_provider_callback)(
1912+ MirPromptSession* prompt_provider, MirBool added, void* context);
1913+
1914+/**
1915+ * Callback member of MirPromptSession for handling of prompt sessions events.
1916+ * \param [in] prompt_provider The prompt session associated with the callback
1917+ * \param [in] state The state of the prompt session
1918+ * \param [in,out] context The context provided by the client
1919+ */
1920+typedef void (*mir_prompt_session_state_change_callback)(
1921+ MirPromptSession* prompt_provider, MirPromptSessionState state, void* context);
1922+
1923 #ifdef __cplusplus
1924 }
1925 /**@}*/
1926
1927=== modified file 'include/shared/mir_toolkit/common.h'
1928--- include/shared/mir_toolkit/common.h 2014-05-05 09:02:17 +0000
1929+++ include/shared/mir_toolkit/common.h 2014-06-18 12:52:17 +0000
1930@@ -88,6 +88,12 @@
1931 mir_power_mode_off /* Powered down. */
1932 } MirPowerMode;
1933
1934+typedef enum MirPromptSessionState
1935+{
1936+ mir_prompt_session_state_stopped = 0,
1937+ mir_prompt_session_state_started
1938+} MirPromptSessionState;
1939+
1940 /**
1941 * The order of components in a format enum matches the
1942 * order of the components as they would be written in an
1943
1944=== modified file 'include/shared/mir_toolkit/event.h'
1945--- include/shared/mir_toolkit/event.h 2014-03-06 06:05:17 +0000
1946+++ include/shared/mir_toolkit/event.h 2014-06-18 12:52:17 +0000
1947@@ -40,7 +40,8 @@
1948 mir_event_type_key,
1949 mir_event_type_motion,
1950 mir_event_type_surface,
1951- mir_event_type_resize
1952+ mir_event_type_resize,
1953+ mir_event_type_prompt_session_state_change
1954 } MirEventType;
1955
1956 typedef enum {
1957@@ -204,6 +205,13 @@
1958 int height;
1959 } MirResizeEvent;
1960
1961+typedef struct
1962+{
1963+ MirEventType type;
1964+
1965+ MirPromptSessionState new_state;
1966+} MirPromptSessionEvent;
1967+
1968 typedef union
1969 {
1970 MirEventType type;
1971@@ -211,6 +219,7 @@
1972 MirMotionEvent motion;
1973 MirSurfaceEvent surface;
1974 MirResizeEvent resize;
1975+ MirPromptSessionEvent prompt_session;
1976 } MirEvent;
1977
1978 #ifdef __cplusplus
1979
1980=== added file 'include/test/mir_test/barrier.h'
1981--- include/test/mir_test/barrier.h 1970-01-01 00:00:00 +0000
1982+++ include/test/mir_test/barrier.h 2014-06-18 12:52:17 +0000
1983@@ -0,0 +1,61 @@
1984+/*
1985+ * Copyright © 2014 Canonical Ltd.
1986+ *
1987+ * This program is free software: you can redistribute it and/or modify it
1988+ * under the terms of the GNU General Public License version 3,
1989+ * as published by the Free Software Foundation.
1990+ *
1991+ * This program is distributed in the hope that it will be useful,
1992+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1993+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1994+ * GNU General Public License for more details.
1995+ *
1996+ * You should have received a copy of the GNU General Public License
1997+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1998+ *
1999+ * Authored By: Alan Griffiths <alan@octopull.co.uk>
2000+ */
2001+
2002+#ifndef MIR_TEST_BARRIER_H_
2003+#define MIR_TEST_BARRIER_H_
2004+
2005+#include <mutex>
2006+#include <condition_variable>
2007+
2008+namespace mir
2009+{
2010+namespace test
2011+{
2012+class Barrier
2013+{
2014+public:
2015+ explicit Barrier(unsigned wait_threads) : wait_threads{wait_threads} {}
2016+
2017+ void reset(unsigned threads)
2018+ {
2019+ std::unique_lock<decltype(mutex)> lock(mutex);
2020+ wait_threads = threads;
2021+ }
2022+
2023+ void ready()
2024+ {
2025+ std::unique_lock<decltype(mutex)> lock(mutex);
2026+ --wait_threads;
2027+ cv.notify_all();
2028+ if (!cv.wait_for(lock, std::chrono::minutes(1), [&]{ return wait_threads == 0; }))
2029+ throw std::runtime_error("Timeout");
2030+ }
2031+
2032+private:
2033+ Barrier(Barrier const&) = default;
2034+ Barrier& operator=(Barrier const&) = default;
2035+ unsigned wait_threads;
2036+ std::mutex mutex;
2037+ std::condition_variable cv;
2038+};
2039+}
2040+}
2041+
2042+
2043+
2044+#endif /* MIR_TEST_BARRIER_H_ */
2045
2046=== added file 'include/test/mir_test/current_thread_name.h'
2047--- include/test/mir_test/current_thread_name.h 1970-01-01 00:00:00 +0000
2048+++ include/test/mir_test/current_thread_name.h 2014-06-18 12:52:17 +0000
2049@@ -0,0 +1,34 @@
2050+/*
2051+ * Copyright © 2014 Canonical Ltd.
2052+ *
2053+ * This program is free software: you can redistribute it and/or modify
2054+ * it under the terms of the GNU General Public License version 3 as
2055+ * published by the Free Software Foundation.
2056+ *
2057+ * This program is distributed in the hope that it will be useful,
2058+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2059+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2060+ * GNU General Public License for more details.
2061+ *
2062+ * You should have received a copy of the GNU General Public License
2063+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2064+ *
2065+ * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
2066+ */
2067+
2068+#ifndef MIR_TEST_CURRENT_THREAD_NAME_H_
2069+#define MIR_TEST_CURRENT_THREAD_NAME_H_
2070+
2071+#include <string>
2072+
2073+namespace mir
2074+{
2075+namespace test
2076+{
2077+
2078+std::string current_thread_name();
2079+
2080+}
2081+}
2082+
2083+#endif
2084
2085=== added file 'include/test/mir_test/fake_clock.h'
2086--- include/test/mir_test/fake_clock.h 1970-01-01 00:00:00 +0000
2087+++ include/test/mir_test/fake_clock.h 2014-06-18 12:52:17 +0000
2088@@ -0,0 +1,72 @@
2089+/*
2090+ * Copyright © 2014 Canonical Ltd.
2091+ *
2092+ * This program is free software: you can redistribute it and/or modify it
2093+ * under the terms of the GNU General Public License version 3,
2094+ * as published by the Free Software Foundation.
2095+ *
2096+ * This program is distributed in the hope that it will be useful,
2097+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2098+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2099+ * GNU General Public License for more details.
2100+ *
2101+ * You should have received a copy of the GNU General Public License
2102+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2103+ *
2104+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2105+ */
2106+
2107+#ifndef MIR_TEST_FAKE_CLOCK_H_
2108+#define MIR_TEST_FAKE_CLOCK_H_
2109+
2110+#include <chrono>
2111+#include <functional>
2112+#include <list>
2113+
2114+namespace mir
2115+{
2116+namespace test
2117+{
2118+/**
2119+ * @brief An invasive time source for Mocks/Stubs/Fakes that depend on timing
2120+ */
2121+class FakeClock
2122+{
2123+public:
2124+ typedef std::chrono::nanoseconds duration;
2125+ typedef duration::rep rep;
2126+ typedef duration::period period;
2127+ typedef std::chrono::time_point<FakeClock, duration> time_point;
2128+
2129+ static constexpr bool is_steady = false;
2130+ time_point now() const;
2131+
2132+ FakeClock();
2133+ /**
2134+ * \brief Advance the fake clock
2135+ * \note Advancing by a negative duration will move the clock backwards
2136+ */
2137+ template<typename rep, typename period>
2138+ void advance_time(std::chrono::duration<rep, period> by)
2139+ {
2140+ advance_time_ns(std::chrono::duration_cast<std::chrono::nanoseconds>(by));
2141+ }
2142+
2143+ /**
2144+ * \brief Register an event callback when the time is changed
2145+ * \param cb Function to call when the time is changed.
2146+ * This function is called with the new time.
2147+ * If the function returns false, it will no longer be called
2148+ * on subsequent time changes.
2149+ */
2150+ void register_time_change_callback(std::function<bool(time_point)> cb);
2151+private:
2152+ void advance_time_ns(std::chrono::nanoseconds by);
2153+ std::chrono::nanoseconds current_time;
2154+ std::list<std::function<bool(time_point)>> callbacks;
2155+};
2156+
2157+}
2158+}
2159+
2160+#endif // MIR_TEST_FAKE_CLOCK_H_
2161
2162=== added file 'include/test/mir_test/signal.h'
2163--- include/test/mir_test/signal.h 1970-01-01 00:00:00 +0000
2164+++ include/test/mir_test/signal.h 2014-06-18 12:52:17 +0000
2165@@ -0,0 +1,63 @@
2166+/*
2167+ * Copyright © 2014 Canonical Ltd.
2168+ *
2169+ * This program is free software: you can redistribute it and/or modify
2170+ * it under the terms of the GNU General Public License version 3 as
2171+ * published by the Free Software Foundation.
2172+ *
2173+ * This program is distributed in the hope that it will be useful,
2174+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2175+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2176+ * GNU General Public License for more details.
2177+ *
2178+ * You should have received a copy of the GNU General Public License
2179+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2180+ *
2181+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2182+ */
2183+
2184+#ifndef MIR_TEST_SIGNAL_H_
2185+#define MIR_TEST_SIGNAL_H_
2186+
2187+#include <condition_variable>
2188+#include <chrono>
2189+#include <mutex>
2190+
2191+namespace mir
2192+{
2193+namespace test
2194+{
2195+/**
2196+ * @brief A threadsafe, waitable signal
2197+ */
2198+class Signal
2199+{
2200+public:
2201+ Signal();
2202+
2203+ void raise();
2204+ bool raised();
2205+
2206+ void wait();
2207+ template<typename rep, typename period>
2208+ bool wait_for(std::chrono::duration<rep, period> delay)
2209+ {
2210+ std::unique_lock<decltype(mutex)> lock(mutex);
2211+ return cv.wait_for(lock, delay, [this]() { return signalled; });
2212+ }
2213+ template<class Clock, class Duration>
2214+ bool wait_until(std::chrono::time_point<Clock, Duration> const& time)
2215+ {
2216+ std::unique_lock<decltype(mutex)> lock(mutex);
2217+ return cv.wait_until(lock, time, [this]() { return signalled; });
2218+ }
2219+
2220+private:
2221+ std::mutex mutex;
2222+ std::condition_variable cv;
2223+ bool signalled;
2224+};
2225+}
2226+}
2227+
2228+#endif // MIR_TEST_SIGNAL_H_
2229
2230=== modified file 'include/test/mir_test/test_protobuf_client.h'
2231--- include/test/mir_test/test_protobuf_client.h 2013-08-28 03:41:48 +0000
2232+++ include/test/mir_test/test_protobuf_client.h 2014-06-18 12:52:17 +0000
2233@@ -21,6 +21,7 @@
2234 #define MIR_TEST_TEST_CLIENT_H_
2235
2236 #include "mir_protobuf.pb.h"
2237+#include "wait_condition.h"
2238
2239 #include <gmock/gmock.h>
2240
2241@@ -49,6 +50,9 @@
2242 mir::protobuf::Connection connection;
2243 mir::protobuf::DisplayConfiguration disp_config;
2244 mir::protobuf::DisplayConfiguration disp_config_response;
2245+ mir::protobuf::PromptSessionParameters prompt_session_parameters;
2246+ mir::protobuf::PromptProvider prompt_provider;
2247+ mir::protobuf::Void prompt_session;
2248
2249 MOCK_METHOD0(connect_done, void());
2250 MOCK_METHOD0(create_surface_done, void());
2251@@ -57,6 +61,9 @@
2252 MOCK_METHOD0(disconnect_done, void());
2253 MOCK_METHOD0(drm_auth_magic_done, void());
2254 MOCK_METHOD0(display_configure_done, void());
2255+ MOCK_METHOD0(prompt_session_start_done, void());
2256+ MOCK_METHOD0(prompt_session_add_prompt_provider_done, void());
2257+ MOCK_METHOD0(prompt_session_stop_done, void());
2258
2259 void on_connect_done();
2260
2261@@ -94,6 +101,12 @@
2262
2263 void wait_for_configure_display_done();
2264
2265+ void wait_for_prompt_session_start_done();
2266+
2267+ void wait_for_prompt_session_add_prompt_provider_done();
2268+
2269+ void wait_for_prompt_session_stop_done();
2270+
2271 const int maxwait;
2272 std::atomic<bool> connect_done_called;
2273 std::atomic<bool> create_surface_called;
2274@@ -104,6 +117,10 @@
2275 std::atomic<bool> configure_display_done_called;
2276 std::atomic<bool> tfd_done_called;
2277
2278+ WaitCondition wc_prompt_session_start;
2279+ WaitCondition wc_prompt_session_add;
2280+ WaitCondition wc_prompt_session_stop;
2281+
2282 std::atomic<int> connect_done_count;
2283 std::atomic<int> create_surface_done_count;
2284 std::atomic<int> disconnect_done_count;
2285
2286=== modified file 'include/test/mir_test_doubles/fake_ipc_factory.h'
2287--- include/test/mir_test_doubles/fake_ipc_factory.h 2014-05-13 10:03:15 +0000
2288+++ include/test/mir_test_doubles/fake_ipc_factory.h 2014-06-18 12:52:17 +0000
2289@@ -40,24 +40,26 @@
2290 std::shared_ptr<frontend::DisplayChanger> const& changer,
2291 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
2292 std::shared_ptr<frontend::SessionMediatorReport> const& sm_report,
2293- const std::shared_ptr<frontend::EventSink>& sink,
2294- const std::shared_ptr<frontend::Screencast>& effective_screencast,
2295- const frontend::ConnectionContext& connection_context)
2296+ std::shared_ptr<frontend::EventSink> const& sink,
2297+ std::shared_ptr<frontend::Screencast> const& effective_screencast,
2298+ frontend::ConnectionContext const& connection_context,
2299+ std::shared_ptr<graphics::CursorImages> const& cursor_images)
2300 {
2301 return frontend::DefaultIpcFactory::make_mediator(
2302 shell, graphics_platform, changer, buffer_allocator,
2303- sm_report, sink, effective_screencast, connection_context);
2304+ sm_report, sink, effective_screencast, connection_context, cursor_images);
2305 }
2306
2307- MOCK_METHOD8(make_mediator, std::shared_ptr<frontend::detail::DisplayServer>(
2308+ MOCK_METHOD9(make_mediator, std::shared_ptr<frontend::detail::DisplayServer>(
2309 std::shared_ptr<frontend::Shell> const& shell,
2310 std::shared_ptr<graphics::Platform> const& graphics_platform,
2311 std::shared_ptr<frontend::DisplayChanger> const& changer,
2312 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
2313 std::shared_ptr<frontend::SessionMediatorReport> const& sm_report,
2314- const std::shared_ptr<frontend::EventSink>& sink,
2315- const std::shared_ptr<frontend::Screencast>& effective_screencast,
2316- const frontend::ConnectionContext& connection_context));
2317+ std::shared_ptr<frontend::EventSink> const& sink,
2318+ std::shared_ptr<frontend::Screencast> const& effective_screencast,
2319+ frontend::ConnectionContext const& connection_context,
2320+ std::shared_ptr<graphics::CursorImages> const& cursor_images));
2321 };
2322 }
2323 }
2324
2325=== modified file 'include/test/mir_test_doubles/fake_renderable.h'
2326--- include/test/mir_test_doubles/fake_renderable.h 2014-05-07 02:56:33 +0000
2327+++ include/test/mir_test_doubles/fake_renderable.h 2014-06-18 12:52:17 +0000
2328@@ -19,6 +19,7 @@
2329 #ifndef MIR_TEST_DOUBLES_FAKE_RENDERABLE_H_
2330 #define MIR_TEST_DOUBLES_FAKE_RENDERABLE_H_
2331
2332+#include "stub_buffer.h"
2333 #include "mir/graphics/renderable.h"
2334 #define GLM_FORCE_RADIANS
2335 #include <glm/gtc/matrix_transform.hpp>
2336@@ -34,12 +35,36 @@
2337 class FakeRenderable : public graphics::Renderable
2338 {
2339 public:
2340- FakeRenderable(int x, int y, int width, int height,
2341- float opacity=1.0f,
2342- bool rectangular=true,
2343- bool visible=true,
2344- bool posted=true)
2345- : rect{{x, y}, {width, height}},
2346+ FakeRenderable(int x, int y, int width, int height)
2347+ : FakeRenderable{geometry::Rectangle{{x,y},{width,height}}}
2348+ {
2349+ }
2350+ FakeRenderable(geometry::Rectangle display_area)
2351+ : FakeRenderable{display_area, 1.0f, true, true, true}
2352+ {
2353+ }
2354+
2355+ FakeRenderable(geometry::Rectangle display_area,
2356+ float opacity)
2357+ : FakeRenderable{display_area, opacity, true, true, true}
2358+ {
2359+ }
2360+
2361+ FakeRenderable(geometry::Rectangle display_area,
2362+ float opacity,
2363+ bool rectangular,
2364+ bool visible)
2365+ : FakeRenderable{display_area, opacity, rectangular, visible, true}
2366+ {
2367+ }
2368+
2369+ FakeRenderable(geometry::Rectangle display_area,
2370+ float opacity,
2371+ bool rectangular,
2372+ bool visible,
2373+ bool posted)
2374+ : buf{std::make_shared<StubBuffer>()},
2375+ rect(display_area),
2376 opacity(opacity),
2377 rectangular(rectangular),
2378 visible_(visible),
2379
2380=== modified file 'include/test/mir_test_doubles/mock_buffer.h'
2381--- include/test/mir_test_doubles/mock_buffer.h 2014-03-06 06:05:17 +0000
2382+++ include/test/mir_test_doubles/mock_buffer.h 2014-06-18 12:52:17 +0000
2383@@ -63,7 +63,7 @@
2384 MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());
2385 MOCK_CONST_METHOD0(native_buffer_handle, std::shared_ptr<graphics::NativeBuffer>());
2386
2387- MOCK_METHOD0(bind_to_texture, void());
2388+ MOCK_METHOD0(gl_bind_to_texture, void());
2389 MOCK_CONST_METHOD0(id, graphics::BufferID());
2390
2391 MOCK_CONST_METHOD0(can_bypass, bool());
2392
2393=== modified file 'include/test/mir_test_doubles/mock_buffer_stream.h'
2394--- include/test/mir_test_doubles/mock_buffer_stream.h 2014-04-14 19:35:21 +0000
2395+++ include/test/mir_test_doubles/mock_buffer_stream.h 2014-06-18 12:52:17 +0000
2396@@ -44,7 +44,8 @@
2397 ON_CALL(*this, buffers_ready_for_compositor())
2398 .WillByDefault(testing::Invoke(this, &MockBufferStream::buffers_ready));
2399 }
2400- MOCK_METHOD2(swap_client_buffers, void(graphics::Buffer*, std::function<void(graphics::Buffer*)> completee));
2401+ MOCK_METHOD1(acquire_client_buffer, void(std::function<void(graphics::Buffer* buffer)>));
2402+ MOCK_METHOD1(release_client_buffer, void(graphics::Buffer*));
2403 MOCK_METHOD1(lock_compositor_buffer,
2404 std::shared_ptr<graphics::Buffer>(void const*));
2405 MOCK_METHOD0(lock_snapshot_buffer, std::shared_ptr<graphics::Buffer>());
2406
2407=== modified file 'include/test/mir_test_doubles/mock_display_buffer.h'
2408--- include/test/mir_test_doubles/mock_display_buffer.h 2014-05-22 09:56:17 +0000
2409+++ include/test/mir_test_doubles/mock_display_buffer.h 2014-06-18 12:52:17 +0000
2410@@ -36,8 +36,6 @@
2411 MockDisplayBuffer()
2412 {
2413 using namespace testing;
2414- ON_CALL(*this, can_bypass())
2415- .WillByDefault(Return(false));
2416 ON_CALL(*this, view_area())
2417 .WillByDefault(Return(geometry::Rectangle{{0,0},{0,0}}));
2418 }
2419@@ -45,9 +43,9 @@
2420 MOCK_METHOD0(make_current, void());
2421 MOCK_METHOD0(release_current, void());
2422 MOCK_METHOD0(post_update, void());
2423- MOCK_CONST_METHOD0(can_bypass, bool());
2424- MOCK_METHOD1(post_renderables_if_optimizable, bool(graphics::RenderableList const&));
2425+ MOCK_METHOD1(post_renderables_if_optimizable, bool(graphics::RenderableList const&));
2426 MOCK_CONST_METHOD0(orientation, MirOrientation());
2427+ MOCK_CONST_METHOD0(uses_alpha, bool());
2428 };
2429
2430 }
2431
2432=== modified file 'include/test/mir_test_doubles/mock_display_device.h'
2433--- include/test/mir_test_doubles/mock_display_device.h 2014-05-20 20:01:43 +0000
2434+++ include/test/mir_test_doubles/mock_display_device.h 2014-06-18 12:52:17 +0000
2435@@ -36,12 +36,11 @@
2436 public:
2437 ~MockDisplayDevice() noexcept {}
2438 MOCK_METHOD1(mode, void(MirPowerMode));
2439- MOCK_METHOD1(render_gl, void(graphics::android::SwappingGLContext const&));
2440- MOCK_METHOD3(prepare_overlays, void(
2441+ MOCK_METHOD1(post_gl, void(graphics::android::SwappingGLContext const&));
2442+ MOCK_METHOD3(post_overlays, bool(
2443 graphics::android::SwappingGLContext const&,
2444 graphics::RenderableList const&,
2445 graphics::android::RenderableListCompositor const&));
2446- MOCK_METHOD1(post, void(graphics::Buffer const&));
2447 MOCK_CONST_METHOD1(apply_orientation, bool(MirOrientation));
2448 };
2449 }
2450
2451=== added file 'include/test/mir_test_doubles/mock_frame_dropping_policy_factory.h'
2452--- include/test/mir_test_doubles/mock_frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000
2453+++ include/test/mir_test_doubles/mock_frame_dropping_policy_factory.h 2014-06-18 12:52:17 +0000
2454@@ -0,0 +1,83 @@
2455+/*
2456+ * Copyright © 2014 Canonical Ltd.
2457+ *
2458+ * This program is free software: you can redistribute it and/or modify it
2459+ * under the terms of the GNU General Public License version 3,
2460+ * as published by the Free Software Foundation.
2461+ *
2462+ * This program is distributed in the hope that it will be useful,
2463+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2464+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2465+ * GNU General Public License for more details.
2466+ *
2467+ * You should have received a copy of the GNU General Public License
2468+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2469+ *
2470+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2471+ */
2472+
2473+
2474+#ifndef MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_
2475+#define MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_
2476+
2477+#include "mir/compositor/frame_dropping_policy_factory.h"
2478+#include "mir/compositor/frame_dropping_policy.h"
2479+
2480+#include <unordered_set>
2481+#include <functional>
2482+
2483+#include <gmock/gmock.h>
2484+
2485+namespace mc = mir::compositor;
2486+
2487+namespace mir
2488+{
2489+namespace test
2490+{
2491+namespace doubles
2492+{
2493+
2494+class MockFrameDroppingPolicyFactory;
2495+
2496+class MockFrameDroppingPolicy : public mc::FrameDroppingPolicy
2497+{
2498+public:
2499+ MockFrameDroppingPolicy(std::function<void(void)> callback,
2500+ MockFrameDroppingPolicyFactory const* parent);
2501+ ~MockFrameDroppingPolicy();
2502+
2503+ MOCK_METHOD0(swap_now_blocking, void(void));
2504+ MOCK_METHOD0(swap_unblocked, void(void));
2505+
2506+ void trigger();
2507+
2508+private:
2509+ friend class MockFrameDroppingPolicyFactory;
2510+ void parent_destroyed();
2511+
2512+ std::function<void(void)> callback;
2513+ MockFrameDroppingPolicyFactory const* parent;
2514+};
2515+
2516+class MockFrameDroppingPolicyFactory : public mc::FrameDroppingPolicyFactory
2517+{
2518+public:
2519+ std::unique_ptr<mc::FrameDroppingPolicy> create_policy(std::function<void(void)> drop_frame) const override;
2520+
2521+ ~MockFrameDroppingPolicyFactory();
2522+
2523+ void trigger_policies() const;
2524+
2525+private:
2526+ friend class MockFrameDroppingPolicy;
2527+
2528+ void policy_destroyed(MockFrameDroppingPolicy* policy) const;
2529+ mutable std::unordered_set<MockFrameDroppingPolicy*> policies;
2530+};
2531+
2532+}
2533+}
2534+}
2535+
2536+
2537+#endif // MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_
2538
2539=== modified file 'include/test/mir_test_doubles/mock_frontend_surface.h'
2540--- include/test/mir_test_doubles/mock_frontend_surface.h 2014-05-22 11:31:21 +0000
2541+++ include/test/mir_test_doubles/mock_frontend_surface.h 2014-06-18 12:52:17 +0000
2542@@ -46,6 +46,8 @@
2543
2544 MOCK_CONST_METHOD0(supports_input, bool());
2545 MOCK_CONST_METHOD0(client_input_fd, int());
2546+
2547+ MOCK_METHOD1(set_cursor_image, void(std::shared_ptr<graphics::CursorImage> const&));
2548
2549 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));
2550 };
2551
2552=== modified file 'include/test/mir_test_doubles/mock_gl.h'
2553--- include/test/mir_test_doubles/mock_gl.h 2014-06-03 19:08:47 +0000
2554+++ include/test/mir_test_doubles/mock_gl.h 2014-06-18 12:52:17 +0000
2555@@ -48,6 +48,7 @@
2556 MOCK_METHOD1(glCheckFramebufferStatus, GLenum(GLenum));
2557 MOCK_METHOD1(glClear, void(GLbitfield));
2558 MOCK_METHOD4(glClearColor, void(GLclampf, GLclampf, GLclampf, GLclampf));
2559+ MOCK_METHOD4(glColorMask, void(GLboolean, GLboolean, GLboolean, GLboolean));
2560 MOCK_METHOD1(glCompileShader, void(GLuint));
2561 MOCK_METHOD0(glCreateProgram, GLuint());
2562 MOCK_METHOD1(glCreateShader, GLuint(GLenum));
2563
2564=== added file 'include/test/mir_test_doubles/mock_prompt_session_listener.h'
2565--- include/test/mir_test_doubles/mock_prompt_session_listener.h 1970-01-01 00:00:00 +0000
2566+++ include/test/mir_test_doubles/mock_prompt_session_listener.h 2014-06-18 12:52:17 +0000
2567@@ -0,0 +1,48 @@
2568+/*
2569+ * Copyright © 2014 Canonical Ltd.
2570+ *
2571+ * This program is free software: you can redistribute it and/or modify it
2572+ * under the terms of the GNU General Public License version 3,
2573+ * as published by the Free Software Foundation.
2574+ *
2575+ * This program is distributed in the hope that it will be useful,
2576+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2577+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2578+ * GNU General Public License for more details.
2579+ *
2580+ * You should have received a copy of the GNU General Public License
2581+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2582+ *
2583+ * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
2584+ */
2585+
2586+#ifndef MIR_TEST_DOUBLES_MOCK_PROMPT_SESSION_LISTENER_H_
2587+#define MIR_TEST_DOUBLES_MOCK_PROMPT_SESSION_LISTENER_H_
2588+
2589+#include "mir/scene/prompt_session_listener.h"
2590+
2591+#include <gmock/gmock.h>
2592+
2593+namespace mir
2594+{
2595+namespace test
2596+{
2597+namespace doubles
2598+{
2599+
2600+struct MockPromptSessionListener : public scene::PromptSessionListener
2601+{
2602+ virtual ~MockPromptSessionListener() noexcept(true) {}
2603+
2604+ MOCK_METHOD1(starting, void(std::shared_ptr<scene::PromptSession> const&));
2605+ MOCK_METHOD1(stopping, void(std::shared_ptr<scene::PromptSession> const&));
2606+
2607+ MOCK_METHOD2(prompt_provider_added, void(scene::PromptSession const&, std::shared_ptr<scene::Session> const&));
2608+ MOCK_METHOD2(prompt_provider_removed, void(scene::PromptSession const&, std::shared_ptr<scene::Session> const&));
2609+};
2610+
2611+}
2612+}
2613+} // namespace mir
2614+
2615+#endif // MIR_TEST_DOUBLES_MOCK_PROMPT_SESSION_LISTENER_H_
2616
2617=== modified file 'include/test/mir_test_doubles/mock_scene_session.h'
2618--- include/test/mir_test_doubles/mock_scene_session.h 2014-05-22 11:31:21 +0000
2619+++ include/test/mir_test_doubles/mock_scene_session.h 2014-06-18 12:52:17 +0000
2620@@ -52,6 +52,9 @@
2621 MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int));
2622
2623 MOCK_METHOD1(set_lifecycle_state, void(MirLifecycleState state));
2624+
2625+ MOCK_METHOD0(start_prompt_session, void());
2626+ MOCK_METHOD0(stop_prompt_session, void());
2627 };
2628
2629 }
2630
2631=== modified file 'include/test/mir_test_doubles/mock_shell.h'
2632--- include/test/mir_test_doubles/mock_shell.h 2014-04-15 05:31:19 +0000
2633+++ include/test/mir_test_doubles/mock_shell.h 2014-06-18 12:52:17 +0000
2634@@ -22,6 +22,7 @@
2635 #include "mir/scene/surface_creation_parameters.h"
2636 #include "mir/frontend/shell.h"
2637 #include "mir/frontend/surface_id.h"
2638+#include "mir/scene/prompt_session_creation_parameters.h"
2639
2640 #include <gmock/gmock.h>
2641
2642@@ -43,6 +44,17 @@
2643
2644 MOCK_METHOD2(create_surface_for, frontend::SurfaceId(std::shared_ptr<frontend::Session> const&, scene::SurfaceCreationParameters const&));
2645 MOCK_METHOD1(handle_surface_created, void(std::shared_ptr<frontend::Session> const&));
2646+
2647+ MOCK_METHOD2(start_prompt_session_for, std::shared_ptr<frontend::PromptSession>(
2648+ std::shared_ptr<frontend::Session> const&,
2649+ scene::PromptSessionCreationParameters const&));
2650+ MOCK_METHOD2(add_prompt_provider_process_for, void(
2651+ std::shared_ptr<frontend::PromptSession> const&,
2652+ pid_t));
2653+ MOCK_METHOD2(add_prompt_provider_for, void(
2654+ std::shared_ptr<frontend::PromptSession> const&,
2655+ std::shared_ptr<frontend::Session> const&));
2656+ MOCK_METHOD1(stop_prompt_session, void(std::shared_ptr<frontend::PromptSession> const&));
2657 };
2658
2659 }
2660
2661=== modified file 'include/test/mir_test_doubles/mock_surface.h'
2662--- include/test/mir_test_doubles/mock_surface.h 2014-05-07 02:56:33 +0000
2663+++ include/test/mir_test_doubles/mock_surface.h 2014-06-18 12:52:17 +0000
2664@@ -41,6 +41,7 @@
2665 {},
2666 {},
2667 {},
2668+ {},
2669 mir::report::null_scene_report())
2670 {
2671 }
2672
2673=== modified file 'include/test/mir_test_doubles/mock_swapping_gl_context.h'
2674--- include/test/mir_test_doubles/mock_swapping_gl_context.h 2014-02-21 16:51:45 +0000
2675+++ include/test/mir_test_doubles/mock_swapping_gl_context.h 2014-06-18 12:52:17 +0000
2676@@ -31,6 +31,7 @@
2677 struct MockSwappingGLContext : public graphics::android::SwappingGLContext
2678 {
2679 MOCK_CONST_METHOD0(swap_buffers, void());
2680+ MOCK_CONST_METHOD0(last_rendered_buffer, std::shared_ptr<graphics::Buffer>());
2681 };
2682
2683 }
2684
2685=== added file 'include/test/mir_test_doubles/mock_timer.h'
2686--- include/test/mir_test_doubles/mock_timer.h 1970-01-01 00:00:00 +0000
2687+++ include/test/mir_test_doubles/mock_timer.h 2014-06-18 12:52:17 +0000
2688@@ -0,0 +1,52 @@
2689+/*
2690+ * Copyright © 2014 Canonical Ltd.
2691+ *
2692+ * This program is free software: you can redistribute it and/or modify it
2693+ * under the terms of the GNU General Public License version 3,
2694+ * as published by the Free Software Foundation.
2695+ *
2696+ * This program is distributed in the hope that it will be useful,
2697+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2698+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2699+ * GNU General Public License for more details.
2700+ *
2701+ * You should have received a copy of the GNU General Public License
2702+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2703+ *
2704+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2705+ */
2706+
2707+#ifndef MIR_TEST_DOUBLES_MOCK_TIMER_H_
2708+#define MIR_TEST_DOUBLES_MOCK_TIMER_H_
2709+
2710+#include "mir/time/timer.h"
2711+#include "mir_test/fake_clock.h"
2712+#include <memory>
2713+
2714+namespace mir
2715+{
2716+namespace test
2717+{
2718+namespace doubles
2719+{
2720+
2721+class FakeTimer : public mir::time::Timer
2722+{
2723+public:
2724+ FakeTimer(std::shared_ptr<FakeClock> const& clock);
2725+
2726+ std::unique_ptr<time::Alarm> notify_in(std::chrono::milliseconds delay,
2727+ std::function<void(void)> callback) override;
2728+ std::unique_ptr<time::Alarm> notify_at(time::Timestamp time_point,
2729+ std::function<void(void)> callback) override;
2730+ std::unique_ptr<time::Alarm> create_alarm(std::function<void ()> callback) override;
2731+
2732+private:
2733+ std::shared_ptr<FakeClock> const clock;
2734+};
2735+
2736+}
2737+}
2738+}
2739+
2740+#endif // MIR_TEST_DOUBLES_MOCK_TIMER_H_
2741
2742=== added file 'include/test/mir_test_doubles/mock_virtual_terminal.h'
2743--- include/test/mir_test_doubles/mock_virtual_terminal.h 1970-01-01 00:00:00 +0000
2744+++ include/test/mir_test_doubles/mock_virtual_terminal.h 2014-06-18 12:52:17 +0000
2745@@ -0,0 +1,48 @@
2746+/*
2747+ * Copyright © 2014 Canonical Ltd.
2748+ *
2749+ * This program is free software: you can redistribute it and/or modify it
2750+ * under the terms of the GNU General Public License version 3,
2751+ * as published by the Free Software Foundation.
2752+ *
2753+ * This program is distributed in the hope that it will be useful,
2754+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2755+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2756+ * GNU General Public License for more details.
2757+ *
2758+ * You should have received a copy of the GNU General Public License
2759+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2760+ *
2761+ * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
2762+ */
2763+
2764+#ifndef MIR_TEST_DOUBLES_MOCK_VIRTUAL_TERMINAL_H_
2765+#define MIR_TEST_DOUBLES_MOCK_VIRTUAL_TERMINAL_H_
2766+
2767+#include "src/platform/graphics/mesa/virtual_terminal.h"
2768+
2769+#include <gmock/gmock.h>
2770+
2771+namespace mir
2772+{
2773+namespace test
2774+{
2775+namespace doubles
2776+{
2777+
2778+class MockVirtualTerminal : public graphics::mesa::VirtualTerminal
2779+{
2780+public:
2781+ MOCK_METHOD0(set_graphics_mode, void());
2782+ MOCK_METHOD3(register_switch_handlers,
2783+ void(graphics::EventHandlerRegister&,
2784+ std::function<bool()> const&,
2785+ std::function<bool()> const&));
2786+ MOCK_METHOD0(restore, void());
2787+};
2788+
2789+}
2790+}
2791+}
2792+
2793+#endif
2794
2795=== added file 'include/test/mir_test_doubles/null_client_event_sink.h'
2796--- include/test/mir_test_doubles/null_client_event_sink.h 1970-01-01 00:00:00 +0000
2797+++ include/test/mir_test_doubles/null_client_event_sink.h 2014-06-18 12:52:17 +0000
2798@@ -0,0 +1,42 @@
2799+/*
2800+ * Copyright © 2012 Canonical Ltd.
2801+ *
2802+ * This program is free software: you can redistribute it and/or modify it
2803+ * under the terms of the GNU General Public License version 3,
2804+ * as published by the Free Software Foundation.
2805+ *
2806+ * This program is distributed in the hope that it will be useful,
2807+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2808+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2809+ * GNU General Public License for more details.
2810+ *
2811+ * You should have received a copy of the GNU General Public License
2812+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2813+ *
2814+ * Authored by: Nick Dedekink <nick.dedekind@canonical.com>
2815+ */
2816+
2817+#ifndef MIR_TEST_DOUBLES_NULL_CLIENT_EVENT_SINK_H_
2818+#define MIR_TEST_DOUBLES_NULL_CLIENT_EVENT_SINK_H_
2819+
2820+#include "src/client/event_sink.h"
2821+
2822+#include <gmock/gmock.h>
2823+
2824+namespace mir
2825+{
2826+namespace test
2827+{
2828+namespace doubles
2829+{
2830+class NullClientEventSink : public client::EventSink
2831+{
2832+public:
2833+ void handle_event(MirEvent const&) override {}
2834+};
2835+
2836+}
2837+}
2838+}
2839+
2840+#endif /* MIR_TEST_DOUBLES_NULL_CLIENT_EVENT_SINK_H_ */
2841
2842=== modified file 'include/test/mir_test_doubles/null_display_buffer.h'
2843--- include/test/mir_test_doubles/null_display_buffer.h 2014-05-22 09:56:17 +0000
2844+++ include/test/mir_test_doubles/null_display_buffer.h 2014-06-18 12:52:17 +0000
2845@@ -35,9 +35,9 @@
2846 void make_current() {}
2847 void release_current() {}
2848 void post_update() {}
2849- bool can_bypass() const override { return false; }
2850 bool post_renderables_if_optimizable(graphics::RenderableList const&) { return false; }
2851 MirOrientation orientation() const override { return mir_orientation_normal; }
2852+ bool uses_alpha() const override { return false; }
2853 };
2854
2855 }
2856
2857=== modified file 'include/test/mir_test_doubles/null_display_buffer_compositor_factory.h'
2858--- include/test/mir_test_doubles/null_display_buffer_compositor_factory.h 2014-04-08 13:12:47 +0000
2859+++ include/test/mir_test_doubles/null_display_buffer_compositor_factory.h 2014-06-18 12:52:17 +0000
2860@@ -37,7 +37,7 @@
2861 {
2862 struct NullDisplayBufferCompositor : compositor::DisplayBufferCompositor
2863 {
2864- bool composite() { return false; }
2865+ void composite() {}
2866 };
2867
2868 auto raw = new NullDisplayBufferCompositor{};
2869
2870=== added file 'include/test/mir_test_doubles/null_pixel_buffer.h'
2871--- include/test/mir_test_doubles/null_pixel_buffer.h 1970-01-01 00:00:00 +0000
2872+++ include/test/mir_test_doubles/null_pixel_buffer.h 2014-06-18 12:52:17 +0000
2873@@ -0,0 +1,43 @@
2874+/*
2875+ * Copyright © 2014 Canonical Ltd.
2876+ *
2877+ * This program is free software: you can redistribute it and/or modify it
2878+ * under the terms of the GNU General Public License version 3,
2879+ * as published by the Free Software Foundation.
2880+ *
2881+ * This program is distributed in the hope that it will be useful,
2882+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2883+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2884+ * GNU General Public License for more details.
2885+ *
2886+ * You should have received a copy of the GNU General Public License
2887+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2888+ *
2889+ * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
2890+ */
2891+
2892+#ifndef MIR_TEST_DOUBLES_NULL_PIXEL_BUFFER_H_
2893+#define MIR_TEST_DOUBLES_NULL_PIXEL_BUFFER_H_
2894+
2895+#include "src/server/scene/pixel_buffer.h"
2896+
2897+namespace mir
2898+{
2899+namespace test
2900+{
2901+namespace doubles
2902+{
2903+
2904+struct NullPixelBuffer : public scene::PixelBuffer
2905+{
2906+ void fill_from(graphics::Buffer&) {}
2907+ void const* as_argb_8888() { return nullptr; }
2908+ geometry::Size size() const { return {}; }
2909+ geometry::Stride stride() const { return {}; }
2910+};
2911+
2912+}
2913+}
2914+}
2915+
2916+#endif /* MIR_TEST_DOUBLES_NULL_PIXEL_BUFFER_H_ */
2917
2918=== added file 'include/test/mir_test_doubles/null_prompt_session.h'
2919--- include/test/mir_test_doubles/null_prompt_session.h 1970-01-01 00:00:00 +0000
2920+++ include/test/mir_test_doubles/null_prompt_session.h 2014-06-18 12:52:17 +0000
2921@@ -0,0 +1,37 @@
2922+/*
2923+ * Copyright © 2013-2014 Canonical Ltd.
2924+ *
2925+ * This program is free software: you can redistribute it and/or modify it
2926+ * under the terms of the GNU General Public License version 3,
2927+ * as published by the Free Software Foundation.
2928+ *
2929+ * This program is distributed in the hope that it will be useful,
2930+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2931+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2932+ * GNU General Public License for more details.
2933+ *
2934+ * You should have received a copy of the GNU General Public License
2935+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2936+ *
2937+ * Authored by: Nick Dedekind <nick.dedekind@gmail.com>
2938+ */
2939+
2940+#ifndef MIR_TEST_DOUBLES_NULL_PROMPT_SESSION_H_
2941+#define MIR_TEST_DOUBLES_NULL_PROMPT_SESSION_H_
2942+
2943+#include "mir/scene/prompt_session.h"
2944+
2945+namespace mir
2946+{
2947+namespace test
2948+{
2949+namespace doubles
2950+{
2951+class NullPromptSession : public scene::PromptSession
2952+{
2953+};
2954+}
2955+}
2956+}
2957+
2958+#endif /* MIR_TEST_DOUBLES_NULL_PROMPT_SESSION_H_ */
2959
2960=== added file 'include/test/mir_test_doubles/null_prompt_session_manager.h'
2961--- include/test/mir_test_doubles/null_prompt_session_manager.h 1970-01-01 00:00:00 +0000
2962+++ include/test/mir_test_doubles/null_prompt_session_manager.h 2014-06-18 12:52:17 +0000
2963@@ -0,0 +1,82 @@
2964+/*
2965+ * Copyright © 2014 Canonical Ltd.
2966+ *
2967+ * This program is free software: you can redistribute it and/or modify it
2968+ * under the terms of the GNU General Public License version 3,
2969+ * as published by the Free Software Foundation.
2970+ *
2971+ * This program is distributed in the hope that it will be useful,
2972+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2973+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2974+ * GNU General Public License for more details.
2975+ *
2976+ * You should have received a copy of the GNU General Public License
2977+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2978+ *
2979+ * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
2980+ */
2981+
2982+#ifndef MIR_SCENE_NULL_PROMPT_SESSION_MANAGER_H_
2983+#define MIR_SCENE_NULL_PROMPT_SESSION_MANAGER_H_
2984+
2985+#include "mir/scene/prompt_session_manager.h"
2986+
2987+namespace mir
2988+{
2989+namespace test
2990+{
2991+namespace doubles
2992+{
2993+
2994+class NullPromptSessionManager: public scene::PromptSessionManager
2995+{
2996+public:
2997+ std::shared_ptr<scene::PromptSession> start_prompt_session_for(std::shared_ptr<scene::Session> const&,
2998+ scene::PromptSessionCreationParameters const&) const
2999+ {
3000+ return std::shared_ptr<scene::PromptSession>();
3001+ }
3002+
3003+ void stop_prompt_session(std::shared_ptr<scene::PromptSession> const&) const
3004+ {
3005+ }
3006+
3007+ void add_prompt_provider(std::shared_ptr<scene::PromptSession> const&,
3008+ std::shared_ptr<scene::Session> const&) const
3009+ {
3010+ }
3011+
3012+ void add_prompt_provider_by_pid(std::shared_ptr<scene::PromptSession> const&,
3013+ pid_t) const
3014+ {
3015+ }
3016+
3017+ void add_expected_session(std::shared_ptr<scene::Session> const&) const
3018+ {
3019+ }
3020+
3021+ void remove_session(std::shared_ptr<scene::Session> const&) const
3022+ {
3023+ }
3024+
3025+ std::shared_ptr<scene::Session> application_for(std::shared_ptr<scene::PromptSession> const&) const
3026+ {
3027+ return std::shared_ptr<scene::Session>();
3028+ }
3029+
3030+ std::shared_ptr<scene::Session> helper_for(std::shared_ptr<scene::PromptSession> const&) const
3031+ {
3032+ return std::shared_ptr<scene::Session>();
3033+ }
3034+
3035+ void for_each_provider_in(std::shared_ptr<scene::PromptSession> const&,
3036+ std::function<void(std::shared_ptr<scene::Session> const&)> const&) const
3037+ {
3038+ }
3039+};
3040+
3041+}
3042+}
3043+}
3044+
3045+#endif // MIR_SCENE_NULL_PROMPT_SESSION_MANAGER_H_
3046
3047=== modified file 'include/test/mir_test_doubles/null_virtual_terminal.h'
3048--- include/test/mir_test_doubles/null_virtual_terminal.h 2014-03-06 06:05:17 +0000
3049+++ include/test/mir_test_doubles/null_virtual_terminal.h 2014-06-18 12:52:17 +0000
3050@@ -31,13 +31,15 @@
3051 class NullVirtualTerminal : public graphics::mesa::VirtualTerminal
3052 {
3053 public:
3054- void set_graphics_mode() {}
3055+ void set_graphics_mode() override {}
3056
3057 void register_switch_handlers(graphics::EventHandlerRegister&,
3058 std::function<bool()> const&,
3059- std::function<bool()> const&)
3060+ std::function<bool()> const&) override
3061 {
3062 }
3063+
3064+ void restore() override {}
3065 };
3066
3067 }
3068
3069=== added file 'include/test/mir_test_doubles/platform_factory.h'
3070--- include/test/mir_test_doubles/platform_factory.h 1970-01-01 00:00:00 +0000
3071+++ include/test/mir_test_doubles/platform_factory.h 2014-06-18 12:52:17 +0000
3072@@ -0,0 +1,46 @@
3073+/*
3074+ * Copyright © 2014 Canonical Ltd.
3075+ *
3076+ * This program is free software: you can redistribute it and/or modify it
3077+ * under the terms of the GNU General Public License version 3,
3078+ * as published by the Free Software Foundation.
3079+ *
3080+ * This program is distributed in the hope that it will be useful,
3081+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3082+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3083+ * GNU General Public License for more details.
3084+ *
3085+ * You should have received a copy of the GNU General Public License
3086+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3087+ *
3088+ * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
3089+ */
3090+
3091+#ifndef MIR_TEST_DOUBLES_PLATFORM_FACTORY_H_
3092+#define MIR_TEST_DOUBLES_PLATFORM_FACTORY_H_
3093+
3094+#include <memory>
3095+
3096+namespace mir
3097+{
3098+namespace graphics
3099+{
3100+class Platform;
3101+namespace mesa { class Platform; }
3102+}
3103+namespace test
3104+{
3105+namespace doubles
3106+{
3107+
3108+std::shared_ptr<graphics::Platform> create_platform_with_null_dependencies();
3109+
3110+#ifndef ANDROID
3111+std::shared_ptr<graphics::mesa::Platform> create_mesa_platform_with_null_dependencies();
3112+#endif
3113+
3114+}
3115+}
3116+}
3117+
3118+#endif /* MIR_TEST_DOUBLES_PLATFORM_FACTORY_H_ */
3119
3120=== modified file 'include/test/mir_test_doubles/stub_buffer.h'
3121--- include/test/mir_test_doubles/stub_buffer.h 2014-03-26 05:48:59 +0000
3122+++ include/test/mir_test_doubles/stub_buffer.h 2014-06-18 12:52:17 +0000
3123@@ -21,6 +21,9 @@
3124
3125 #ifdef ANDROID
3126 #include "mock_android_native_buffer.h"
3127+#else
3128+#include "src/platform/graphics/mesa/gbm_buffer.h"
3129+#include "mock_gbm.h"
3130 #endif
3131
3132 #include "mir/graphics/buffer_basic.h"
3133@@ -59,6 +62,14 @@
3134 buf_pixel_format{properties.format},
3135 buf_stride{stride}
3136 {
3137+#ifndef ANDROID
3138+ auto buffer = std::make_shared<graphics::mesa::GBMNativeBuffer>();
3139+ int fake_bo{0};
3140+ buffer->bo = reinterpret_cast<gbm_bo*>(&fake_bo); //gbm_bo is opaque, so test code shouldn't dereference.
3141+ native_buffer = buffer;
3142+#else
3143+ native_buffer = std::make_shared<StubAndroidNativeBuffer>();
3144+#endif
3145 }
3146
3147 virtual geometry::Size size() const { return buf_size; }
3148@@ -67,18 +78,12 @@
3149
3150 virtual MirPixelFormat pixel_format() const { return buf_pixel_format; }
3151
3152- virtual std::shared_ptr<graphics::NativeBuffer> native_buffer_handle() const
3153- {
3154-#ifndef ANDROID
3155- return std::make_shared<graphics::NativeBuffer>();
3156-#else
3157- return std::make_shared<StubAndroidNativeBuffer>();
3158-#endif
3159- }
3160- virtual void bind_to_texture() {}
3161-
3162- virtual bool can_bypass() const override { return false; }
3163-
3164+ virtual std::shared_ptr<graphics::NativeBuffer> native_buffer_handle() const { return native_buffer; }
3165+ virtual void gl_bind_to_texture() override {}
3166+
3167+ virtual bool can_bypass() const override { return true; }
3168+
3169+ std::shared_ptr<graphics::NativeBuffer> native_buffer;
3170 geometry::Size const buf_size;
3171 MirPixelFormat const buf_pixel_format;
3172 geometry::Stride const buf_stride;
3173
3174=== modified file 'include/test/mir_test_doubles/stub_buffer_stream.h'
3175--- include/test/mir_test_doubles/stub_buffer_stream.h 2014-03-26 05:48:59 +0000
3176+++ include/test/mir_test_doubles/stub_buffer_stream.h 2014-06-18 12:52:17 +0000
3177@@ -36,10 +36,17 @@
3178 {
3179 stub_compositor_buffer = std::make_shared<StubBuffer>();
3180 }
3181- void swap_client_buffers(graphics::Buffer*, std::function<void(graphics::Buffer* new_buffer)> complete) override
3182+
3183+ void acquire_client_buffer(
3184+ std::function<void(graphics::Buffer* buffer)> complete) override
3185 {
3186 complete(&stub_client_buffer);
3187 }
3188+
3189+ void release_client_buffer(graphics::Buffer*) override
3190+ {
3191+ }
3192+
3193 std::shared_ptr<graphics::Buffer> lock_compositor_buffer(void const*) override
3194 {
3195 return stub_compositor_buffer;
3196
3197=== modified file 'include/test/mir_test_doubles/stub_display_builder.h'
3198--- include/test/mir_test_doubles/stub_display_builder.h 2014-05-28 07:43:51 +0000
3199+++ include/test/mir_test_doubles/stub_display_builder.h 2014-06-18 12:52:17 +0000
3200@@ -41,9 +41,9 @@
3201 void make_current() {}
3202 void release_current() {}
3203 void post_update() {}
3204- bool can_bypass() const override { return false; }
3205 bool post_renderables_if_optimizable(graphics::RenderableList const&) { return false; }
3206 MirOrientation orientation() const override { return mir_orientation_normal; }
3207+ bool uses_alpha() const override { return false; };
3208 void configure(graphics::DisplayConfigurationOutput const&) {}
3209 graphics::DisplayConfigurationOutput configuration() const
3210 {
3211
3212=== added file 'include/test/mir_test_doubles/stub_frame_dropping_policy_factory.h'
3213--- include/test/mir_test_doubles/stub_frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000
3214+++ include/test/mir_test_doubles/stub_frame_dropping_policy_factory.h 2014-06-18 12:52:17 +0000
3215@@ -0,0 +1,58 @@
3216+/*
3217+ * Copyright © 2014 Canonical Ltd.
3218+ *
3219+ * This program is free software: you can redistribute it and/or modify it
3220+ * under the terms of the GNU General Public License version 3,
3221+ * as published by the Free Software Foundation.
3222+ *
3223+ * This program is distributed in the hope that it will be useful,
3224+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3225+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3226+ * GNU General Public License for more details.
3227+ *
3228+ * You should have received a copy of the GNU General Public License
3229+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3230+ *
3231+ * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
3232+ */
3233+
3234+
3235+#ifndef MIR_TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_
3236+#define MIR_TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_
3237+
3238+#include "mir/compositor/frame_dropping_policy_factory.h"
3239+#include "mir/compositor/frame_dropping_policy.h"
3240+
3241+namespace mc = mir::compositor;
3242+
3243+namespace mir
3244+{
3245+namespace test
3246+{
3247+namespace doubles
3248+{
3249+
3250+class StubFrameDroppingPolicy : public mc::FrameDroppingPolicy
3251+{
3252+public:
3253+ void swap_now_blocking()
3254+ {
3255+ }
3256+ void swap_unblocked()
3257+ {
3258+ }
3259+};
3260+
3261+class StubFrameDroppingPolicyFactory : public mc::FrameDroppingPolicyFactory
3262+{
3263+public:
3264+ std::unique_ptr<mc::FrameDroppingPolicy> create_policy(std::function<void(void)>) const override
3265+ {
3266+ return std::unique_ptr<mc::FrameDroppingPolicy>{new StubFrameDroppingPolicy};
3267+ }
3268+};
3269+
3270+}
3271+}
3272+}
3273+#endif // TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_
3274
3275=== modified file 'include/test/mir_test_doubles/stub_renderable.h'
3276--- include/test/mir_test_doubles/stub_renderable.h 2014-05-22 16:50:25 +0000
3277+++ include/test/mir_test_doubles/stub_renderable.h 2014-06-18 12:52:17 +0000
3278@@ -22,6 +22,11 @@
3279 #include "mir_test_doubles/stub_buffer.h"
3280 #include <mir/graphics/renderable.h>
3281 #include <memory>
3282+#define GLM_FORCE_RADIANS
3283+#define GLM_PRECISION_MEDIUMP_FLOAT
3284+#include <glm/glm.hpp>
3285+#include <glm/gtc/matrix_transform.hpp>
3286+#include <glm/gtc/type_ptr.hpp>
3287
3288 namespace mir
3289 {
3290@@ -33,20 +38,26 @@
3291 class StubRenderable : public graphics::Renderable
3292 {
3293 public:
3294+ StubRenderable(std::shared_ptr<graphics::Buffer> const& buffer, geometry::Rectangle const& rect)
3295+ : rect(rect),
3296+ stub_buffer(buffer)
3297+ {}
3298+
3299 StubRenderable(geometry::Rectangle const& rect)
3300- : rect(rect)
3301+ : StubRenderable(make_stub_buffer(rect), rect)
3302 {}
3303+
3304 StubRenderable() :
3305- StubRenderable({{},{}})
3306+ StubRenderable(make_stub_buffer({{},{}}), {{},{}})
3307 {}
3308+
3309 ID id() const override
3310 {
3311 return this;
3312 }
3313 std::shared_ptr<graphics::Buffer> buffer() const override
3314 {
3315- graphics::BufferProperties prop{rect.size, mir_pixel_format_abgr_8888, graphics::BufferUsage::hardware};
3316- return std::make_shared<StubBuffer>(prop);
3317+ return stub_buffer;
3318 }
3319 bool alpha_enabled() const
3320 {
3321@@ -79,8 +90,44 @@
3322 }
3323
3324 private:
3325+ std::shared_ptr<graphics::Buffer> make_stub_buffer(geometry::Rectangle const& rect)
3326+ {
3327+ graphics::BufferProperties prop{
3328+ rect.size, mir_pixel_format_abgr_8888, graphics::BufferUsage::hardware};
3329+ return std::make_shared<StubBuffer>(prop);
3330+ }
3331+
3332 glm::mat4 trans;
3333 geometry::Rectangle const rect;
3334+ std::shared_ptr<graphics::Buffer> const stub_buffer;
3335+};
3336+
3337+struct StubTransformedRenderable : public StubRenderable
3338+{
3339+ glm::mat4 transformation() const override
3340+ {
3341+ glm::mat4 transform(1.0);
3342+ glm::vec3 vec(1.0, 0.0, 0.0);
3343+ transform = glm::rotate(transform, 33.0f, vec);
3344+ return transform;
3345+ }
3346+};
3347+
3348+//hopefully the alpha representation gets condensed at some point
3349+struct StubShapedRenderable : public StubRenderable
3350+{
3351+ bool shaped() const override
3352+ {
3353+ return true;
3354+ }
3355+};
3356+
3357+struct StubTranslucentRenderable : public StubRenderable
3358+{
3359+ bool alpha_enabled() const override
3360+ {
3361+ return true;
3362+ }
3363 };
3364
3365 }
3366
3367=== modified file 'include/test/mir_test_doubles/stub_scene_session.h'
3368--- include/test/mir_test_doubles/stub_scene_session.h 2014-05-22 11:31:21 +0000
3369+++ include/test/mir_test_doubles/stub_scene_session.h 2014-06-18 12:52:17 +0000
3370@@ -30,6 +30,8 @@
3371
3372 struct StubSceneSession : public scene::Session
3373 {
3374+ StubSceneSession(pid_t pid = -1) : pid(pid) {}
3375+
3376 frontend::SurfaceId create_surface(scene::SurfaceCreationParameters const& /* params */) override
3377 {
3378 return frontend::SurfaceId{0};
3379@@ -45,9 +47,10 @@
3380 {
3381 return std::string();
3382 }
3383+
3384 pid_t process_id() const override
3385 {
3386- return -1;
3387+ return pid;
3388 }
3389
3390 void force_requests_to_complete() override
3391@@ -76,6 +79,16 @@
3392 void set_lifecycle_state(MirLifecycleState /*state*/)
3393 {
3394 }
3395+
3396+ void start_prompt_session() override
3397+ {
3398+ }
3399+
3400+ void stop_prompt_session() override
3401+ {
3402+ }
3403+
3404+ pid_t const pid;
3405 };
3406
3407 }
3408
3409=== modified file 'include/test/mir_test_doubles/stub_scene_surface.h'
3410--- include/test/mir_test_doubles/stub_scene_surface.h 2014-05-09 09:56:45 +0000
3411+++ include/test/mir_test_doubles/stub_scene_surface.h 2014-06-18 12:52:17 +0000
3412@@ -83,6 +83,10 @@
3413 void remove_observer(std::weak_ptr<scene::SurfaceObserver> const&) override {}
3414
3415 void set_reception_mode(input::InputReceptionMode mode) override { input_mode = mode; }
3416+
3417+ void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& /* image */) {}
3418+ std::shared_ptr<graphics::CursorImage> cursor_image() { return {}; }
3419+
3420 MirPixelFormat pixel_format() const override { return mir_pixel_format_xrgb_8888; }
3421
3422 void swap_buffers(graphics::Buffer*, std::function<void(graphics::Buffer*)>) override {}
3423
3424=== modified file 'include/test/mir_test_doubles/stub_shell.h'
3425--- include/test/mir_test_doubles/stub_shell.h 2014-04-15 05:31:19 +0000
3426+++ include/test/mir_test_doubles/stub_shell.h 2014-06-18 12:52:17 +0000
3427@@ -49,6 +49,25 @@
3428 void handle_surface_created(std::shared_ptr<frontend::Session> const& /* session */) override
3429 {
3430 }
3431+ std::shared_ptr<frontend::PromptSession> start_prompt_session_for(std::shared_ptr<frontend::Session> const& /* session */,
3432+ scene::PromptSessionCreationParameters const& /* params */)
3433+ {
3434+ return std::shared_ptr<frontend::PromptSession>();
3435+ }
3436+ void add_prompt_provider_process_for(
3437+ std::shared_ptr<frontend::PromptSession> const& /* prompt_session */,
3438+ pid_t /* process_id */)
3439+ {
3440+ }
3441+ void add_prompt_provider_for(
3442+ std::shared_ptr<frontend::PromptSession> const& /* prompt_session */,
3443+ std::shared_ptr<frontend::Session> const& /* session */)
3444+ {
3445+ }
3446+ void stop_prompt_session(std::shared_ptr<frontend::PromptSession> const& /* prompt_session */)
3447+ {
3448+ }
3449+
3450 std::shared_ptr<StubSession> const stub_session;
3451 };
3452
3453
3454=== modified file 'include/test/mir_test_doubles/stub_swapping_gl_context.h'
3455--- include/test/mir_test_doubles/stub_swapping_gl_context.h 2014-02-21 16:51:45 +0000
3456+++ include/test/mir_test_doubles/stub_swapping_gl_context.h 2014-06-18 12:52:17 +0000
3457@@ -20,6 +20,7 @@
3458 #define MIR_TEST_DOUBLES_STUB_SWAPPING_GL_CONTEXT_H_
3459
3460 #include "src/platform/graphics/android/gl_context.h"
3461+#include "stub_buffer.h"
3462
3463 namespace mir
3464 {
3465@@ -31,6 +32,10 @@
3466 struct StubSwappingGLContext : public graphics::android::SwappingGLContext
3467 {
3468 void swap_buffers() const {}
3469+ std::shared_ptr<graphics::Buffer> last_rendered_buffer() const
3470+ {
3471+ return std::make_shared<StubBuffer>();
3472+ }
3473 };
3474
3475 }
3476
3477=== modified file 'include/test/mir_test_framework/in_process_server.h'
3478--- include/test/mir_test_framework/in_process_server.h 2014-03-06 06:05:17 +0000
3479+++ include/test/mir_test_framework/in_process_server.h 2014-06-18 12:52:17 +0000
3480@@ -1,5 +1,5 @@
3481 /*
3482- * Copyright © 2013 Canonical Ltd.
3483+ * Copyright © 2013-2014 Canonical Ltd.
3484 *
3485 * This program is free software: you can redistribute it and/or modify it
3486 * under the terms of the GNU General Public License version 3,
3487@@ -19,6 +19,8 @@
3488 #ifndef MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_
3489 #define MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_
3490
3491+#include "mir_test_framework/server_runner.h"
3492+
3493 #include <gtest/gtest.h>
3494
3495 #include <string>
3496@@ -34,29 +36,18 @@
3497 namespace mir_test_framework
3498 {
3499 /// Fixture for running Mir server in test process
3500-struct InProcessServer : testing::Test
3501+struct InProcessServer : testing::Test, private ServerRunner
3502 {
3503- InProcessServer();
3504- ~InProcessServer();
3505-
3506 /// Starts the server
3507 /// \warning don't forget to call this if you override SetUp()
3508- void SetUp() override;
3509+ void SetUp() override { ServerRunner::start_server(); }
3510
3511 /// Stops the server
3512 /// \warning don't forget to call this if you override TearDown()
3513- void TearDown() override;
3514+ void TearDown() override { ServerRunner::stop_server(); }
3515
3516 /// \return a connection string for a new client to connect to the server
3517- std::string new_connection();
3518-
3519-private:
3520- mir::DisplayServer* start_mir_server();
3521- virtual mir::DefaultServerConfiguration& server_config() = 0;
3522-
3523- char const* const old_env;
3524- std::thread server_thread;
3525- mir::DisplayServer* display_server = 0;
3526+ using ServerRunner::new_connection;
3527 };
3528 }
3529
3530
3531=== modified file 'include/test/mir_test_framework/input_testing_client_configuration.h'
3532--- include/test/mir_test_framework/input_testing_client_configuration.h 2014-05-26 14:41:49 +0000
3533+++ include/test/mir_test_framework/input_testing_client_configuration.h 2014-06-18 12:52:17 +0000
3534@@ -20,8 +20,7 @@
3535 #define MIR_TEST_FRAMEWORK_INPUT_TESTING_CLIENT_CONFIGURATION
3536
3537 #include "mir_test_framework/testing_client_configuration.h"
3538-#include "mir_test_framework/cross_process_sync.h"
3539-#include "mir_test/wait_condition.h"
3540+#include "mir_test/barrier.h"
3541
3542 #include <mir_toolkit/event.h>
3543
3544@@ -29,6 +28,7 @@
3545
3546 #include <string>
3547
3548+namespace mir { namespace test { class WaitCondition; } }
3549 namespace mir_test_framework
3550 {
3551
3552@@ -38,7 +38,7 @@
3553 class InputTestingClientConfiguration : public TestingClientConfiguration
3554 {
3555 public:
3556- InputTestingClientConfiguration(std::string const& client_name, CrossProcessSync const& input_cb_setup_fence);
3557+ InputTestingClientConfiguration(std::string const& client_name, mir::test::Barrier& input_cb_setup_fence);
3558 virtual ~InputTestingClientConfiguration() = default;
3559
3560 void exec();
3561@@ -62,7 +62,7 @@
3562 std::string connect_string;
3563 private:
3564 std::string const client_name;
3565- CrossProcessSync input_cb_setup_fence;
3566+ mir::test::Barrier& input_cb_setup_fence;
3567 };
3568
3569 }
3570
3571=== added file 'include/test/mir_test_framework/server_runner.h'
3572--- include/test/mir_test_framework/server_runner.h 1970-01-01 00:00:00 +0000
3573+++ include/test/mir_test_framework/server_runner.h 2014-06-18 12:52:17 +0000
3574@@ -0,0 +1,60 @@
3575+/*
3576+ * Copyright © 2014 Canonical Ltd.
3577+ *
3578+ * This program is free software: you can redistribute it and/or modify it
3579+ * under the terms of the GNU General Public License version 3,
3580+ * as published by the Free Software Foundation.
3581+ *
3582+ * This program is distributed in the hope that it will be useful,
3583+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3584+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3585+ * GNU General Public License for more details.
3586+ *
3587+ * You should have received a copy of the GNU General Public License
3588+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3589+ *
3590+ * Authored By: Alan Griffiths <alan@octopull.co.uk>
3591+ */
3592+
3593+#ifndef MIR_TEST_FRAMEWORK_SERVER_RUNNER_H_
3594+#define MIR_TEST_FRAMEWORK_SERVER_RUNNER_H_
3595+
3596+#include <gtest/gtest.h>
3597+
3598+#include <string>
3599+#include <thread>
3600+
3601+namespace mir
3602+{
3603+class DisplayServer;
3604+class DefaultServerConfiguration;
3605+}
3606+
3607+namespace mir_test_framework
3608+{
3609+/// Utility for running Mir server in test process
3610+struct ServerRunner
3611+{
3612+ ServerRunner();
3613+ virtual ~ServerRunner();
3614+
3615+ /// Starts the server
3616+ void start_server();
3617+
3618+ /// Stops the server
3619+ void stop_server();
3620+
3621+ /// \return a connection string for a new client to connect to the server
3622+ std::string new_connection();
3623+
3624+private:
3625+ mir::DisplayServer* start_mir_server();
3626+ virtual mir::DefaultServerConfiguration& server_config() = 0;
3627+
3628+ char const* const old_env;
3629+ std::thread server_thread;
3630+ mir::DisplayServer* display_server = 0;
3631+};
3632+}
3633+
3634+#endif /* MIR_TEST_FRAMEWORK_SERVER_RUNNER_H_ */
3635
3636=== modified file 'src/client/CMakeLists.txt'
3637--- src/client/CMakeLists.txt 2014-05-22 11:31:21 +0000
3638+++ src/client/CMakeLists.txt 2014-06-18 12:52:17 +0000
3639@@ -48,6 +48,9 @@
3640 mir_screencast.cpp
3641 mir_screencast_api.cpp
3642 mir_cursor_api.cpp
3643+ mir_prompt_session.cpp
3644+ mir_prompt_session_api.cpp
3645+ mir_event_distributor.cpp
3646 )
3647
3648 add_library(
3649@@ -82,7 +85,7 @@
3650 mirclientlttngstatic
3651
3652 ${MIR_COMMON_PLATFORM_LIBRARIES}
3653-
3654+
3655 3rd_party
3656 )
3657
3658
3659=== modified file 'src/client/connection_configuration.h'
3660--- src/client/connection_configuration.h 2014-03-06 06:05:17 +0000
3661+++ src/client/connection_configuration.h 2014-06-18 12:52:17 +0000
3662@@ -47,6 +47,8 @@
3663 class ClientPlatformFactory;
3664 class DisplayConfiguration;
3665 class LifecycleControl;
3666+class EventSink;
3667+class EventHandlerRegister;
3668
3669 class ConnectionConfiguration
3670 {
3671@@ -60,6 +62,8 @@
3672 virtual std::shared_ptr<input::receiver::InputPlatform> the_input_platform() = 0;
3673 virtual std::shared_ptr<DisplayConfiguration> the_display_configuration() = 0;
3674 virtual std::shared_ptr<LifecycleControl> the_lifecycle_control() = 0;
3675+ virtual std::shared_ptr<EventSink> the_event_sink() = 0;
3676+ virtual std::shared_ptr<EventHandlerRegister> the_event_handler_register() = 0;
3677
3678 protected:
3679 ConnectionConfiguration() = default;
3680
3681=== modified file 'src/client/connection_surface_map.h'
3682--- src/client/connection_surface_map.h 2014-03-06 06:05:17 +0000
3683+++ src/client/connection_surface_map.h 2014-06-18 12:52:17 +0000
3684@@ -33,6 +33,7 @@
3685 {
3686 public:
3687 ConnectionSurfaceMap();
3688+ ~ConnectionSurfaceMap() noexcept;
3689
3690 void with_surface_do(int surface_id, std::function<void(MirSurface*)> exec) const override;
3691 void insert(int surface_id, MirSurface* surface);
3692
3693=== modified file 'src/client/default_connection_configuration.cpp'
3694--- src/client/default_connection_configuration.cpp 2014-03-26 05:48:59 +0000
3695+++ src/client/default_connection_configuration.cpp 2014-06-18 12:52:17 +0000
3696@@ -32,6 +32,7 @@
3697 #include "lifecycle_control.h"
3698 #include "mir/shared_library.h"
3699 #include "client_platform_factory.h"
3700+#include "mir_event_distributor.h"
3701
3702 namespace mcl = mir::client;
3703
3704@@ -81,7 +82,7 @@
3705 [this]
3706 {
3707 return mcl::rpc::make_rpc_channel(
3708- the_socket_file(), the_surface_map(), the_display_configuration(), the_rpc_report(), the_lifecycle_control());
3709+ the_socket_file(), the_surface_map(), the_display_configuration(), the_rpc_report(), the_lifecycle_control(), the_event_sink());
3710 });
3711 }
3712
3713@@ -182,3 +183,21 @@
3714 return std::make_shared<mcl::LifecycleControl>();
3715 });
3716 }
3717+
3718+std::shared_ptr<mcl::EventSink> mcl::DefaultConnectionConfiguration::the_event_sink()
3719+{
3720+ return event_distributor(
3721+ []
3722+ {
3723+ return std::make_shared<MirEventDistributor>();
3724+ });
3725+}
3726+
3727+std::shared_ptr<mcl::EventHandlerRegister> mcl::DefaultConnectionConfiguration::the_event_handler_register()
3728+{
3729+ return event_distributor(
3730+ []
3731+ {
3732+ return std::make_shared<MirEventDistributor>();
3733+ });
3734+}
3735
3736=== modified file 'src/client/default_connection_configuration.h'
3737--- src/client/default_connection_configuration.h 2014-03-06 06:05:17 +0000
3738+++ src/client/default_connection_configuration.h 2014-06-18 12:52:17 +0000
3739@@ -36,6 +36,7 @@
3740 }
3741 namespace client
3742 {
3743+class EventDistributor;
3744
3745 namespace rpc
3746 {
3747@@ -54,6 +55,8 @@
3748 std::shared_ptr<input::receiver::InputPlatform> the_input_platform();
3749 std::shared_ptr<DisplayConfiguration> the_display_configuration();
3750 std::shared_ptr<LifecycleControl> the_lifecycle_control();
3751+ std::shared_ptr<EventSink> the_event_sink();
3752+ std::shared_ptr<EventHandlerRegister> the_event_handler_register();
3753
3754 virtual std::string the_socket_file();
3755 virtual std::shared_ptr<rpc::RpcReport> the_rpc_report();
3756@@ -67,6 +70,7 @@
3757 CachedPtr<ConnectionSurfaceMap> surface_map;
3758 CachedPtr<DisplayConfiguration> display_configuration;
3759 CachedPtr<LifecycleControl> lifecycle_control;
3760+ CachedPtr<EventDistributor> event_distributor;
3761
3762 CachedPtr<rpc::RpcReport> rpc_report;
3763 CachedPtr<input::receiver::InputReceiverReport> input_receiver_report;
3764
3765=== added file 'src/client/event_distributor.h'
3766--- src/client/event_distributor.h 1970-01-01 00:00:00 +0000
3767+++ src/client/event_distributor.h 2014-06-18 12:52:17 +0000
3768@@ -0,0 +1,37 @@
3769+/*
3770+ * Copyright © 2014 Canonical Ltd.
3771+ *
3772+ * This program is free software: you can redistribute it and/or modify it
3773+ * under the terms of the GNU Lesser General Public License version 3,
3774+ * as published by the Free Software Foundation.
3775+ *
3776+ * This program is distributed in the hope that it will be useful,
3777+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3778+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3779+ * GNU Lesser General Public License for more details.
3780+ *
3781+ * You should have received a copy of the GNU Lesser General Public License
3782+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3783+ *
3784+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
3785+ */
3786+
3787+#ifndef MIR_CLIENT_EVENT_DISTRIBUTOR_H_
3788+#define MIR_CLIENT_EVENT_DISTRIBUTOR_H_
3789+
3790+#include "event_sink.h"
3791+#include "event_handler_register.h"
3792+
3793+namespace mir
3794+{
3795+namespace client
3796+{
3797+
3798+class EventDistributor : public EventHandlerRegister, public EventSink
3799+{
3800+};
3801+
3802+} // namespace client
3803+} // namespace mir
3804+
3805+#endif // MIR_CLIENT_EVENT_DISTRIBUTOR_H_
3806
3807=== added file 'src/client/event_handler_register.h'
3808--- src/client/event_handler_register.h 1970-01-01 00:00:00 +0000
3809+++ src/client/event_handler_register.h 2014-06-18 12:52:17 +0000
3810@@ -0,0 +1,47 @@
3811+/*
3812+ * Copyright © 2014 Canonical Ltd.
3813+ *
3814+ * This program is free software: you can redistribute it and/or modify it
3815+ * under the terms of the GNU Lesser General Public License version 3,
3816+ * as published by the Free Software Foundation.
3817+ *
3818+ * This program is distributed in the hope that it will be useful,
3819+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3820+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3821+ * GNU Lesser General Public License for more details.
3822+ *
3823+ * You should have received a copy of the GNU Lesser General Public License
3824+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3825+ *
3826+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
3827+ */
3828+
3829+#ifndef MIR_CLIENT_EVENT_HANDLER_REGISTER_H_
3830+#define MIR_CLIENT_EVENT_HANDLER_REGISTER_H_
3831+
3832+#include "mir_toolkit/event.h"
3833+
3834+#include <functional>
3835+
3836+namespace mir
3837+{
3838+namespace client
3839+{
3840+
3841+class EventHandlerRegister
3842+{
3843+public:
3844+ virtual ~EventHandlerRegister() = default;
3845+
3846+ virtual int register_event_handler(std::function<void(MirEvent const&)> const&) = 0;
3847+ virtual void unregister_event_handler(int id) = 0;
3848+
3849+protected:
3850+ EventHandlerRegister() = default;
3851+ EventHandlerRegister(EventHandlerRegister const&) = delete;
3852+ EventHandlerRegister& operator=(EventHandlerRegister const&) = delete;
3853+};
3854+} // namespace client
3855+} // namespace mir
3856+
3857+#endif // MIR_CLIENT_EVENT_HANDLER_REGISTER_H_
3858
3859=== added file 'src/client/event_sink.h'
3860--- src/client/event_sink.h 1970-01-01 00:00:00 +0000
3861+++ src/client/event_sink.h 2014-06-18 12:52:17 +0000
3862@@ -0,0 +1,44 @@
3863+/*
3864+ * Copyright © 2014 Canonical Ltd.
3865+ *
3866+ * This program is free software: you can redistribute it and/or modify it
3867+ * under the terms of the GNU Lesser General Public License version 3,
3868+ * as published by the Free Software Foundation.
3869+ *
3870+ * This program is distributed in the hope that it will be useful,
3871+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3872+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3873+ * GNU Lesser General Public License for more details.
3874+ *
3875+ * You should have received a copy of the GNU Lesser General Public License
3876+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3877+ *
3878+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
3879+ */
3880+
3881+#ifndef MIR_CLIENT_EVENT_SINK_H_
3882+#define MIR_CLIENT_EVENT_SINK_H_
3883+
3884+#include "mir_toolkit/event.h"
3885+
3886+namespace mir
3887+{
3888+namespace client
3889+{
3890+
3891+class EventSink
3892+{
3893+public:
3894+ virtual ~EventSink() = default;
3895+
3896+ virtual void handle_event(MirEvent const& e) = 0;
3897+
3898+protected:
3899+ EventSink() = default;
3900+ EventSink(EventSink const&) = delete;
3901+ EventSink& operator=(EventSink const&) = delete;
3902+};
3903+} // namespace client
3904+} // namespace mir
3905+
3906+#endif // MIR_CLIENT_EVENT_SINK_H_
3907
3908=== modified file 'src/client/logging/input_receiver_report.cpp'
3909--- src/client/logging/input_receiver_report.cpp 2014-03-06 06:05:17 +0000
3910+++ src/client/logging/input_receiver_report.cpp 2014-06-18 12:52:17 +0000
3911@@ -91,6 +91,7 @@
3912 ss << " orientation: " << ev.pointer_coordinates[i].orientation << std::endl;
3913 ss << " vscroll: " << ev.pointer_coordinates[i].vscroll << std::endl;
3914 ss << " hscroll: " << ev.pointer_coordinates[i].hscroll << std::endl;
3915+ ss << " tool_type: " << ev.pointer_coordinates[i].tool_type << std::endl;
3916 ss << " }" << std::endl;
3917 }
3918 ss << "}";
3919
3920=== modified file 'src/client/mir_connection.cpp'
3921--- src/client/mir_connection.cpp 2014-05-22 11:31:21 +0000
3922+++ src/client/mir_connection.cpp 2014-06-18 12:52:17 +0000
3923@@ -18,6 +18,7 @@
3924
3925 #include "mir_connection.h"
3926 #include "mir_surface.h"
3927+#include "mir_prompt_session.h"
3928 #include "client_platform.h"
3929 #include "client_platform_factory.h"
3930 #include "rpc/mir_basic_rpc_channel.h"
3931@@ -82,7 +83,8 @@
3932 input_platform(conf.the_input_platform()),
3933 display_configuration(conf.the_display_configuration()),
3934 lifecycle_control(conf.the_lifecycle_control()),
3935- surface_map(conf.the_surface_map())
3936+ surface_map(conf.the_surface_map()),
3937+ event_handler_register(conf.the_event_handler_register())
3938 {
3939 connect_result.set_error("connect not called");
3940 {
3941@@ -186,6 +188,7 @@
3942 release_wait_handles.push_back(new_wait_handle);
3943 }
3944
3945+ new_wait_handle->expect_result();
3946 server.release_surface(0, &message, &void_response,
3947 gp::NewCallback(this, &MirConnection::released, surf_release));
3948
3949@@ -193,6 +196,11 @@
3950 return new_wait_handle;
3951 }
3952
3953+MirPromptSession* MirConnection::create_prompt_session()
3954+{
3955+ return new MirPromptSession(display_server(), event_handler_register);
3956+}
3957+
3958 namespace
3959 {
3960 void default_lifecycle_event_handler(MirLifecycleState transition)
3961@@ -272,6 +280,7 @@
3962
3963 MirWaitHandle* MirConnection::disconnect()
3964 {
3965+ disconnect_wait_handle.expect_result();
3966 server.disconnect(0, &ignored, &ignored,
3967 google::protobuf::NewCallback(this, &MirConnection::done_disconnect));
3968
3969@@ -294,6 +303,7 @@
3970 mir::protobuf::DRMMagic request;
3971 request.set_magic(magic);
3972
3973+ drm_auth_magic_wait_handle.expect_result();
3974 server.drm_auth_magic(
3975 0,
3976 &request,
3977@@ -304,40 +314,6 @@
3978 return &drm_auth_magic_wait_handle;
3979 }
3980
3981-MirWaitHandle* MirConnection::new_fds_for_trusted_clients(
3982- unsigned int no_of_fds,
3983- mir_client_fd_callback callback,
3984- void * context)
3985-{
3986- mir::protobuf::SocketFDRequest request;
3987- request.set_number(no_of_fds);
3988-
3989- server.new_fds_for_trusted_clients(
3990- nullptr,
3991- &request,
3992- &socket_fd_response,
3993- google::protobuf::NewCallback(this, &MirConnection::done_fds_for_trusted_clients,
3994- callback, context));
3995-
3996- return &fds_for_trusted_clients_wait_handle;
3997-}
3998-
3999-void MirConnection::done_fds_for_trusted_clients(
4000- mir_client_fd_callback callback,
4001- void* context)
4002-{
4003- auto const size = socket_fd_response.fd_size();
4004-
4005- std::vector<int> fds;
4006- fds.reserve(size);
4007-
4008- for (auto i = 0; i != size; ++i)
4009- fds.push_back(socket_fd_response.fd(i));
4010-
4011- callback(this, size, fds.data(), context);
4012- fds_for_trusted_clients_wait_handle.result_received();
4013-}
4014-
4015 bool MirConnection::is_valid(MirConnection *connection)
4016 {
4017 {
4018@@ -500,6 +476,7 @@
4019 }
4020 }
4021
4022+ configure_display_wait_handle.expect_result();
4023 server.configure_display(0, &request, &display_configuration_response,
4024 google::protobuf::NewCallback(this, &MirConnection::done_display_configure));
4025
4026@@ -522,6 +499,6 @@
4027 }
4028
4029 mir::protobuf::DisplayServer& MirConnection::display_server()
4030-{
4031+{
4032 return server;
4033 }
4034
4035=== modified file 'src/client/mir_connection.h'
4036--- src/client/mir_connection.h 2014-05-22 11:31:21 +0000
4037+++ src/client/mir_connection.h 2014-06-18 12:52:17 +0000
4038@@ -45,6 +45,7 @@
4039 class ConnectionSurfaceMap;
4040 class DisplayConfiguration;
4041 class LifecycleControl;
4042+class EventHandlerRegister;
4043
4044 namespace rpc
4045 {
4046@@ -86,6 +87,8 @@
4047 mir_surface_callback callback,
4048 void *context);
4049
4050+ MirPromptSession* create_prompt_session();
4051+
4052 char const * get_error_message();
4053
4054 MirWaitHandle* connect(
4055@@ -123,11 +126,6 @@
4056
4057 bool set_extra_platform_data(std::vector<int> const& extra_platform_data);
4058
4059- MirWaitHandle* new_fds_for_trusted_clients(
4060- unsigned int no_of_fds,
4061- mir_client_fd_callback callback,
4062- void * context);
4063-
4064 std::shared_ptr<google::protobuf::RpcChannel> rpc_channel() const
4065 {
4066 return channel;
4067@@ -147,7 +145,6 @@
4068 mir::protobuf::ConnectParameters connect_parameters;
4069 mir::protobuf::DRMAuthMagicStatus drm_auth_magic_status;
4070 mir::protobuf::DisplayConfiguration display_configuration_response;
4071- mir::protobuf::SocketFD socket_fd_response;
4072
4073 std::shared_ptr<mir::client::ClientPlatformFactory> const client_platform_factory;
4074 std::shared_ptr<mir::client::ClientPlatform> platform;
4075@@ -161,7 +158,6 @@
4076 MirWaitHandle disconnect_wait_handle;
4077 MirWaitHandle drm_auth_magic_wait_handle;
4078 MirWaitHandle configure_display_wait_handle;
4079- MirWaitHandle fds_for_trusted_clients_wait_handle;
4080
4081 std::mutex release_wait_handle_guard;
4082 std::vector<MirWaitHandle*> release_wait_handles;
4083@@ -172,6 +168,8 @@
4084
4085 std::shared_ptr<mir::client::ConnectionSurfaceMap> const surface_map;
4086
4087+ std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register;
4088+
4089 std::vector<int> extra_platform_data;
4090
4091 struct SurfaceRelease;
4092@@ -181,7 +179,6 @@
4093 void connected(mir_connected_callback callback, void * context);
4094 void released(SurfaceRelease );
4095 void done_drm_auth_magic(mir_drm_auth_magic_callback callback, void* context);
4096- void done_fds_for_trusted_clients(mir_client_fd_callback callback, void* context);
4097 bool validate_user_display_config(MirDisplayConfiguration* config);
4098 };
4099
4100
4101=== modified file 'src/client/mir_connection_api.cpp'
4102--- src/client/mir_connection_api.cpp 2014-05-22 11:31:21 +0000
4103+++ src/client/mir_connection_api.cpp 2014-06-18 12:52:17 +0000
4104@@ -272,24 +272,6 @@
4105 }
4106 }
4107
4108-MirWaitHandle* mir_connection_new_fds_for_trusted_clients(
4109- MirConnection* connection,
4110- unsigned int no_of_fds,
4111- mir_client_fd_callback callback,
4112- void * context)
4113-{
4114- try
4115- {
4116- return connection ?
4117- connection->new_fds_for_trusted_clients(no_of_fds, callback, context) :
4118- nullptr;
4119- }
4120- catch (std::exception const&)
4121- {
4122- return nullptr;
4123- }
4124-}
4125-
4126 MirEGLNativeDisplayType mir_connection_get_egl_native_display(
4127 MirConnection* connection)
4128 {
4129
4130=== added file 'src/client/mir_event_distributor.cpp'
4131--- src/client/mir_event_distributor.cpp 1970-01-01 00:00:00 +0000
4132+++ src/client/mir_event_distributor.cpp 2014-06-18 12:52:17 +0000
4133@@ -0,0 +1,56 @@
4134+/*
4135+ * Copyright © 2014 Canonical Ltd.
4136+ *
4137+ * This program is free software: you can redistribute it and/or modify it
4138+ * under the terms of the GNU Lesser General Public License version 3,
4139+ * as published by the Free Software Foundation.
4140+ *
4141+ * This program is distributed in the hope that it will be useful,
4142+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4143+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4144+ * GNU Lesser General Public License for more details.
4145+ *
4146+ * You should have received a copy of the GNU Lesser General Public License
4147+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4148+ *
4149+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
4150+ */
4151+
4152+#include "mir_event_distributor.h"
4153+
4154+MirEventDistributor::MirEventDistributor() :
4155+ next_fn_id{0}
4156+{
4157+}
4158+
4159+int MirEventDistributor::register_event_handler(std::function<void(MirEvent const&)> const& fn)
4160+{
4161+ std::unique_lock<decltype(mutex)> lock(mutex);
4162+
4163+ int id = ++next_fn_id;
4164+ event_handlers[id] = fn;
4165+ return id;
4166+}
4167+
4168+void MirEventDistributor::unregister_event_handler(int id)
4169+{
4170+ std::unique_lock<decltype(mutex)> lock(mutex);
4171+
4172+ event_handlers.erase(id);
4173+}
4174+
4175+void MirEventDistributor::handle_event(MirEvent const& event)
4176+{
4177+ std::unique_lock<decltype(mutex)> lock(mutex);
4178+
4179+ auto const event_handlers_copy(event_handlers);
4180+
4181+ for (auto const& handler : event_handlers_copy)
4182+ {
4183+ // Ensure handler wasn't unregistered since making copy
4184+ if (event_handlers.find(handler.first) != event_handlers.end())
4185+ {
4186+ handler.second(event);
4187+ }
4188+ }
4189+}
4190
4191=== added file 'src/client/mir_event_distributor.h'
4192--- src/client/mir_event_distributor.h 1970-01-01 00:00:00 +0000
4193+++ src/client/mir_event_distributor.h 2014-06-18 12:52:17 +0000
4194@@ -0,0 +1,43 @@
4195+/*
4196+ * Copyright © 2014 Canonical Ltd.
4197+ *
4198+ * This program is free software: you can redistribute it and/or modify it
4199+ * under the terms of the GNU Lesser General Public License version 3,
4200+ * as published by the Free Software Foundation.
4201+ *
4202+ * This program is distributed in the hope that it will be useful,
4203+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4204+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4205+ * GNU Lesser General Public License for more details.
4206+ *
4207+ * You should have received a copy of the GNU Lesser General Public License
4208+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4209+ *
4210+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
4211+ */
4212+
4213+#ifndef MIR_EVENT_DISTRIBUTOR_H
4214+
4215+#include "event_distributor.h"
4216+
4217+#include <mutex>
4218+#include <map>
4219+
4220+class MirEventDistributor : public mir::client::EventDistributor
4221+{
4222+public:
4223+ MirEventDistributor();
4224+ ~MirEventDistributor() = default;
4225+
4226+ int register_event_handler(std::function<void(MirEvent const&)> const&) override;
4227+ void unregister_event_handler(int id) override;
4228+
4229+ void handle_event(MirEvent const& event) override;
4230+
4231+private:
4232+ mutable std::recursive_mutex mutex;
4233+ std::map<int, std::function<void(MirEvent const&)>> event_handlers;
4234+ int next_fn_id;
4235+};
4236+
4237+#endif /* MIR_EVENT_DISTRIBUTOR_H */
4238
4239=== added file 'src/client/mir_prompt_session.cpp'
4240--- src/client/mir_prompt_session.cpp 1970-01-01 00:00:00 +0000
4241+++ src/client/mir_prompt_session.cpp 2014-06-18 12:52:17 +0000
4242@@ -0,0 +1,203 @@
4243+/*
4244+ * Copyright © 2014 Canonical Ltd.
4245+ *
4246+ * This program is free software: you can redistribute it and/or modify it
4247+ * under the terms of the GNU Lesser General Public License version 3,
4248+ * as published by the Free Software Foundation.
4249+ *
4250+ * This program is distributed in the hope that it will be useful,
4251+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4252+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4253+ * GNU Lesser General Public License for more details.
4254+ *
4255+ * You should have received a copy of the GNU Lesser General Public License
4256+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4257+ *
4258+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
4259+ */
4260+
4261+#include "mir_prompt_session.h"
4262+#include "event_handler_register.h"
4263+
4264+namespace mp = mir::protobuf;
4265+namespace mcl = mir::client;
4266+
4267+MirPromptSession::MirPromptSession(
4268+ mp::DisplayServer& server,
4269+ std::shared_ptr<mcl::EventHandlerRegister> const& event_handler_register) :
4270+ server(server),
4271+ event_handler_register(event_handler_register),
4272+ event_handler_register_id{event_handler_register->register_event_handler(
4273+ [this](MirEvent const& event)
4274+ {
4275+ if (event.type == mir_event_type_prompt_session_state_change)
4276+ set_state(event.prompt_session.new_state);
4277+ })},
4278+ state(mir_prompt_session_state_stopped),
4279+ handle_prompt_session_state_change{[](MirPromptSessionState){}}
4280+{
4281+}
4282+
4283+MirPromptSession::~MirPromptSession()
4284+{
4285+ set_state(mir_prompt_session_state_stopped);
4286+}
4287+
4288+void MirPromptSession::set_state(MirPromptSessionState new_state)
4289+{
4290+ std::lock_guard<decltype(event_handler_mutex)> lock(event_handler_mutex);
4291+
4292+ if (new_state != state)
4293+ {
4294+ handle_prompt_session_state_change(new_state);
4295+
4296+ if (new_state == mir_prompt_session_state_stopped)
4297+ {
4298+ event_handler_register->unregister_event_handler(event_handler_register_id);
4299+ }
4300+
4301+ state = new_state;
4302+ }
4303+}
4304+
4305+MirWaitHandle* MirPromptSession::start(pid_t application_pid, mir_prompt_session_callback callback, void* context)
4306+{
4307+ {
4308+ std::lock_guard<decltype(mutex)> lock(mutex);
4309+ parameters.set_application_pid(application_pid);
4310+ }
4311+
4312+ start_wait_handle.expect_result();
4313+ server.start_prompt_session(
4314+ 0,
4315+ &parameters,
4316+ &session,
4317+ google::protobuf::NewCallback(this, &MirPromptSession::done_start,
4318+ callback, context));
4319+
4320+ return &start_wait_handle;
4321+}
4322+
4323+MirWaitHandle* MirPromptSession::stop(mir_prompt_session_callback callback, void* context)
4324+{
4325+ stop_wait_handle.expect_result();
4326+
4327+ server.stop_prompt_session(
4328+ 0,
4329+ &protobuf_void,
4330+ &protobuf_void,
4331+ google::protobuf::NewCallback(this, &MirPromptSession::done_stop,
4332+ callback, context));
4333+
4334+ return &stop_wait_handle;
4335+}
4336+
4337+MirWaitHandle* MirPromptSession::add_prompt_provider(pid_t provider_pid,
4338+ mir_prompt_session_add_prompt_provider_callback callback,
4339+ void* context)
4340+{
4341+ {
4342+ std::lock_guard<decltype(mutex)> lock(mutex);
4343+ prompt_provider.set_pid(provider_pid);
4344+ }
4345+
4346+ add_result_wait_handle.expect_result();
4347+ server.add_prompt_provider(
4348+ 0,
4349+ &prompt_provider,
4350+ &add_result,
4351+ google::protobuf::NewCallback(this, &MirPromptSession::done_add_prompt_provider,
4352+ callback, context));
4353+
4354+ return &add_result_wait_handle;
4355+}
4356+
4357+void MirPromptSession::register_prompt_session_state_change_callback(
4358+ mir_prompt_session_state_change_callback callback,
4359+ void* context)
4360+{
4361+ std::lock_guard<decltype(event_handler_mutex)> lock(event_handler_mutex);
4362+
4363+ handle_prompt_session_state_change =
4364+ [this, callback, context](MirPromptSessionState new_state)
4365+ {
4366+ callback(this, new_state, context);
4367+ };
4368+}
4369+
4370+void MirPromptSession::done_start(mir_prompt_session_callback callback, void* context)
4371+{
4372+ {
4373+ std::lock_guard<decltype(session_mutex)> lock(session_mutex);
4374+
4375+ state = session.has_error() ? mir_prompt_session_state_stopped : mir_prompt_session_state_started;
4376+ }
4377+
4378+ callback(this, context);
4379+ start_wait_handle.result_received();
4380+}
4381+
4382+void MirPromptSession::done_stop(mir_prompt_session_callback callback, void* context)
4383+{
4384+ set_state(mir_prompt_session_state_stopped);
4385+
4386+ callback(this, context);
4387+ stop_wait_handle.result_received();
4388+}
4389+
4390+void MirPromptSession::done_add_prompt_provider(mir_prompt_session_add_prompt_provider_callback callback, void* context)
4391+{
4392+ MirBool added = mir_true;
4393+ if (add_result.has_error())
4394+ {
4395+ added = mir_false;
4396+ }
4397+ callback(this, added, context);
4398+ add_result_wait_handle.result_received();
4399+}
4400+
4401+char const* MirPromptSession::get_error_message()
4402+{
4403+ std::lock_guard<decltype(session_mutex)> lock(session_mutex);
4404+
4405+ if (!session.has_error())
4406+ session.set_error(std::string{});
4407+
4408+ return session.error().c_str();
4409+}
4410+
4411+MirWaitHandle* MirPromptSession::new_fds_for_prompt_providers(
4412+ unsigned int no_of_fds,
4413+ mir_client_fd_callback callback,
4414+ void * context)
4415+{
4416+ mir::protobuf::SocketFDRequest request;
4417+ request.set_number(no_of_fds);
4418+
4419+ fds_for_prompt_providers_wait_handle.expect_result();
4420+
4421+ server.new_fds_for_prompt_providers(
4422+ nullptr,
4423+ &request,
4424+ &socket_fd_response,
4425+ google::protobuf::NewCallback(this, &MirPromptSession::done_fds_for_prompt_providers,
4426+ callback, context));
4427+
4428+ return &fds_for_prompt_providers_wait_handle;
4429+}
4430+
4431+void MirPromptSession::done_fds_for_prompt_providers(
4432+ mir_client_fd_callback callback,
4433+ void* context)
4434+{
4435+ auto const size = socket_fd_response.fd_size();
4436+
4437+ std::vector<int> fds;
4438+ fds.reserve(size);
4439+
4440+ for (auto i = 0; i != size; ++i)
4441+ fds.push_back(socket_fd_response.fd(i));
4442+
4443+ callback(this, size, fds.data(), context);
4444+ fds_for_prompt_providers_wait_handle.result_received();
4445+}
4446
4447=== added file 'src/client/mir_prompt_session.h'
4448--- src/client/mir_prompt_session.h 1970-01-01 00:00:00 +0000
4449+++ src/client/mir_prompt_session.h 2014-06-18 12:52:17 +0000
4450@@ -0,0 +1,94 @@
4451+/*
4452+ * Copyright © 2014 Canonical Ltd.
4453+ *
4454+ * This program is free software: you can redistribute it and/or modify it
4455+ * under the terms of the GNU Lesser General Public License version 3,
4456+ * as published by the Free Software Foundation.
4457+ *
4458+ * This program is distributed in the hope that it will be useful,
4459+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4460+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4461+ * GNU Lesser General Public License for more details.
4462+ *
4463+ * You should have received a copy of the GNU Lesser General Public License
4464+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4465+ *
4466+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
4467+ */
4468+
4469+#ifndef MIR_CLIENT_MIR_PROMPT_SESSION_H_
4470+#define MIR_CLIENT_MIR_PROMPT_SESSION_H_
4471+
4472+#include "mir_toolkit/mir_client_library.h"
4473+
4474+#include "mir_protobuf.pb.h"
4475+#include "mir_wait_handle.h"
4476+
4477+#include <mutex>
4478+#include <memory>
4479+#include <atomic>
4480+
4481+namespace mir
4482+{
4483+/// The client-side library implementation namespace
4484+namespace client
4485+{
4486+class EventHandlerRegister;
4487+}
4488+}
4489+
4490+struct MirPromptSession
4491+{
4492+public:
4493+ MirPromptSession(mir::protobuf::DisplayServer& server,
4494+ std::shared_ptr<mir::client::EventHandlerRegister> const& event_handler_register);
4495+
4496+ ~MirPromptSession();
4497+
4498+ MirWaitHandle* start(pid_t application_pid, mir_prompt_session_callback callback, void* context);
4499+ MirWaitHandle* stop(mir_prompt_session_callback callback, void* context);
4500+ MirWaitHandle* add_prompt_provider(pid_t provider_pid, mir_prompt_session_add_prompt_provider_callback callback, void* context);
4501+
4502+ MirWaitHandle* new_fds_for_prompt_providers(
4503+ unsigned int no_of_fds,
4504+ mir_client_fd_callback callback,
4505+ void * context);
4506+
4507+ void register_prompt_session_state_change_callback(mir_prompt_session_state_change_callback callback, void* context);
4508+
4509+ char const* get_error_message();
4510+
4511+private:
4512+ std::mutex mutable mutex; // Protects parameters, wait_handles & results
4513+ mir::protobuf::DisplayServer& server;
4514+ mir::protobuf::PromptProvider prompt_provider;
4515+ mir::protobuf::PromptSessionParameters parameters;
4516+ mir::protobuf::Void add_result;
4517+ mir::protobuf::Void protobuf_void;
4518+ mir::protobuf::SocketFD socket_fd_response;
4519+ std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register;
4520+ int const event_handler_register_id;
4521+
4522+ MirWaitHandle start_wait_handle;
4523+ MirWaitHandle stop_wait_handle;
4524+ MirWaitHandle add_result_wait_handle;
4525+ MirWaitHandle fds_for_prompt_providers_wait_handle;
4526+ std::atomic<MirPromptSessionState> state;
4527+
4528+ std::mutex mutable session_mutex; // Protects session
4529+ mir::protobuf::Void session;
4530+
4531+ std::mutex mutable event_handler_mutex; // Need another mutex for callback access to members
4532+ std::function<void(MirPromptSessionState)> handle_prompt_session_state_change;
4533+
4534+ void set_state(MirPromptSessionState new_state);
4535+ void done_start(mir_prompt_session_callback callback, void* context);
4536+ void done_stop(mir_prompt_session_callback callback, void* context);
4537+ void done_add_prompt_provider(mir_prompt_session_add_prompt_provider_callback callback, void* context);
4538+ void done_fds_for_prompt_providers(mir_client_fd_callback callback, void* context);
4539+ MirPromptSession(MirPromptSession const&) = delete;
4540+ MirPromptSession& operator=(MirPromptSession const&) = delete;
4541+};
4542+
4543+#endif /* MIR_CLIENT_MIR_PROMPT_SESSION_H_ */
4544+
4545
4546=== added file 'src/client/mir_prompt_session_api.cpp'
4547--- src/client/mir_prompt_session_api.cpp 1970-01-01 00:00:00 +0000
4548+++ src/client/mir_prompt_session_api.cpp 2014-06-18 12:52:17 +0000
4549@@ -0,0 +1,118 @@
4550+/*
4551+ * Copyright © 2014 Canonical Ltd.
4552+ *
4553+ * This program is free software: you can redistribute it and/or modify it
4554+ * under the terms of the GNU Lesser General Public License version 3,
4555+ * as published by the Free Software Foundation.
4556+ *
4557+ * This program is distributed in the hope that it will be useful,
4558+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4559+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4560+ * GNU Lesser General Public License for more details.
4561+ *
4562+ * You should have received a copy of the GNU Lesser General Public License
4563+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4564+ *
4565+ * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
4566+ */
4567+
4568+
4569+#include "mir_toolkit/mir_prompt_session.h"
4570+#include "mir_prompt_session.h"
4571+#include "mir_connection.h"
4572+
4573+#include <stdexcept>
4574+#include <boost/throw_exception.hpp>
4575+
4576+namespace
4577+{
4578+void null_callback(MirPromptSession*, void*) {}
4579+
4580+void add_prompt_provider_callback(
4581+ MirPromptSession*,
4582+ MirBool added,
4583+ void* context)
4584+{
4585+ if (context)
4586+ *(MirBool*)context = added;
4587+}
4588+
4589+}
4590+
4591+MirPromptSession *mir_connection_create_prompt_session_sync(
4592+ MirConnection* connection,
4593+ pid_t application_pid,
4594+ mir_prompt_session_state_change_callback state_change_callback,
4595+ void* context)
4596+{
4597+ try
4598+ {
4599+ auto prompt_session = connection->create_prompt_session();
4600+ if (state_change_callback)
4601+ prompt_session->register_prompt_session_state_change_callback(state_change_callback, context);
4602+
4603+ mir_wait_for(prompt_session->start(application_pid,
4604+ null_callback,
4605+ nullptr));
4606+ return prompt_session;
4607+ }
4608+ catch (std::exception const&)
4609+ {
4610+ // TODO callback with an error
4611+ return nullptr;
4612+ }
4613+}
4614+
4615+MirWaitHandle *mir_prompt_session_add_prompt_provider(
4616+ MirPromptSession *prompt_session,
4617+ pid_t provider_pid,
4618+ mir_prompt_session_add_prompt_provider_callback callback,
4619+ void* context)
4620+{
4621+ try
4622+ {
4623+ return prompt_session->add_prompt_provider(provider_pid, callback, context);
4624+ }
4625+ catch (std::exception const&)
4626+ {
4627+ // TODO callback with an error
4628+ return nullptr;
4629+ }
4630+}
4631+
4632+MirBool mir_prompt_session_add_prompt_provider_sync(
4633+ MirPromptSession *prompt_session,
4634+ pid_t provider_pid)
4635+{
4636+ MirBool result;
4637+ mir_wait_for(mir_prompt_session_add_prompt_provider(prompt_session,
4638+ provider_pid,
4639+ add_prompt_provider_callback,
4640+ &result));
4641+ return result;
4642+}
4643+
4644+MirWaitHandle* mir_prompt_session_new_fds_for_prompt_providers(
4645+ MirPromptSession *prompt_session,
4646+ unsigned int no_of_fds,
4647+ mir_client_fd_callback callback,
4648+ void * context)
4649+{
4650+ try
4651+ {
4652+ return prompt_session ?
4653+ prompt_session->new_fds_for_prompt_providers(no_of_fds, callback, context) :
4654+ nullptr;
4655+ }
4656+ catch (std::exception const&)
4657+ {
4658+ return nullptr;
4659+ }
4660+}
4661+
4662+void mir_prompt_session_release_sync(
4663+ MirPromptSession *prompt_session)
4664+{
4665+ mir_wait_for(prompt_session->stop(&null_callback, nullptr));
4666+ delete prompt_session;
4667+}
4668
4669=== modified file 'src/client/mir_screencast.cpp'
4670--- src/client/mir_screencast.cpp 2014-03-11 16:19:27 +0000
4671+++ src/client/mir_screencast.cpp 2014-06-18 12:52:17 +0000
4672@@ -102,6 +102,7 @@
4673 parameters.set_height(output_size.height.as_uint32_t());
4674 parameters.set_pixel_format(pixel_format);
4675
4676+ create_screencast_wait_handle.expect_result();
4677 server.create_screencast(
4678 nullptr,
4679 &parameters,
4680@@ -143,6 +144,7 @@
4681 mir::protobuf::ScreencastId screencast_id;
4682 screencast_id.set_value(protobuf_screencast.screencast_id().value());
4683
4684+ release_wait_handle.expect_result();
4685 server.release_screencast(
4686 nullptr,
4687 &screencast_id,
4688@@ -159,6 +161,7 @@
4689 mir::protobuf::ScreencastId screencast_id;
4690 screencast_id.set_value(protobuf_screencast.screencast_id().value());
4691
4692+ next_buffer_wait_handle.expect_result();
4693 server.screencast_buffer(
4694 nullptr,
4695 &screencast_id,
4696
4697=== modified file 'src/client/mir_surface.cpp'
4698--- src/client/mir_surface.cpp 2014-05-23 07:25:58 +0000
4699+++ src/client/mir_surface.cpp 2014-06-18 12:52:17 +0000
4700@@ -62,6 +62,7 @@
4701 message.set_buffer_usage(params.buffer_usage);
4702 message.set_output_id(params.output_id);
4703
4704+ create_wait_handle.expect_result();
4705 server.create_surface(0, &message, &surface, gp::NewCallback(this, &MirSurface::created, callback, context));
4706
4707 for (int i = 0; i < mir_surface_attribs; i++)
4708@@ -76,6 +77,11 @@
4709
4710 MirSurface::~MirSurface()
4711 {
4712+ {
4713+ std::lock_guard<decltype(handle_mutex)> lock(handle_mutex);
4714+ valid_surfaces.erase(this);
4715+ }
4716+
4717 std::lock_guard<decltype(mutex)> lock(mutex);
4718
4719 if (input_thread)
4720@@ -158,6 +164,7 @@
4721 auto const mutable_buffer = surface.mutable_buffer();
4722 lock.unlock();
4723
4724+ next_buffer_wait_handle.expect_result();
4725 server.next_buffer(
4726 0,
4727 id,
4728@@ -243,8 +250,10 @@
4729 mir_surface_callback callback,
4730 void * context)
4731 {
4732- std::lock_guard<decltype(handle_mutex)> lock(handle_mutex);
4733- valid_surfaces.erase(this);
4734+ {
4735+ std::lock_guard<decltype(handle_mutex)> lock(handle_mutex);
4736+ valid_surfaces.erase(this);
4737+ }
4738
4739 return connection->release_surface(this, callback, context);
4740 }
4741@@ -323,7 +332,7 @@
4742
4743 configure_cursor_wait_handle.expect_result();
4744 server.configure_cursor(0, &setting, &void_response,
4745- google::protobuf::NewCallback(this, &MirSurface::on_configured));
4746+ google::protobuf::NewCallback(this, &MirSurface::on_cursor_configured));
4747
4748 return &configure_cursor_wait_handle;
4749 }
4750@@ -375,6 +384,12 @@
4751 }
4752 }
4753
4754+void MirSurface::on_cursor_configured()
4755+{
4756+ configure_cursor_wait_handle.result_received();
4757+}
4758+
4759+
4760 int MirSurface::attrib(MirSurfaceAttrib at) const
4761 {
4762 std::lock_guard<decltype(mutex)> lock(mutex);
4763
4764=== modified file 'src/client/mir_surface.h'
4765--- src/client/mir_surface.h 2014-05-23 07:25:58 +0000
4766+++ src/client/mir_surface.h 2014-06-18 12:52:17 +0000
4767@@ -102,6 +102,7 @@
4768 mutable std::mutex mutex; // Protects all members of *this
4769
4770 void on_configured();
4771+ void on_cursor_configured();
4772 void process_incoming_buffer();
4773 void populate(MirBufferPackage& buffer_package);
4774 void created(mir_surface_callback callback, void * context);
4775
4776=== modified file 'src/client/mir_wait_handle.cpp'
4777--- src/client/mir_wait_handle.cpp 2013-10-03 03:44:08 +0000
4778+++ src/client/mir_wait_handle.cpp 2014-06-18 12:52:17 +0000
4779@@ -1,5 +1,5 @@
4780 /*
4781- * Copyright © 2012 Canonical Ltd.
4782+ * Copyright © 2012-2014 Canonical Ltd.
4783 *
4784 * This program is free software: you can redistribute it and/or modify it
4785 * under the terms of the GNU Lesser General Public License version 3,
4786@@ -33,14 +33,14 @@
4787
4788 void MirWaitHandle::expect_result()
4789 {
4790- std::unique_lock<std::mutex> lock(guard);
4791+ std::lock_guard<std::mutex> lock(guard);
4792
4793 expecting++;
4794 }
4795
4796 void MirWaitHandle::result_received()
4797 {
4798- std::unique_lock<std::mutex> lock(guard);
4799+ std::lock_guard<std::mutex> lock(guard);
4800
4801 received++;
4802 wait_condition.notify_all();
4803@@ -50,8 +50,7 @@
4804 {
4805 std::unique_lock<std::mutex> lock(guard);
4806
4807- while ((!expecting && !received) || (received < expecting))
4808- wait_condition.wait(lock);
4809+ wait_condition.wait(lock, [&]{ return received == expecting; });
4810
4811 received = 0;
4812 expecting = 0;
4813@@ -59,14 +58,9 @@
4814
4815 void MirWaitHandle::wait_for_pending(std::chrono::milliseconds limit)
4816 {
4817- using std::chrono::steady_clock;
4818-
4819 std::unique_lock<std::mutex> lock(guard);
4820
4821- auto time_limit = steady_clock::now() + limit;
4822-
4823- while (received < expecting && steady_clock::now() < time_limit)
4824- wait_condition.wait_until(lock, time_limit);
4825+ wait_condition.wait_for(lock, limit, [&]{ return received == expecting; });
4826 }
4827
4828
4829@@ -74,11 +68,9 @@
4830 {
4831 std::unique_lock<std::mutex> lock(guard);
4832
4833- while (received == 0)
4834- wait_condition.wait(lock);
4835+ wait_condition.wait(lock, [&]{ return received != 0; });
4836
4837- received--;
4838- if (expecting > 0)
4839- expecting--;
4840+ --received;
4841+ --expecting;
4842 }
4843
4844
4845=== modified file 'src/client/rpc/make_rpc_channel.h'
4846--- src/client/rpc/make_rpc_channel.h 2014-03-06 06:05:17 +0000
4847+++ src/client/rpc/make_rpc_channel.h 2014-06-18 12:52:17 +0000
4848@@ -29,6 +29,7 @@
4849 class SurfaceMap;
4850 class DisplayConfiguration;
4851 class LifecycleControl;
4852+class EventSink;
4853
4854 namespace rpc
4855 {
4856@@ -39,7 +40,8 @@
4857 std::shared_ptr<SurfaceMap> const& map,
4858 std::shared_ptr<DisplayConfiguration> const& disp_conf,
4859 std::shared_ptr<RpcReport> const& rpc_report,
4860- std::shared_ptr<LifecycleControl> const& lifecycle_control);
4861+ std::shared_ptr<LifecycleControl> const& lifecycle_control,
4862+ std::shared_ptr<EventSink> const& event_distributor);
4863 }
4864 }
4865 }
4866
4867=== modified file 'src/client/rpc/make_socket_rpc_channel.cpp'
4868--- src/client/rpc/make_socket_rpc_channel.cpp 2014-03-06 06:05:17 +0000
4869+++ src/client/rpc/make_socket_rpc_channel.cpp 2014-06-18 12:52:17 +0000
4870@@ -44,13 +44,14 @@
4871 std::shared_ptr<mcl::SurfaceMap> const& map,
4872 std::shared_ptr<mcl::DisplayConfiguration> const& disp_conf,
4873 std::shared_ptr<RpcReport> const& rpc_report,
4874- std::shared_ptr<mcl::LifecycleControl> const& lifecycle_control)
4875+ std::shared_ptr<mcl::LifecycleControl> const& lifecycle_control,
4876+ std::shared_ptr<mcl::EventSink> const& event_sink)
4877 {
4878 if (fd_prefix.is_start_of(name))
4879 {
4880 auto const fd = atoi(name.c_str()+fd_prefix.size);
4881- return std::make_shared<MirSocketRpcChannel>(fd, map, disp_conf, rpc_report, lifecycle_control);
4882+ return std::make_shared<MirSocketRpcChannel>(fd, map, disp_conf, rpc_report, lifecycle_control, event_sink);
4883 }
4884
4885- return std::make_shared<MirSocketRpcChannel>(name, map, disp_conf, rpc_report, lifecycle_control);
4886+ return std::make_shared<MirSocketRpcChannel>(name, map, disp_conf, rpc_report, lifecycle_control, event_sink);
4887 }
4888
4889=== modified file 'src/client/rpc/mir_socket_rpc_channel.cpp'
4890--- src/client/rpc/mir_socket_rpc_channel.cpp 2014-05-22 12:41:12 +0000
4891+++ src/client/rpc/mir_socket_rpc_channel.cpp 2014-06-18 12:52:17 +0000
4892@@ -24,6 +24,7 @@
4893 #include "../mir_surface.h"
4894 #include "../display_configuration.h"
4895 #include "../lifecycle_control.h"
4896+#include "../event_sink.h"
4897 #include "mir/variable_length_array.h"
4898
4899 #include "mir_protobuf.pb.h" // For Buffer frig
4900@@ -50,7 +51,8 @@
4901 std::shared_ptr<mcl::SurfaceMap> const& surface_map,
4902 std::shared_ptr<DisplayConfiguration> const& disp_config,
4903 std::shared_ptr<RpcReport> const& rpc_report,
4904- std::shared_ptr<LifecycleControl> const& lifecycle_control) :
4905+ std::shared_ptr<LifecycleControl> const& lifecycle_control,
4906+ std::shared_ptr<EventSink> const& event_sink) :
4907 rpc_report(rpc_report),
4908 pending_calls(rpc_report),
4909 work(io_service),
4910@@ -58,6 +60,7 @@
4911 surface_map(surface_map),
4912 display_configuration(disp_config),
4913 lifecycle_control(lifecycle_control),
4914+ event_sink(event_sink),
4915 disconnected(false)
4916 {
4917 socket.connect(endpoint);
4918@@ -69,7 +72,8 @@
4919 std::shared_ptr<mcl::SurfaceMap> const& surface_map,
4920 std::shared_ptr<DisplayConfiguration> const& disp_config,
4921 std::shared_ptr<RpcReport> const& rpc_report,
4922- std::shared_ptr<LifecycleControl> const& lifecycle_control) :
4923+ std::shared_ptr<LifecycleControl> const& lifecycle_control,
4924+ std::shared_ptr<EventSink> const& event_sink) :
4925 rpc_report(rpc_report),
4926 pending_calls(rpc_report),
4927 work(io_service),
4928@@ -77,6 +81,7 @@
4929 surface_map(surface_map),
4930 display_configuration(disp_config),
4931 lifecycle_control(lifecycle_control),
4932+ event_sink(event_sink),
4933 disconnected(false)
4934 {
4935 socket.assign(boost::asio::local::stream_protocol(), native_socket);
4936@@ -413,11 +418,25 @@
4937
4938 rpc_report->event_parsing_succeeded(e);
4939
4940- surface_map->with_surface_do(e.surface.id,
4941- [&e](MirSurface* surface)
4942- {
4943- surface->handle_event(e);
4944- });
4945+ event_sink->handle_event(e);
4946+
4947+ // todo - surfaces should register with the event handler register.
4948+ if (e.type == mir_event_type_surface)
4949+ {
4950+ surface_map->with_surface_do(e.surface.id,
4951+ [&e](MirSurface* surface)
4952+ {
4953+ surface->handle_event(e);
4954+ });
4955+ }
4956+ else if (e.type == mir_event_type_resize)
4957+ {
4958+ surface_map->with_surface_do(e.resize.surface_id,
4959+ [&e](MirSurface* surface)
4960+ {
4961+ surface->handle_event(e);
4962+ });
4963+ }
4964 }
4965 else
4966 {
4967
4968=== modified file 'src/client/rpc/mir_socket_rpc_channel.h'
4969--- src/client/rpc/mir_socket_rpc_channel.h 2014-05-07 02:56:33 +0000
4970+++ src/client/rpc/mir_socket_rpc_channel.h 2014-06-18 12:52:17 +0000
4971@@ -44,6 +44,7 @@
4972 class DisplayConfiguration;
4973 class SurfaceMap;
4974 class LifecycleControl;
4975+class EventSink;
4976 namespace rpc
4977 {
4978
4979@@ -56,13 +57,15 @@
4980 std::shared_ptr<SurfaceMap> const& surface_map,
4981 std::shared_ptr<DisplayConfiguration> const& disp_config,
4982 std::shared_ptr<RpcReport> const& rpc_report,
4983- std::shared_ptr<LifecycleControl> const& lifecycle_control);
4984+ std::shared_ptr<LifecycleControl> const& lifecycle_control,
4985+ std::shared_ptr<EventSink> const& event_sink);
4986
4987 MirSocketRpcChannel(int native_socket,
4988 std::shared_ptr<SurfaceMap> const& surface_map,
4989 std::shared_ptr<DisplayConfiguration> const& disp_config,
4990 std::shared_ptr<RpcReport> const& rpc_report,
4991- std::shared_ptr<LifecycleControl> const& lifecycle_control);
4992+ std::shared_ptr<LifecycleControl> const& lifecycle_control,
4993+ std::shared_ptr<EventSink> const& event_sink);
4994 ~MirSocketRpcChannel();
4995
4996 private:
4997@@ -102,6 +105,7 @@
4998 std::shared_ptr<SurfaceMap> surface_map;
4999 std::shared_ptr<DisplayConfiguration> display_configuration;
5000 std::shared_ptr<LifecycleControl> lifecycle_control;
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: