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
=== modified file '3rd_party/android-deps/std/Thread.h'
--- 3rd_party/android-deps/std/Thread.h 2014-05-22 11:31:21 +0000
+++ 3rd_party/android-deps/std/Thread.h 2014-06-18 17:25:24 +0000
@@ -35,6 +35,7 @@
35namespace mir35namespace mir
36{36{
37void terminate_with_current_exception();37void terminate_with_current_exception();
38void set_thread_name(std::string const&);
38}39}
3940
40namespace mir_input41namespace mir_input
@@ -54,13 +55,15 @@
54 int32_t priority = PRIORITY_DEFAULT,55 int32_t priority = PRIORITY_DEFAULT,
55 size_t stack = 0)56 size_t stack = 0)
56 {57 {
57 (void)name; (void)priority; (void)stack;58 (void)priority; (void)stack;
59 std::string const name_str{name};
5860
59 status.store(NO_ERROR);61 status.store(NO_ERROR);
60 exit_pending.store(false);62 exit_pending.store(false);
6163
62 thread = std::thread([this]() -> void64 thread = std::thread([name_str,this]() -> void
63 {65 {
66 mir::set_thread_name(name_str);
64 try67 try
65 {68 {
66 if (auto result = readyToRun()) status.store(result);69 if (auto result = readyToRun()) status.store(result);
6770
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-06-05 12:55:18 +0000
+++ CMakeLists.txt 2014-06-18 17:25:24 +0000
@@ -27,7 +27,7 @@
27set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)27set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
2828
29set(MIR_VERSION_MAJOR 0)29set(MIR_VERSION_MAJOR 0)
30set(MIR_VERSION_MINOR 2) # This should change at least with every MIRSERVER_ABI30set(MIR_VERSION_MINOR 3) # This should change at least with every MIRSERVER_ABI
31set(MIR_VERSION_PATCH 0)31set(MIR_VERSION_PATCH 0)
3232
33set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)33set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
3434
=== modified file 'debian/control'
--- debian/control 2014-05-28 07:43:51 +0000
+++ debian/control 2014-06-18 17:25:24 +0000
@@ -27,7 +27,7 @@
27 libglm-dev,27 libglm-dev,
28 libprotobuf-dev,28 libprotobuf-dev,
29 pkg-config,29 pkg-config,
30 android-headers (>=4.2.2) [i386 amd64 armhf],30 android-headers (>=4.4.2) [i386 amd64 armhf],
31 libhardware-dev [i386 amd64 armhf],31 libhardware-dev [i386 amd64 armhf],
32 libandroid-properties-dev [i386 amd64 armhf],32 libandroid-properties-dev [i386 amd64 armhf],
33 libgoogle-glog-dev,33 libgoogle-glog-dev,
@@ -72,7 +72,7 @@
72 .72 .
73 Contains the protocol's definition files.73 Contains the protocol's definition files.
7474
75Package: libmirserver2075Package: libmirserver21
76Section: libs76Section: libs
77Architecture: i386 amd64 armhf arm6477Architecture: i386 amd64 armhf arm64
78Multi-Arch: same78Multi-Arch: same
@@ -150,7 +150,7 @@
150Architecture: i386 amd64 armhf arm64150Architecture: i386 amd64 armhf arm64
151Multi-Arch: same151Multi-Arch: same
152Pre-Depends: ${misc:Pre-Depends}152Pre-Depends: ${misc:Pre-Depends}
153Depends: libmirserver20 (= ${binary:Version}),153Depends: libmirserver21 (= ${binary:Version}),
154 libmirprotobuf-dev (= ${binary:Version}),154 libmirprotobuf-dev (= ${binary:Version}),
155 mircommon-dev (= ${binary:Version}),155 mircommon-dev (= ${binary:Version}),
156 libglm-dev,156 libglm-dev,
157157
=== renamed file 'debian/libmirserver20.install' => 'debian/libmirserver21.install'
--- debian/libmirserver20.install 2014-05-07 02:56:33 +0000
+++ debian/libmirserver21.install 2014-06-18 17:25:24 +0000
@@ -1,1 +1,1 @@
1usr/lib/*/libmirserver.so.201usr/lib/*/libmirserver.so.21
22
=== modified file 'examples/CMakeLists.txt'
--- examples/CMakeLists.txt 2014-05-28 07:43:51 +0000
+++ examples/CMakeLists.txt 2014-06-18 17:25:24 +0000
@@ -92,6 +92,9 @@
9292
93)93)
9494
95add_executable(mir_demo_client_prompt_session prompt_session.c)
96target_link_libraries(mir_demo_client_prompt_session mirclient)
97
95add_library(mirdraw STATIC graphics_utils.cpp)98add_library(mirdraw STATIC graphics_utils.cpp)
96target_link_libraries(mirdraw ${GLESv2_LIBRARIES})99target_link_libraries(mirdraw ${GLESv2_LIBRARIES})
97100
@@ -143,7 +146,7 @@
143 server_configuration.cpp146 server_configuration.cpp
144)147)
145148
146target_link_libraries(mir_demo_standalone_input_filter 149target_link_libraries(mir_demo_standalone_input_filter
147 mirserver150 mirserver
148)151)
149152
@@ -158,8 +161,9 @@
158 mir_demo_client_multiwin161 mir_demo_client_multiwin
159 mir_demo_client_display_config162 mir_demo_client_display_config
160 mir_demo_client_progressbar163 mir_demo_client_progressbar
164 mir_demo_client_prompt_session
161 mir_demo_standalone_input_filter165 mir_demo_standalone_input_filter
162 mir_demo_standalone_render_to_fb 166 mir_demo_standalone_render_to_fb
163 mir_demo_standalone_render_surfaces167 mir_demo_standalone_render_surfaces
164)168)
165169
166170
=== modified file 'examples/buffer_render_target.cpp'
--- examples/buffer_render_target.cpp 2014-03-06 06:05:17 +0000
+++ examples/buffer_render_target.cpp 2014-06-18 17:25:24 +0000
@@ -77,7 +77,7 @@
77 /* Set up color buffer... */77 /* Set up color buffer... */
78 glGenTextures(1, &color_tex);78 glGenTextures(1, &color_tex);
79 glBindTexture(GL_TEXTURE_2D, color_tex);79 glBindTexture(GL_TEXTURE_2D, color_tex);
80 buffer.bind_to_texture();80 buffer.gl_bind_to_texture();
81 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,81 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
82 GL_TEXTURE_2D, color_tex, 0);82 GL_TEXTURE_2D, color_tex, 0);
8383
8484
=== modified file 'examples/demo-inprocess-surface-client/inprocess_egl_client.cpp'
--- examples/demo-inprocess-surface-client/inprocess_egl_client.cpp 2014-04-15 05:31:19 +0000
+++ examples/demo-inprocess-surface-client/inprocess_egl_client.cpp 2014-06-18 17:25:24 +0000
@@ -102,7 +102,7 @@
102102
103 auto input_platform = mircv::InputPlatform::create();103 auto input_platform = mircv::InputPlatform::create();
104 input_thread = input_platform->create_input_thread(104 input_thread = input_platform->create_input_thread(
105 surface->client_input_fd(), 105 surface->client_input_fd(),
106 std::bind(std::mem_fn(&me::InprocessEGLClient::handle_event), this, std::placeholders::_1));106 std::bind(std::mem_fn(&me::InprocessEGLClient::handle_event), this, std::placeholders::_1));
107 input_thread->start();107 input_thread->start();
108108
109109
=== modified file 'examples/demo-shell/demo_renderer.cpp'
--- examples/demo-shell/demo_renderer.cpp 2014-06-03 17:20:17 +0000
+++ examples/demo-shell/demo_renderer.cpp 2014-06-18 17:25:24 +0000
@@ -18,6 +18,7 @@
1818
19#include "demo_renderer.h"19#include "demo_renderer.h"
20#include <mir/graphics/renderable.h>20#include <mir/graphics/renderable.h>
21#include <mir/compositor/destination_alpha.h>
21#include <mir/compositor/recently_used_cache.h>22#include <mir/compositor/recently_used_cache.h>
22#include <cmath>23#include <cmath>
2324
@@ -93,15 +94,6 @@
93 {94 {
94 Color col = color;95 Color col = color;
9596
96 // Cut out the corner in a circular shape.
97 if (x < cx && y < cy)
98 {
99 int dx = cx - x;
100 int dy = cy - y;
101 if (dx * dx + dy * dy >= radius_sqr)
102 col.a = 0;
103 }
104
105 // Set gradient97 // Set gradient
106 if (y < cy)98 if (y < cy)
107 {99 {
@@ -113,6 +105,15 @@
113 col.b += (highlight - col.b) * brighten;105 col.b += (highlight - col.b) * brighten;
114 }106 }
115107
108 // Cut out the corner in a circular shape.
109 if (x < cx && y < cy)
110 {
111 int dx = cx - x;
112 int dy = cy - y;
113 if (dx * dx + dy * dy >= radius_sqr)
114 col = {0, 0, 0, 0};
115 }
116
116 image[y * width + x] = col;117 image[y * width + x] = col;
117 }118 }
118 }119 }
@@ -137,10 +138,12 @@
137138
138DemoRenderer::DemoRenderer(139DemoRenderer::DemoRenderer(
139 graphics::GLProgramFactory const& program_factory,140 graphics::GLProgramFactory const& program_factory,
140 geometry::Rectangle const& display_area)141 geometry::Rectangle const& display_area,
142 compositor::DestinationAlpha dest_alpha)
141 : GLRenderer(program_factory,143 : GLRenderer(program_factory,
142 std::unique_ptr<graphics::GLTextureCache>(new compositor::RecentlyUsedCache()),144 std::unique_ptr<graphics::GLTextureCache>(new compositor::RecentlyUsedCache()),
143 display_area)145 display_area,
146 dest_alpha)
144 , corner_radius(0.5f)147 , corner_radius(0.5f)
145{148{
146 shadow_corner_tex = generate_shadow_corner_texture(0.4f);149 shadow_corner_tex = generate_shadow_corner_texture(0.4f);
@@ -157,8 +160,20 @@
157160
158void DemoRenderer::begin() const161void DemoRenderer::begin() const
159{162{
160 glClearColor(0.2f, 0.2f, 0.2f, 1.0f);163 bool const opaque = destination_alpha() == compositor::DestinationAlpha::opaque;
164 if (opaque)
165 glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
166 else
167 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
168
169 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
161 glClear(GL_COLOR_BUFFER_BIT);170 glClear(GL_COLOR_BUFFER_BIT);
171<<<<<<< TREE
172=======
173
174 if (opaque)
175 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
176>>>>>>> MERGE-SOURCE
162}177}
163178
164void DemoRenderer::tessellate(std::vector<graphics::GLPrimitive>& primitives,179void DemoRenderer::tessellate(std::vector<graphics::GLPrimitive>& primitives,
@@ -261,7 +276,7 @@
261276
262 // Shadows always need blending...277 // Shadows always need blending...
263 glEnable(GL_BLEND);278 glEnable(GL_BLEND);
264 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);279 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
265}280}
266281
267void DemoRenderer::tessellate_frame(std::vector<graphics::GLPrimitive>& primitives,282void DemoRenderer::tessellate_frame(std::vector<graphics::GLPrimitive>& primitives,
268283
=== modified file 'examples/demo-shell/demo_renderer.h'
--- examples/demo-shell/demo_renderer.h 2014-05-19 02:55:29 +0000
+++ examples/demo-shell/demo_renderer.h 2014-06-18 17:25:24 +0000
@@ -29,7 +29,8 @@
29class DemoRenderer : public compositor::GLRenderer29class DemoRenderer : public compositor::GLRenderer
30{30{
31public:31public:
32 DemoRenderer(graphics::GLProgramFactory const& factory, geometry::Rectangle const& display_area);32 DemoRenderer(graphics::GLProgramFactory const& factory, geometry::Rectangle const& display_area,
33 compositor::DestinationAlpha dest_alpha);
33 ~DemoRenderer();34 ~DemoRenderer();
3435
35 void begin() const override;36 void begin() const override;
3637
=== modified file 'examples/demo-shell/demo_shell.cpp'
--- examples/demo-shell/demo_shell.cpp 2014-04-24 08:42:12 +0000
+++ examples/demo-shell/demo_shell.cpp 2014-06-18 17:25:24 +0000
@@ -53,9 +53,10 @@
53 }53 }
5454
55 std::unique_ptr<compositor::Renderer> create_renderer_for(55 std::unique_ptr<compositor::Renderer> create_renderer_for(
56 geometry::Rectangle const& rect) override56 geometry::Rectangle const& rect,
57 mir::compositor::DestinationAlpha dest_alpha) override
57 {58 {
58 return std::unique_ptr<compositor::Renderer>(new DemoRenderer(*gl_program_factory, rect));59 return std::unique_ptr<compositor::Renderer>(new DemoRenderer(*gl_program_factory, rect, dest_alpha));
59 }60 }
60private:61private:
61 std::shared_ptr<graphics::GLProgramFactory> const gl_program_factory;62 std::shared_ptr<graphics::GLProgramFactory> const gl_program_factory;
6263
=== modified file 'examples/demo-shell/window_manager.cpp'
--- examples/demo-shell/window_manager.cpp 2014-05-22 11:31:21 +0000
+++ examples/demo-shell/window_manager.cpp 2014-06-18 17:25:24 +0000
@@ -156,6 +156,13 @@
156 return true;156 return true;
157 }157 }
158 else if ((event.key.modifiers & mir_key_modifier_alt) &&158 else if ((event.key.modifiers & mir_key_modifier_alt) &&
159 (event.key.modifiers & mir_key_modifier_ctrl) &&
160 (event.key.scan_code == KEY_ESC))
161 {
162 std::abort();
163 return true;
164 }
165 else if ((event.key.modifiers & mir_key_modifier_alt) &&
159 (event.key.modifiers & mir_key_modifier_ctrl))166 (event.key.modifiers & mir_key_modifier_ctrl))
160 {167 {
161 MirOrientation orientation = mir_orientation_normal;168 MirOrientation orientation = mir_orientation_normal;
162169
=== modified file 'examples/eglcounter.cpp'
--- examples/eglcounter.cpp 2014-05-07 02:56:33 +0000
+++ examples/eglcounter.cpp 2014-06-18 17:25:24 +0000
@@ -201,7 +201,7 @@
201};201};
202202
203/* Colours from http://design.ubuntu.com/brand/colour-palette */203/* Colours from http://design.ubuntu.com/brand/colour-palette */
204#define MID_AUBERGINE 0.368627451f, 0.152941176f, 0.31372549f204#define MID_AUBERGINE(x) x*0.368627451f, x*0.152941176f, x*0.31372549f
205#define ORANGE 0.866666667f, 0.282352941f, 0.141414141f205#define ORANGE 0.866666667f, 0.282352941f, 0.141414141f
206206
207int main(int argc, char *argv[])207int main(int argc, char *argv[])
@@ -254,7 +254,8 @@
254 return 2;254 return 2;
255 }255 }
256256
257 glClearColor(MID_AUBERGINE, mir_eglapp_background_opacity);257 float const opacity = mir_eglapp_background_opacity;
258 glClearColor(MID_AUBERGINE(opacity), opacity);
258 glViewport(0, 0, width, height);259 glViewport(0, 0, width, height);
259260
260 glUseProgram(prog);261 glUseProgram(prog);
261262
=== modified file 'examples/eglflash.c'
--- examples/eglflash.c 2013-10-07 09:21:27 +0000
+++ examples/eglflash.c 2014-06-18 17:25:24 +0000
@@ -23,6 +23,11 @@
23#include <unistd.h>23#include <unistd.h>
24#include <GLES2/gl2.h>24#include <GLES2/gl2.h>
2525
26typedef struct Color
27{
28 GLfloat r, g, b, a;
29} Color;
30
26int main(int argc, char *argv[])31int main(int argc, char *argv[])
27{32{
28 unsigned int width = 0, height = 0;33 unsigned int width = 0, height = 0;
@@ -30,20 +35,25 @@
30 if (!mir_eglapp_init(argc, argv, &width, &height))35 if (!mir_eglapp_init(argc, argv, &width, &height))
31 return 1;36 return 1;
3237
38 float const opacity = mir_eglapp_background_opacity;
39 Color red = {opacity, 0.0f, 0.0f, opacity};
40 Color green = {0.0f, opacity, 0.0f, opacity};
41 Color blue = {0.0f, 0.0f, opacity, opacity};
42
33 /* This is probably the simplest GL you can do */43 /* This is probably the simplest GL you can do */
34 while (mir_eglapp_running())44 while (mir_eglapp_running())
35 {45 {
36 glClearColor(1.0f, 0.0f, 0.0f, mir_eglapp_background_opacity);46 glClearColor(red.r, red.g, red.b, red.a);
37 glClear(GL_COLOR_BUFFER_BIT);47 glClear(GL_COLOR_BUFFER_BIT);
38 mir_eglapp_swap_buffers();48 mir_eglapp_swap_buffers();
39 sleep(1);49 sleep(1);
4050
41 glClearColor(0.0f, 1.0f, 0.0f, mir_eglapp_background_opacity);51 glClearColor(green.r, green.g, green.b, green.a);
42 glClear(GL_COLOR_BUFFER_BIT);52 glClear(GL_COLOR_BUFFER_BIT);
43 mir_eglapp_swap_buffers();53 mir_eglapp_swap_buffers();
44 sleep(1);54 sleep(1);
4555
46 glClearColor(0.0f, 0.0f, 1.0f, mir_eglapp_background_opacity);56 glClearColor(blue.r, blue.g, blue.b, blue.a);
47 glClear(GL_COLOR_BUFFER_BIT);57 glClear(GL_COLOR_BUFFER_BIT);
48 mir_eglapp_swap_buffers();58 mir_eglapp_swap_buffers();
49 sleep(1);59 sleep(1);
5060
=== modified file 'examples/egltriangle.c'
--- examples/egltriangle.c 2013-10-07 09:21:27 +0000
+++ examples/egltriangle.c 2014-06-18 17:25:24 +0000
@@ -44,7 +44,7 @@
44}44}
4545
46/* Colours from http://design.ubuntu.com/brand/colour-palette */46/* Colours from http://design.ubuntu.com/brand/colour-palette */
47#define MID_AUBERGINE 0.368627451f, 0.152941176f, 0.31372549f47#define MID_AUBERGINE(x) x*0.368627451f, x*0.152941176f, x*0.31372549f
48#define ORANGE 0.866666667f, 0.282352941f, 0.141414141f48#define ORANGE 0.866666667f, 0.282352941f, 0.141414141f
4949
50int main(int argc, char *argv[])50int main(int argc, char *argv[])
@@ -105,7 +105,8 @@
105 return 2;105 return 2;
106 }106 }
107107
108 glClearColor(MID_AUBERGINE, mir_eglapp_background_opacity);108 float const opacity = mir_eglapp_background_opacity;
109 glClearColor(MID_AUBERGINE(opacity), opacity);
109 glViewport(0, 0, width, height);110 glViewport(0, 0, width, height);
110111
111 glUseProgram(prog);112 glUseProgram(prog);
112113
=== added file 'examples/prompt_session.c'
--- examples/prompt_session.c 1970-01-01 00:00:00 +0000
+++ examples/prompt_session.c 2014-06-18 17:25:24 +0000
@@ -0,0 +1,231 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nick Dedekind <nick.dedekind <nick.dedekind@canonical.com>
17 */
18
19#define _POSIX_SOURCE
20
21#include "mir_toolkit/mir_client_library.h"
22#include "mir_toolkit/mir_prompt_session.h"
23
24#undef NDEBUG
25#include <assert.h>
26#include <string.h>
27#include <stdio.h>
28#include <stdlib.h>
29#include <getopt.h>
30#include <unistd.h>
31#include <errno.h>
32#include <sys/wait.h>
33#include <sys/types.h>
34#include <signal.h>
35
36///\page prompt_session.c prompt_session.c: A mir client which starts a prompt session and prompt client app.
37/// mir_demo_client_prompt_session shows the use of mir prompt session API.
38/// This program opens a mir connection and creates a prompt session.
39///\section helper helper()
40/// Opens a mir connection and creates a prompt session
41/// before closing the prompt session and connection.
42///\section prompt_session_app prompt_session_app()
43/// Opens a mir connection and creates a surface
44/// before releasing the surface and closing the connection.
45///\example prompt_session.c A mir client demonstrating prompt sessions.
46///\section MirDemoState MirDemoState
47/// The handles needs to be accessible both to callbacks and to the control function.
48///\snippet prompt_session.c MirDemoState_tag
49///\section Callbacks Callbacks
50///\snippet prompt_session.c Callback_tag
51/// This program creates two processes, both opening a mir connection, one starting
52/// a prompt session with the other process.
53
54///\internal [MirDemoState_tag]
55// Utility structure for the state of a single session.
56typedef struct MirDemoState
57{
58 MirConnection *connection;
59 MirSurface *surface;
60 MirPromptSession *prompt_session;
61 pid_t child_pid;
62 MirPromptSessionState state;
63
64 int* client_fds;
65 unsigned int client_fd_count;
66} MirDemoState;
67///\internal [MirDemoState_tag]
68
69
70///\internal [Callback_tag]
71// Callback to update MirDemoState on prompt_session_event
72static void prompt_session_event_callback(MirPromptSession* prompt_session,
73 MirPromptSessionState state,
74 void* context)
75{
76 (void)prompt_session;
77 MirDemoState* demo_state = (MirDemoState*)context;
78 demo_state->state = state;
79
80 printf("helper: Prompt Session state updated to %d\n", state);
81 if (state == mir_prompt_session_state_stopped)
82 {
83 kill(demo_state->child_pid, SIGINT);
84 }
85}
86
87static void client_fd_callback(MirPromptSession* prompt_session, size_t count, int const* fds, void* context)
88{
89 (void)prompt_session;
90 ((MirDemoState*)context)->client_fds = malloc(sizeof(int)*count);
91 unsigned int i = 0;
92 for (; i < count; i++)
93 {
94 ((MirDemoState*)context)->client_fds[i] = fds[i];
95 }
96 ((MirDemoState*)context)->client_fd_count = count;
97}
98///\internal [Callback_tag]
99
100void start_session(const char* server, const char* name, MirDemoState* mcd)
101{
102 // Call mir_connect synchronously
103 mcd->connection = mir_connect_sync(server, name);
104
105 // We expect a connection handle;
106 // we expect it to be valid; and,
107 // we don't expect an error description
108 assert(mcd->connection != NULL);
109 assert(mir_connection_is_valid(mcd->connection));
110 assert(strcmp(mir_connection_get_error_message(mcd->connection), "") == 0);
111 printf("%s: Connected\n", name);
112
113 // We can query information about the platform we're running on
114 {
115 MirPlatformPackage platform_package;
116 platform_package.data_items = -1;
117 platform_package.fd_items = -1;
118
119 mir_connection_get_platform(mcd->connection, &platform_package);
120 assert(0 <= platform_package.data_items);
121 assert(0 <= platform_package.fd_items);
122 }
123}
124
125void stop_session(MirDemoState* mcd, const char* name)
126{
127 if (mcd->surface)
128 {
129 // We should release our surface
130 mir_surface_release_sync(mcd->surface);
131 mcd->surface = 0;
132 printf("%s: Surface released\n", name);
133 }
134
135 // We should release our connection
136 mir_connection_release(mcd->connection);
137 printf("%s: Connection released\n", name);
138}
139
140void helper(const char* server)
141{
142 MirDemoState mcd;
143 mcd.connection = 0;
144 mcd.surface = 0;
145 mcd.prompt_session = 0;
146 mcd.state = mir_prompt_session_state_stopped;
147 mcd.client_fd_count = 0;
148 start_session(server, "helper", &mcd);
149
150 // We create a prompt session
151 mcd.prompt_session = mir_connection_create_prompt_session_sync(mcd.connection, getpid(), prompt_session_event_callback, &mcd);
152 assert(mcd.prompt_session != NULL);
153
154 assert(mcd.state == mir_prompt_session_state_started);
155 puts("helper: Started prompt session");
156
157 mir_wait_for(mir_prompt_session_new_fds_for_prompt_providers(mcd.prompt_session, 1, client_fd_callback, &mcd));
158 assert(mcd.client_fd_count == 1);
159 puts("helper: Added waiting FD");
160
161 printf("helper: Starting child application 'mir_demo_client_basic' with fd://%d\n", mcd.client_fds[0]);
162 mcd.child_pid = fork();
163
164 if (mcd.child_pid == 0)
165 {
166 char buffer[128] = {0};
167 sprintf(buffer, "fd://%d", mcd.client_fds[0]);
168
169 char* args[4];
170 args[0] = "mir_demo_client_basic";
171 args[1] = "-m";
172 args[2] = &buffer[0];
173 args[3] = NULL;
174
175 errno = 0;
176 execvp("mir_demo_client_basic", args);
177 return;
178 }
179
180 int status;
181 printf("helper: Waiting on child application: %d\n", mcd.child_pid);
182 waitpid(mcd.child_pid, &status, 0);
183
184 if (mcd.state == mir_prompt_session_state_started)
185 {
186 mir_prompt_session_release_sync(mcd.prompt_session);
187 mcd.prompt_session = NULL;
188 puts("helper: Stopped prompt session");
189 }
190 else
191 {
192 puts("helper: Prompt session stopped by server");
193 }
194 puts("helper: Done");
195
196 stop_session(&mcd, "helper");
197}
198
199// The main() function deals with parsing arguments and defaults
200int main(int argc, char* argv[])
201{
202 // Some variables for holding command line options
203 char const *server = NULL;
204
205 // Parse the command line
206 {
207 int arg;
208 opterr = 0;
209 while ((arg = getopt (argc, argv, "c:hm:")) != -1)
210 {
211 switch (arg)
212 {
213 case 'm':
214 server = optarg;
215 break;
216
217 case '?':
218 case 'h':
219 default:
220 puts(argv[0]);
221 puts("Usage:");
222 puts(" -m <Mir server socket>");
223 puts(" -h: this help text");
224 return -1;
225 }
226 }
227 }
228
229 helper(server);
230 return 0;
231}
0232
=== modified file 'examples/render_surfaces.cpp'
--- examples/render_surfaces.cpp 2014-05-28 07:56:16 +0000
+++ examples/render_surfaces.cpp 2014-06-18 17:25:24 +0000
@@ -324,7 +324,7 @@
324 {324 {
325 }325 }
326326
327 bool composite()327 void composite()
328 {328 {
329 while (!created) std::this_thread::yield();329 while (!created) std::this_thread::yield();
330 stop_watch.stop();330 stop_watch.stop();
@@ -342,7 +342,6 @@
342 m.step();342 m.step();
343343
344 frames++;344 frames++;
345 return false;
346 }345 }
347346
348 private:347 private:
349348
=== modified file 'include/client/mir_toolkit/mir_connection.h'
--- include/client/mir_toolkit/mir_connection.h 2014-05-22 11:31:21 +0000
+++ include/client/mir_toolkit/mir_connection.h 2014-06-18 17:25:24 +0000
@@ -169,26 +169,6 @@
169 MirConnection* connection, MirPixelFormat* formats,169 MirConnection* connection, MirPixelFormat* formats,
170 unsigned const int format_size, unsigned int *num_valid_formats);170 unsigned const int format_size, unsigned int *num_valid_formats);
171171
172/**
173 * Allocate some FDs for trusted clients to connect on
174 *
175 * Trust session helpers need to allocate connection FDs it will pass to
176 * trusted clients to use when connecting to the server. The server can
177 * then associate them with the trust session.
178 *
179 * \warning This API is tentative until the implementation of trust sessions is complete
180 * \param [in] connection The connection
181 * \param [in] no_of_fds The number of fds to allocate
182 * \param [in] callback Callback invoked when request completes
183 * \param [in,out] context User data passed to the callback function
184 * \return A handle that can be passed to mir_wait_for
185 */
186MirWaitHandle* mir_connection_new_fds_for_trusted_clients(
187 MirConnection* connection,
188 unsigned int no_of_fds,
189 mir_client_fd_callback callback,
190 void * context);
191
192#ifdef __cplusplus172#ifdef __cplusplus
193}173}
194/**@}*/174/**@}*/
195175
=== added file 'include/client/mir_toolkit/mir_prompt_session.h'
--- include/client/mir_toolkit/mir_prompt_session.h 1970-01-01 00:00:00 +0000
+++ include/client/mir_toolkit/mir_prompt_session.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,87 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MIR_TOOLKIT_MIR_PROMPT_SESSION_H_
18#define MIR_TOOLKIT_MIR_PROMPT_SESSION_H_
19
20#include "mir_toolkit/mir_client_library.h"
21
22#include <sys/types.h>
23
24#ifdef __cplusplus
25/**
26 * \addtogroup mir_toolkit
27 * @{
28 */
29extern "C" {
30#endif
31
32/**
33 * Create and start a new prompt session
34 * \param [in] connection The connection
35 * \param [in] application_pid The process id of the initiating application
36 * \param [in] state_change_callback The function to be called when a prompt session state change occurs
37 * \param [in,out] context User data passed to the callback functions
38 * \return A handle that can be passed to mir_wait_for
39 */
40MirPromptSession *mir_connection_create_prompt_session_sync(
41 MirConnection* connection,
42 pid_t application_pid,
43 mir_prompt_session_state_change_callback state_change_callback,
44 void *context);
45
46/**
47 * Add a prompt provider process id to the prompt session
48 * \param [in] prompt_session The prompt session
49 * \param [in] provider_pid The process id of the prompt provider to add
50 * \return True if the process id was added, false otherwise
51 */
52MirBool mir_prompt_session_add_prompt_provider_sync(
53 MirPromptSession *prompt_session,
54 pid_t provider_pid);
55
56/**
57 * Allocate some FDs for prompt providers to connect on
58 *
59 * Prompt helpers need to allocate connection FDs it will pass to
60 * prompt providers to use when connecting to the server. The server can
61 * then associate them with the prompt session.
62 *
63 * \warning This API is tentative until the implementation of prompt sessions is complete
64 * \param [in] prompt_session The prompt session
65 * \param [in] no_of_fds The number of fds to allocate
66 * \param [in] callback Callback invoked when request completes
67 * \param [in,out] context User data passed to the callback function
68 * \return A handle that can be passed to mir_wait_for
69 */
70MirWaitHandle* mir_prompt_session_new_fds_for_prompt_providers(
71 MirPromptSession *prompt_session,
72 unsigned int no_of_fds,
73 mir_client_fd_callback callback,
74 void * context);
75
76/**
77 * Stop and release the specified prompt session
78 * \param [in] prompt_session The prompt session
79 */
80void mir_prompt_session_release_sync(MirPromptSession *prompt_session);
81
82#ifdef __cplusplus
83}
84/**@}*/
85#endif
86
87#endif /* MIR_TOOLKIT_MIR_PROMPT_SESSION_H_ */
088
=== modified file 'include/platform/mir/graphics/buffer.h'
--- include/platform/mir/graphics/buffer.h 2014-03-06 06:05:17 +0000
+++ include/platform/mir/graphics/buffer.h 2014-06-18 17:25:24 +0000
@@ -41,7 +41,8 @@
41 virtual geometry::Size size() const = 0;41 virtual geometry::Size size() const = 0;
42 virtual geometry::Stride stride() const = 0;42 virtual geometry::Stride stride() const = 0;
43 virtual MirPixelFormat pixel_format() const = 0;43 virtual MirPixelFormat pixel_format() const = 0;
44 virtual void bind_to_texture() = 0;44 virtual void gl_bind_to_texture() = 0;
45 /* TODO: remove this function, as it is specific to the mesa platform */
45 virtual bool can_bypass() const = 0;46 virtual bool can_bypass() const = 0;
4647
47protected:48protected:
4849
=== modified file 'include/platform/mir/graphics/buffer_id.h'
--- include/platform/mir/graphics/buffer_id.h 2014-05-22 09:56:17 +0000
+++ include/platform/mir/graphics/buffer_id.h 2014-06-18 17:25:24 +0000
@@ -27,7 +27,7 @@
27class BufferID27class BufferID
28{28{
29public:29public:
30 BufferID() : value(id_invalid){}30 BufferID() noexcept: value(id_invalid){}
31 explicit BufferID(uint32_t val) : value(val) {}31 explicit BufferID(uint32_t val) : value(val) {}
32 bool is_valid() const { return (id_invalid != value); }32 bool is_valid() const { return (id_invalid != value); }
33 uint32_t as_uint32_t() const { return value; };33 uint32_t as_uint32_t() const { return value; };
3434
=== modified file 'include/platform/mir/graphics/display_buffer.h'
--- include/platform/mir/graphics/display_buffer.h 2014-05-22 09:56:17 +0000
+++ include/platform/mir/graphics/display_buffer.h 2014-06-18 17:25:24 +0000
@@ -67,10 +67,6 @@
67 **/67 **/
68 virtual bool post_renderables_if_optimizable(RenderableList const& renderlist) = 0;68 virtual bool post_renderables_if_optimizable(RenderableList const& renderlist) = 0;
6969
70 /** to be deprecated */
71 virtual bool can_bypass() const = 0;
72 virtual void post_update(std::shared_ptr<Buffer> /* bypass_buf */) {}
73
74 /** Returns the orientation of the display buffer relative to how the70 /** Returns the orientation of the display buffer relative to how the
75 * user should see it (the orientation of the output).71 * user should see it (the orientation of the output).
76 * This tells us how much (if any) rotation the renderer needs to do.72 * This tells us how much (if any) rotation the renderer needs to do.
@@ -81,6 +77,12 @@
81 */77 */
82 virtual MirOrientation orientation() const = 0;78 virtual MirOrientation orientation() const = 0;
8379
80 /** Returns true if the display buffer has an alpha channel and the alpha
81 * channel will be read from at some point - in which case the renderer
82 * must produce valid alpha channel content
83 */
84 virtual bool uses_alpha() const = 0;
85
84protected:86protected:
85 DisplayBuffer() = default;87 DisplayBuffer() = default;
86 DisplayBuffer(DisplayBuffer const& c) = delete;88 DisplayBuffer(DisplayBuffer const& c) = delete;
8789
=== modified file 'include/platform/mir/graphics/platform.h'
--- include/platform/mir/graphics/platform.h 2014-05-07 02:56:33 +0000
+++ include/platform/mir/graphics/platform.h 2014-06-18 17:25:24 +0000
@@ -27,6 +27,8 @@
2727
28namespace mir28namespace mir
29{29{
30class EmergencyCleanupRegistry;
31
30namespace frontend32namespace frontend
31{33{
32class Surface;34class Surface;
@@ -116,14 +118,21 @@
116 * Function prototype used to return a new graphics platform.118 * Function prototype used to return a new graphics platform.
117 *119 *
118 * \param [in] options options to use for this platform120 * \param [in] options options to use for this platform
121 * \param [in] emergency_cleanup_registry object to register emergency shutdown handlers with
119 * \param [in] report the object to use to report interesting events from the display subsystem122 * \param [in] report the object to use to report interesting events from the display subsystem
120 *123 *
121 * This factory function needs to be implemented by each platform.124 * This factory function needs to be implemented by each platform.
122 *125 *
123 * \ingroup platform_enablement126 * \ingroup platform_enablement
124 */127 */
125extern "C" typedef std::shared_ptr<Platform>(*CreatePlatform)(std::shared_ptr<options::Option> const& options, std::shared_ptr<DisplayReport> const& report);128extern "C" typedef std::shared_ptr<Platform>(*CreatePlatform)(
126extern "C" std::shared_ptr<Platform> create_platform (std::shared_ptr<options::Option> const& options, std::shared_ptr<DisplayReport> const& report);129 std::shared_ptr<options::Option> const& options,
130 std::shared_ptr<EmergencyCleanupRegistry> const& emergency_cleanup_registry,
131 std::shared_ptr<DisplayReport> const& report);
132extern "C" std::shared_ptr<Platform> create_platform(
133 std::shared_ptr<options::Option> const& options,
134 std::shared_ptr<EmergencyCleanupRegistry> const& emergency_cleanup_registry,
135 std::shared_ptr<DisplayReport> const& report);
127extern "C" typedef void(*AddPlatformOptions)(136extern "C" typedef void(*AddPlatformOptions)(
128 boost::program_options::options_description& config);137 boost::program_options::options_description& config);
129extern "C" void add_platform_options(138extern "C" void add_platform_options(
130139
=== modified file 'include/server/mir/asio_main_loop.h'
--- include/server/mir/asio_main_loop.h 2014-05-28 07:43:51 +0000
+++ include/server/mir/asio_main_loop.h 2014-06-18 17:25:24 +0000
@@ -58,6 +58,8 @@
58 std::function<void()> callback) override;58 std::function<void()> callback) override;
59 std::unique_ptr<time::Alarm> notify_at(mir::time::Timestamp time_point,59 std::unique_ptr<time::Alarm> notify_at(mir::time::Timestamp time_point,
60 std::function<void()> callback) override;60 std::function<void()> callback) override;
61 std::unique_ptr<time::Alarm> create_alarm(std::function<void()> callback) override;
62
61 void enqueue(void const* owner, ServerAction const& action);63 void enqueue(void const* owner, ServerAction const& action);
62 void pause_processing_for(void const* owner);64 void pause_processing_for(void const* owner);
63 void resume_processing_for(void const* owner);65 void resume_processing_for(void const* owner);
6466
=== modified file 'include/server/mir/compositor/buffer_stream.h'
--- include/server/mir/compositor/buffer_stream.h 2014-03-26 05:48:59 +0000
+++ include/server/mir/compositor/buffer_stream.h 2014-06-18 17:25:24 +0000
@@ -41,7 +41,9 @@
41public:41public:
42 virtual ~BufferStream() = default;42 virtual ~BufferStream() = default;
4343
44 virtual void swap_client_buffers(graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) = 0;44 virtual void acquire_client_buffer(
45 std::function<void(graphics::Buffer* buffer)> complete) = 0;
46 virtual void release_client_buffer(graphics::Buffer* buf) = 0;
45 virtual std::shared_ptr<graphics::Buffer>47 virtual std::shared_ptr<graphics::Buffer>
46 lock_compositor_buffer(void const* user_id) = 0;48 lock_compositor_buffer(void const* user_id) = 0;
47 virtual std::shared_ptr<graphics::Buffer> lock_snapshot_buffer() = 0;49 virtual std::shared_ptr<graphics::Buffer> lock_snapshot_buffer() = 0;
4850
=== added file 'include/server/mir/compositor/destination_alpha.h'
--- include/server/mir/compositor/destination_alpha.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/compositor/destination_alpha.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,36 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alberto Aguirre <alberto.aguirre@canonical.com>
17 */
18
19#ifndef MIR_COMPOSITOR_DESTINATION_ALPHA_H_
20#define MIR_COMPOSITOR_DESTINATION_ALPHA_H_
21
22namespace mir
23{
24namespace compositor
25{
26
27enum class DestinationAlpha
28{
29 generate_from_source,
30 opaque
31};
32
33}
34}
35
36#endif
037
=== modified file 'include/server/mir/compositor/display_buffer_compositor.h'
--- include/server/mir/compositor/display_buffer_compositor.h 2014-03-05 07:31:06 +0000
+++ include/server/mir/compositor/display_buffer_compositor.h 2014-06-18 17:25:24 +0000
@@ -30,9 +30,7 @@
30public:30public:
31 virtual ~DisplayBufferCompositor() = default;31 virtual ~DisplayBufferCompositor() = default;
3232
33 /// Returns true if there is additional work to do. E.g. a composited surface33 virtual void composite() = 0;
34 /// has additional buffers ready to composite or during animation
35 virtual bool composite() = 0;
3634
37protected:35protected:
38 DisplayBufferCompositor() = default;36 DisplayBufferCompositor() = default;
3937
=== added file 'include/server/mir/compositor/frame_dropping_policy.h'
--- include/server/mir/compositor/frame_dropping_policy.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/compositor/frame_dropping_policy.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,69 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_
20#define MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_
21
22#include <functional>
23
24namespace mir
25{
26namespace compositor
27{
28/**
29 * \brief Policy to determine when to drop a frame from a client
30 *
31 * The FrameDroppingPolicy objects are constructed from a
32 * \ref FrameDroppingPolicyFactory
33 *
34 * The frame dropping mechanism is provided as the
35 * \a drop_frames argument of \ref FrameDroppingPolicyFactory::create_policy
36 *
37 * The policy may decide to drop a frame any time that there is an outstanding
38 * swap - namely, when there have been more calls to \ref swap_now_blocking
39 * than to \ref swap_unblocked
40 */
41class FrameDroppingPolicy
42{
43public:
44 virtual ~FrameDroppingPolicy() = default;
45
46 FrameDroppingPolicy(FrameDroppingPolicy const&) = delete;
47 FrameDroppingPolicy& operator=(FrameDroppingPolicy const&) = delete;
48
49 /**
50 * \brief Notify that a swap is now blocking
51 */
52 virtual void swap_now_blocking() = 0;
53 /**
54 * \brief Notify that previous swap is no longer blocking
55 */
56 virtual void swap_unblocked() = 0;
57
58protected:
59 /**
60 * \note FrameDroppingPolicies should not be constructed directly;
61 * use a \ref FrameDroppingPolicyFactory
62 */
63 FrameDroppingPolicy() = default;
64};
65
66}
67}
68
69#endif // MIR_COMPOSITOR_FRAME_DROPPING_POLICY_H_
070
=== added file 'include/server/mir/compositor/frame_dropping_policy_factory.h'
--- include/server/mir/compositor/frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/compositor/frame_dropping_policy_factory.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,57 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_
20#define MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_
21
22#include <memory>
23
24namespace mir
25{
26namespace compositor
27{
28class FrameDroppingPolicy;
29
30/**
31 * \brief Creator of FrameDroppingPolicies
32 *
33 * The FrameDroppingPolicyFactory is how you go from a means of dropping frames -
34 * the \a drop_frames parameter of \ref create_policy -
35 * to a \ref FrameDroppingPolicy
36 */
37class FrameDroppingPolicyFactory
38{
39public:
40 FrameDroppingPolicyFactory() = default;
41 virtual ~FrameDroppingPolicyFactory() = default;
42
43 FrameDroppingPolicyFactory(FrameDroppingPolicyFactory const&) = delete;
44 FrameDroppingPolicyFactory& operator=(FrameDroppingPolicyFactory const&) = delete;
45
46 /**
47 * \brief Create a FrameDroppingPolicy that will call \a drop_frame when it decides to drop a frame
48 * \param drop_frame Function to call when a frame needs to be dropped
49 * \return The policy object.
50 */
51 virtual std::unique_ptr<FrameDroppingPolicy> create_policy(std::function<void(void)> drop_frame) const = 0;
52};
53
54}
55}
56
57#endif // MIR_COMPOSITOR_FRAME_DROPPING_POLICY_FACTORY_H_
058
=== modified file 'include/server/mir/compositor/gl_renderer.h'
--- include/server/mir/compositor/gl_renderer.h 2014-05-28 07:43:51 +0000
+++ include/server/mir/compositor/gl_renderer.h 2014-06-18 17:25:24 +0000
@@ -37,13 +37,16 @@
37namespace compositor37namespace compositor
38{38{
3939
40enum class DestinationAlpha;
41
40class GLRenderer : public Renderer42class GLRenderer : public Renderer
41{43{
42public:44public:
43 GLRenderer(45 GLRenderer(
44 graphics::GLProgramFactory const& program_factory,46 graphics::GLProgramFactory const& program_factory,
45 std::unique_ptr<graphics::GLTextureCache> && texture_cache, 47 std::unique_ptr<graphics::GLTextureCache> && texture_cache,
46 geometry::Rectangle const& display_area);48 geometry::Rectangle const& display_area,
49 DestinationAlpha dest_alpha);
4750
48 // These are called with a valid GL context:51 // These are called with a valid GL context:
49 void set_viewport(geometry::Rectangle const& rect) override;52 void set_viewport(geometry::Rectangle const& rect) override;
@@ -75,6 +78,9 @@
75 graphics::Renderable const& renderable) const;78 graphics::Renderable const& renderable) const;
7679
77 virtual void render(graphics::Renderable const& renderable) const;80 virtual void render(graphics::Renderable const& renderable) const;
81
82 DestinationAlpha destination_alpha() const;
83
78private:84private:
79 std::unique_ptr<graphics::GLProgram> program;85 std::unique_ptr<graphics::GLProgram> program;
80 std::unique_ptr<graphics::GLTextureCache> mutable texture_cache;86 std::unique_ptr<graphics::GLTextureCache> mutable texture_cache;
@@ -85,7 +91,7 @@
85 GLuint transform_uniform_loc;91 GLuint transform_uniform_loc;
86 GLuint alpha_uniform_loc;92 GLuint alpha_uniform_loc;
87 float rotation;93 float rotation;
8894 DestinationAlpha const dest_alpha;
89 geometry::Rectangle viewport;95 geometry::Rectangle viewport;
90};96};
9197
9298
=== modified file 'include/server/mir/compositor/renderer_factory.h'
--- include/server/mir/compositor/renderer_factory.h 2014-03-06 06:05:17 +0000
+++ include/server/mir/compositor/renderer_factory.h 2014-06-18 17:25:24 +0000
@@ -31,13 +31,15 @@
31{31{
3232
33class Renderer;33class Renderer;
34enum class DestinationAlpha;
3435
35class RendererFactory36class RendererFactory
36{37{
37public:38public:
38 virtual ~RendererFactory() = default;39 virtual ~RendererFactory() = default;
3940
40 virtual std::unique_ptr<Renderer> create_renderer_for(geometry::Rectangle const& rect) = 0;41 virtual std::unique_ptr<Renderer> create_renderer_for(geometry::Rectangle const& rect,
42 DestinationAlpha dest_alpha) = 0;
4143
42protected:44protected:
43 RendererFactory() = default;45 RendererFactory() = default;
4446
=== modified file 'include/server/mir/default_server_configuration.h'
--- include/server/mir/default_server_configuration.h 2014-05-28 07:56:16 +0000
+++ include/server/mir/default_server_configuration.h 2014-06-18 17:25:24 +0000
@@ -46,6 +46,7 @@
46class Compositor;46class Compositor;
47class RendererFactory;47class RendererFactory;
48class CompositorReport;48class CompositorReport;
49class FrameDroppingPolicyFactory;
49}50}
50namespace frontend51namespace frontend
51{52{
@@ -92,6 +93,8 @@
92class SurfaceStackModel;93class SurfaceStackModel;
93class SurfaceStack;94class SurfaceStack;
94class SceneReport;95class SceneReport;
96class PromptSessionListener;
97class PromptSessionManager;
95}98}
96namespace graphics99namespace graphics
97{100{
@@ -196,6 +199,7 @@
196 * @{ */199 * @{ */
197 virtual std::shared_ptr<graphics::GraphicBufferAllocator> the_buffer_allocator();200 virtual std::shared_ptr<graphics::GraphicBufferAllocator> the_buffer_allocator();
198 virtual std::shared_ptr<compositor::Scene> the_scene();201 virtual std::shared_ptr<compositor::Scene> the_scene();
202 virtual std::shared_ptr<compositor::FrameDroppingPolicyFactory> the_frame_dropping_policy_factory();
199 /** @} */203 /** @} */
200204
201 /** @name frontend configuration - dependencies205 /** @name frontend configuration - dependencies
@@ -229,6 +233,8 @@
229 virtual std::shared_ptr<scene::PlacementStrategy> the_placement_strategy();233 virtual std::shared_ptr<scene::PlacementStrategy> the_placement_strategy();
230 virtual std::shared_ptr<scene::SessionListener> the_session_listener();234 virtual std::shared_ptr<scene::SessionListener> the_session_listener();
231 virtual std::shared_ptr<shell::DisplayLayout> the_shell_display_layout();235 virtual std::shared_ptr<shell::DisplayLayout> the_shell_display_layout();
236 virtual std::shared_ptr<scene::PromptSessionListener> the_prompt_session_listener();
237 virtual std::shared_ptr<scene::PromptSessionManager> the_prompt_session_manager();
232 /** @} */238 /** @} */
233239
234 /** @name internal scene configuration240 /** @name internal scene configuration
@@ -336,6 +342,7 @@
336 CachedPtr<frontend::Screencast> screencast;342 CachedPtr<frontend::Screencast> screencast;
337 CachedPtr<compositor::RendererFactory> renderer_factory;343 CachedPtr<compositor::RendererFactory> renderer_factory;
338 CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory;344 CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory;
345 CachedPtr<compositor::FrameDroppingPolicyFactory> frame_dropping_policy_factory;
339 CachedPtr<scene::SurfaceStack> surface_stack;346 CachedPtr<scene::SurfaceStack> surface_stack;
340 CachedPtr<scene::SceneReport> scene_report;347 CachedPtr<scene::SceneReport> scene_report;
341348
@@ -362,6 +369,8 @@
362 CachedPtr<scene::MediatingDisplayChanger> mediating_display_changer;369 CachedPtr<scene::MediatingDisplayChanger> mediating_display_changer;
363 CachedPtr<graphics::GLProgramFactory> gl_program_factory;370 CachedPtr<graphics::GLProgramFactory> gl_program_factory;
364 CachedPtr<graphics::GLConfig> gl_config;371 CachedPtr<graphics::GLConfig> gl_config;
372 CachedPtr<scene::PromptSessionListener> prompt_session_listener;
373 CachedPtr<scene::PromptSessionManager> prompt_session_manager;
365 CachedPtr<scene::SessionCoordinator> session_coordinator;374 CachedPtr<scene::SessionCoordinator> session_coordinator;
366 CachedPtr<EmergencyCleanup> emergency_cleanup;375 CachedPtr<EmergencyCleanup> emergency_cleanup;
367376
368377
=== added file 'include/server/mir/frontend/prompt_session.h'
--- include/server/mir/frontend/prompt_session.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/frontend/prompt_session.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,48 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_FRONTEND_PROMPT_SESSION_H_
20#define MIR_FRONTEND_PROMPT_SESSION_H_
21
22#include "mir_toolkit/common.h"
23
24#include <sys/types.h>
25#include <vector>
26#include <string>
27#include <memory>
28
29namespace mir
30{
31
32namespace frontend
33{
34class PromptSession
35{
36public:
37 virtual ~PromptSession() = default;
38
39protected:
40 PromptSession() = default;
41 PromptSession(const PromptSession&) = delete;
42 PromptSession& operator=(const PromptSession&) = delete;
43};
44
45}
46}
47
48#endif // MIR_FRONTEND_PROMPT_SESSION_H_
049
=== modified file 'include/server/mir/frontend/session_mediator_report.h'
--- include/server/mir/frontend/session_mediator_report.h 2014-03-06 06:05:17 +0000
+++ include/server/mir/frontend/session_mediator_report.h 2014-06-18 17:25:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,5 * under the terms of the GNU General Public License version 3,
@@ -22,6 +22,8 @@
2222
23#include <string>23#include <string>
2424
25#include <sys/types.h>
26
25namespace mir27namespace mir
26{28{
27namespace frontend29namespace frontend
@@ -46,8 +48,16 @@
4648
47 virtual void session_configure_surface_called(std::string const& app_name) = 0;49 virtual void session_configure_surface_called(std::string const& app_name) = 0;
4850
51 virtual void session_configure_surface_cursor_called(std::string const& app_name) = 0;
52
49 virtual void session_configure_display_called(std::string const& app_name) = 0;53 virtual void session_configure_display_called(std::string const& app_name) = 0;
5054
55 virtual void session_start_prompt_session_called(std::string const& app_name, pid_t application_process) = 0;
56
57 virtual void session_add_prompt_provider_called(std::string const& app_name, pid_t provider_process) = 0;
58
59 virtual void session_stop_prompt_session_called(std::string const& app_name) = 0;
60
51 virtual void session_error(61 virtual void session_error(
52 std::string const& app_name,62 std::string const& app_name,
53 char const* method,63 char const* method,
5464
=== modified file 'include/server/mir/frontend/shell.h'
--- include/server/mir/frontend/shell.h 2014-04-15 05:31:19 +0000
+++ include/server/mir/frontend/shell.h 2014-06-18 17:25:24 +0000
@@ -30,11 +30,13 @@
30namespace scene30namespace scene
31{31{
32struct SurfaceCreationParameters;32struct SurfaceCreationParameters;
33struct PromptSessionCreationParameters;
33}34}
34namespace frontend35namespace frontend
35{36{
36class EventSink;37class EventSink;
37class Session;38class Session;
39class PromptSession;
3840
39class Shell41class Shell
40{42{
@@ -54,6 +56,14 @@
5456
55 virtual void handle_surface_created(std::shared_ptr<Session> const& session) = 0;57 virtual void handle_surface_created(std::shared_ptr<Session> const& session) = 0;
5658
59 virtual std::shared_ptr<PromptSession> start_prompt_session_for(std::shared_ptr<Session> const& session,
60 scene::PromptSessionCreationParameters const& params) = 0;
61 virtual void add_prompt_provider_process_for(std::shared_ptr<PromptSession> const& prompt_session,
62 pid_t process_id) = 0;
63 virtual void add_prompt_provider_for(std::shared_ptr<PromptSession> const& prompt_session,
64 std::shared_ptr<Session> const& session) = 0;
65 virtual void stop_prompt_session(std::shared_ptr<PromptSession> const& prompt_session) = 0;
66
57protected:67protected:
58 Shell() = default;68 Shell() = default;
59 Shell(const Shell&) = delete;69 Shell(const Shell&) = delete;
6070
=== modified file 'include/server/mir/frontend/surface.h'
--- include/server/mir/frontend/surface.h 2014-05-22 11:31:21 +0000
+++ include/server/mir/frontend/surface.h 2014-06-18 17:25:24 +0000
@@ -20,12 +20,9 @@
20#ifndef MIR_FRONTEND_SURFACE_H_20#ifndef MIR_FRONTEND_SURFACE_H_
21#define MIR_FRONTEND_SURFACE_H_21#define MIR_FRONTEND_SURFACE_H_
2222
23#include "mir/geometry/point.h"
24#include "mir/geometry/size.h"23#include "mir/geometry/size.h"
25#include "mir_toolkit/common.h"24#include "mir_toolkit/common.h"
2625
27#include <glm/glm.hpp>
28
29#include <memory>26#include <memory>
3027
31namespace mir28namespace mir
@@ -34,22 +31,17 @@
34{31{
35class Buffer;32class Buffer;
36class InternalSurface;33class InternalSurface;
37}34class CursorImage;
38namespace input
39{
40class InputChannel;
41}35}
4236
43namespace frontend37namespace frontend
44{38{
45
46class ClientBufferTracker;39class ClientBufferTracker;
4740
48class Surface41class Surface
49{42{
50public:43public:
5144 virtual ~Surface() = default;
52 virtual ~Surface() {}
5345
54 /// Size of the client area of the surface (excluding any decorations)46 /// Size of the client area of the surface (excluding any decorations)
55 virtual geometry::Size client_size() const = 0;47 virtual geometry::Size client_size() const = 0;
@@ -62,6 +54,8 @@
6254
63 virtual int configure(MirSurfaceAttrib attrib, int value) = 0;55 virtual int configure(MirSurfaceAttrib attrib, int value) = 0;
6456
57 virtual void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& image) = 0;
58
65 /**59 /**
66 * swap_buffers_blocking() is a convenience wrapper around swap_buffers()60 * swap_buffers_blocking() is a convenience wrapper around swap_buffers()
67 * it forces the current thread to block until complete() is called.61 * it forces the current thread to block until complete() is called.
6862
=== modified file 'include/server/mir/graphics/cursor_images.h'
--- include/server/mir/graphics/cursor_images.h 2014-04-28 23:15:05 +0000
+++ include/server/mir/graphics/cursor_images.h 2014-06-18 17:25:24 +0000
@@ -31,6 +31,8 @@
31{31{
32class CursorImage;32class CursorImage;
3333
34geometry::Size const default_cursor_size{geometry::Width{64}, geometry::Height{64}};
35
34/// CursorImages is used to lookup cursor images.36/// CursorImages is used to lookup cursor images.
35class CursorImages37class CursorImages
36{38{
3739
=== added file 'include/server/mir/scene/null_prompt_session_listener.h'
--- include/server/mir/scene/null_prompt_session_listener.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/scene/null_prompt_session_listener.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,40 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_SCENE_NULL_PROMPT_SESSION_LISTENER_H_
20#define MIR_SCENE_NULL_PROMPT_SESSION_LISTENER_H_
21
22#include "mir/scene/prompt_session_listener.h"
23
24namespace mir
25{
26namespace scene
27{
28class NullPromptSessionListener : public PromptSessionListener
29{
30public:
31 void starting(std::shared_ptr<PromptSession> const&) override {}
32 void stopping(std::shared_ptr<PromptSession> const&) override {}
33
34 void prompt_provider_added(PromptSession const&, std::shared_ptr<Session> const&) override {}
35 void prompt_provider_removed(PromptSession const&, std::shared_ptr<Session> const&) override {}
36};
37}
38}
39
40#endif // MIR_SHELL_NULL_PROMPT_SESSION_LISTENER_H_
041
=== modified file 'include/server/mir/scene/null_surface_observer.h'
--- include/server/mir/scene/null_surface_observer.h 2014-05-22 22:44:19 +0000
+++ include/server/mir/scene/null_surface_observer.h 2014-06-18 17:25:24 +0000
@@ -38,6 +38,7 @@
38 void frame_posted(int frames_available);38 void frame_posted(int frames_available);
39 void alpha_set_to(float alpha);39 void alpha_set_to(float alpha);
40 void transformation_set_to(glm::mat4 const& t);40 void transformation_set_to(glm::mat4 const& t);
41 void cursor_image_set_to(graphics::CursorImage const& image);
41 void reception_mode_set_to(input::InputReceptionMode mode);42 void reception_mode_set_to(input::InputReceptionMode mode);
4243
43protected:44protected:
4445
=== added file 'include/server/mir/scene/prompt_session.h'
--- include/server/mir/scene/prompt_session.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/scene/prompt_session.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_SCENE_PROMPT_SESSION_H_
20#define MIR_SCENE_PROMPT_SESSION_H_
21
22#include "mir/frontend/prompt_session.h"
23
24namespace mir
25{
26namespace scene
27{
28class Session;
29
30class PromptSession : public frontend::PromptSession
31{
32};
33
34}
35}
36
37#endif // MIR_SHELL_PROMPT_SESSION_H_
038
=== added file 'include/server/mir/scene/prompt_session_creation_parameters.h'
--- include/server/mir/scene/prompt_session_creation_parameters.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/scene/prompt_session_creation_parameters.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,36 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_SCENE_PROMPT_SESSION_CREATION_PARAMETERS_H_
20#define MIR_SCENE_PROMPT_SESSION_CREATION_PARAMETERS_H_
21
22#include <sys/types.h>
23
24namespace mir
25{
26namespace scene
27{
28
29struct PromptSessionCreationParameters
30{
31 pid_t application_pid = 0;
32};
33}
34}
35
36#endif /* MIR_SCENE_PROMPT_SESSION_CREATION_PARAMETERS_H_ */
037
=== added file 'include/server/mir/scene/prompt_session_listener.h'
--- include/server/mir/scene/prompt_session_listener.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/scene/prompt_session_listener.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,52 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_SCENE_PROMPT_SESSION_LISTENER_H_
20#define MIR_SCENE_PROMPT_SESSION_LISTENER_H_
21
22#include <memory>
23
24namespace mir
25{
26namespace scene
27{
28class Session;
29class PromptSession;
30
31class PromptSessionListener
32{
33public:
34 virtual void starting(std::shared_ptr<PromptSession> const& prompt_session) = 0;
35 virtual void stopping(std::shared_ptr<PromptSession> const& prompt_session) = 0;
36
37 virtual void prompt_provider_added(PromptSession const& prompt_session, std::shared_ptr<Session> const& prompt_provider) = 0;
38 virtual void prompt_provider_removed(PromptSession const& prompt_session, std::shared_ptr<Session> const& prompt_provider) = 0;
39
40protected:
41 PromptSessionListener() = default;
42 virtual ~PromptSessionListener() = default;
43
44 PromptSessionListener(const PromptSessionListener&) = delete;
45 PromptSessionListener& operator=(const PromptSessionListener&) = delete;
46};
47
48}
49}
50
51
52#endif // MIR_SCENE_PROMPT_SESSION_LISTENER_H_
053
=== added file 'include/server/mir/scene/prompt_session_manager.h'
--- include/server/mir/scene/prompt_session_manager.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/scene/prompt_session_manager.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,110 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_SCENE_PROMPT_SESSION_MANAGER_H_
20#define MIR_SCENE_PROMPT_SESSION_MANAGER_H_
21
22#include <sys/types.h>
23#include <memory>
24#include <functional>
25
26namespace mir
27{
28namespace scene
29{
30class Session;
31class PromptSession;
32struct PromptSessionCreationParameters;
33
34class PromptSessionManager
35{
36public:
37 virtual ~PromptSessionManager() = default;
38
39 /**
40 * Start a new prompt session
41 * \param [in] session The prompt helper session
42 * \param [in] params The creation parameters for constructing the prompt session
43 */
44 virtual std::shared_ptr<PromptSession> start_prompt_session_for(std::shared_ptr<Session> const& session,
45 PromptSessionCreationParameters const& params) const = 0;
46
47 /**
48 * Stop a started prompt session
49 * \param [in] prompt_session The prompt session
50 */
51 virtual void stop_prompt_session(std::shared_ptr<PromptSession> const& prompt_session) const = 0;
52
53 /**
54 * Add a prompt provider to an existing prompt session
55 * \param [in] prompt_session The prompt session
56 * \param [in] prompt_provider The prompt provider to add to the prompt session
57 */
58 virtual void add_prompt_provider(std::shared_ptr<PromptSession> const& prompt_session,
59 std::shared_ptr<Session> const& prompt_provider) const = 0;
60
61 /**
62 * Add a process id to wait for to the prompt session
63 * \param [in] prompt_session The prompt session
64 * \param [in] process_id The process id to wait for
65 */
66 virtual void add_prompt_provider_by_pid(std::shared_ptr<PromptSession> const& prompt_session,
67 pid_t process_id) const = 0;
68
69 /**
70 * Add a session that may have been expected by a prompt session.
71 * \param [in] session The new session that was being expected
72 */
73 virtual void add_expected_session(std::shared_ptr<Session> const& new_session) const = 0;
74
75 /**
76 * Remove a session from all associated prompt sessions
77 * \param [in] session The new session that is to be removed
78 */
79 virtual void remove_session(std::shared_ptr<Session> const& session) const = 0;
80
81 /**
82 * Retrieve the application session for a prompt session
83 * \param [in] prompt_session The prompt session
84 */
85 virtual std::shared_ptr<Session> application_for(std::shared_ptr<PromptSession> const& prompt_session) const = 0;
86
87 /**
88 * Retrieve the helper session for a prompt session
89 * \param [in] prompt_session The prompt session
90 */
91 virtual std::shared_ptr<Session> helper_for(std::shared_ptr<PromptSession> const& prompt_session) const = 0;
92
93 /**
94 * Iterate over all the prompt providers associated with a prompt session
95 * \param [in] prompt_session The prompt session
96 * \param [in] f The callback function to call for each provider
97 */
98 virtual void for_each_provider_in(std::shared_ptr<PromptSession> const& prompt_session,
99 std::function<void(std::shared_ptr<Session> const& prompt_provider)> const& f) const = 0;
100
101protected:
102 PromptSessionManager() = default;
103 PromptSessionManager(const PromptSessionManager&) = delete;
104 PromptSessionManager& operator=(const PromptSessionManager&) = delete;
105};
106
107}
108}
109
110#endif // MIR_SCENE_PROMPT_SESSION_MANAGER_H_
0111
=== modified file 'include/server/mir/scene/session.h'
--- include/server/mir/scene/session.h 2014-04-15 05:31:19 +0000
+++ include/server/mir/scene/session.h 2014-06-18 17:25:24 +0000
@@ -40,6 +40,9 @@
40 virtual std::shared_ptr<Surface> default_surface() const = 0;40 virtual std::shared_ptr<Surface> default_surface() const = 0;
41 virtual void set_lifecycle_state(MirLifecycleState state) = 0;41 virtual void set_lifecycle_state(MirLifecycleState state) = 0;
42 virtual void send_display_config(graphics::DisplayConfiguration const&) = 0;42 virtual void send_display_config(graphics::DisplayConfiguration const&) = 0;
43
44 virtual void start_prompt_session() = 0;
45 virtual void stop_prompt_session() = 0;
43};46};
44}47}
45}48}
4649
=== modified file 'include/server/mir/scene/surface.h'
--- include/server/mir/scene/surface.h 2014-05-22 11:31:21 +0000
+++ include/server/mir/scene/surface.h 2014-06-18 17:25:24 +0000
@@ -31,6 +31,7 @@
31namespace input { class InputChannel; }31namespace input { class InputChannel; }
32namespace shell { class InputTargeter; }32namespace shell { class InputTargeter; }
33namespace geometry { class Rectangle; }33namespace geometry { class Rectangle; }
34namespace graphics { class CursorImage; }
3435
35namespace scene36namespace scene
36{37{
@@ -70,6 +71,9 @@
70 virtual void set_transformation(glm::mat4 const& t) = 0;71 virtual void set_transformation(glm::mat4 const& t) = 0;
71 virtual void set_alpha(float alpha) = 0;72 virtual void set_alpha(float alpha) = 0;
72 virtual void force_requests_to_complete() = 0;73 virtual void force_requests_to_complete() = 0;
74
75 virtual void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& image) = 0;
76 virtual std::shared_ptr<graphics::CursorImage> cursor_image() = 0;
7377
74 virtual void add_observer(std::shared_ptr<SurfaceObserver> const& observer) = 0;78 virtual void add_observer(std::shared_ptr<SurfaceObserver> const& observer) = 0;
75 virtual void remove_observer(std::weak_ptr<SurfaceObserver> const& observer) = 0;79 virtual void remove_observer(std::weak_ptr<SurfaceObserver> const& observer) = 0;
7680
=== modified file 'include/server/mir/scene/surface_observer.h'
--- include/server/mir/scene/surface_observer.h 2014-05-22 22:44:19 +0000
+++ include/server/mir/scene/surface_observer.h 2014-06-18 17:25:24 +0000
@@ -32,6 +32,10 @@
32struct Size;32struct Size;
33struct Point;33struct Point;
34}34}
35namespace graphics
36{
37class CursorImage;
38}
3539
36namespace scene40namespace scene
37{41{
@@ -46,6 +50,7 @@
46 virtual void alpha_set_to(float alpha) = 0;50 virtual void alpha_set_to(float alpha) = 0;
47 virtual void transformation_set_to(glm::mat4 const& t) = 0;51 virtual void transformation_set_to(glm::mat4 const& t) = 0;
48 virtual void reception_mode_set_to(input::InputReceptionMode mode) = 0;52 virtual void reception_mode_set_to(input::InputReceptionMode mode) = 0;
53 virtual void cursor_image_set_to(graphics::CursorImage const& image) = 0;
4954
50protected:55protected:
51 SurfaceObserver() = default;56 SurfaceObserver() = default;
5257
=== modified file 'include/server/mir/shell/session_coordinator_wrapper.h'
--- include/server/mir/shell/session_coordinator_wrapper.h 2014-05-23 12:59:00 +0000
+++ include/server/mir/shell/session_coordinator_wrapper.h 2014-06-18 17:25:24 +0000
@@ -48,6 +48,20 @@
4848
49 void handle_surface_created(std::shared_ptr<frontend::Session> const& session) override;49 void handle_surface_created(std::shared_ptr<frontend::Session> const& session) override;
5050
51 std::shared_ptr<frontend::PromptSession> start_prompt_session_for(
52 std::shared_ptr<frontend::Session> const& session,
53 scene::PromptSessionCreationParameters const& params) override;
54
55 void add_prompt_provider_process_for(
56 std::shared_ptr<frontend::PromptSession> const& prompt_session,
57 pid_t process_id) override;
58
59 void add_prompt_provider_for(
60 std::shared_ptr<frontend::PromptSession> const& prompt_session,
61 std::shared_ptr<frontend::Session> const& session) override;
62
63 void stop_prompt_session(std::shared_ptr<frontend::PromptSession> const& prompt_session) override;
64
51protected:65protected:
52 std::shared_ptr<scene::SessionCoordinator> const wrapped;66 std::shared_ptr<scene::SessionCoordinator> const wrapped;
53};67};
5468
=== modified file 'include/server/mir/time/timer.h'
--- include/server/mir/time/timer.h 2014-05-22 09:56:17 +0000
+++ include/server/mir/time/timer.h 2014-06-18 17:25:24 +0000
@@ -58,7 +58,14 @@
58 */58 */
59 virtual std::unique_ptr<Alarm> notify_at(Timestamp time_point,59 virtual std::unique_ptr<Alarm> notify_at(Timestamp time_point,
60 std::function<void()> callback) = 0;60 std::function<void()> callback) = 0;
6161 /**
62 * \brief Create an Alarm that will not fire until scheduled
63 *
64 * \param callback Function to call when the Alarm signals
65 *
66 * \return A handle to an Alarm that can later be scheduled
67 */
68 virtual std::unique_ptr<Alarm> create_alarm(std::function<void()> callback) = 0;
6269
63 Timer(Timer const&) = delete;70 Timer(Timer const&) = delete;
64 Timer& operator=(Timer const&) = delete;71 Timer& operator=(Timer const&) = delete;
6572
=== added file 'include/shared/mir/thread_name.h'
--- include/shared/mir/thread_name.h 1970-01-01 00:00:00 +0000
+++ include/shared/mir/thread_name.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,29 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_THREAD_NAME_H_
20#define MIR_THREAD_NAME_H_
21
22#include <string>
23
24namespace mir
25{
26void set_thread_name(std::string const& name);
27}
28
29#endif /* MIR_THREAD_NAME_H_ */
030
=== modified file 'include/shared/mir_toolkit/client_types.h'
--- include/shared/mir_toolkit/client_types.h 2014-05-22 11:31:21 +0000
+++ include/shared/mir_toolkit/client_types.h 2014-06-18 17:25:24 +0000
@@ -46,6 +46,7 @@
46typedef struct MirConnection MirConnection;46typedef struct MirConnection MirConnection;
47typedef struct MirSurface MirSurface;47typedef struct MirSurface MirSurface;
48typedef struct MirScreencast MirScreencast;48typedef struct MirScreencast MirScreencast;
49typedef struct MirPromptSession MirPromptSession;
4950
50/**51/**
51 * Returned by asynchronous functions. Must not be free'd by52 * Returned by asynchronous functions. Must not be free'd by
@@ -105,7 +106,7 @@
105106
106/**107/**
107 * Callback called when a request for client file descriptors completes108 * Callback called when a request for client file descriptors completes
108 * \param [in] connection The connection associated with the display change109 * \param [in] prompt_session The prompt session
109 * \param [in] count The number of FDs allocated110 * \param [in] count The number of FDs allocated
110 * \param [in] fds Array of FDs111 * \param [in] fds Array of FDs
111 * \param [in,out] context The context provided by client112 * \param [in,out] context The context provided by client
@@ -114,7 +115,7 @@
114 */115 */
115116
116typedef void (*mir_client_fd_callback)(117typedef void (*mir_client_fd_callback)(
117 MirConnection* connection, size_t count, int const* fds, void* context);118 MirPromptSession *prompt_session, size_t count, int const* fds, void* context);
118119
119/**120/**
120 * MirBufferUsage specifies how a surface can and will be used. A "hardware"121 * MirBufferUsage specifies how a surface can and will be used. A "hardware"
@@ -319,6 +320,31 @@
319 */320 */
320typedef void (*mir_screencast_callback)(MirScreencast *screencast, void *client_context);321typedef void (*mir_screencast_callback)(MirScreencast *screencast, void *client_context);
321322
323/**
324 * Callback member of MirPromptSession for handling of prompt sessions.
325 * \param [in] prompt_provider The prompt session associated with the callback
326 * \param [in,out] context The context provided by the client
327 */
328typedef void (*mir_prompt_session_callback)(MirPromptSession* prompt_provider, void* context);
329
330/**
331 * Callback member of MirPromptSession for adding prompt providers
332 * \param [in] prompt_provider The prompt session associated with the callback
333 * \param [in] added True if the session was added, false otherwise
334 * \param [in,out] context The context provided by the client
335 */
336typedef void (*mir_prompt_session_add_prompt_provider_callback)(
337 MirPromptSession* prompt_provider, MirBool added, void* context);
338
339/**
340 * Callback member of MirPromptSession for handling of prompt sessions events.
341 * \param [in] prompt_provider The prompt session associated with the callback
342 * \param [in] state The state of the prompt session
343 * \param [in,out] context The context provided by the client
344 */
345typedef void (*mir_prompt_session_state_change_callback)(
346 MirPromptSession* prompt_provider, MirPromptSessionState state, void* context);
347
322#ifdef __cplusplus348#ifdef __cplusplus
323}349}
324/**@}*/350/**@}*/
325351
=== modified file 'include/shared/mir_toolkit/common.h'
--- include/shared/mir_toolkit/common.h 2014-05-05 09:02:17 +0000
+++ include/shared/mir_toolkit/common.h 2014-06-18 17:25:24 +0000
@@ -88,6 +88,12 @@
88 mir_power_mode_off /* Powered down. */88 mir_power_mode_off /* Powered down. */
89} MirPowerMode;89} MirPowerMode;
9090
91typedef enum MirPromptSessionState
92{
93 mir_prompt_session_state_stopped = 0,
94 mir_prompt_session_state_started
95} MirPromptSessionState;
96
91/**97/**
92 * The order of components in a format enum matches the98 * The order of components in a format enum matches the
93 * order of the components as they would be written in an99 * order of the components as they would be written in an
94100
=== modified file 'include/shared/mir_toolkit/event.h'
--- include/shared/mir_toolkit/event.h 2014-03-06 06:05:17 +0000
+++ include/shared/mir_toolkit/event.h 2014-06-18 17:25:24 +0000
@@ -40,7 +40,8 @@
40 mir_event_type_key,40 mir_event_type_key,
41 mir_event_type_motion,41 mir_event_type_motion,
42 mir_event_type_surface,42 mir_event_type_surface,
43 mir_event_type_resize43 mir_event_type_resize,
44 mir_event_type_prompt_session_state_change
44} MirEventType;45} MirEventType;
4546
46typedef enum {47typedef enum {
@@ -204,6 +205,13 @@
204 int height;205 int height;
205} MirResizeEvent;206} MirResizeEvent;
206207
208typedef struct
209{
210 MirEventType type;
211
212 MirPromptSessionState new_state;
213} MirPromptSessionEvent;
214
207typedef union215typedef union
208{216{
209 MirEventType type;217 MirEventType type;
@@ -211,6 +219,7 @@
211 MirMotionEvent motion;219 MirMotionEvent motion;
212 MirSurfaceEvent surface;220 MirSurfaceEvent surface;
213 MirResizeEvent resize;221 MirResizeEvent resize;
222 MirPromptSessionEvent prompt_session;
214} MirEvent;223} MirEvent;
215224
216#ifdef __cplusplus225#ifdef __cplusplus
217226
=== added file 'include/test/mir_test/barrier.h'
--- include/test/mir_test/barrier.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test/barrier.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,61 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored By: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIR_TEST_BARRIER_H_
20#define MIR_TEST_BARRIER_H_
21
22#include <mutex>
23#include <condition_variable>
24
25namespace mir
26{
27namespace test
28{
29class Barrier
30{
31public:
32 explicit Barrier(unsigned wait_threads) : wait_threads{wait_threads} {}
33
34 void reset(unsigned threads)
35 {
36 std::unique_lock<decltype(mutex)> lock(mutex);
37 wait_threads = threads;
38 }
39
40 void ready()
41 {
42 std::unique_lock<decltype(mutex)> lock(mutex);
43 --wait_threads;
44 cv.notify_all();
45 if (!cv.wait_for(lock, std::chrono::minutes(1), [&]{ return wait_threads == 0; }))
46 throw std::runtime_error("Timeout");
47 }
48
49private:
50 Barrier(Barrier const&) = default;
51 Barrier& operator=(Barrier const&) = default;
52 unsigned wait_threads;
53 std::mutex mutex;
54 std::condition_variable cv;
55};
56}
57}
58
59
60
61#endif /* MIR_TEST_BARRIER_H_ */
062
=== added file 'include/test/mir_test/current_thread_name.h'
--- include/test/mir_test/current_thread_name.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test/current_thread_name.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,34 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_TEST_CURRENT_THREAD_NAME_H_
20#define MIR_TEST_CURRENT_THREAD_NAME_H_
21
22#include <string>
23
24namespace mir
25{
26namespace test
27{
28
29std::string current_thread_name();
30
31}
32}
33
34#endif
035
=== added file 'include/test/mir_test/fake_clock.h'
--- include/test/mir_test/fake_clock.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test/fake_clock.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,72 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_TEST_FAKE_CLOCK_H_
20#define MIR_TEST_FAKE_CLOCK_H_
21
22#include <chrono>
23#include <functional>
24#include <list>
25
26namespace mir
27{
28namespace test
29{
30/**
31 * @brief An invasive time source for Mocks/Stubs/Fakes that depend on timing
32 */
33class FakeClock
34{
35public:
36 typedef std::chrono::nanoseconds duration;
37 typedef duration::rep rep;
38 typedef duration::period period;
39 typedef std::chrono::time_point<FakeClock, duration> time_point;
40
41 static constexpr bool is_steady = false;
42 time_point now() const;
43
44 FakeClock();
45 /**
46 * \brief Advance the fake clock
47 * \note Advancing by a negative duration will move the clock backwards
48 */
49 template<typename rep, typename period>
50 void advance_time(std::chrono::duration<rep, period> by)
51 {
52 advance_time_ns(std::chrono::duration_cast<std::chrono::nanoseconds>(by));
53 }
54
55 /**
56 * \brief Register an event callback when the time is changed
57 * \param cb Function to call when the time is changed.
58 * This function is called with the new time.
59 * If the function returns false, it will no longer be called
60 * on subsequent time changes.
61 */
62 void register_time_change_callback(std::function<bool(time_point)> cb);
63private:
64 void advance_time_ns(std::chrono::nanoseconds by);
65 std::chrono::nanoseconds current_time;
66 std::list<std::function<bool(time_point)>> callbacks;
67};
68
69}
70}
71
72#endif // MIR_TEST_FAKE_CLOCK_H_
073
=== added file 'include/test/mir_test/signal.h'
--- include/test/mir_test/signal.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test/signal.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,63 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_TEST_SIGNAL_H_
20#define MIR_TEST_SIGNAL_H_
21
22#include <condition_variable>
23#include <chrono>
24#include <mutex>
25
26namespace mir
27{
28namespace test
29{
30/**
31 * @brief A threadsafe, waitable signal
32 */
33class Signal
34{
35public:
36 Signal();
37
38 void raise();
39 bool raised();
40
41 void wait();
42 template<typename rep, typename period>
43 bool wait_for(std::chrono::duration<rep, period> delay)
44 {
45 std::unique_lock<decltype(mutex)> lock(mutex);
46 return cv.wait_for(lock, delay, [this]() { return signalled; });
47 }
48 template<class Clock, class Duration>
49 bool wait_until(std::chrono::time_point<Clock, Duration> const& time)
50 {
51 std::unique_lock<decltype(mutex)> lock(mutex);
52 return cv.wait_until(lock, time, [this]() { return signalled; });
53 }
54
55private:
56 std::mutex mutex;
57 std::condition_variable cv;
58 bool signalled;
59};
60}
61}
62
63#endif // MIR_TEST_SIGNAL_H_
064
=== modified file 'include/test/mir_test/test_protobuf_client.h'
--- include/test/mir_test/test_protobuf_client.h 2013-08-28 03:41:48 +0000
+++ include/test/mir_test/test_protobuf_client.h 2014-06-18 17:25:24 +0000
@@ -21,6 +21,7 @@
21#define MIR_TEST_TEST_CLIENT_H_21#define MIR_TEST_TEST_CLIENT_H_
2222
23#include "mir_protobuf.pb.h"23#include "mir_protobuf.pb.h"
24#include "wait_condition.h"
2425
25#include <gmock/gmock.h>26#include <gmock/gmock.h>
2627
@@ -49,6 +50,9 @@
49 mir::protobuf::Connection connection;50 mir::protobuf::Connection connection;
50 mir::protobuf::DisplayConfiguration disp_config;51 mir::protobuf::DisplayConfiguration disp_config;
51 mir::protobuf::DisplayConfiguration disp_config_response;52 mir::protobuf::DisplayConfiguration disp_config_response;
53 mir::protobuf::PromptSessionParameters prompt_session_parameters;
54 mir::protobuf::PromptProvider prompt_provider;
55 mir::protobuf::Void prompt_session;
5256
53 MOCK_METHOD0(connect_done, void());57 MOCK_METHOD0(connect_done, void());
54 MOCK_METHOD0(create_surface_done, void());58 MOCK_METHOD0(create_surface_done, void());
@@ -57,6 +61,9 @@
57 MOCK_METHOD0(disconnect_done, void());61 MOCK_METHOD0(disconnect_done, void());
58 MOCK_METHOD0(drm_auth_magic_done, void());62 MOCK_METHOD0(drm_auth_magic_done, void());
59 MOCK_METHOD0(display_configure_done, void());63 MOCK_METHOD0(display_configure_done, void());
64 MOCK_METHOD0(prompt_session_start_done, void());
65 MOCK_METHOD0(prompt_session_add_prompt_provider_done, void());
66 MOCK_METHOD0(prompt_session_stop_done, void());
6067
61 void on_connect_done();68 void on_connect_done();
6269
@@ -94,6 +101,12 @@
94101
95 void wait_for_configure_display_done();102 void wait_for_configure_display_done();
96103
104 void wait_for_prompt_session_start_done();
105
106 void wait_for_prompt_session_add_prompt_provider_done();
107
108 void wait_for_prompt_session_stop_done();
109
97 const int maxwait;110 const int maxwait;
98 std::atomic<bool> connect_done_called;111 std::atomic<bool> connect_done_called;
99 std::atomic<bool> create_surface_called;112 std::atomic<bool> create_surface_called;
@@ -104,6 +117,10 @@
104 std::atomic<bool> configure_display_done_called;117 std::atomic<bool> configure_display_done_called;
105 std::atomic<bool> tfd_done_called;118 std::atomic<bool> tfd_done_called;
106119
120 WaitCondition wc_prompt_session_start;
121 WaitCondition wc_prompt_session_add;
122 WaitCondition wc_prompt_session_stop;
123
107 std::atomic<int> connect_done_count;124 std::atomic<int> connect_done_count;
108 std::atomic<int> create_surface_done_count;125 std::atomic<int> create_surface_done_count;
109 std::atomic<int> disconnect_done_count;126 std::atomic<int> disconnect_done_count;
110127
=== modified file 'include/test/mir_test_doubles/fake_ipc_factory.h'
--- include/test/mir_test_doubles/fake_ipc_factory.h 2014-05-13 10:03:15 +0000
+++ include/test/mir_test_doubles/fake_ipc_factory.h 2014-06-18 17:25:24 +0000
@@ -40,24 +40,26 @@
40 std::shared_ptr<frontend::DisplayChanger> const& changer,40 std::shared_ptr<frontend::DisplayChanger> const& changer,
41 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,41 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
42 std::shared_ptr<frontend::SessionMediatorReport> const& sm_report,42 std::shared_ptr<frontend::SessionMediatorReport> const& sm_report,
43 const std::shared_ptr<frontend::EventSink>& sink,43 std::shared_ptr<frontend::EventSink> const& sink,
44 const std::shared_ptr<frontend::Screencast>& effective_screencast,44 std::shared_ptr<frontend::Screencast> const& effective_screencast,
45 const frontend::ConnectionContext& connection_context)45 frontend::ConnectionContext const& connection_context,
46 std::shared_ptr<graphics::CursorImages> const& cursor_images)
46 {47 {
47 return frontend::DefaultIpcFactory::make_mediator(48 return frontend::DefaultIpcFactory::make_mediator(
48 shell, graphics_platform, changer, buffer_allocator,49 shell, graphics_platform, changer, buffer_allocator,
49 sm_report, sink, effective_screencast, connection_context);50 sm_report, sink, effective_screencast, connection_context, cursor_images);
50 }51 }
5152
52 MOCK_METHOD8(make_mediator, std::shared_ptr<frontend::detail::DisplayServer>(53 MOCK_METHOD9(make_mediator, std::shared_ptr<frontend::detail::DisplayServer>(
53 std::shared_ptr<frontend::Shell> const& shell,54 std::shared_ptr<frontend::Shell> const& shell,
54 std::shared_ptr<graphics::Platform> const& graphics_platform,55 std::shared_ptr<graphics::Platform> const& graphics_platform,
55 std::shared_ptr<frontend::DisplayChanger> const& changer,56 std::shared_ptr<frontend::DisplayChanger> const& changer,
56 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,57 std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
57 std::shared_ptr<frontend::SessionMediatorReport> const& sm_report,58 std::shared_ptr<frontend::SessionMediatorReport> const& sm_report,
58 const std::shared_ptr<frontend::EventSink>& sink,59 std::shared_ptr<frontend::EventSink> const& sink,
59 const std::shared_ptr<frontend::Screencast>& effective_screencast,60 std::shared_ptr<frontend::Screencast> const& effective_screencast,
60 const frontend::ConnectionContext& connection_context));61 frontend::ConnectionContext const& connection_context,
62 std::shared_ptr<graphics::CursorImages> const& cursor_images));
61};63};
62}64}
63}65}
6466
=== modified file 'include/test/mir_test_doubles/fake_renderable.h'
--- include/test/mir_test_doubles/fake_renderable.h 2014-05-07 02:56:33 +0000
+++ include/test/mir_test_doubles/fake_renderable.h 2014-06-18 17:25:24 +0000
@@ -19,6 +19,7 @@
19#ifndef MIR_TEST_DOUBLES_FAKE_RENDERABLE_H_19#ifndef MIR_TEST_DOUBLES_FAKE_RENDERABLE_H_
20#define MIR_TEST_DOUBLES_FAKE_RENDERABLE_H_20#define MIR_TEST_DOUBLES_FAKE_RENDERABLE_H_
2121
22#include "stub_buffer.h"
22#include "mir/graphics/renderable.h"23#include "mir/graphics/renderable.h"
23#define GLM_FORCE_RADIANS24#define GLM_FORCE_RADIANS
24#include <glm/gtc/matrix_transform.hpp>25#include <glm/gtc/matrix_transform.hpp>
@@ -34,12 +35,36 @@
34class FakeRenderable : public graphics::Renderable35class FakeRenderable : public graphics::Renderable
35{36{
36public:37public:
37 FakeRenderable(int x, int y, int width, int height,38 FakeRenderable(int x, int y, int width, int height)
38 float opacity=1.0f,39 : FakeRenderable{geometry::Rectangle{{x,y},{width,height}}}
39 bool rectangular=true,40 {
40 bool visible=true,41 }
41 bool posted=true)42 FakeRenderable(geometry::Rectangle display_area)
42 : rect{{x, y}, {width, height}},43 : FakeRenderable{display_area, 1.0f, true, true, true}
44 {
45 }
46
47 FakeRenderable(geometry::Rectangle display_area,
48 float opacity)
49 : FakeRenderable{display_area, opacity, true, true, true}
50 {
51 }
52
53 FakeRenderable(geometry::Rectangle display_area,
54 float opacity,
55 bool rectangular,
56 bool visible)
57 : FakeRenderable{display_area, opacity, rectangular, visible, true}
58 {
59 }
60
61 FakeRenderable(geometry::Rectangle display_area,
62 float opacity,
63 bool rectangular,
64 bool visible,
65 bool posted)
66 : buf{std::make_shared<StubBuffer>()},
67 rect(display_area),
43 opacity(opacity),68 opacity(opacity),
44 rectangular(rectangular),69 rectangular(rectangular),
45 visible_(visible),70 visible_(visible),
4671
=== modified file 'include/test/mir_test_doubles/mock_buffer.h'
--- include/test/mir_test_doubles/mock_buffer.h 2014-03-06 06:05:17 +0000
+++ include/test/mir_test_doubles/mock_buffer.h 2014-06-18 17:25:24 +0000
@@ -63,7 +63,7 @@
63 MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());63 MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());
64 MOCK_CONST_METHOD0(native_buffer_handle, std::shared_ptr<graphics::NativeBuffer>());64 MOCK_CONST_METHOD0(native_buffer_handle, std::shared_ptr<graphics::NativeBuffer>());
6565
66 MOCK_METHOD0(bind_to_texture, void());66 MOCK_METHOD0(gl_bind_to_texture, void());
67 MOCK_CONST_METHOD0(id, graphics::BufferID());67 MOCK_CONST_METHOD0(id, graphics::BufferID());
6868
69 MOCK_CONST_METHOD0(can_bypass, bool());69 MOCK_CONST_METHOD0(can_bypass, bool());
7070
=== modified file 'include/test/mir_test_doubles/mock_buffer_stream.h'
--- include/test/mir_test_doubles/mock_buffer_stream.h 2014-04-14 19:35:21 +0000
+++ include/test/mir_test_doubles/mock_buffer_stream.h 2014-06-18 17:25:24 +0000
@@ -44,7 +44,8 @@
44 ON_CALL(*this, buffers_ready_for_compositor())44 ON_CALL(*this, buffers_ready_for_compositor())
45 .WillByDefault(testing::Invoke(this, &MockBufferStream::buffers_ready));45 .WillByDefault(testing::Invoke(this, &MockBufferStream::buffers_ready));
46 }46 }
47 MOCK_METHOD2(swap_client_buffers, void(graphics::Buffer*, std::function<void(graphics::Buffer*)> completee));47 MOCK_METHOD1(acquire_client_buffer, void(std::function<void(graphics::Buffer* buffer)>));
48 MOCK_METHOD1(release_client_buffer, void(graphics::Buffer*));
48 MOCK_METHOD1(lock_compositor_buffer,49 MOCK_METHOD1(lock_compositor_buffer,
49 std::shared_ptr<graphics::Buffer>(void const*));50 std::shared_ptr<graphics::Buffer>(void const*));
50 MOCK_METHOD0(lock_snapshot_buffer, std::shared_ptr<graphics::Buffer>());51 MOCK_METHOD0(lock_snapshot_buffer, std::shared_ptr<graphics::Buffer>());
5152
=== modified file 'include/test/mir_test_doubles/mock_display_buffer.h'
--- include/test/mir_test_doubles/mock_display_buffer.h 2014-05-22 09:56:17 +0000
+++ include/test/mir_test_doubles/mock_display_buffer.h 2014-06-18 17:25:24 +0000
@@ -36,8 +36,6 @@
36 MockDisplayBuffer()36 MockDisplayBuffer()
37 {37 {
38 using namespace testing;38 using namespace testing;
39 ON_CALL(*this, can_bypass())
40 .WillByDefault(Return(false));
41 ON_CALL(*this, view_area())39 ON_CALL(*this, view_area())
42 .WillByDefault(Return(geometry::Rectangle{{0,0},{0,0}}));40 .WillByDefault(Return(geometry::Rectangle{{0,0},{0,0}}));
43 }41 }
@@ -45,9 +43,9 @@
45 MOCK_METHOD0(make_current, void());43 MOCK_METHOD0(make_current, void());
46 MOCK_METHOD0(release_current, void());44 MOCK_METHOD0(release_current, void());
47 MOCK_METHOD0(post_update, void());45 MOCK_METHOD0(post_update, void());
48 MOCK_CONST_METHOD0(can_bypass, bool());46 MOCK_METHOD1(post_renderables_if_optimizable, bool(graphics::RenderableList const&));
49 MOCK_METHOD1(post_renderables_if_optimizable, bool(graphics::RenderableList const&));
50 MOCK_CONST_METHOD0(orientation, MirOrientation());47 MOCK_CONST_METHOD0(orientation, MirOrientation());
48 MOCK_CONST_METHOD0(uses_alpha, bool());
51};49};
5250
53}51}
5452
=== modified file 'include/test/mir_test_doubles/mock_display_device.h'
--- include/test/mir_test_doubles/mock_display_device.h 2014-05-20 20:01:43 +0000
+++ include/test/mir_test_doubles/mock_display_device.h 2014-06-18 17:25:24 +0000
@@ -36,12 +36,11 @@
36public:36public:
37 ~MockDisplayDevice() noexcept {}37 ~MockDisplayDevice() noexcept {}
38 MOCK_METHOD1(mode, void(MirPowerMode));38 MOCK_METHOD1(mode, void(MirPowerMode));
39 MOCK_METHOD1(render_gl, void(graphics::android::SwappingGLContext const&));39 MOCK_METHOD1(post_gl, void(graphics::android::SwappingGLContext const&));
40 MOCK_METHOD3(prepare_overlays, void(40 MOCK_METHOD3(post_overlays, bool(
41 graphics::android::SwappingGLContext const&,41 graphics::android::SwappingGLContext const&,
42 graphics::RenderableList const&,42 graphics::RenderableList const&,
43 graphics::android::RenderableListCompositor const&));43 graphics::android::RenderableListCompositor const&));
44 MOCK_METHOD1(post, void(graphics::Buffer const&));
45 MOCK_CONST_METHOD1(apply_orientation, bool(MirOrientation));44 MOCK_CONST_METHOD1(apply_orientation, bool(MirOrientation));
46};45};
47}46}
4847
=== added file 'include/test/mir_test_doubles/mock_frame_dropping_policy_factory.h'
--- include/test/mir_test_doubles/mock_frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/mock_frame_dropping_policy_factory.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,83 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19
20#ifndef MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_
21#define MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_
22
23#include "mir/compositor/frame_dropping_policy_factory.h"
24#include "mir/compositor/frame_dropping_policy.h"
25
26#include <unordered_set>
27#include <functional>
28
29#include <gmock/gmock.h>
30
31namespace mc = mir::compositor;
32
33namespace mir
34{
35namespace test
36{
37namespace doubles
38{
39
40class MockFrameDroppingPolicyFactory;
41
42class MockFrameDroppingPolicy : public mc::FrameDroppingPolicy
43{
44public:
45 MockFrameDroppingPolicy(std::function<void(void)> callback,
46 MockFrameDroppingPolicyFactory const* parent);
47 ~MockFrameDroppingPolicy();
48
49 MOCK_METHOD0(swap_now_blocking, void(void));
50 MOCK_METHOD0(swap_unblocked, void(void));
51
52 void trigger();
53
54private:
55 friend class MockFrameDroppingPolicyFactory;
56 void parent_destroyed();
57
58 std::function<void(void)> callback;
59 MockFrameDroppingPolicyFactory const* parent;
60};
61
62class MockFrameDroppingPolicyFactory : public mc::FrameDroppingPolicyFactory
63{
64public:
65 std::unique_ptr<mc::FrameDroppingPolicy> create_policy(std::function<void(void)> drop_frame) const override;
66
67 ~MockFrameDroppingPolicyFactory();
68
69 void trigger_policies() const;
70
71private:
72 friend class MockFrameDroppingPolicy;
73
74 void policy_destroyed(MockFrameDroppingPolicy* policy) const;
75 mutable std::unordered_set<MockFrameDroppingPolicy*> policies;
76};
77
78}
79}
80}
81
82
83#endif // MIR_TEST_DOUBLES_MOCK_FRAME_DROPPING_POLICY_FACTORY_H_
084
=== modified file 'include/test/mir_test_doubles/mock_frontend_surface.h'
--- include/test/mir_test_doubles/mock_frontend_surface.h 2014-05-22 11:31:21 +0000
+++ include/test/mir_test_doubles/mock_frontend_surface.h 2014-06-18 17:25:24 +0000
@@ -46,6 +46,8 @@
4646
47 MOCK_CONST_METHOD0(supports_input, bool());47 MOCK_CONST_METHOD0(supports_input, bool());
48 MOCK_CONST_METHOD0(client_input_fd, int());48 MOCK_CONST_METHOD0(client_input_fd, int());
49
50 MOCK_METHOD1(set_cursor_image, void(std::shared_ptr<graphics::CursorImage> const&));
4951
50 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));52 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));
51};53};
5254
=== added file 'include/test/mir_test_doubles/mock_prompt_session_listener.h'
--- include/test/mir_test_doubles/mock_prompt_session_listener.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/mock_prompt_session_listener.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,48 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_PROMPT_SESSION_LISTENER_H_
20#define MIR_TEST_DOUBLES_MOCK_PROMPT_SESSION_LISTENER_H_
21
22#include "mir/scene/prompt_session_listener.h"
23
24#include <gmock/gmock.h>
25
26namespace mir
27{
28namespace test
29{
30namespace doubles
31{
32
33struct MockPromptSessionListener : public scene::PromptSessionListener
34{
35 virtual ~MockPromptSessionListener() noexcept(true) {}
36
37 MOCK_METHOD1(starting, void(std::shared_ptr<scene::PromptSession> const&));
38 MOCK_METHOD1(stopping, void(std::shared_ptr<scene::PromptSession> const&));
39
40 MOCK_METHOD2(prompt_provider_added, void(scene::PromptSession const&, std::shared_ptr<scene::Session> const&));
41 MOCK_METHOD2(prompt_provider_removed, void(scene::PromptSession const&, std::shared_ptr<scene::Session> const&));
42};
43
44}
45}
46} // namespace mir
47
48#endif // MIR_TEST_DOUBLES_MOCK_PROMPT_SESSION_LISTENER_H_
049
=== modified file 'include/test/mir_test_doubles/mock_scene_session.h'
--- include/test/mir_test_doubles/mock_scene_session.h 2014-05-22 11:31:21 +0000
+++ include/test/mir_test_doubles/mock_scene_session.h 2014-06-18 17:25:24 +0000
@@ -52,6 +52,9 @@
52 MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int));52 MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int));
5353
54 MOCK_METHOD1(set_lifecycle_state, void(MirLifecycleState state));54 MOCK_METHOD1(set_lifecycle_state, void(MirLifecycleState state));
55
56 MOCK_METHOD0(start_prompt_session, void());
57 MOCK_METHOD0(stop_prompt_session, void());
55};58};
5659
57}60}
5861
=== modified file 'include/test/mir_test_doubles/mock_shell.h'
--- include/test/mir_test_doubles/mock_shell.h 2014-04-15 05:31:19 +0000
+++ include/test/mir_test_doubles/mock_shell.h 2014-06-18 17:25:24 +0000
@@ -22,6 +22,7 @@
22#include "mir/scene/surface_creation_parameters.h"22#include "mir/scene/surface_creation_parameters.h"
23#include "mir/frontend/shell.h"23#include "mir/frontend/shell.h"
24#include "mir/frontend/surface_id.h"24#include "mir/frontend/surface_id.h"
25#include "mir/scene/prompt_session_creation_parameters.h"
2526
26#include <gmock/gmock.h>27#include <gmock/gmock.h>
2728
@@ -43,6 +44,17 @@
4344
44 MOCK_METHOD2(create_surface_for, frontend::SurfaceId(std::shared_ptr<frontend::Session> const&, scene::SurfaceCreationParameters const&));45 MOCK_METHOD2(create_surface_for, frontend::SurfaceId(std::shared_ptr<frontend::Session> const&, scene::SurfaceCreationParameters const&));
45 MOCK_METHOD1(handle_surface_created, void(std::shared_ptr<frontend::Session> const&));46 MOCK_METHOD1(handle_surface_created, void(std::shared_ptr<frontend::Session> const&));
47
48 MOCK_METHOD2(start_prompt_session_for, std::shared_ptr<frontend::PromptSession>(
49 std::shared_ptr<frontend::Session> const&,
50 scene::PromptSessionCreationParameters const&));
51 MOCK_METHOD2(add_prompt_provider_process_for, void(
52 std::shared_ptr<frontend::PromptSession> const&,
53 pid_t));
54 MOCK_METHOD2(add_prompt_provider_for, void(
55 std::shared_ptr<frontend::PromptSession> const&,
56 std::shared_ptr<frontend::Session> const&));
57 MOCK_METHOD1(stop_prompt_session, void(std::shared_ptr<frontend::PromptSession> const&));
46};58};
4759
48}60}
4961
=== modified file 'include/test/mir_test_doubles/mock_surface.h'
--- include/test/mir_test_doubles/mock_surface.h 2014-05-07 02:56:33 +0000
+++ include/test/mir_test_doubles/mock_surface.h 2014-06-18 17:25:24 +0000
@@ -41,6 +41,7 @@
41 {},41 {},
42 {},42 {},
43 {},43 {},
44 {},
44 mir::report::null_scene_report())45 mir::report::null_scene_report())
45 {46 {
46 }47 }
4748
=== modified file 'include/test/mir_test_doubles/mock_swapping_gl_context.h'
--- include/test/mir_test_doubles/mock_swapping_gl_context.h 2014-02-21 16:51:45 +0000
+++ include/test/mir_test_doubles/mock_swapping_gl_context.h 2014-06-18 17:25:24 +0000
@@ -31,6 +31,7 @@
31struct MockSwappingGLContext : public graphics::android::SwappingGLContext31struct MockSwappingGLContext : public graphics::android::SwappingGLContext
32{32{
33 MOCK_CONST_METHOD0(swap_buffers, void());33 MOCK_CONST_METHOD0(swap_buffers, void());
34 MOCK_CONST_METHOD0(last_rendered_buffer, std::shared_ptr<graphics::Buffer>());
34};35};
3536
36}37}
3738
=== added file 'include/test/mir_test_doubles/mock_timer.h'
--- include/test/mir_test_doubles/mock_timer.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/mock_timer.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,52 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_TIMER_H_
20#define MIR_TEST_DOUBLES_MOCK_TIMER_H_
21
22#include "mir/time/timer.h"
23#include "mir_test/fake_clock.h"
24#include <memory>
25
26namespace mir
27{
28namespace test
29{
30namespace doubles
31{
32
33class FakeTimer : public mir::time::Timer
34{
35public:
36 FakeTimer(std::shared_ptr<FakeClock> const& clock);
37
38 std::unique_ptr<time::Alarm> notify_in(std::chrono::milliseconds delay,
39 std::function<void(void)> callback) override;
40 std::unique_ptr<time::Alarm> notify_at(time::Timestamp time_point,
41 std::function<void(void)> callback) override;
42 std::unique_ptr<time::Alarm> create_alarm(std::function<void ()> callback) override;
43
44private:
45 std::shared_ptr<FakeClock> const clock;
46};
47
48}
49}
50}
51
52#endif // MIR_TEST_DOUBLES_MOCK_TIMER_H_
053
=== added file 'include/test/mir_test_doubles/mock_virtual_terminal.h'
--- include/test/mir_test_doubles/mock_virtual_terminal.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/mock_virtual_terminal.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,48 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_VIRTUAL_TERMINAL_H_
20#define MIR_TEST_DOUBLES_MOCK_VIRTUAL_TERMINAL_H_
21
22#include "src/platform/graphics/mesa/virtual_terminal.h"
23
24#include <gmock/gmock.h>
25
26namespace mir
27{
28namespace test
29{
30namespace doubles
31{
32
33class MockVirtualTerminal : public graphics::mesa::VirtualTerminal
34{
35public:
36 MOCK_METHOD0(set_graphics_mode, void());
37 MOCK_METHOD3(register_switch_handlers,
38 void(graphics::EventHandlerRegister&,
39 std::function<bool()> const&,
40 std::function<bool()> const&));
41 MOCK_METHOD0(restore, void());
42};
43
44}
45}
46}
47
48#endif
049
=== added file 'include/test/mir_test_doubles/null_client_event_sink.h'
--- include/test/mir_test_doubles/null_client_event_sink.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/null_client_event_sink.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nick Dedekink <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_NULL_CLIENT_EVENT_SINK_H_
20#define MIR_TEST_DOUBLES_NULL_CLIENT_EVENT_SINK_H_
21
22#include "src/client/event_sink.h"
23
24#include <gmock/gmock.h>
25
26namespace mir
27{
28namespace test
29{
30namespace doubles
31{
32class NullClientEventSink : public client::EventSink
33{
34public:
35 void handle_event(MirEvent const&) override {}
36};
37
38}
39}
40}
41
42#endif /* MIR_TEST_DOUBLES_NULL_CLIENT_EVENT_SINK_H_ */
043
=== modified file 'include/test/mir_test_doubles/null_display_buffer.h'
--- include/test/mir_test_doubles/null_display_buffer.h 2014-05-22 09:56:17 +0000
+++ include/test/mir_test_doubles/null_display_buffer.h 2014-06-18 17:25:24 +0000
@@ -35,9 +35,9 @@
35 void make_current() {}35 void make_current() {}
36 void release_current() {}36 void release_current() {}
37 void post_update() {}37 void post_update() {}
38 bool can_bypass() const override { return false; }
39 bool post_renderables_if_optimizable(graphics::RenderableList const&) { return false; }38 bool post_renderables_if_optimizable(graphics::RenderableList const&) { return false; }
40 MirOrientation orientation() const override { return mir_orientation_normal; }39 MirOrientation orientation() const override { return mir_orientation_normal; }
40 bool uses_alpha() const override { return false; }
41};41};
4242
43}43}
4444
=== modified file 'include/test/mir_test_doubles/null_display_buffer_compositor_factory.h'
--- include/test/mir_test_doubles/null_display_buffer_compositor_factory.h 2014-04-08 13:12:47 +0000
+++ include/test/mir_test_doubles/null_display_buffer_compositor_factory.h 2014-06-18 17:25:24 +0000
@@ -37,7 +37,7 @@
37 {37 {
38 struct NullDisplayBufferCompositor : compositor::DisplayBufferCompositor38 struct NullDisplayBufferCompositor : compositor::DisplayBufferCompositor
39 {39 {
40 bool composite() { return false; }40 void composite() {}
41 };41 };
4242
43 auto raw = new NullDisplayBufferCompositor{};43 auto raw = new NullDisplayBufferCompositor{};
4444
=== added file 'include/test/mir_test_doubles/null_pixel_buffer.h'
--- include/test/mir_test_doubles/null_pixel_buffer.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/null_pixel_buffer.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_NULL_PIXEL_BUFFER_H_
20#define MIR_TEST_DOUBLES_NULL_PIXEL_BUFFER_H_
21
22#include "src/server/scene/pixel_buffer.h"
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30
31struct NullPixelBuffer : public scene::PixelBuffer
32{
33 void fill_from(graphics::Buffer&) {}
34 void const* as_argb_8888() { return nullptr; }
35 geometry::Size size() const { return {}; }
36 geometry::Stride stride() const { return {}; }
37};
38
39}
40}
41}
42
43#endif /* MIR_TEST_DOUBLES_NULL_PIXEL_BUFFER_H_ */
044
=== added file 'include/test/mir_test_doubles/null_prompt_session.h'
--- include/test/mir_test_doubles/null_prompt_session.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/null_prompt_session.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright © 2013-2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nick Dedekind <nick.dedekind@gmail.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_NULL_PROMPT_SESSION_H_
20#define MIR_TEST_DOUBLES_NULL_PROMPT_SESSION_H_
21
22#include "mir/scene/prompt_session.h"
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30class NullPromptSession : public scene::PromptSession
31{
32};
33}
34}
35}
36
37#endif /* MIR_TEST_DOUBLES_NULL_PROMPT_SESSION_H_ */
038
=== added file 'include/test/mir_test_doubles/null_prompt_session_manager.h'
--- include/test/mir_test_doubles/null_prompt_session_manager.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/null_prompt_session_manager.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,82 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored By: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_SCENE_NULL_PROMPT_SESSION_MANAGER_H_
20#define MIR_SCENE_NULL_PROMPT_SESSION_MANAGER_H_
21
22#include "mir/scene/prompt_session_manager.h"
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30
31class NullPromptSessionManager: public scene::PromptSessionManager
32{
33public:
34 std::shared_ptr<scene::PromptSession> start_prompt_session_for(std::shared_ptr<scene::Session> const&,
35 scene::PromptSessionCreationParameters const&) const
36 {
37 return std::shared_ptr<scene::PromptSession>();
38 }
39
40 void stop_prompt_session(std::shared_ptr<scene::PromptSession> const&) const
41 {
42 }
43
44 void add_prompt_provider(std::shared_ptr<scene::PromptSession> const&,
45 std::shared_ptr<scene::Session> const&) const
46 {
47 }
48
49 void add_prompt_provider_by_pid(std::shared_ptr<scene::PromptSession> const&,
50 pid_t) const
51 {
52 }
53
54 void add_expected_session(std::shared_ptr<scene::Session> const&) const
55 {
56 }
57
58 void remove_session(std::shared_ptr<scene::Session> const&) const
59 {
60 }
61
62 std::shared_ptr<scene::Session> application_for(std::shared_ptr<scene::PromptSession> const&) const
63 {
64 return std::shared_ptr<scene::Session>();
65 }
66
67 std::shared_ptr<scene::Session> helper_for(std::shared_ptr<scene::PromptSession> const&) const
68 {
69 return std::shared_ptr<scene::Session>();
70 }
71
72 void for_each_provider_in(std::shared_ptr<scene::PromptSession> const&,
73 std::function<void(std::shared_ptr<scene::Session> const&)> const&) const
74 {
75 }
76};
77
78}
79}
80}
81
82#endif // MIR_SCENE_NULL_PROMPT_SESSION_MANAGER_H_
083
=== modified file 'include/test/mir_test_doubles/null_virtual_terminal.h'
--- include/test/mir_test_doubles/null_virtual_terminal.h 2014-03-06 06:05:17 +0000
+++ include/test/mir_test_doubles/null_virtual_terminal.h 2014-06-18 17:25:24 +0000
@@ -31,13 +31,15 @@
31class NullVirtualTerminal : public graphics::mesa::VirtualTerminal31class NullVirtualTerminal : public graphics::mesa::VirtualTerminal
32{32{
33public:33public:
34 void set_graphics_mode() {}34 void set_graphics_mode() override {}
3535
36 void register_switch_handlers(graphics::EventHandlerRegister&,36 void register_switch_handlers(graphics::EventHandlerRegister&,
37 std::function<bool()> const&,37 std::function<bool()> const&,
38 std::function<bool()> const&)38 std::function<bool()> const&) override
39 {39 {
40 }40 }
41
42 void restore() override {}
41};43};
4244
43}45}
4446
=== added file 'include/test/mir_test_doubles/platform_factory.h'
--- include/test/mir_test_doubles/platform_factory.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/platform_factory.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_PLATFORM_FACTORY_H_
20#define MIR_TEST_DOUBLES_PLATFORM_FACTORY_H_
21
22#include <memory>
23
24namespace mir
25{
26namespace graphics
27{
28class Platform;
29namespace mesa { class Platform; }
30}
31namespace test
32{
33namespace doubles
34{
35
36std::shared_ptr<graphics::Platform> create_platform_with_null_dependencies();
37
38#ifndef ANDROID
39std::shared_ptr<graphics::mesa::Platform> create_mesa_platform_with_null_dependencies();
40#endif
41
42}
43}
44}
45
46#endif /* MIR_TEST_DOUBLES_PLATFORM_FACTORY_H_ */
047
=== modified file 'include/test/mir_test_doubles/stub_buffer.h'
--- include/test/mir_test_doubles/stub_buffer.h 2014-03-26 05:48:59 +0000
+++ include/test/mir_test_doubles/stub_buffer.h 2014-06-18 17:25:24 +0000
@@ -21,6 +21,9 @@
2121
22#ifdef ANDROID22#ifdef ANDROID
23#include "mock_android_native_buffer.h"23#include "mock_android_native_buffer.h"
24#else
25#include "src/platform/graphics/mesa/gbm_buffer.h"
26#include "mock_gbm.h"
24#endif27#endif
2528
26#include "mir/graphics/buffer_basic.h"29#include "mir/graphics/buffer_basic.h"
@@ -59,6 +62,14 @@
59 buf_pixel_format{properties.format},62 buf_pixel_format{properties.format},
60 buf_stride{stride}63 buf_stride{stride}
61 {64 {
65#ifndef ANDROID
66 auto buffer = std::make_shared<graphics::mesa::GBMNativeBuffer>();
67 int fake_bo{0};
68 buffer->bo = reinterpret_cast<gbm_bo*>(&fake_bo); //gbm_bo is opaque, so test code shouldn't dereference.
69 native_buffer = buffer;
70#else
71 native_buffer = std::make_shared<StubAndroidNativeBuffer>();
72#endif
62 }73 }
6374
64 virtual geometry::Size size() const { return buf_size; }75 virtual geometry::Size size() const { return buf_size; }
@@ -67,18 +78,12 @@
6778
68 virtual MirPixelFormat pixel_format() const { return buf_pixel_format; }79 virtual MirPixelFormat pixel_format() const { return buf_pixel_format; }
6980
70 virtual std::shared_ptr<graphics::NativeBuffer> native_buffer_handle() const81 virtual std::shared_ptr<graphics::NativeBuffer> native_buffer_handle() const { return native_buffer; }
71 {82 virtual void gl_bind_to_texture() override {}
72#ifndef ANDROID83
73 return std::make_shared<graphics::NativeBuffer>();84 virtual bool can_bypass() const override { return true; }
74#else85
75 return std::make_shared<StubAndroidNativeBuffer>();86 std::shared_ptr<graphics::NativeBuffer> native_buffer;
76#endif
77 }
78 virtual void bind_to_texture() {}
79
80 virtual bool can_bypass() const override { return false; }
81
82 geometry::Size const buf_size;87 geometry::Size const buf_size;
83 MirPixelFormat const buf_pixel_format;88 MirPixelFormat const buf_pixel_format;
84 geometry::Stride const buf_stride;89 geometry::Stride const buf_stride;
8590
=== modified file 'include/test/mir_test_doubles/stub_buffer_stream.h'
--- include/test/mir_test_doubles/stub_buffer_stream.h 2014-03-26 05:48:59 +0000
+++ include/test/mir_test_doubles/stub_buffer_stream.h 2014-06-18 17:25:24 +0000
@@ -36,10 +36,17 @@
36 {36 {
37 stub_compositor_buffer = std::make_shared<StubBuffer>();37 stub_compositor_buffer = std::make_shared<StubBuffer>();
38 }38 }
39 void swap_client_buffers(graphics::Buffer*, std::function<void(graphics::Buffer* new_buffer)> complete) override39
40 void acquire_client_buffer(
41 std::function<void(graphics::Buffer* buffer)> complete) override
40 {42 {
41 complete(&stub_client_buffer);43 complete(&stub_client_buffer);
42 }44 }
45
46 void release_client_buffer(graphics::Buffer*) override
47 {
48 }
49
43 std::shared_ptr<graphics::Buffer> lock_compositor_buffer(void const*) override50 std::shared_ptr<graphics::Buffer> lock_compositor_buffer(void const*) override
44 {51 {
45 return stub_compositor_buffer;52 return stub_compositor_buffer;
4653
=== modified file 'include/test/mir_test_doubles/stub_display_builder.h'
--- include/test/mir_test_doubles/stub_display_builder.h 2014-05-28 07:43:51 +0000
+++ include/test/mir_test_doubles/stub_display_builder.h 2014-06-18 17:25:24 +0000
@@ -41,9 +41,9 @@
41 void make_current() {}41 void make_current() {}
42 void release_current() {}42 void release_current() {}
43 void post_update() {}43 void post_update() {}
44 bool can_bypass() const override { return false; }
45 bool post_renderables_if_optimizable(graphics::RenderableList const&) { return false; }44 bool post_renderables_if_optimizable(graphics::RenderableList const&) { return false; }
46 MirOrientation orientation() const override { return mir_orientation_normal; }45 MirOrientation orientation() const override { return mir_orientation_normal; }
46 bool uses_alpha() const override { return false; };
47 void configure(graphics::DisplayConfigurationOutput const&) {} 47 void configure(graphics::DisplayConfigurationOutput const&) {}
48 graphics::DisplayConfigurationOutput configuration() const48 graphics::DisplayConfigurationOutput configuration() const
49 {49 {
5050
=== added file 'include/test/mir_test_doubles/stub_frame_dropping_policy_factory.h'
--- include/test/mir_test_doubles/stub_frame_dropping_policy_factory.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/stub_frame_dropping_policy_factory.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,58 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17 */
18
19
20#ifndef MIR_TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_
21#define MIR_TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_
22
23#include "mir/compositor/frame_dropping_policy_factory.h"
24#include "mir/compositor/frame_dropping_policy.h"
25
26namespace mc = mir::compositor;
27
28namespace mir
29{
30namespace test
31{
32namespace doubles
33{
34
35class StubFrameDroppingPolicy : public mc::FrameDroppingPolicy
36{
37public:
38 void swap_now_blocking()
39 {
40 }
41 void swap_unblocked()
42 {
43 }
44};
45
46class StubFrameDroppingPolicyFactory : public mc::FrameDroppingPolicyFactory
47{
48public:
49 std::unique_ptr<mc::FrameDroppingPolicy> create_policy(std::function<void(void)>) const override
50 {
51 return std::unique_ptr<mc::FrameDroppingPolicy>{new StubFrameDroppingPolicy};
52 }
53};
54
55}
56}
57}
58#endif // TEST_DOUBLES_STUB_FRAME_DROPPING_POLICY_FACTORY_H_
059
=== modified file 'include/test/mir_test_doubles/stub_renderable.h'
--- include/test/mir_test_doubles/stub_renderable.h 2014-05-22 16:50:25 +0000
+++ include/test/mir_test_doubles/stub_renderable.h 2014-06-18 17:25:24 +0000
@@ -22,6 +22,11 @@
22#include "mir_test_doubles/stub_buffer.h"22#include "mir_test_doubles/stub_buffer.h"
23#include <mir/graphics/renderable.h>23#include <mir/graphics/renderable.h>
24#include <memory>24#include <memory>
25#define GLM_FORCE_RADIANS
26#define GLM_PRECISION_MEDIUMP_FLOAT
27#include <glm/glm.hpp>
28#include <glm/gtc/matrix_transform.hpp>
29#include <glm/gtc/type_ptr.hpp>
2530
26namespace mir31namespace mir
27{32{
@@ -33,20 +38,26 @@
33class StubRenderable : public graphics::Renderable38class StubRenderable : public graphics::Renderable
34{39{
35public:40public:
41 StubRenderable(std::shared_ptr<graphics::Buffer> const& buffer, geometry::Rectangle const& rect)
42 : rect(rect),
43 stub_buffer(buffer)
44 {}
45
36 StubRenderable(geometry::Rectangle const& rect)46 StubRenderable(geometry::Rectangle const& rect)
37 : rect(rect)47 : StubRenderable(make_stub_buffer(rect), rect)
38 {}48 {}
49
39 StubRenderable() :50 StubRenderable() :
40 StubRenderable({{},{}})51 StubRenderable(make_stub_buffer({{},{}}), {{},{}})
41 {}52 {}
53
42 ID id() const override54 ID id() const override
43 {55 {
44 return this;56 return this;
45 }57 }
46 std::shared_ptr<graphics::Buffer> buffer() const override58 std::shared_ptr<graphics::Buffer> buffer() const override
47 {59 {
48 graphics::BufferProperties prop{rect.size, mir_pixel_format_abgr_8888, graphics::BufferUsage::hardware};60 return stub_buffer;
49 return std::make_shared<StubBuffer>(prop);
50 }61 }
51 bool alpha_enabled() const62 bool alpha_enabled() const
52 {63 {
@@ -79,10 +90,58 @@
79 }90 }
8091
81private:92private:
93 std::shared_ptr<graphics::Buffer> make_stub_buffer(geometry::Rectangle const& rect)
94 {
95 graphics::BufferProperties prop{
96 rect.size, mir_pixel_format_abgr_8888, graphics::BufferUsage::hardware};
97 return std::make_shared<StubBuffer>(prop);
98 }
99
82 glm::mat4 trans;100 glm::mat4 trans;
83 geometry::Rectangle const rect;101 geometry::Rectangle const rect;
84};102 std::shared_ptr<graphics::Buffer> const stub_buffer;
85103};
104
105struct StubTransformedRenderable : public StubRenderable
106{
107 glm::mat4 transformation() const override
108 {
109 glm::mat4 transform(1.0);
110 glm::vec3 vec(1.0, 0.0, 0.0);
111 transform = glm::rotate(transform, 33.0f, vec);
112 return transform;
113 }
114};
115
116//hopefully the alpha representation gets condensed at some point
117struct StubShapedRenderable : public StubRenderable
118{
119 bool shaped() const override
120 {
121 return true;
122 }
123};
124
125struct StubTranslucentRenderable : public StubRenderable
126{
127 bool alpha_enabled() const override
128 {
129 return true;
130 }
131};
132
133struct PlaneAlphaRenderable : public StubRenderable
134{
135 bool alpha_enabled() const override
136 {
137 return true;
138 }
139 float alpha() const override
140 {
141 //approx 99% alpha
142 return 1.0f - ( 3.0f / 1024.0f );
143 }
144};
86}145}
87}146}
88}147}
89148
=== modified file 'include/test/mir_test_doubles/stub_scene_session.h'
--- include/test/mir_test_doubles/stub_scene_session.h 2014-05-22 11:31:21 +0000
+++ include/test/mir_test_doubles/stub_scene_session.h 2014-06-18 17:25:24 +0000
@@ -30,6 +30,8 @@
3030
31struct StubSceneSession : public scene::Session31struct StubSceneSession : public scene::Session
32{32{
33 StubSceneSession(pid_t pid = -1) : pid(pid) {}
34
33 frontend::SurfaceId create_surface(scene::SurfaceCreationParameters const& /* params */) override35 frontend::SurfaceId create_surface(scene::SurfaceCreationParameters const& /* params */) override
34 {36 {
35 return frontend::SurfaceId{0};37 return frontend::SurfaceId{0};
@@ -45,9 +47,10 @@
45 {47 {
46 return std::string();48 return std::string();
47 }49 }
50
48 pid_t process_id() const override51 pid_t process_id() const override
49 {52 {
50 return -1;53 return pid;
51 }54 }
5255
53 void force_requests_to_complete() override56 void force_requests_to_complete() override
@@ -76,6 +79,16 @@
76 void set_lifecycle_state(MirLifecycleState /*state*/)79 void set_lifecycle_state(MirLifecycleState /*state*/)
77 {80 {
78 }81 }
82
83 void start_prompt_session() override
84 {
85 }
86
87 void stop_prompt_session() override
88 {
89 }
90
91 pid_t const pid;
79};92};
8093
81}94}
8295
=== modified file 'include/test/mir_test_doubles/stub_scene_surface.h'
--- include/test/mir_test_doubles/stub_scene_surface.h 2014-05-09 09:56:45 +0000
+++ include/test/mir_test_doubles/stub_scene_surface.h 2014-06-18 17:25:24 +0000
@@ -83,6 +83,10 @@
83 void remove_observer(std::weak_ptr<scene::SurfaceObserver> const&) override {}83 void remove_observer(std::weak_ptr<scene::SurfaceObserver> const&) override {}
8484
85 void set_reception_mode(input::InputReceptionMode mode) override { input_mode = mode; }85 void set_reception_mode(input::InputReceptionMode mode) override { input_mode = mode; }
86
87 void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& /* image */) {}
88 std::shared_ptr<graphics::CursorImage> cursor_image() { return {}; }
89
86 MirPixelFormat pixel_format() const override { return mir_pixel_format_xrgb_8888; }90 MirPixelFormat pixel_format() const override { return mir_pixel_format_xrgb_8888; }
8791
88 void swap_buffers(graphics::Buffer*, std::function<void(graphics::Buffer*)>) override {}92 void swap_buffers(graphics::Buffer*, std::function<void(graphics::Buffer*)>) override {}
8993
=== modified file 'include/test/mir_test_doubles/stub_shell.h'
--- include/test/mir_test_doubles/stub_shell.h 2014-04-15 05:31:19 +0000
+++ include/test/mir_test_doubles/stub_shell.h 2014-06-18 17:25:24 +0000
@@ -49,6 +49,25 @@
49 void handle_surface_created(std::shared_ptr<frontend::Session> const& /* session */) override49 void handle_surface_created(std::shared_ptr<frontend::Session> const& /* session */) override
50 {50 {
51 }51 }
52 std::shared_ptr<frontend::PromptSession> start_prompt_session_for(std::shared_ptr<frontend::Session> const& /* session */,
53 scene::PromptSessionCreationParameters const& /* params */)
54 {
55 return std::shared_ptr<frontend::PromptSession>();
56 }
57 void add_prompt_provider_process_for(
58 std::shared_ptr<frontend::PromptSession> const& /* prompt_session */,
59 pid_t /* process_id */)
60 {
61 }
62 void add_prompt_provider_for(
63 std::shared_ptr<frontend::PromptSession> const& /* prompt_session */,
64 std::shared_ptr<frontend::Session> const& /* session */)
65 {
66 }
67 void stop_prompt_session(std::shared_ptr<frontend::PromptSession> const& /* prompt_session */)
68 {
69 }
70
52 std::shared_ptr<StubSession> const stub_session;71 std::shared_ptr<StubSession> const stub_session;
53};72};
5473
5574
=== modified file 'include/test/mir_test_doubles/stub_swapping_gl_context.h'
--- include/test/mir_test_doubles/stub_swapping_gl_context.h 2014-02-21 16:51:45 +0000
+++ include/test/mir_test_doubles/stub_swapping_gl_context.h 2014-06-18 17:25:24 +0000
@@ -20,6 +20,7 @@
20#define MIR_TEST_DOUBLES_STUB_SWAPPING_GL_CONTEXT_H_20#define MIR_TEST_DOUBLES_STUB_SWAPPING_GL_CONTEXT_H_
2121
22#include "src/platform/graphics/android/gl_context.h"22#include "src/platform/graphics/android/gl_context.h"
23#include "stub_buffer.h"
2324
24namespace mir25namespace mir
25{26{
@@ -31,6 +32,10 @@
31struct StubSwappingGLContext : public graphics::android::SwappingGLContext32struct StubSwappingGLContext : public graphics::android::SwappingGLContext
32{33{
33 void swap_buffers() const {}34 void swap_buffers() const {}
35 std::shared_ptr<graphics::Buffer> last_rendered_buffer() const
36 {
37 return std::make_shared<StubBuffer>();
38 }
34};39};
3540
36}41}
3742
=== modified file 'include/test/mir_test_framework/in_process_server.h'
--- include/test/mir_test_framework/in_process_server.h 2014-03-06 06:05:17 +0000
+++ include/test/mir_test_framework/in_process_server.h 2014-06-18 17:25:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2013 Canonical Ltd.2 * Copyright © 2013-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,5 * under the terms of the GNU General Public License version 3,
@@ -19,6 +19,8 @@
19#ifndef MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_19#ifndef MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_
20#define MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_20#define MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_
2121
22#include "mir_test_framework/server_runner.h"
23
22#include <gtest/gtest.h>24#include <gtest/gtest.h>
2325
24#include <string>26#include <string>
@@ -34,29 +36,18 @@
34namespace mir_test_framework36namespace mir_test_framework
35{37{
36/// Fixture for running Mir server in test process38/// Fixture for running Mir server in test process
37struct InProcessServer : testing::Test39struct InProcessServer : testing::Test, private ServerRunner
38{40{
39 InProcessServer();
40 ~InProcessServer();
41
42 /// Starts the server41 /// Starts the server
43 /// \warning don't forget to call this if you override SetUp()42 /// \warning don't forget to call this if you override SetUp()
44 void SetUp() override;43 void SetUp() override { ServerRunner::start_server(); }
4544
46 /// Stops the server45 /// Stops the server
47 /// \warning don't forget to call this if you override TearDown()46 /// \warning don't forget to call this if you override TearDown()
48 void TearDown() override;47 void TearDown() override { ServerRunner::stop_server(); }
4948
50 /// \return a connection string for a new client to connect to the server49 /// \return a connection string for a new client to connect to the server
51 std::string new_connection();50 using ServerRunner::new_connection;
52
53private:
54 mir::DisplayServer* start_mir_server();
55 virtual mir::DefaultServerConfiguration& server_config() = 0;
56
57 char const* const old_env;
58 std::thread server_thread;
59 mir::DisplayServer* display_server = 0;
60};51};
61}52}
6253
6354
=== modified file 'include/test/mir_test_framework/input_testing_client_configuration.h'
--- include/test/mir_test_framework/input_testing_client_configuration.h 2014-05-26 14:41:49 +0000
+++ include/test/mir_test_framework/input_testing_client_configuration.h 2014-06-18 17:25:24 +0000
@@ -20,8 +20,7 @@
20#define MIR_TEST_FRAMEWORK_INPUT_TESTING_CLIENT_CONFIGURATION20#define MIR_TEST_FRAMEWORK_INPUT_TESTING_CLIENT_CONFIGURATION
2121
22#include "mir_test_framework/testing_client_configuration.h"22#include "mir_test_framework/testing_client_configuration.h"
23#include "mir_test_framework/cross_process_sync.h"23#include "mir_test/barrier.h"
24#include "mir_test/wait_condition.h"
2524
26#include <mir_toolkit/event.h>25#include <mir_toolkit/event.h>
2726
@@ -29,6 +28,7 @@
2928
30#include <string>29#include <string>
3130
31namespace mir { namespace test { class WaitCondition; } }
32namespace mir_test_framework32namespace mir_test_framework
33{33{
3434
@@ -38,7 +38,7 @@
38class InputTestingClientConfiguration : public TestingClientConfiguration38class InputTestingClientConfiguration : public TestingClientConfiguration
39{39{
40public:40public:
41 InputTestingClientConfiguration(std::string const& client_name, CrossProcessSync const& input_cb_setup_fence);41 InputTestingClientConfiguration(std::string const& client_name, mir::test::Barrier& input_cb_setup_fence);
42 virtual ~InputTestingClientConfiguration() = default;42 virtual ~InputTestingClientConfiguration() = default;
4343
44 void exec();44 void exec();
@@ -62,7 +62,7 @@
62 std::string connect_string;62 std::string connect_string;
63private:63private:
64 std::string const client_name;64 std::string const client_name;
65 CrossProcessSync input_cb_setup_fence;65 mir::test::Barrier& input_cb_setup_fence;
66};66};
6767
68}68}
6969
=== added file 'include/test/mir_test_framework/server_runner.h'
--- include/test/mir_test_framework/server_runner.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_framework/server_runner.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,60 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored By: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIR_TEST_FRAMEWORK_SERVER_RUNNER_H_
20#define MIR_TEST_FRAMEWORK_SERVER_RUNNER_H_
21
22#include <gtest/gtest.h>
23
24#include <string>
25#include <thread>
26
27namespace mir
28{
29class DisplayServer;
30class DefaultServerConfiguration;
31}
32
33namespace mir_test_framework
34{
35/// Utility for running Mir server in test process
36struct ServerRunner
37{
38 ServerRunner();
39 virtual ~ServerRunner();
40
41 /// Starts the server
42 void start_server();
43
44 /// Stops the server
45 void stop_server();
46
47 /// \return a connection string for a new client to connect to the server
48 std::string new_connection();
49
50private:
51 mir::DisplayServer* start_mir_server();
52 virtual mir::DefaultServerConfiguration& server_config() = 0;
53
54 char const* const old_env;
55 std::thread server_thread;
56 mir::DisplayServer* display_server = 0;
57};
58}
59
60#endif /* MIR_TEST_FRAMEWORK_SERVER_RUNNER_H_ */
061
=== modified file 'src/client/CMakeLists.txt'
--- src/client/CMakeLists.txt 2014-05-22 11:31:21 +0000
+++ src/client/CMakeLists.txt 2014-06-18 17:25:24 +0000
@@ -48,6 +48,9 @@
48 mir_screencast.cpp48 mir_screencast.cpp
49 mir_screencast_api.cpp49 mir_screencast_api.cpp
50 mir_cursor_api.cpp50 mir_cursor_api.cpp
51 mir_prompt_session.cpp
52 mir_prompt_session_api.cpp
53 mir_event_distributor.cpp
51)54)
5255
53add_library(56add_library(
@@ -82,7 +85,7 @@
82 mirclientlttngstatic85 mirclientlttngstatic
8386
84 ${MIR_COMMON_PLATFORM_LIBRARIES}87 ${MIR_COMMON_PLATFORM_LIBRARIES}
85 88
86 3rd_party89 3rd_party
87)90)
8891
8992
=== modified file 'src/client/connection_configuration.h'
--- src/client/connection_configuration.h 2014-03-06 06:05:17 +0000
+++ src/client/connection_configuration.h 2014-06-18 17:25:24 +0000
@@ -47,6 +47,8 @@
47class ClientPlatformFactory;47class ClientPlatformFactory;
48class DisplayConfiguration;48class DisplayConfiguration;
49class LifecycleControl;49class LifecycleControl;
50class EventSink;
51class EventHandlerRegister;
5052
51class ConnectionConfiguration53class ConnectionConfiguration
52{54{
@@ -60,6 +62,8 @@
60 virtual std::shared_ptr<input::receiver::InputPlatform> the_input_platform() = 0;62 virtual std::shared_ptr<input::receiver::InputPlatform> the_input_platform() = 0;
61 virtual std::shared_ptr<DisplayConfiguration> the_display_configuration() = 0;63 virtual std::shared_ptr<DisplayConfiguration> the_display_configuration() = 0;
62 virtual std::shared_ptr<LifecycleControl> the_lifecycle_control() = 0;64 virtual std::shared_ptr<LifecycleControl> the_lifecycle_control() = 0;
65 virtual std::shared_ptr<EventSink> the_event_sink() = 0;
66 virtual std::shared_ptr<EventHandlerRegister> the_event_handler_register() = 0;
6367
64protected:68protected:
65 ConnectionConfiguration() = default;69 ConnectionConfiguration() = default;
6670
=== modified file 'src/client/connection_surface_map.h'
--- src/client/connection_surface_map.h 2014-03-06 06:05:17 +0000
+++ src/client/connection_surface_map.h 2014-06-18 17:25:24 +0000
@@ -33,6 +33,7 @@
33{33{
34public:34public:
35 ConnectionSurfaceMap();35 ConnectionSurfaceMap();
36 ~ConnectionSurfaceMap() noexcept;
3637
37 void with_surface_do(int surface_id, std::function<void(MirSurface*)> exec) const override;38 void with_surface_do(int surface_id, std::function<void(MirSurface*)> exec) const override;
38 void insert(int surface_id, MirSurface* surface);39 void insert(int surface_id, MirSurface* surface);
3940
=== modified file 'src/client/default_connection_configuration.cpp'
--- src/client/default_connection_configuration.cpp 2014-03-26 05:48:59 +0000
+++ src/client/default_connection_configuration.cpp 2014-06-18 17:25:24 +0000
@@ -32,6 +32,7 @@
32#include "lifecycle_control.h"32#include "lifecycle_control.h"
33#include "mir/shared_library.h"33#include "mir/shared_library.h"
34#include "client_platform_factory.h"34#include "client_platform_factory.h"
35#include "mir_event_distributor.h"
3536
36namespace mcl = mir::client;37namespace mcl = mir::client;
3738
@@ -81,7 +82,7 @@
81 [this]82 [this]
82 {83 {
83 return mcl::rpc::make_rpc_channel(84 return mcl::rpc::make_rpc_channel(
84 the_socket_file(), the_surface_map(), the_display_configuration(), the_rpc_report(), the_lifecycle_control());85 the_socket_file(), the_surface_map(), the_display_configuration(), the_rpc_report(), the_lifecycle_control(), the_event_sink());
85 });86 });
86}87}
8788
@@ -182,3 +183,21 @@
182 return std::make_shared<mcl::LifecycleControl>();183 return std::make_shared<mcl::LifecycleControl>();
183 });184 });
184}185}
186
187std::shared_ptr<mcl::EventSink> mcl::DefaultConnectionConfiguration::the_event_sink()
188{
189 return event_distributor(
190 []
191 {
192 return std::make_shared<MirEventDistributor>();
193 });
194}
195
196std::shared_ptr<mcl::EventHandlerRegister> mcl::DefaultConnectionConfiguration::the_event_handler_register()
197{
198 return event_distributor(
199 []
200 {
201 return std::make_shared<MirEventDistributor>();
202 });
203}
185204
=== modified file 'src/client/default_connection_configuration.h'
--- src/client/default_connection_configuration.h 2014-03-06 06:05:17 +0000
+++ src/client/default_connection_configuration.h 2014-06-18 17:25:24 +0000
@@ -36,6 +36,7 @@
36}36}
37namespace client37namespace client
38{38{
39class EventDistributor;
3940
40namespace rpc41namespace rpc
41{42{
@@ -54,6 +55,8 @@
54 std::shared_ptr<input::receiver::InputPlatform> the_input_platform();55 std::shared_ptr<input::receiver::InputPlatform> the_input_platform();
55 std::shared_ptr<DisplayConfiguration> the_display_configuration();56 std::shared_ptr<DisplayConfiguration> the_display_configuration();
56 std::shared_ptr<LifecycleControl> the_lifecycle_control();57 std::shared_ptr<LifecycleControl> the_lifecycle_control();
58 std::shared_ptr<EventSink> the_event_sink();
59 std::shared_ptr<EventHandlerRegister> the_event_handler_register();
5760
58 virtual std::string the_socket_file();61 virtual std::string the_socket_file();
59 virtual std::shared_ptr<rpc::RpcReport> the_rpc_report();62 virtual std::shared_ptr<rpc::RpcReport> the_rpc_report();
@@ -67,6 +70,7 @@
67 CachedPtr<ConnectionSurfaceMap> surface_map;70 CachedPtr<ConnectionSurfaceMap> surface_map;
68 CachedPtr<DisplayConfiguration> display_configuration;71 CachedPtr<DisplayConfiguration> display_configuration;
69 CachedPtr<LifecycleControl> lifecycle_control;72 CachedPtr<LifecycleControl> lifecycle_control;
73 CachedPtr<EventDistributor> event_distributor;
7074
71 CachedPtr<rpc::RpcReport> rpc_report;75 CachedPtr<rpc::RpcReport> rpc_report;
72 CachedPtr<input::receiver::InputReceiverReport> input_receiver_report;76 CachedPtr<input::receiver::InputReceiverReport> input_receiver_report;
7377
=== added file 'src/client/event_distributor.h'
--- src/client/event_distributor.h 1970-01-01 00:00:00 +0000
+++ src/client/event_distributor.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_CLIENT_EVENT_DISTRIBUTOR_H_
20#define MIR_CLIENT_EVENT_DISTRIBUTOR_H_
21
22#include "event_sink.h"
23#include "event_handler_register.h"
24
25namespace mir
26{
27namespace client
28{
29
30class EventDistributor : public EventHandlerRegister, public EventSink
31{
32};
33
34} // namespace client
35} // namespace mir
36
37#endif // MIR_CLIENT_EVENT_DISTRIBUTOR_H_
038
=== added file 'src/client/event_handler_register.h'
--- src/client/event_handler_register.h 1970-01-01 00:00:00 +0000
+++ src/client/event_handler_register.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,47 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_CLIENT_EVENT_HANDLER_REGISTER_H_
20#define MIR_CLIENT_EVENT_HANDLER_REGISTER_H_
21
22#include "mir_toolkit/event.h"
23
24#include <functional>
25
26namespace mir
27{
28namespace client
29{
30
31class EventHandlerRegister
32{
33public:
34 virtual ~EventHandlerRegister() = default;
35
36 virtual int register_event_handler(std::function<void(MirEvent const&)> const&) = 0;
37 virtual void unregister_event_handler(int id) = 0;
38
39protected:
40 EventHandlerRegister() = default;
41 EventHandlerRegister(EventHandlerRegister const&) = delete;
42 EventHandlerRegister& operator=(EventHandlerRegister const&) = delete;
43};
44} // namespace client
45} // namespace mir
46
47#endif // MIR_CLIENT_EVENT_HANDLER_REGISTER_H_
048
=== added file 'src/client/event_sink.h'
--- src/client/event_sink.h 1970-01-01 00:00:00 +0000
+++ src/client/event_sink.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,44 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_CLIENT_EVENT_SINK_H_
20#define MIR_CLIENT_EVENT_SINK_H_
21
22#include "mir_toolkit/event.h"
23
24namespace mir
25{
26namespace client
27{
28
29class EventSink
30{
31public:
32 virtual ~EventSink() = default;
33
34 virtual void handle_event(MirEvent const& e) = 0;
35
36protected:
37 EventSink() = default;
38 EventSink(EventSink const&) = delete;
39 EventSink& operator=(EventSink const&) = delete;
40};
41} // namespace client
42} // namespace mir
43
44#endif // MIR_CLIENT_EVENT_SINK_H_
045
=== modified file 'src/client/logging/input_receiver_report.cpp'
--- src/client/logging/input_receiver_report.cpp 2014-03-06 06:05:17 +0000
+++ src/client/logging/input_receiver_report.cpp 2014-06-18 17:25:24 +0000
@@ -91,6 +91,7 @@
91 ss << " orientation: " << ev.pointer_coordinates[i].orientation << std::endl;91 ss << " orientation: " << ev.pointer_coordinates[i].orientation << std::endl;
92 ss << " vscroll: " << ev.pointer_coordinates[i].vscroll << std::endl;92 ss << " vscroll: " << ev.pointer_coordinates[i].vscroll << std::endl;
93 ss << " hscroll: " << ev.pointer_coordinates[i].hscroll << std::endl;93 ss << " hscroll: " << ev.pointer_coordinates[i].hscroll << std::endl;
94 ss << " tool_type: " << ev.pointer_coordinates[i].tool_type << std::endl;
94 ss << " }" << std::endl;95 ss << " }" << std::endl;
95 }96 }
96 ss << "}";97 ss << "}";
9798
=== modified file 'src/client/mir_connection.cpp'
--- src/client/mir_connection.cpp 2014-05-22 11:31:21 +0000
+++ src/client/mir_connection.cpp 2014-06-18 17:25:24 +0000
@@ -18,6 +18,7 @@
1818
19#include "mir_connection.h"19#include "mir_connection.h"
20#include "mir_surface.h"20#include "mir_surface.h"
21#include "mir_prompt_session.h"
21#include "client_platform.h"22#include "client_platform.h"
22#include "client_platform_factory.h"23#include "client_platform_factory.h"
23#include "rpc/mir_basic_rpc_channel.h"24#include "rpc/mir_basic_rpc_channel.h"
@@ -82,7 +83,8 @@
82 input_platform(conf.the_input_platform()),83 input_platform(conf.the_input_platform()),
83 display_configuration(conf.the_display_configuration()),84 display_configuration(conf.the_display_configuration()),
84 lifecycle_control(conf.the_lifecycle_control()),85 lifecycle_control(conf.the_lifecycle_control()),
85 surface_map(conf.the_surface_map())86 surface_map(conf.the_surface_map()),
87 event_handler_register(conf.the_event_handler_register())
86{88{
87 connect_result.set_error("connect not called");89 connect_result.set_error("connect not called");
88 {90 {
@@ -186,6 +188,7 @@
186 release_wait_handles.push_back(new_wait_handle);188 release_wait_handles.push_back(new_wait_handle);
187 }189 }
188190
191 new_wait_handle->expect_result();
189 server.release_surface(0, &message, &void_response,192 server.release_surface(0, &message, &void_response,
190 gp::NewCallback(this, &MirConnection::released, surf_release));193 gp::NewCallback(this, &MirConnection::released, surf_release));
191194
@@ -193,6 +196,11 @@
193 return new_wait_handle;196 return new_wait_handle;
194}197}
195198
199MirPromptSession* MirConnection::create_prompt_session()
200{
201 return new MirPromptSession(display_server(), event_handler_register);
202}
203
196namespace204namespace
197{205{
198void default_lifecycle_event_handler(MirLifecycleState transition)206void default_lifecycle_event_handler(MirLifecycleState transition)
@@ -272,6 +280,7 @@
272280
273MirWaitHandle* MirConnection::disconnect()281MirWaitHandle* MirConnection::disconnect()
274{282{
283 disconnect_wait_handle.expect_result();
275 server.disconnect(0, &ignored, &ignored,284 server.disconnect(0, &ignored, &ignored,
276 google::protobuf::NewCallback(this, &MirConnection::done_disconnect));285 google::protobuf::NewCallback(this, &MirConnection::done_disconnect));
277286
@@ -294,6 +303,7 @@
294 mir::protobuf::DRMMagic request;303 mir::protobuf::DRMMagic request;
295 request.set_magic(magic);304 request.set_magic(magic);
296305
306 drm_auth_magic_wait_handle.expect_result();
297 server.drm_auth_magic(307 server.drm_auth_magic(
298 0,308 0,
299 &request,309 &request,
@@ -304,40 +314,6 @@
304 return &drm_auth_magic_wait_handle;314 return &drm_auth_magic_wait_handle;
305}315}
306316
307MirWaitHandle* MirConnection::new_fds_for_trusted_clients(
308 unsigned int no_of_fds,
309 mir_client_fd_callback callback,
310 void * context)
311{
312 mir::protobuf::SocketFDRequest request;
313 request.set_number(no_of_fds);
314
315 server.new_fds_for_trusted_clients(
316 nullptr,
317 &request,
318 &socket_fd_response,
319 google::protobuf::NewCallback(this, &MirConnection::done_fds_for_trusted_clients,
320 callback, context));
321
322 return &fds_for_trusted_clients_wait_handle;
323}
324
325void MirConnection::done_fds_for_trusted_clients(
326 mir_client_fd_callback callback,
327 void* context)
328{
329 auto const size = socket_fd_response.fd_size();
330
331 std::vector<int> fds;
332 fds.reserve(size);
333
334 for (auto i = 0; i != size; ++i)
335 fds.push_back(socket_fd_response.fd(i));
336
337 callback(this, size, fds.data(), context);
338 fds_for_trusted_clients_wait_handle.result_received();
339}
340
341bool MirConnection::is_valid(MirConnection *connection)317bool MirConnection::is_valid(MirConnection *connection)
342{318{
343 {319 {
@@ -500,6 +476,7 @@
500 }476 }
501 }477 }
502478
479 configure_display_wait_handle.expect_result();
503 server.configure_display(0, &request, &display_configuration_response,480 server.configure_display(0, &request, &display_configuration_response,
504 google::protobuf::NewCallback(this, &MirConnection::done_display_configure));481 google::protobuf::NewCallback(this, &MirConnection::done_display_configure));
505482
@@ -522,6 +499,6 @@
522}499}
523500
524mir::protobuf::DisplayServer& MirConnection::display_server()501mir::protobuf::DisplayServer& MirConnection::display_server()
525{ 502{
526 return server;503 return server;
527}504}
528505
=== modified file 'src/client/mir_connection.h'
--- src/client/mir_connection.h 2014-05-22 11:31:21 +0000
+++ src/client/mir_connection.h 2014-06-18 17:25:24 +0000
@@ -45,6 +45,7 @@
45class ConnectionSurfaceMap;45class ConnectionSurfaceMap;
46class DisplayConfiguration;46class DisplayConfiguration;
47class LifecycleControl;47class LifecycleControl;
48class EventHandlerRegister;
4849
49namespace rpc50namespace rpc
50{51{
@@ -86,6 +87,8 @@
86 mir_surface_callback callback,87 mir_surface_callback callback,
87 void *context);88 void *context);
8889
90 MirPromptSession* create_prompt_session();
91
89 char const * get_error_message();92 char const * get_error_message();
9093
91 MirWaitHandle* connect(94 MirWaitHandle* connect(
@@ -123,11 +126,6 @@
123126
124 bool set_extra_platform_data(std::vector<int> const& extra_platform_data);127 bool set_extra_platform_data(std::vector<int> const& extra_platform_data);
125128
126 MirWaitHandle* new_fds_for_trusted_clients(
127 unsigned int no_of_fds,
128 mir_client_fd_callback callback,
129 void * context);
130
131 std::shared_ptr<google::protobuf::RpcChannel> rpc_channel() const129 std::shared_ptr<google::protobuf::RpcChannel> rpc_channel() const
132 {130 {
133 return channel;131 return channel;
@@ -147,7 +145,6 @@
147 mir::protobuf::ConnectParameters connect_parameters;145 mir::protobuf::ConnectParameters connect_parameters;
148 mir::protobuf::DRMAuthMagicStatus drm_auth_magic_status;146 mir::protobuf::DRMAuthMagicStatus drm_auth_magic_status;
149 mir::protobuf::DisplayConfiguration display_configuration_response;147 mir::protobuf::DisplayConfiguration display_configuration_response;
150 mir::protobuf::SocketFD socket_fd_response;
151148
152 std::shared_ptr<mir::client::ClientPlatformFactory> const client_platform_factory;149 std::shared_ptr<mir::client::ClientPlatformFactory> const client_platform_factory;
153 std::shared_ptr<mir::client::ClientPlatform> platform;150 std::shared_ptr<mir::client::ClientPlatform> platform;
@@ -161,7 +158,6 @@
161 MirWaitHandle disconnect_wait_handle;158 MirWaitHandle disconnect_wait_handle;
162 MirWaitHandle drm_auth_magic_wait_handle;159 MirWaitHandle drm_auth_magic_wait_handle;
163 MirWaitHandle configure_display_wait_handle;160 MirWaitHandle configure_display_wait_handle;
164 MirWaitHandle fds_for_trusted_clients_wait_handle;
165161
166 std::mutex release_wait_handle_guard;162 std::mutex release_wait_handle_guard;
167 std::vector<MirWaitHandle*> release_wait_handles;163 std::vector<MirWaitHandle*> release_wait_handles;
@@ -172,6 +168,8 @@
172168
173 std::shared_ptr<mir::client::ConnectionSurfaceMap> const surface_map;169 std::shared_ptr<mir::client::ConnectionSurfaceMap> const surface_map;
174170
171 std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register;
172
175 std::vector<int> extra_platform_data;173 std::vector<int> extra_platform_data;
176174
177 struct SurfaceRelease;175 struct SurfaceRelease;
@@ -181,7 +179,6 @@
181 void connected(mir_connected_callback callback, void * context);179 void connected(mir_connected_callback callback, void * context);
182 void released(SurfaceRelease );180 void released(SurfaceRelease );
183 void done_drm_auth_magic(mir_drm_auth_magic_callback callback, void* context);181 void done_drm_auth_magic(mir_drm_auth_magic_callback callback, void* context);
184 void done_fds_for_trusted_clients(mir_client_fd_callback callback, void* context);
185 bool validate_user_display_config(MirDisplayConfiguration* config);182 bool validate_user_display_config(MirDisplayConfiguration* config);
186};183};
187184
188185
=== modified file 'src/client/mir_connection_api.cpp'
--- src/client/mir_connection_api.cpp 2014-05-22 11:31:21 +0000
+++ src/client/mir_connection_api.cpp 2014-06-18 17:25:24 +0000
@@ -272,24 +272,6 @@
272 }272 }
273}273}
274274
275MirWaitHandle* mir_connection_new_fds_for_trusted_clients(
276 MirConnection* connection,
277 unsigned int no_of_fds,
278 mir_client_fd_callback callback,
279 void * context)
280{
281 try
282 {
283 return connection ?
284 connection->new_fds_for_trusted_clients(no_of_fds, callback, context) :
285 nullptr;
286 }
287 catch (std::exception const&)
288 {
289 return nullptr;
290 }
291}
292
293MirEGLNativeDisplayType mir_connection_get_egl_native_display(275MirEGLNativeDisplayType mir_connection_get_egl_native_display(
294 MirConnection* connection)276 MirConnection* connection)
295{277{
296278
=== added file 'src/client/mir_event_distributor.cpp'
--- src/client/mir_event_distributor.cpp 1970-01-01 00:00:00 +0000
+++ src/client/mir_event_distributor.cpp 2014-06-18 17:25:24 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#include "mir_event_distributor.h"
20
21MirEventDistributor::MirEventDistributor() :
22 next_fn_id{0}
23{
24}
25
26int MirEventDistributor::register_event_handler(std::function<void(MirEvent const&)> const& fn)
27{
28 std::unique_lock<decltype(mutex)> lock(mutex);
29
30 int id = ++next_fn_id;
31 event_handlers[id] = fn;
32 return id;
33}
34
35void MirEventDistributor::unregister_event_handler(int id)
36{
37 std::unique_lock<decltype(mutex)> lock(mutex);
38
39 event_handlers.erase(id);
40}
41
42void MirEventDistributor::handle_event(MirEvent const& event)
43{
44 std::unique_lock<decltype(mutex)> lock(mutex);
45
46 auto const event_handlers_copy(event_handlers);
47
48 for (auto const& handler : event_handlers_copy)
49 {
50 // Ensure handler wasn't unregistered since making copy
51 if (event_handlers.find(handler.first) != event_handlers.end())
52 {
53 handler.second(event);
54 }
55 }
56}
057
=== added file 'src/client/mir_event_distributor.h'
--- src/client/mir_event_distributor.h 1970-01-01 00:00:00 +0000
+++ src/client/mir_event_distributor.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_EVENT_DISTRIBUTOR_H
20
21#include "event_distributor.h"
22
23#include <mutex>
24#include <map>
25
26class MirEventDistributor : public mir::client::EventDistributor
27{
28public:
29 MirEventDistributor();
30 ~MirEventDistributor() = default;
31
32 int register_event_handler(std::function<void(MirEvent const&)> const&) override;
33 void unregister_event_handler(int id) override;
34
35 void handle_event(MirEvent const& event) override;
36
37private:
38 mutable std::recursive_mutex mutex;
39 std::map<int, std::function<void(MirEvent const&)>> event_handlers;
40 int next_fn_id;
41};
42
43#endif /* MIR_EVENT_DISTRIBUTOR_H */
044
=== added file 'src/client/mir_prompt_session.cpp'
--- src/client/mir_prompt_session.cpp 1970-01-01 00:00:00 +0000
+++ src/client/mir_prompt_session.cpp 2014-06-18 17:25:24 +0000
@@ -0,0 +1,203 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#include "mir_prompt_session.h"
20#include "event_handler_register.h"
21
22namespace mp = mir::protobuf;
23namespace mcl = mir::client;
24
25MirPromptSession::MirPromptSession(
26 mp::DisplayServer& server,
27 std::shared_ptr<mcl::EventHandlerRegister> const& event_handler_register) :
28 server(server),
29 event_handler_register(event_handler_register),
30 event_handler_register_id{event_handler_register->register_event_handler(
31 [this](MirEvent const& event)
32 {
33 if (event.type == mir_event_type_prompt_session_state_change)
34 set_state(event.prompt_session.new_state);
35 })},
36 state(mir_prompt_session_state_stopped),
37 handle_prompt_session_state_change{[](MirPromptSessionState){}}
38{
39}
40
41MirPromptSession::~MirPromptSession()
42{
43 set_state(mir_prompt_session_state_stopped);
44}
45
46void MirPromptSession::set_state(MirPromptSessionState new_state)
47{
48 std::lock_guard<decltype(event_handler_mutex)> lock(event_handler_mutex);
49
50 if (new_state != state)
51 {
52 handle_prompt_session_state_change(new_state);
53
54 if (new_state == mir_prompt_session_state_stopped)
55 {
56 event_handler_register->unregister_event_handler(event_handler_register_id);
57 }
58
59 state = new_state;
60 }
61}
62
63MirWaitHandle* MirPromptSession::start(pid_t application_pid, mir_prompt_session_callback callback, void* context)
64{
65 {
66 std::lock_guard<decltype(mutex)> lock(mutex);
67 parameters.set_application_pid(application_pid);
68 }
69
70 start_wait_handle.expect_result();
71 server.start_prompt_session(
72 0,
73 &parameters,
74 &session,
75 google::protobuf::NewCallback(this, &MirPromptSession::done_start,
76 callback, context));
77
78 return &start_wait_handle;
79}
80
81MirWaitHandle* MirPromptSession::stop(mir_prompt_session_callback callback, void* context)
82{
83 stop_wait_handle.expect_result();
84
85 server.stop_prompt_session(
86 0,
87 &protobuf_void,
88 &protobuf_void,
89 google::protobuf::NewCallback(this, &MirPromptSession::done_stop,
90 callback, context));
91
92 return &stop_wait_handle;
93}
94
95MirWaitHandle* MirPromptSession::add_prompt_provider(pid_t provider_pid,
96 mir_prompt_session_add_prompt_provider_callback callback,
97 void* context)
98{
99 {
100 std::lock_guard<decltype(mutex)> lock(mutex);
101 prompt_provider.set_pid(provider_pid);
102 }
103
104 add_result_wait_handle.expect_result();
105 server.add_prompt_provider(
106 0,
107 &prompt_provider,
108 &add_result,
109 google::protobuf::NewCallback(this, &MirPromptSession::done_add_prompt_provider,
110 callback, context));
111
112 return &add_result_wait_handle;
113}
114
115void MirPromptSession::register_prompt_session_state_change_callback(
116 mir_prompt_session_state_change_callback callback,
117 void* context)
118{
119 std::lock_guard<decltype(event_handler_mutex)> lock(event_handler_mutex);
120
121 handle_prompt_session_state_change =
122 [this, callback, context](MirPromptSessionState new_state)
123 {
124 callback(this, new_state, context);
125 };
126}
127
128void MirPromptSession::done_start(mir_prompt_session_callback callback, void* context)
129{
130 {
131 std::lock_guard<decltype(session_mutex)> lock(session_mutex);
132
133 state = session.has_error() ? mir_prompt_session_state_stopped : mir_prompt_session_state_started;
134 }
135
136 callback(this, context);
137 start_wait_handle.result_received();
138}
139
140void MirPromptSession::done_stop(mir_prompt_session_callback callback, void* context)
141{
142 set_state(mir_prompt_session_state_stopped);
143
144 callback(this, context);
145 stop_wait_handle.result_received();
146}
147
148void MirPromptSession::done_add_prompt_provider(mir_prompt_session_add_prompt_provider_callback callback, void* context)
149{
150 MirBool added = mir_true;
151 if (add_result.has_error())
152 {
153 added = mir_false;
154 }
155 callback(this, added, context);
156 add_result_wait_handle.result_received();
157}
158
159char const* MirPromptSession::get_error_message()
160{
161 std::lock_guard<decltype(session_mutex)> lock(session_mutex);
162
163 if (!session.has_error())
164 session.set_error(std::string{});
165
166 return session.error().c_str();
167}
168
169MirWaitHandle* MirPromptSession::new_fds_for_prompt_providers(
170 unsigned int no_of_fds,
171 mir_client_fd_callback callback,
172 void * context)
173{
174 mir::protobuf::SocketFDRequest request;
175 request.set_number(no_of_fds);
176
177 fds_for_prompt_providers_wait_handle.expect_result();
178
179 server.new_fds_for_prompt_providers(
180 nullptr,
181 &request,
182 &socket_fd_response,
183 google::protobuf::NewCallback(this, &MirPromptSession::done_fds_for_prompt_providers,
184 callback, context));
185
186 return &fds_for_prompt_providers_wait_handle;
187}
188
189void MirPromptSession::done_fds_for_prompt_providers(
190 mir_client_fd_callback callback,
191 void* context)
192{
193 auto const size = socket_fd_response.fd_size();
194
195 std::vector<int> fds;
196 fds.reserve(size);
197
198 for (auto i = 0; i != size; ++i)
199 fds.push_back(socket_fd_response.fd(i));
200
201 callback(this, size, fds.data(), context);
202 fds_for_prompt_providers_wait_handle.result_received();
203}
0204
=== added file 'src/client/mir_prompt_session.h'
--- src/client/mir_prompt_session.h 1970-01-01 00:00:00 +0000
+++ src/client/mir_prompt_session.h 2014-06-18 17:25:24 +0000
@@ -0,0 +1,94 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef MIR_CLIENT_MIR_PROMPT_SESSION_H_
20#define MIR_CLIENT_MIR_PROMPT_SESSION_H_
21
22#include "mir_toolkit/mir_client_library.h"
23
24#include "mir_protobuf.pb.h"
25#include "mir_wait_handle.h"
26
27#include <mutex>
28#include <memory>
29#include <atomic>
30
31namespace mir
32{
33/// The client-side library implementation namespace
34namespace client
35{
36class EventHandlerRegister;
37}
38}
39
40struct MirPromptSession
41{
42public:
43 MirPromptSession(mir::protobuf::DisplayServer& server,
44 std::shared_ptr<mir::client::EventHandlerRegister> const& event_handler_register);
45
46 ~MirPromptSession();
47
48 MirWaitHandle* start(pid_t application_pid, mir_prompt_session_callback callback, void* context);
49 MirWaitHandle* stop(mir_prompt_session_callback callback, void* context);
50 MirWaitHandle* add_prompt_provider(pid_t provider_pid, mir_prompt_session_add_prompt_provider_callback callback, void* context);
51
52 MirWaitHandle* new_fds_for_prompt_providers(
53 unsigned int no_of_fds,
54 mir_client_fd_callback callback,
55 void * context);
56
57 void register_prompt_session_state_change_callback(mir_prompt_session_state_change_callback callback, void* context);
58
59 char const* get_error_message();
60
61private:
62 std::mutex mutable mutex; // Protects parameters, wait_handles & results
63 mir::protobuf::DisplayServer& server;
64 mir::protobuf::PromptProvider prompt_provider;
65 mir::protobuf::PromptSessionParameters parameters;
66 mir::protobuf::Void add_result;
67 mir::protobuf::Void protobuf_void;
68 mir::protobuf::SocketFD socket_fd_response;
69 std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register;
70 int const event_handler_register_id;
71
72 MirWaitHandle start_wait_handle;
73 MirWaitHandle stop_wait_handle;
74 MirWaitHandle add_result_wait_handle;
75 MirWaitHandle fds_for_prompt_providers_wait_handle;
76 std::atomic<MirPromptSessionState> state;
77
78 std::mutex mutable session_mutex; // Protects session
79 mir::protobuf::Void session;
80
81 std::mutex mutable event_handler_mutex; // Need another mutex for callback access to members
82 std::function<void(MirPromptSessionState)> handle_prompt_session_state_change;
83
84 void set_state(MirPromptSessionState new_state);
85 void done_start(mir_prompt_session_callback callback, void* context);
86 void done_stop(mir_prompt_session_callback callback, void* context);
87 void done_add_prompt_provider(mir_prompt_session_add_prompt_provider_callback callback, void* context);
88 void done_fds_for_prompt_providers(mir_client_fd_callback callback, void* context);
89 MirPromptSession(MirPromptSession const&) = delete;
90 MirPromptSession& operator=(MirPromptSession const&) = delete;
91};
92
93#endif /* MIR_CLIENT_MIR_PROMPT_SESSION_H_ */
94
095
=== added file 'src/client/mir_prompt_session_api.cpp'
--- src/client/mir_prompt_session_api.cpp 1970-01-01 00:00:00 +0000
+++ src/client/mir_prompt_session_api.cpp 2014-06-18 17:25:24 +0000
@@ -0,0 +1,118 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19
20#include "mir_toolkit/mir_prompt_session.h"
21#include "mir_prompt_session.h"
22#include "mir_connection.h"
23
24#include <stdexcept>
25#include <boost/throw_exception.hpp>
26
27namespace
28{
29void null_callback(MirPromptSession*, void*) {}
30
31void add_prompt_provider_callback(
32 MirPromptSession*,
33 MirBool added,
34 void* context)
35{
36 if (context)
37 *(MirBool*)context = added;
38}
39
40}
41
42MirPromptSession *mir_connection_create_prompt_session_sync(
43 MirConnection* connection,
44 pid_t application_pid,
45 mir_prompt_session_state_change_callback state_change_callback,
46 void* context)
47{
48 try
49 {
50 auto prompt_session = connection->create_prompt_session();
51 if (state_change_callback)
52 prompt_session->register_prompt_session_state_change_callback(state_change_callback, context);
53
54 mir_wait_for(prompt_session->start(application_pid,
55 null_callback,
56 nullptr));
57 return prompt_session;
58 }
59 catch (std::exception const&)
60 {
61 // TODO callback with an error
62 return nullptr;
63 }
64}
65
66MirWaitHandle *mir_prompt_session_add_prompt_provider(
67 MirPromptSession *prompt_session,
68 pid_t provider_pid,
69 mir_prompt_session_add_prompt_provider_callback callback,
70 void* context)
71{
72 try
73 {
74 return prompt_session->add_prompt_provider(provider_pid, callback, context);
75 }
76 catch (std::exception const&)
77 {
78 // TODO callback with an error
79 return nullptr;
80 }
81}
82
83MirBool mir_prompt_session_add_prompt_provider_sync(
84 MirPromptSession *prompt_session,
85 pid_t provider_pid)
86{
87 MirBool result;
88 mir_wait_for(mir_prompt_session_add_prompt_provider(prompt_session,
89 provider_pid,
90 add_prompt_provider_callback,
91 &result));
92 return result;
93}
94
95MirWaitHandle* mir_prompt_session_new_fds_for_prompt_providers(
96 MirPromptSession *prompt_session,
97 unsigned int no_of_fds,
98 mir_client_fd_callback callback,
99 void * context)
100{
101 try
102 {
103 return prompt_session ?
104 prompt_session->new_fds_for_prompt_providers(no_of_fds, callback, context) :
105 nullptr;
106 }
107 catch (std::exception const&)
108 {
109 return nullptr;
110 }
111}
112
113void mir_prompt_session_release_sync(
114 MirPromptSession *prompt_session)
115{
116 mir_wait_for(prompt_session->stop(&null_callback, nullptr));
117 delete prompt_session;
118}
0119
=== modified file 'src/client/mir_screencast.cpp'
--- src/client/mir_screencast.cpp 2014-03-11 16:19:27 +0000
+++ src/client/mir_screencast.cpp 2014-06-18 17:25:24 +0000
@@ -102,6 +102,7 @@
102 parameters.set_height(output_size.height.as_uint32_t());102 parameters.set_height(output_size.height.as_uint32_t());
103 parameters.set_pixel_format(pixel_format);103 parameters.set_pixel_format(pixel_format);
104104
105 create_screencast_wait_handle.expect_result();
105 server.create_screencast(106 server.create_screencast(
106 nullptr,107 nullptr,
107 &parameters,108 &parameters,
@@ -143,6 +144,7 @@
143 mir::protobuf::ScreencastId screencast_id;144 mir::protobuf::ScreencastId screencast_id;
144 screencast_id.set_value(protobuf_screencast.screencast_id().value());145 screencast_id.set_value(protobuf_screencast.screencast_id().value());
145146
147 release_wait_handle.expect_result();
146 server.release_screencast(148 server.release_screencast(
147 nullptr,149 nullptr,
148 &screencast_id,150 &screencast_id,
@@ -159,6 +161,7 @@
159 mir::protobuf::ScreencastId screencast_id;161 mir::protobuf::ScreencastId screencast_id;
160 screencast_id.set_value(protobuf_screencast.screencast_id().value());162 screencast_id.set_value(protobuf_screencast.screencast_id().value());
161163
164 next_buffer_wait_handle.expect_result();
162 server.screencast_buffer(165 server.screencast_buffer(
163 nullptr,166 nullptr,
164 &screencast_id,167 &screencast_id,
165168
=== modified file 'src/client/mir_surface.cpp'
--- src/client/mir_surface.cpp 2014-05-23 07:25:58 +0000
+++ src/client/mir_surface.cpp 2014-06-18 17:25:24 +0000
@@ -62,6 +62,7 @@
62 message.set_buffer_usage(params.buffer_usage);62 message.set_buffer_usage(params.buffer_usage);
63 message.set_output_id(params.output_id);63 message.set_output_id(params.output_id);
6464
65 create_wait_handle.expect_result();
65 server.create_surface(0, &message, &surface, gp::NewCallback(this, &MirSurface::created, callback, context));66 server.create_surface(0, &message, &surface, gp::NewCallback(this, &MirSurface::created, callback, context));
6667
67 for (int i = 0; i < mir_surface_attribs; i++)68 for (int i = 0; i < mir_surface_attribs; i++)
@@ -76,6 +77,11 @@
7677
77MirSurface::~MirSurface()78MirSurface::~MirSurface()
78{79{
80 {
81 std::lock_guard<decltype(handle_mutex)> lock(handle_mutex);
82 valid_surfaces.erase(this);
83 }
84
79 std::lock_guard<decltype(mutex)> lock(mutex);85 std::lock_guard<decltype(mutex)> lock(mutex);
8086
81 if (input_thread)87 if (input_thread)
@@ -158,6 +164,7 @@
158 auto const mutable_buffer = surface.mutable_buffer();164 auto const mutable_buffer = surface.mutable_buffer();
159 lock.unlock();165 lock.unlock();
160166
167 next_buffer_wait_handle.expect_result();
161 server.next_buffer(168 server.next_buffer(
162 0,169 0,
163 id,170 id,
@@ -243,8 +250,10 @@
243 mir_surface_callback callback,250 mir_surface_callback callback,
244 void * context)251 void * context)
245{252{
246 std::lock_guard<decltype(handle_mutex)> lock(handle_mutex);253 {
247 valid_surfaces.erase(this);254 std::lock_guard<decltype(handle_mutex)> lock(handle_mutex);
255 valid_surfaces.erase(this);
256 }
248257
249 return connection->release_surface(this, callback, context);258 return connection->release_surface(this, callback, context);
250}259}
@@ -323,7 +332,7 @@
323 332
324 configure_cursor_wait_handle.expect_result();333 configure_cursor_wait_handle.expect_result();
325 server.configure_cursor(0, &setting, &void_response,334 server.configure_cursor(0, &setting, &void_response,
326 google::protobuf::NewCallback(this, &MirSurface::on_configured));335 google::protobuf::NewCallback(this, &MirSurface::on_cursor_configured));
327 336
328 return &configure_cursor_wait_handle;337 return &configure_cursor_wait_handle;
329}338}
@@ -375,6 +384,12 @@
375 }384 }
376}385}
377386
387void MirSurface::on_cursor_configured()
388{
389 configure_cursor_wait_handle.result_received();
390}
391
392
378int MirSurface::attrib(MirSurfaceAttrib at) const393int MirSurface::attrib(MirSurfaceAttrib at) const
379{394{
380 std::lock_guard<decltype(mutex)> lock(mutex);395 std::lock_guard<decltype(mutex)> lock(mutex);
381396
=== modified file 'src/client/mir_surface.h'
--- src/client/mir_surface.h 2014-05-23 07:25:58 +0000
+++ src/client/mir_surface.h 2014-06-18 17:25:24 +0000
@@ -102,6 +102,7 @@
102 mutable std::mutex mutex; // Protects all members of *this102 mutable std::mutex mutex; // Protects all members of *this
103103
104 void on_configured();104 void on_configured();
105 void on_cursor_configured();
105 void process_incoming_buffer();106 void process_incoming_buffer();
106 void populate(MirBufferPackage& buffer_package);107 void populate(MirBufferPackage& buffer_package);
107 void created(mir_surface_callback callback, void * context);108 void created(mir_surface_callback callback, void * context);
108109
=== modified file 'src/client/mir_wait_handle.cpp'
--- src/client/mir_wait_handle.cpp 2013-10-03 03:44:08 +0000
+++ src/client/mir_wait_handle.cpp 2014-06-18 17:25:24 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,5 * under the terms of the GNU Lesser General Public License version 3,
@@ -33,14 +33,14 @@
3333
34void MirWaitHandle::expect_result()34void MirWaitHandle::expect_result()
35{35{
36 std::unique_lock<std::mutex> lock(guard);36 std::lock_guard<std::mutex> lock(guard);
3737
38 expecting++;38 expecting++;
39}39}
4040
41void MirWaitHandle::result_received()41void MirWaitHandle::result_received()
42{42{
43 std::unique_lock<std::mutex> lock(guard);43 std::lock_guard<std::mutex> lock(guard);
4444
45 received++;45 received++;
46 wait_condition.notify_all();46 wait_condition.notify_all();
@@ -50,8 +50,7 @@
50{50{
51 std::unique_lock<std::mutex> lock(guard);51 std::unique_lock<std::mutex> lock(guard);
5252
53 while ((!expecting && !received) || (received < expecting))53 wait_condition.wait(lock, [&]{ return received == expecting; });
54 wait_condition.wait(lock);
5554
56 received = 0;55 received = 0;
57 expecting = 0;56 expecting = 0;
@@ -59,14 +58,9 @@
5958
60void MirWaitHandle::wait_for_pending(std::chrono::milliseconds limit)59void MirWaitHandle::wait_for_pending(std::chrono::milliseconds limit)
61{60{
62 using std::chrono::steady_clock;
63
64 std::unique_lock<std::mutex> lock(guard);61 std::unique_lock<std::mutex> lock(guard);
6562
66 auto time_limit = steady_clock::now() + limit;63 wait_condition.wait_for(lock, limit, [&]{ return received == expecting; });
67
68 while (received < expecting && steady_clock::now() < time_limit)
69 wait_condition.wait_until(lock, time_limit);
70}64}
7165
7266
@@ -74,11 +68,9 @@
74{68{
75 std::unique_lock<std::mutex> lock(guard);69 std::unique_lock<std::mutex> lock(guard);
7670
77 while (received == 0)71 wait_condition.wait(lock, [&]{ return received != 0; });
78 wait_condition.wait(lock);
7972
80 received--;73 --received;
81 if (expecting > 0)74 --expecting;
82 expecting--;
83}75}
8476
8577
=== modified file 'src/client/rpc/make_rpc_channel.h'
--- src/client/rpc/make_rpc_channel.h 2014-03-06 06:05:17 +0000
+++ src/client/rpc/make_rpc_channel.h 2014-06-18 17:25:24 +0000
@@ -29,6 +29,7 @@
29class SurfaceMap;29class SurfaceMap;
30class DisplayConfiguration;30class DisplayConfiguration;
31class LifecycleControl;31class LifecycleControl;
32class EventSink;
3233
33namespace rpc34namespace rpc
34{35{
@@ -39,7 +40,8 @@
39 std::shared_ptr<SurfaceMap> const& map,40 std::shared_ptr<SurfaceMap> const& map,
40 std::shared_ptr<DisplayConfiguration> const& disp_conf,41 std::shared_ptr<DisplayConfiguration> const& disp_conf,
41 std::shared_ptr<RpcReport> const& rpc_report,42 std::shared_ptr<RpcReport> const& rpc_report,
42 std::shared_ptr<LifecycleControl> const& lifecycle_control);43 std::shared_ptr<LifecycleControl> const& lifecycle_control,
44 std::shared_ptr<EventSink> const& event_distributor);
43}45}
44}46}
45}47}
4648
=== modified file 'src/client/rpc/make_socket_rpc_channel.cpp'
--- src/client/rpc/make_socket_rpc_channel.cpp 2014-03-06 06:05:17 +0000
+++ src/client/rpc/make_socket_rpc_channel.cpp 2014-06-18 17:25:24 +0000
@@ -44,13 +44,14 @@
44 std::shared_ptr<mcl::SurfaceMap> const& map,44 std::shared_ptr<mcl::SurfaceMap> const& map,
45 std::shared_ptr<mcl::DisplayConfiguration> const& disp_conf,45 std::shared_ptr<mcl::DisplayConfiguration> const& disp_conf,
46 std::shared_ptr<RpcReport> const& rpc_report,46 std::shared_ptr<RpcReport> const& rpc_report,
47 std::shared_ptr<mcl::LifecycleControl> const& lifecycle_control)47 std::shared_ptr<mcl::LifecycleControl> const& lifecycle_control,
48 std::shared_ptr<mcl::EventSink> const& event_sink)
48{49{
49 if (fd_prefix.is_start_of(name))50 if (fd_prefix.is_start_of(name))
50 {51 {
51 auto const fd = atoi(name.c_str()+fd_prefix.size);52 auto const fd = atoi(name.c_str()+fd_prefix.size);
52 return std::make_shared<MirSocketRpcChannel>(fd, map, disp_conf, rpc_report, lifecycle_control);53 return std::make_shared<MirSocketRpcChannel>(fd, map, disp_conf, rpc_report, lifecycle_control, event_sink);
53 }54 }
5455
55 return std::make_shared<MirSocketRpcChannel>(name, map, disp_conf, rpc_report, lifecycle_control);56 return std::make_shared<MirSocketRpcChannel>(name, map, disp_conf, rpc_report, lifecycle_control, event_sink);
56}57}
5758
=== modified file 'src/client/rpc/mir_socket_rpc_channel.cpp'
--- src/client/rpc/mir_socket_rpc_channel.cpp 2014-05-22 12:41:12 +0000
+++ src/client/rpc/mir_socket_rpc_channel.cpp 2014-06-18 17:25:24 +0000
@@ -24,6 +24,7 @@
24#include "../mir_surface.h"24#include "../mir_surface.h"
25#include "../display_configuration.h"25#include "../display_configuration.h"
26#include "../lifecycle_control.h"26#include "../lifecycle_control.h"
27#include "../event_sink.h"
27#include "mir/variable_length_array.h"28#include "mir/variable_length_array.h"
2829
29#include "mir_protobuf.pb.h" // For Buffer frig30#include "mir_protobuf.pb.h" // For Buffer frig
@@ -50,7 +51,8 @@
50 std::shared_ptr<mcl::SurfaceMap> const& surface_map,51 std::shared_ptr<mcl::SurfaceMap> const& surface_map,
51 std::shared_ptr<DisplayConfiguration> const& disp_config,52 std::shared_ptr<DisplayConfiguration> const& disp_config,
52 std::shared_ptr<RpcReport> const& rpc_report,53 std::shared_ptr<RpcReport> const& rpc_report,
53 std::shared_ptr<LifecycleControl> const& lifecycle_control) :54 std::shared_ptr<LifecycleControl> const& lifecycle_control,
55 std::shared_ptr<EventSink> const& event_sink) :
54 rpc_report(rpc_report),56 rpc_report(rpc_report),
55 pending_calls(rpc_report),57 pending_calls(rpc_report),
56 work(io_service),58 work(io_service),
@@ -58,6 +60,7 @@
58 surface_map(surface_map),60 surface_map(surface_map),
59 display_configuration(disp_config),61 display_configuration(disp_config),
60 lifecycle_control(lifecycle_control),62 lifecycle_control(lifecycle_control),
63 event_sink(event_sink),
61 disconnected(false)64 disconnected(false)
62{65{
63 socket.connect(endpoint);66 socket.connect(endpoint);
@@ -69,7 +72,8 @@
69 std::shared_ptr<mcl::SurfaceMap> const& surface_map,72 std::shared_ptr<mcl::SurfaceMap> const& surface_map,
70 std::shared_ptr<DisplayConfiguration> const& disp_config,73 std::shared_ptr<DisplayConfiguration> const& disp_config,
71 std::shared_ptr<RpcReport> const& rpc_report,74 std::shared_ptr<RpcReport> const& rpc_report,
72 std::shared_ptr<LifecycleControl> const& lifecycle_control) :75 std::shared_ptr<LifecycleControl> const& lifecycle_control,
76 std::shared_ptr<EventSink> const& event_sink) :
73 rpc_report(rpc_report),77 rpc_report(rpc_report),
74 pending_calls(rpc_report),78 pending_calls(rpc_report),
75 work(io_service),79 work(io_service),
@@ -77,6 +81,7 @@
77 surface_map(surface_map),81 surface_map(surface_map),
78 display_configuration(disp_config),82 display_configuration(disp_config),
79 lifecycle_control(lifecycle_control),83 lifecycle_control(lifecycle_control),
84 event_sink(event_sink),
80 disconnected(false)85 disconnected(false)
81{86{
82 socket.assign(boost::asio::local::stream_protocol(), native_socket);87 socket.assign(boost::asio::local::stream_protocol(), native_socket);
@@ -413,11 +418,25 @@
413418
414 rpc_report->event_parsing_succeeded(e);419 rpc_report->event_parsing_succeeded(e);
415420
416 surface_map->with_surface_do(e.surface.id,421 event_sink->handle_event(e);
417 [&e](MirSurface* surface)422
418 {423 // todo - surfaces should register with the event handler register.
419 surface->handle_event(e);424 if (e.type == mir_event_type_surface)
420 });425 {
426 surface_map->with_surface_do(e.surface.id,
427 [&e](MirSurface* surface)
428 {
429 surface->handle_event(e);
430 });
431 }
432 else if (e.type == mir_event_type_resize)
433 {
434 surface_map->with_surface_do(e.resize.surface_id,
435 [&e](MirSurface* surface)
436 {
437 surface->handle_event(e);
438 });
439 }
421 }440 }
422 else441 else
423 {442 {
424443
=== modified file 'src/client/rpc/mir_socket_rpc_channel.h'
--- src/client/rpc/mir_socket_rpc_channel.h 2014-05-07 02:56:33 +0000
+++ src/client/rpc/mir_socket_rpc_channel.h 2014-06-18 17:25:24 +0000
@@ -44,6 +44,7 @@
44class DisplayConfiguration;44class DisplayConfiguration;
45class SurfaceMap;45class SurfaceMap;
46class LifecycleControl;46class LifecycleControl;
47class EventSink;
47namespace rpc48namespace rpc
48{49{
4950
@@ -56,13 +57,15 @@
56 std::shared_ptr<SurfaceMap> const& surface_map,57 std::shared_ptr<SurfaceMap> const& surface_map,
57 std::shared_ptr<DisplayConfiguration> const& disp_config,58 std::shared_ptr<DisplayConfiguration> const& disp_config,
58 std::shared_ptr<RpcReport> const& rpc_report,59 std::shared_ptr<RpcReport> const& rpc_report,
59 std::shared_ptr<LifecycleControl> const& lifecycle_control);60 std::shared_ptr<LifecycleControl> const& lifecycle_control,
61 std::shared_ptr<EventSink> const& event_sink);
6062
61 MirSocketRpcChannel(int native_socket,63 MirSocketRpcChannel(int native_socket,
62 std::shared_ptr<SurfaceMap> const& surface_map,64 std::shared_ptr<SurfaceMap> const& surface_map,
63 std::shared_ptr<DisplayConfiguration> const& disp_config,65 std::shared_ptr<DisplayConfiguration> const& disp_config,
64 std::shared_ptr<RpcReport> const& rpc_report,66 std::shared_ptr<RpcReport> const& rpc_report,
65 std::shared_ptr<LifecycleControl> const& lifecycle_control);67 std::shared_ptr<LifecycleControl> const& lifecycle_control,
68 std::shared_ptr<EventSink> const& event_sink);
66 ~MirSocketRpcChannel();69 ~MirSocketRpcChannel();
6770
68private:71private:
@@ -102,6 +105,7 @@
102 std::shared_ptr<SurfaceMap> surface_map;105 std::shared_ptr<SurfaceMap> surface_map;
103 std::shared_ptr<DisplayConfiguration> display_configuration;106 std::shared_ptr<DisplayConfiguration> display_configuration;
104 std::shared_ptr<LifecycleControl> lifecycle_control;107 std::shared_ptr<LifecycleControl> lifecycle_control;
108 std::shared_ptr<EventSink> event_sink;
105 std::atomic<bool> disconnected;109 std::atomic<bool> disconnected;
106};110};
107111
108112
=== modified file 'src/client/surface_map.cpp'
--- src/client/surface_map.cpp 2014-03-06 06:05:17 +0000
+++ src/client/surface_map.cpp 2014-06-18 17:25:24 +0000
@@ -17,8 +17,10 @@
17 */17 */
1818
19#include "connection_surface_map.h"19#include "connection_surface_map.h"
20#include "mir_surface.h"
21
22#include <boost/throw_exception.hpp>
20#include <sstream>23#include <sstream>
21#include <boost/throw_exception.hpp>
2224
23namespace mcl=mir::client;25namespace mcl=mir::client;
2426
@@ -26,10 +28,23 @@
26{28{
27}29}
2830
31mcl::ConnectionSurfaceMap::~ConnectionSurfaceMap() noexcept
32{
33 // Unless the client has screwed up there should be no surfaces left
34 // here. (OTOH *we* don't need to leak memory when clients screw up.)
35 std::lock_guard<std::mutex> lk(guard);
36
37 for (auto const& surface :surfaces)
38 {
39 if (MirSurface::is_valid(surface.second))
40 delete surface.second;
41 }
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches