Mir

Merge lp:~kdub/mir/hwc-alpha-support into lp:mir/ubuntu

Proposed by Kevin DuBois
Status: Superseded
Proposed branch: lp:~kdub/mir/hwc-alpha-support
Merge into: lp:mir/ubuntu
Diff against target: 22375 lines (+9938/-3616) (has conflicts)
338 files modified
3rd_party/android-deps/std/Thread.h (+5/-2)
CMakeLists.txt (+1/-1)
debian/control (+3/-3)
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 (+28/-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_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 (+65/-6)
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 (+46/-15)
src/platform/graphics/android/hwc_device.h (+7/-4)
src/platform/graphics/android/hwc_fallback_gl_renderer.cpp (+7/-2)
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_layers.cpp (+12/-1)
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 (+27/-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 (+228/-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_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 (+39/-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/hwc_struct_helpers.cpp (+1/-0)
tests/unit-tests/graphics/android/hwc_struct_helpers.h (+1/-0)
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 (+118/-97)
tests/unit-tests/graphics/android/test_hwc_display.cpp (+49/-106)
tests/unit-tests/graphics/android/test_hwc_fallback_gl_renderer.cpp (+24/-7)
tests/unit-tests/graphics/android/test_hwc_fb_device.cpp (+12/-26)
tests/unit-tests/graphics/android/test_hwc_layers.cpp (+3/-1)
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 (+272/-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)
Text conflict in examples/demo-shell/demo_renderer.cpp
Text conflict in src/server/compositor/gl_renderer.cpp
Text conflict in tests/unit-tests/compositor/test_gl_renderer.cpp
To merge this branch: bzr merge lp:~kdub/mir/hwc-alpha-support
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+223614@code.launchpad.net

Commit message

android: support alpha blending overlays together in HWC. bumps android-headers version requirement from 4.2.2 to 4.4.2. also change to premultiplied blending in hwc by default, as thats more in line with the rest of the system.

Description of the change

android: support alpha blending overlays together in HWC. bumps android-headers version requirement from 4.2.2 to 4.4.2. also change to premultiplied blending in hwc by default, as thats more in line with the rest of the system.

To post a comment you must log in.

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

Subscribers

People subscribed via source and target branches