Mir

Merge lp:~andreas-pokorny/mir/reworked-external-output-centering-integration-branch into lp:mir

Proposed by Andreas Pokorny
Status: Work in progress
Proposed branch: lp:~andreas-pokorny/mir/reworked-external-output-centering-integration-branch
Merge into: lp:mir
Diff against target: 62199 lines (+12134/-27251)
820 files modified
3rd_party/CMakeLists.txt (+13/-1)
3rd_party/android-deps/std/Thread.h (+1/-4)
3rd_party/android-input/android/CMakeLists.txt (+4/-4)
3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp (+8/-41)
3rd_party/android-input/android/frameworks/base/services/input/EventHub.h (+12/-20)
3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp (+1/-11)
3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.h (+0/-2)
3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp (+22/-6)
3rd_party/android-input/android/frameworks/base/services/input/MirLog.cpp (+3/-5)
3rd_party/android-input/android/frameworks/base/services/input/PointerController.cpp (+5/-0)
3rd_party/android-input/android/frameworks/base/services/input/PointerController.h (+4/-0)
3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp (+1/-1)
3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp (+29/-34)
3rd_party/xcursor/CMakeLists.txt (+1/-1)
CMakeLists.txt (+11/-18)
benchmarks/android-input/CMakeLists.txt (+2/-2)
benchmarks/benchmark_multiplexing_dispatchable.cpp (+1/-0)
benchmarks/frame-uniformity/CMakeLists.txt (+9/-5)
benchmarks/frame-uniformity/main.cpp (+7/-8)
benchmarks/frame-uniformity/touch_measuring_client.cpp (+13/-9)
benchmarks/frame-uniformity/touch_measuring_client.h (+5/-0)
benchmarks/frame-uniformity/touch_producing_server.cpp (+2/-2)
benchmarks/frame-uniformity/touch_samples.cpp (+15/-18)
benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp (+19/-22)
cmake/ABICheck.cmake (+2/-12)
cmake/FindGtestGmock.cmake (+0/-2)
cmake/MirCommon.cmake (+118/-89)
cmake/src/mir/CMakeLists.txt (+10/-0)
cmake/src/mir/mir_discover_gtest_tests.cpp (+405/-0)
debian/changelog (+11/-166)
debian/control (+14/-13)
debian/libmirclient-debug-extension1.install (+1/-1)
debian/libmirclient-dev.install (+0/-3)
debian/libmircommon3.install (+1/-1)
debian/libmirserver30.install (+1/-1)
debian/mir-demos.install (+1/-2)
debian/mir-platform-graphics-android1.install (+1/-1)
debian/mir-platform-graphics-mesa1.install (+1/-1)
debian/mir-test-tools.install (+0/-2)
debian/rules (+8/-2)
doc/component_reports.md (+13/-17)
doc/demo_shell_controls.md (+0/-1)
doc/footer.html.in (+1/-1)
doc/mainpage.md (+2/-8)
examples/CMakeLists.txt (+7/-57)
examples/animated_cursor_demo_client.c (+0/-90)
examples/demo_client_display_config.c (+6/-5)
examples/eglapp.c (+13/-18)
examples/eglsquare.cpp (+0/-417)
examples/fingerpaint.c (+55/-60)
examples/mir_demo_server_loader.cpp (+0/-46)
examples/multiwin.c (+5/-12)
examples/progressbar.c (+6/-12)
examples/render_overlays.cpp (+6/-10)
examples/render_surfaces.cpp (+16/-25)
examples/render_to_fb.cpp (+10/-14)
examples/server_example.cpp (+5/-9)
examples/server_example_adorning_compositor.cpp (+0/-163)
examples/server_example_adorning_compositor.h (+0/-82)
examples/server_example_basic_window_manager.h (+42/-149)
examples/server_example_canonical_window_manager.cpp (+0/-948)
examples/server_example_canonical_window_manager.h (+0/-157)
examples/server_example_custom_compositor.cpp (+0/-103)
examples/server_example_custom_compositor.h (+0/-33)
examples/server_example_fullscreen_placement_strategy.cpp (+63/-0)
examples/server_example_fullscreen_placement_strategy.h (+57/-0)
examples/server_example_generic_shell.cpp (+125/-0)
examples/server_example_generic_shell.h (+73/-0)
examples/server_example_input_event_filter.cpp (+4/-4)
examples/server_example_input_filter.cpp (+16/-14)
examples/server_example_shell.cpp (+153/-0)
examples/server_example_shell.h (+66/-0)
examples/server_example_test_client.cpp (+5/-6)
examples/server_example_tiling_window_manager.cpp (+56/-103)
examples/server_example_tiling_window_manager.h (+9/-20)
examples/server_example_window_management.cpp (+82/-114)
examples/server_example_window_manager.h (+15/-27)
examples/target.c (+0/-342)
examples/tooltip.c (+5/-18)
include/client/mir/event_printer.h (+0/-54)
include/client/mir_toolkit/events/input_configuration_event.h (+0/-78)
include/client/mir_toolkit/events/keymap_event.h (+0/-48)
include/client/mir_toolkit/mir_buffer_stream.h (+9/-89)
include/client/mir_toolkit/mir_client_library.h (+0/-1)
include/client/mir_toolkit/mir_client_library_drm.h (+2/-4)
include/client/mir_toolkit/mir_cursor_configuration.h (+0/-14)
include/client/mir_toolkit/mir_surface.h (+4/-122)
include/common/mir/dispatch/action_queue.h (+0/-53)
include/common/mir/dispatch/multiplexing_dispatchable.h (+2/-0)
include/common/mir/dispatch/simple_dispatch_thread.h (+0/-2)
include/common/mir/events/event_builders.h (+10/-11)
include/common/mir/flags.h (+0/-161)
include/common/mir/frontend/buffer_stream_id.h (+0/-33)
include/common/mir/geometry/dimensions.h (+17/-29)
include/common/mir/geometry/displacement.h (+0/-5)
include/common/mir/geometry/overrides.h (+92/-0)
include/common/mir/geometry/point.h (+0/-9)
include/common/mir/input/input_platform.h (+8/-13)
include/common/mir/input/input_receiver_thread.h (+48/-0)
include/common/mir/module_deleter.h (+0/-105)
include/common/mir/optional_value.h (+1/-4)
include/common/mir_toolkit/client_types.h (+20/-3)
include/common/mir_toolkit/common.h (+2/-0)
include/common/mir_toolkit/cursors.h (+0/-6)
include/common/mir_toolkit/events/event.h (+10/-27)
include/common/mir_toolkit/events/event_deprecated.h (+79/-38)
include/common/mir_toolkit/events/input/input_event.h (+12/-12)
include/common/mir_toolkit/events/input/key_input_event.h (+14/-23)
include/common/mir_toolkit/events/input/pointer_input_event.h (+27/-27)
include/common/mir_toolkit/events/input/touch_input_event.h (+27/-27)
include/platform/mir/graphics/buffer.h (+3/-8)
include/platform/mir/graphics/cursor.h (+2/-0)
include/platform/mir/graphics/display.h (+2/-33)
include/platform/mir/graphics/display_buffer.h (+28/-0)
include/platform/mir/graphics/platform.h (+14/-17)
include/platform/mir/graphics/renderable.h (+3/-2)
include/platform/mir/input/device_capability.h (+0/-51)
include/platform/mir/input/input_device.h (+0/-65)
include/platform/mir/input/input_device_info.h (+0/-42)
include/platform/mir/input/input_device_registry.h (+0/-48)
include/platform/mir/input/input_sink.h (+0/-54)
include/platform/mir/input/platform.h (+0/-143)
include/server/mir/compositor/display_listener.h (+0/-43)
include/server/mir/frontend/buffer_stream.h (+0/-66)
include/server/mir/frontend/session.h (+0/-7)
include/server/mir/frontend/surface.h (+2/-8)
include/server/mir/input/input_device_hub.h (+0/-47)
include/server/mir/input/input_device_observer.h (+0/-49)
include/server/mir/input/input_dispatcher.h (+8/-0)
include/server/mir/input/input_manager.h (+0/-4)
include/server/mir/input/input_region.h (+7/-0)
include/server/mir/lockable_callback.h (+0/-40)
include/server/mir/main_loop.h (+3/-3)
include/server/mir/scene/null_surface_observer.h (+0/-2)
include/server/mir/scene/session.h (+0/-6)
include/server/mir/scene/surface.h (+4/-4)
include/server/mir/scene/surface_configurator.h (+54/-0)
include/server/mir/scene/surface_coordinator.h (+2/-15)
include/server/mir/scene/surface_creation_parameters.h (+0/-10)
include/server/mir/scene/surface_observer.h (+0/-3)
include/server/mir/server.h (+13/-14)
include/server/mir/shell/abstract_shell.h (+20/-33)
include/server/mir/shell/focus_controller.h (+4/-18)
include/server/mir/shell/input_targeter.h (+3/-3)
include/server/mir/shell/shell.h (+4/-12)
include/server/mir/shell/shell_wrapper.h (+7/-20)
include/server/mir/shell/surface_ready_observer.h (+0/-58)
include/server/mir/shell/surface_specification.h (+0/-74)
include/server/mir/shell/window_manager_builder.h (+0/-37)
include/server/mir/time/timer.h (+39/-14)
playground/demo-shell/CMakeLists.txt (+0/-3)
playground/demo-shell/demo_compositor.cpp (+18/-11)
playground/demo-shell/demo_renderer.cpp (+14/-53)
playground/demo-shell/demo_renderer.h (+5/-11)
playground/demo-shell/demo_shell.cpp (+32/-43)
playground/demo-shell/typo/CMakeLists.txt (+0/-25)
playground/demo-shell/typo/typo_freetype_renderer.cpp (+0/-125)
playground/demo-shell/typo/typo_freetype_renderer.h (+0/-44)
playground/demo-shell/typo/typo_glcache.cpp (+0/-98)
playground/demo-shell/typo/typo_glcache.h (+0/-56)
playground/demo-shell/typo/typo_renderer.cpp (+0/-58)
playground/demo-shell/typo/typo_renderer.h (+0/-47)
playground/demo-shell/typo/typo_stub_renderer.cpp (+0/-47)
playground/demo-shell/typo/typo_stub_renderer.h (+0/-34)
playground/demo-shell/window_manager.cpp (+320/-407)
playground/demo-shell/window_manager.h (+0/-3)
playground/server_configuration.cpp (+7/-19)
playground/server_configuration.h (+0/-5)
src/client/CMakeLists.txt (+22/-33)
src/client/buffer_stream.cpp (+1/-90)
src/client/buffer_stream.h (+0/-20)
src/client/client_buffer_depository.cpp (+3/-14)
src/client/client_buffer_depository.h (+2/-2)
src/client/client_buffer_stream.h (+1/-12)
src/client/client_buffer_stream_factory.h (+0/-8)
src/client/cursor_configuration.h (+0/-12)
src/client/default_client_buffer_stream_factory.cpp (+0/-12)
src/client/default_client_buffer_stream_factory.h (+0/-4)
src/client/default_connection_configuration.cpp (+19/-0)
src/client/event_printer.cpp (+0/-348)
src/client/input/android/event_conversion_helpers.cpp (+0/-102)
src/client/logging/input_receiver_report.cpp (+82/-2)
src/client/logging/rpc_report.cpp (+17/-0)
src/client/logging/rpc_report.h (+3/-0)
src/client/lttng/CMakeLists.txt (+4/-5)
src/client/lttng/input_receiver_report.cpp (+15/-15)
src/client/lttng/perf_report.cpp (+0/-40)
src/client/lttng/perf_report.h (+0/-43)
src/client/lttng/perf_report_tp.h (+0/-51)
src/client/lttng/rpc_report.cpp (+9/-0)
src/client/lttng/rpc_report.h (+3/-0)
src/client/lttng/tracepoints.c (+0/-1)
src/client/mir_buffer_stream_api.cpp (+10/-91)
src/client/mir_connection.cpp (+10/-1)
src/client/mir_connection.h (+1/-1)
src/client/mir_cursor_api.cpp (+16/-40)
src/client/mir_surface.cpp (+30/-162)
src/client/mir_surface.h (+9/-33)
src/client/mir_surface_api.cpp (+15/-133)
src/client/perf_report.h (+1/-5)
src/client/rpc/CMakeLists.txt (+1/-1)
src/client/rpc/mir_protobuf_rpc_channel.cpp (+4/-11)
src/client/rpc/null_rpc_report.cpp (+9/-0)
src/client/rpc/null_rpc_report.h (+3/-0)
src/client/rpc/rpc_report.h (+3/-0)
src/client/rpc/stream_socket_transport.cpp (+37/-23)
src/client/rpc/stream_socket_transport.h (+4/-15)
src/client/rpc/stream_transport.h (+0/-7)
src/client/symbols-debug.map (+8/-0)
src/client/symbols.map (+25/-206)
src/common/CMakeLists.txt (+11/-1)
src/common/dispatch/CMakeLists.txt (+0/-2)
src/common/dispatch/action_queue.cpp (+0/-98)
src/common/dispatch/simple_dispatch_thread.cpp (+22/-69)
src/common/event.cpp (+1/-42)
src/common/events/CMakeLists.txt (+2/-2)
src/common/events/event_builders.cpp (+104/-65)
src/common/geometry/ostream.cpp (+1/-0)
src/common/geometry/rectangle.cpp (+2/-2)
src/common/geometry/rectangles.cpp (+3/-1)
src/common/graphics/android/CMakeLists.txt (+1/-1)
src/common/graphics/android/mir_native_window.cpp (+11/-6)
src/common/input/CMakeLists.txt (+16/-10)
src/common/input/android/CMakeLists.txt (+1/-1)
src/common/input/android/android_input_lexicon.cpp (+20/-7)
src/common/input/android/android_input_platform.cpp (+6/-8)
src/common/input/android/android_input_platform.h (+8/-13)
src/common/input/android/android_input_receiver.cpp (+77/-148)
src/common/input/android/android_input_receiver.h (+16/-24)
src/common/input/android/android_input_receiver_thread.cpp (+70/-0)
src/common/input/android/android_input_receiver_thread.h (+71/-0)
src/common/input/input_event.cpp (+141/-79)
src/common/input/udev_wrapper.cpp (+2/-2)
src/common/input/xkb_mapper.cpp (+11/-20)
src/common/logging/input_timestamp.cpp (+2/-0)
src/common/logging/logger.cpp (+2/-2)
src/common/logging/shared_library_prober_report.cpp (+4/-5)
src/common/sharedlibrary/CMakeLists.txt (+1/-5)
src/common/sharedlibrary/module_deleter.cpp (+0/-56)
src/common/sharedlibrary/shared_library.cpp (+1/-1)
src/common/symbols.map (+157/-60)
src/common/thread/CMakeLists.txt (+1/-2)
src/common/thread/signal_blocker.cpp (+0/-48)
src/include/client/mir/client_platform_factory.h (+5/-4)
src/include/client/mir/egl_native_surface.h (+0/-1)
src/include/common/mir/graphics/android/android_driver_interpreter.h (+0/-1)
src/include/common/mir/input/android/event_conversion_helpers.h (+0/-45)
src/include/common/mir/input/xkb_mapper.h (+3/-6)
src/include/common/mir/logging/input_timestamp.h (+5/-1)
src/include/common/mir/signal_blocker.h (+0/-39)
src/include/platform/mir/graphics/display_report.h (+0/-2)
src/include/platform/mir/graphics/egl_error.h (+0/-40)
src/include/platform/mir/options/configuration.h (+0/-2)
src/include/server/mir/basic_callback.h (+0/-44)
src/include/server/mir/compositor/buffer_stream.h (+7/-3)
src/include/server/mir/compositor/compositor_report.h (+4/-7)
src/include/server/mir/compositor/decoration.h (+0/-38)
src/include/server/mir/compositor/destination_alpha.h (+36/-0)
src/include/server/mir/compositor/frame_dropping_policy_factory.h (+5/-5)
src/include/server/mir/compositor/gl_renderer.h (+11/-5)
src/include/server/mir/compositor/renderer_factory.h (+3/-1)
src/include/server/mir/compositor/scene_element.h (+5/-5)
src/include/server/mir/default_server_configuration.h (+5/-20)
src/include/server/mir/display_changer.h (+1/-0)
src/include/server/mir/frontend/shell.h (+2/-3)
src/include/server/mir/glib_main_loop.h (+15/-5)
src/include/server/mir/glib_main_loop_sources.h (+3/-3)
src/include/server/mir/input/input_report.h (+4/-7)
src/include/server/mir/lockable_callback_wrapper.h (+0/-51)
src/include/server/mir/scene/buffer_stream_factory.h (+0/-2)
src/include/server/mir/scene/surface_event_source.h (+0/-1)
src/include/server/mir/scene/surface_factory.h (+1/-4)
src/include/server/mir/scene/surface_observers.h (+0/-54)
src/include/server/mir/shell/basic_window_manager.h (+0/-337)
src/include/server/mir/shell/canonical_window_manager.h (+0/-151)
src/include/server/mir/shell/default_window_manager.h (+0/-81)
src/platform/CMakeLists.txt (+4/-6)
src/platform/graphics/CMakeLists.txt (+0/-1)
src/platform/graphics/egl_error.cpp (+0/-72)
src/platform/graphics/egl_resources.cpp (+2/-3)
src/platform/graphics/platform_probe.cpp (+11/-12)
src/platform/options/default_configuration.cpp (+20/-6)
src/platform/symbols.map (+1/-21)
src/platform/udev/CMakeLists.txt (+0/-6)
src/platforms/CMakeLists.txt (+1/-5)
src/platforms/android/client/CMakeLists.txt (+2/-2)
src/platforms/android/client/client_platform_factory.cpp (+2/-2)
src/platforms/android/client/egl_native_surface_interpreter.cpp (+0/-7)
src/platforms/android/client/egl_native_surface_interpreter.h (+5/-6)
src/platforms/android/client/gralloc_registrar.cpp (+1/-1)
src/platforms/android/server/CMakeLists.txt (+2/-3)
src/platforms/android/server/android_buffer_allocator.cpp (+0/-19)
src/platforms/android/server/android_graphic_buffer_allocator.h (+3/-6)
src/platforms/android/server/buffer.cpp (+7/-33)
src/platforms/android/server/buffer.h (+0/-1)
src/platforms/android/server/configurable_display_buffer.h (+2/-3)
src/platforms/android/server/display.cpp (+58/-59)
src/platforms/android/server/display.h (+5/-5)
src/platforms/android/server/display_buffer.cpp (+24/-15)
src/platforms/android/server/display_buffer.h (+5/-4)
src/platforms/android/server/display_component_factory.h (+2/-2)
src/platforms/android/server/display_configuration.cpp (+104/-15)
src/platforms/android/server/display_configuration.h (+3/-2)
src/platforms/android/server/display_device.h (+9/-10)
src/platforms/android/server/display_group.cpp (+0/-81)
src/platforms/android/server/display_group.h (+0/-62)
src/platforms/android/server/fb_device.cpp (+25/-31)
src/platforms/android/server/fb_device.h (+9/-5)
src/platforms/android/server/framebuffer_bundle.h (+2/-0)
src/platforms/android/server/framebuffers.cpp (+13/-1)
src/platforms/android/server/framebuffers.h (+9/-8)
src/platforms/android/server/gl_context.cpp (+10/-6)
src/platforms/android/server/hal_component_factory.cpp (+13/-15)
src/platforms/android/server/hal_component_factory.h (+1/-4)
src/platforms/android/server/hwc_blanking_control.cpp (+28/-151)
src/platforms/android/server/hwc_configuration.h (+15/-24)
src/platforms/android/server/hwc_device.cpp (+97/-34)
src/platforms/android/server/hwc_device.h (+28/-1)
src/platforms/android/server/hwc_fb_device.cpp (+13/-10)
src/platforms/android/server/hwc_fb_device.h (+7/-1)
src/platforms/android/server/hwc_loggers.cpp (+5/-52)
src/platforms/android/server/hwc_loggers.h (+0/-2)
src/platforms/android/server/hwc_report.h (+0/-5)
src/platforms/android/server/hwc_wrapper.h (+0/-5)
src/platforms/android/server/platform.cpp (+2/-2)
src/platforms/android/server/platform.h (+2/-0)
src/platforms/android/server/power_mode.h (+0/-43)
src/platforms/android/server/real_hwc_wrapper.cpp (+0/-36)
src/platforms/android/server/real_hwc_wrapper.h (+0/-4)
src/platforms/android/server/resource_factory.cpp (+0/-1)
src/platforms/android/server/server_render_window.cpp (+1/-7)
src/platforms/android/server/server_render_window.h (+5/-7)
src/platforms/android/server/symbols.map (+1/-1)
src/platforms/common/server/symbols.map (+9/-0)
src/platforms/mesa/client/CMakeLists.txt (+1/-1)
src/platforms/mesa/client/client_platform.cpp (+0/-15)
src/platforms/mesa/client/client_platform_factory.cpp (+2/-2)
src/platforms/mesa/include/mir_toolkit/mesa/native_display.h (+2/-0)
src/platforms/mesa/server/CMakeLists.txt (+1/-1)
src/platforms/mesa/server/buffer_allocator.cpp (+2/-33)
src/platforms/mesa/server/buffer_allocator.h (+0/-2)
src/platforms/mesa/server/cursor.cpp (+15/-2)
src/platforms/mesa/server/cursor.h (+3/-0)
src/platforms/mesa/server/display.cpp (+3/-3)
src/platforms/mesa/server/display.h (+2/-2)
src/platforms/mesa/server/display_buffer.cpp (+88/-62)
src/platforms/mesa/server/display_buffer.h (+8/-13)
src/platforms/mesa/server/display_helpers.cpp (+7/-9)
src/platforms/mesa/server/gbm_buffer.cpp (+0/-5)
src/platforms/mesa/server/gbm_buffer.h (+0/-1)
src/platforms/mesa/server/guest_platform.cpp (+1/-0)
src/platforms/mesa/server/kms_page_flipper.cpp (+11/-19)
src/platforms/mesa/server/kms_page_flipper.h (+2/-5)
src/platforms/mesa/server/platform.cpp (+2/-17)
src/platforms/mesa/server/real_kms_output.cpp (+1/-0)
src/platforms/mesa/server/shm_buffer.cpp (+0/-5)
src/platforms/mesa/server/shm_buffer.h (+0/-1)
src/platforms/mesa/server/symbols.map (+1/-1)
src/protobuf/CMakeLists.txt (+1/-3)
src/protobuf/mir_protobuf.proto (+10/-64)
src/server/CMakeLists.txt (+4/-11)
src/server/basic_callback.cpp (+0/-37)
src/server/compositor/buffer_queue.cpp (+30/-53)
src/server/compositor/buffer_queue.h (+1/-2)
src/server/compositor/buffer_stream_factory.cpp (+6/-17)
src/server/compositor/buffer_stream_factory.h (+3/-6)
src/server/compositor/buffer_stream_surfaces.cpp (+15/-51)
src/server/compositor/buffer_stream_surfaces.h (+5/-16)
src/server/compositor/default_configuration.cpp (+2/-6)
src/server/compositor/default_display_buffer_compositor.cpp (+4/-4)
src/server/compositor/default_display_buffer_compositor_factory.cpp (+4/-1)
src/server/compositor/default_display_buffer_compositor_factory.h (+2/-0)
src/server/compositor/gl_program_family.cpp (+0/-5)
src/server/compositor/gl_renderer.cpp (+26/-14)
src/server/compositor/gl_renderer_factory.cpp (+8/-2)
src/server/compositor/gl_renderer_factory.h (+2/-1)
src/server/compositor/multi_threaded_compositor.cpp (+41/-84)
src/server/compositor/multi_threaded_compositor.h (+5/-10)
src/server/compositor/recently_used_cache.cpp (+1/-0)
src/server/compositor/screencast_display_buffer.cpp (+9/-0)
src/server/compositor/screencast_display_buffer.h (+3/-0)
src/server/compositor/temporary_buffers.cpp (+0/-5)
src/server/compositor/temporary_buffers.h (+0/-1)
src/server/compositor/timeout_frame_dropping_policy_factory.cpp (+21/-13)
src/server/compositor/timeout_frame_dropping_policy_factory.h (+9/-8)
src/server/default_server_configuration.cpp (+20/-0)
src/server/display_server.cpp (+25/-20)
src/server/frontend/CMakeLists.txt (+1/-1)
src/server/frontend/event_sender.cpp (+2/-1)
src/server/frontend/protobuf_buffer_packer.h (+1/-7)
src/server/frontend/protobuf_message_processor.cpp (+0/-18)
src/server/frontend/protobuf_message_processor.h (+0/-1)
src/server/frontend/session_mediator.cpp (+229/-349)
src/server/frontend/session_mediator.h (+7/-29)
src/server/frontend/shell_wrapper.cpp (+6/-5)
src/server/frontend/shell_wrapper.h (+2/-2)
src/server/frontend/socket_messenger.cpp (+1/-0)
src/server/frontend/surface_tracker.cpp (+12/-16)
src/server/frontend/surface_tracker.h (+23/-21)
src/server/glib_main_loop.cpp (+52/-26)
src/server/glib_main_loop_sources.cpp (+25/-28)
src/server/graphics/default_configuration.cpp (+21/-32)
src/server/graphics/nested/CMakeLists.txt (+7/-3)
src/server/graphics/nested/cursor.cpp (+0/-52)
src/server/graphics/nested/cursor.h (+0/-51)
src/server/graphics/nested/host_connection.h (+18/-9)
src/server/graphics/nested/host_surface.h (+0/-51)
src/server/graphics/nested/mir_client_host_connection.cpp (+9/-94)
src/server/graphics/nested/mir_client_host_connection.h (+1/-11)
src/server/graphics/nested/nested_display.cpp (+35/-54)
src/server/graphics/nested/nested_display.h (+14/-30)
src/server/graphics/nested/nested_output.cpp (+31/-34)
src/server/graphics/nested/nested_output.h (+9/-16)
src/server/graphics/offscreen/display.cpp (+8/-25)
src/server/graphics/offscreen/display.h (+2/-12)
src/server/graphics/offscreen/display_buffer.cpp (+9/-0)
src/server/graphics/offscreen/display_buffer.h (+2/-0)
src/server/graphics/software_cursor.cpp (+143/-2)
src/server/graphics/software_cursor.h (+12/-0)
src/server/graphics/surfaceless_egl_context.cpp (+4/-4)
src/server/input/CMakeLists.txt (+0/-2)
src/server/input/android/CMakeLists.txt (+1/-1)
src/server/input/android/android_input_dispatcher.cpp (+24/-34)
src/server/input/android/android_input_dispatcher.h (+2/-0)
src/server/input/android/android_input_manager.cpp (+57/-0)
src/server/input/android/android_input_manager.h (+65/-0)
src/server/input/android/android_input_reader_policy.cpp (+16/-2)
src/server/input/android/android_input_targeter.cpp (+3/-5)
src/server/input/android/android_input_targeter.h (+2/-2)
src/server/input/android/android_pointer_controller.cpp (+26/-0)
src/server/input/android/android_pointer_controller.h (+2/-0)
src/server/input/android/event_filter_dispatcher_policy.cpp (+2/-1)
src/server/input/android/event_filter_dispatcher_policy.h (+3/-4)
src/server/input/android/input_reader_dispatchable.cpp (+0/-54)
src/server/input/android/input_reader_dispatchable.h (+0/-56)
src/server/input/android/input_sender.cpp (+19/-21)
src/server/input/android/input_translator.cpp (+43/-36)
src/server/input/cursor_controller.cpp (+2/-2)
src/server/input/default_configuration.cpp (+42/-129)
src/server/input/default_input_device_hub.cpp (+0/-300)
src/server/input/default_input_device_hub.h (+0/-114)
src/server/input/default_input_manager.cpp (+0/-144)
src/server/input/default_input_manager.h (+0/-79)
src/server/input/display_input_region.cpp (+72/-27)
src/server/input/display_input_region.h (+15/-3)
src/server/input/null_input_dispatcher.cpp (+10/-0)
src/server/input/null_input_dispatcher.h (+2/-0)
src/server/input/null_input_manager.h (+0/-3)
src/server/input/null_input_targeter.cpp (+2/-2)
src/server/input/null_input_targeter.h (+2/-2)
src/server/input/touchspot_controller.cpp (+1/-2)
src/server/input/vt_filter.cpp (+5/-4)
src/server/lockable_callback_wrapper.cpp (+0/-54)
src/server/report/logging/compositor_report.cpp (+0/-4)
src/server/report/logging/compositor_report.h (+0/-1)
src/server/report/logging/display_report.cpp (+1/-26)
src/server/report/logging/display_report.h (+13/-24)
src/server/report/logging/input_report.cpp (+2/-102)
src/server/report/logging/input_report.h (+7/-9)
src/server/report/logging/logging_report_factory.cpp (+1/-1)
src/server/report/lttng/compositor_report.cpp (+1/-11)
src/server/report/lttng/compositor_report.h (+4/-5)
src/server/report/lttng/compositor_report_tp.h (+0/-10)
src/server/report/lttng/display_report.cpp (+6/-2)
src/server/report/lttng/display_report.h (+11/-10)
src/server/report/lttng/display_report_tp.h (+0/-9)
src/server/report/lttng/input_report.cpp (+0/-10)
src/server/report/lttng/input_report.h (+0/-2)
src/server/report/lttng/input_report_tp.h (+0/-20)
src/server/report/lttng/message_processor_report.cpp (+2/-0)
src/server/report/null/compositor_report.cpp (+0/-4)
src/server/report/null/compositor_report.h (+0/-1)
src/server/report/null/display_report.cpp (+0/-1)
src/server/report/null/display_report.h (+0/-1)
src/server/report/null/input_report.cpp (+0/-6)
src/server/report/null/input_report.h (+6/-9)
src/server/run_mir.cpp (+1/-3)
src/server/scene/application_session.cpp (+25/-109)
src/server/scene/application_session.h (+2/-16)
src/server/scene/basic_surface.cpp (+61/-168)
src/server/scene/basic_surface.h (+30/-16)
src/server/scene/default_configuration.cpp (+1/-4)
src/server/scene/default_coordinate_translator.cpp (+1/-2)
src/server/scene/default_session_container.cpp (+2/-0)
src/server/scene/legacy_scene_change_notification.cpp (+2/-1)
src/server/scene/legacy_surface_change_notification.cpp (+0/-10)
src/server/scene/legacy_surface_change_notification.h (+0/-2)
src/server/scene/mediating_display_changer.cpp (+17/-0)
src/server/scene/mediating_display_changer.h (+5/-0)
src/server/scene/null_surface_observer.cpp (+0/-2)
src/server/scene/prompt_session_container.cpp (+4/-1)
src/server/scene/session_manager.cpp (+6/-10)
src/server/scene/session_manager.h (+1/-6)
src/server/scene/surface_allocator.cpp (+7/-3)
src/server/scene/surface_allocator.h (+9/-9)
src/server/scene/surface_controller.cpp (+5/-16)
src/server/scene/surface_controller.h (+3/-8)
src/server/scene/surface_event_source.cpp (+0/-5)
src/server/scene/surface_stack.cpp (+10/-72)
src/server/scene/surface_stack.h (+0/-4)
src/server/scene/surface_stack_model.h (+1/-10)
src/server/scene/threaded_snapshot_strategy.cpp (+7/-4)
src/server/server.cpp (+8/-20)
src/server/shell/CMakeLists.txt (+1/-3)
src/server/shell/abstract_shell.cpp (+73/-128)
src/server/shell/canonical_window_manager.cpp (+0/-791)
src/server/shell/default_configuration.cpp (+4/-17)
src/server/shell/default_shell.cpp (+96/-0)
src/server/shell/default_shell.h (+73/-0)
src/server/shell/default_window_manager.cpp (+0/-125)
src/server/shell/frontend_shell.cpp (+8/-17)
src/server/shell/frontend_shell.h (+2/-2)
src/server/shell/graphics_display_layout.cpp (+16/-16)
src/server/shell/shell_wrapper.cpp (+18/-52)
src/server/shell/surface_ready_observer.cpp (+0/-45)
src/server/symbols.map (+255/-113)
src/utils/out.c (+1/-1)
src/utils/ping.c (+1/-1)
src/utils/screencast.cpp (+74/-186)
src/wrapper.c (+0/-3)
tests/CMakeLists.txt (+0/-5)
tests/acceptance-tests/CMakeLists.txt (+16/-17)
tests/acceptance-tests/server_configuration_wrapping.cpp (+3/-3)
tests/acceptance-tests/server_signal_handling.cpp (+3/-4)
tests/acceptance-tests/test_client_focus_notification.cpp (+24/-18)
tests/acceptance-tests/test_client_input.cpp (+0/-574)
tests/acceptance-tests/test_client_library.cpp (+152/-232)
tests/acceptance-tests/test_client_library_errors.cpp (+1/-5)
tests/acceptance-tests/test_client_surface_events.cpp (+44/-32)
tests/acceptance-tests/test_client_surface_visibility.cpp (+22/-18)
tests/acceptance-tests/test_client_surfaces.cpp (+0/-32)
tests/acceptance-tests/test_custom_input_dispatcher.cpp (+0/-98)
tests/acceptance-tests/test_custom_window_management.cpp (+0/-274)
tests/acceptance-tests/test_debug_api.cpp (+11/-23)
tests/acceptance-tests/test_display_configuration.cpp (+10/-14)
tests/acceptance-tests/test_input_device_hub.cpp (+0/-84)
tests/acceptance-tests/test_latency.cpp (+0/-204)
tests/acceptance-tests/test_nested_input.cpp (+0/-157)
tests/acceptance-tests/test_nested_mir.cpp (+130/-41)
tests/acceptance-tests/test_render_override.cpp (+0/-132)
tests/acceptance-tests/test_server_disconnect.cpp (+3/-6)
tests/acceptance-tests/test_server_shutdown.cpp (+6/-7)
tests/acceptance-tests/test_server_without_active_outputs.cpp (+1/-1)
tests/acceptance-tests/test_surface_modifications.cpp (+0/-507)
tests/acceptance-tests/test_surface_placement.cpp (+0/-370)
tests/acceptance-tests/test_surfaces_with_output_id.cpp (+1/-0)
tests/acceptance-tests/test_unresponsive_client.cpp (+2/-2)
tests/acceptance-tests/throwback/CMakeLists.txt (+3/-1)
tests/acceptance-tests/throwback/clients.cpp (+0/-1)
tests/acceptance-tests/throwback/test_client_cursor_api.cpp (+12/-115)
tests/acceptance-tests/throwback/test_client_input.cpp (+626/-0)
tests/acceptance-tests/throwback/test_custom_input_dispatcher.cpp (+101/-32)
tests/acceptance-tests/throwback/test_focus_selection.cpp (+11/-2)
tests/acceptance-tests/throwback/test_shell_control_of_surface_configuration.cpp (+109/-86)
tests/acceptance-tests/throwback/test_touchspot_visualization.cpp (+64/-44)
tests/include/mir_test/auto_unblock_thread.h (+14/-33)
tests/include/mir_test/cross_process_action.h (+4/-3)
tests/include/mir_test/event_matchers.h (+59/-135)
tests/include/mir_test/fake_event_hub.h (+2/-6)
tests/include/mir_test/signal.h (+3/-3)
tests/include/mir_test_doubles/mock_android_alloc_device.h (+15/-32)
tests/include/mir_test_doubles/mock_buffer.h (+0/-1)
tests/include/mir_test_doubles/mock_buffer_bundle.h (+4/-5)
tests/include/mir_test_doubles/mock_buffer_stream.h (+2/-18)
tests/include/mir_test_doubles/mock_client_buffer_factory.h (+0/-3)
tests/include/mir_test_doubles/mock_client_buffer_stream.h (+0/-5)
tests/include/mir_test_doubles/mock_client_buffer_stream_factory.h (+0/-6)
tests/include/mir_test_doubles/mock_compositor_report.h (+0/-2)
tests/include/mir_test_doubles/mock_display.h (+1/-1)
tests/include/mir_test_doubles/mock_display_buffer.h (+2/-0)
tests/include/mir_test_doubles/mock_display_device.h (+7/-1)
tests/include/mir_test_doubles/mock_display_report.h (+2/-1)
tests/include/mir_test_doubles/mock_egl.h (+1/-8)
tests/include/mir_test_doubles/mock_egl_native_surface.h (+0/-1)
tests/include/mir_test_doubles/mock_event_filter.h (+2/-0)
tests/include/mir_test_doubles/mock_event_hub.h (+0/-69)
tests/include/mir_test_doubles/mock_frame_dropping_policy_factory.h (+13/-9)
tests/include/mir_test_doubles/mock_framebuffer_bundle.h (+8/-2)
tests/include/mir_test_doubles/mock_frontend_surface.h (+5/-9)
tests/include/mir_test_doubles/mock_gbm.h (+0/-1)
tests/include/mir_test_doubles/mock_hwc_composer_device_1.h (+1/-1)
tests/include/mir_test_doubles/mock_hwc_device_wrapper.h (+0/-5)
tests/include/mir_test_doubles/mock_hwc_report.h (+0/-1)
tests/include/mir_test_doubles/mock_input_dispatcher.h (+2/-0)
tests/include/mir_test_doubles/mock_input_manager.h (+0/-1)
tests/include/mir_test_doubles/mock_input_platform.h (+0/-43)
tests/include/mir_test_doubles/mock_input_reader.h (+0/-58)
tests/include/mir_test_doubles/mock_input_region.h (+3/-0)
tests/include/mir_test_doubles/mock_input_targeter.h (+2/-2)
tests/include/mir_test_doubles/mock_lockable_callback.h (+0/-47)
tests/include/mir_test_doubles/mock_main_loop.h (+11/-1)
tests/include/mir_test_doubles/mock_rpc_report.h (+4/-0)
tests/include/mir_test_doubles/mock_scene_session.h (+0/-6)
tests/include/mir_test_doubles/mock_shell.h (+4/-4)
tests/include/mir_test_doubles/mock_surface.h (+2/-5)
tests/include/mir_test_doubles/mock_surface_configurator.h (+43/-0)
tests/include/mir_test_doubles/mock_surface_coordinator.h (+3/-4)
tests/include/mir_test_doubles/mock_timer.h (+9/-3)
tests/include/mir_test_doubles/mock_window_manager.h (+0/-77)
tests/include/mir_test_doubles/nested_mock_egl.h (+0/-44)
tests/include/mir_test_doubles/null_display.h (+4/-5)
tests/include/mir_test_doubles/null_display_buffer.h (+2/-0)
tests/include/mir_test_doubles/null_display_sync_group.h (+0/-81)
tests/include/mir_test_doubles/null_surface_configurator.h (+48/-0)
tests/include/mir_test_doubles/stub_buffer.h (+2/-13)
tests/include/mir_test_doubles/stub_buffer_stream.h (+21/-16)
tests/include/mir_test_doubles/stub_buffer_stream_factory.h (+0/-42)
tests/include/mir_test_doubles/stub_client_buffer.h (+1/-1)
tests/include/mir_test_doubles/stub_client_buffer_stream_factory.h (+2/-10)
tests/include/mir_test_doubles/stub_cursor.h (+0/-43)
tests/include/mir_test_doubles/stub_cursor_listener.h (+0/-40)
tests/include/mir_test_doubles/stub_display.h (+12/-26)
tests/include/mir_test_doubles/stub_display_builder.h (+34/-21)
tests/include/mir_test_doubles/stub_display_changer.h (+52/-0)
tests/include/mir_test_doubles/stub_display_configuration.h (+1/-33)
tests/include/mir_test_doubles/stub_driver_interpreter.h (+4/-12)
tests/include/mir_test_doubles/stub_frame_dropping_policy_factory.h (+3/-1)
tests/include/mir_test_doubles/stub_host_connection.h (+2/-12)
tests/include/mir_test_doubles/stub_input_targeter.h (+2/-2)
tests/include/mir_test_doubles/stub_scene_element.h (+3/-4)
tests/include/mir_test_doubles/stub_scene_session.h (+0/-17)
tests/include/mir_test_doubles/stub_scene_surface.h (+9/-8)
tests/include/mir_test_doubles/stub_session.h (+0/-12)
tests/include/mir_test_doubles/stub_shell.h (+3/-0)
tests/include/mir_test_doubles/stub_surface_factory.h (+0/-48)
tests/include/mir_test_doubles/stub_timer.h (+22/-8)
tests/include/mir_test_doubles/triggered_main_loop.h (+1/-1)
tests/include/mir_test_framework/async_server_runner.h (+1/-2)
tests/include/mir_test_framework/cross_process_sync.h (+4/-7)
tests/include/mir_test_framework/fake_event_hub_server_configuration.h (+0/-3)
tests/include/mir_test_framework/fake_input_device.h (+0/-55)
tests/include/mir_test_framework/headless_nested_server_runner.h (+0/-33)
tests/include/mir_test_framework/headless_test.h (+1/-2)
tests/include/mir_test_framework/input_testing_server_configuration.h (+22/-0)
tests/include/mir_test_framework/interprocess_client_server_test.h (+2/-2)
tests/include/mir_test_framework/placement_applying_shell.h (+0/-59)
tests/include/mir_test_framework/stub_server_platform_factory.h (+1/-10)
tests/include/mir_test_framework/testing_server_configuration.h (+2/-2)
tests/integration-tests/CMakeLists.txt (+11/-11)
tests/integration-tests/compositor/test_buffer_stream.cpp (+4/-3)
tests/integration-tests/frontend/test_session_mediator_report.cpp (+1/-1)
tests/integration-tests/graphics/android/test_client_render.cpp (+20/-21)
tests/integration-tests/graphics/android/test_display_integration.cpp (+23/-27)
tests/integration-tests/graphics/mesa/test_buffer_integration.cpp (+1/-1)
tests/integration-tests/input/CMakeLists.txt (+5/-1)
tests/integration-tests/input/android/CMakeLists.txt (+10/-0)
tests/integration-tests/input/android/test_android_cursor_listener.cpp (+29/-22)
tests/integration-tests/input/android/test_android_input_manager.cpp (+333/-0)
tests/integration-tests/input/test_nested_input.cpp (+84/-0)
tests/integration-tests/session_management.cpp (+21/-0)
tests/integration-tests/surface_composition.cpp (+1/-1)
tests/integration-tests/test_default_shell.cpp (+110/-38)
tests/integration-tests/test_display_info.cpp (+4/-5)
tests/integration-tests/test_display_server_main_loop_events.cpp (+184/-123)
tests/integration-tests/test_drm_auth_magic.cpp (+0/-2)
tests/integration-tests/test_error_reporting.cpp (+10/-7)
tests/integration-tests/test_exchange_buffer.cpp (+38/-30)
tests/integration-tests/test_server_shutdown.cpp (+22/-5)
tests/integration-tests/test_session.cpp (+69/-11)
tests/integration-tests/test_stale_frames.cpp (+11/-3)
tests/integration-tests/test_surface_first_frame_sync.cpp (+23/-30)
tests/integration-tests/test_surface_stack_with_compositor.cpp (+36/-47)
tests/integration-tests/test_surfaceloop.cpp (+14/-16)
tests/integration-tests/test_swapinterval.cpp (+26/-34)
tests/integration-tests/test_test_framework.cpp (+24/-47)
tests/mir-stress/src/client.cpp (+11/-9)
tests/mir_test/CMakeLists.txt (+5/-4)
tests/mir_test/event_matchers.cpp (+0/-35)
tests/mir_test/signal.cpp (+7/-7)
tests/mir_test_doubles/CMakeLists.txt (+7/-8)
tests/mir_test_doubles/fake_event_hub.cpp (+17/-42)
tests/mir_test_doubles/mock_egl.cpp (+2/-25)
tests/mir_test_doubles/mock_frame_dropping_policy_factory.cpp (+14/-14)
tests/mir_test_doubles/mock_gbm.cpp (+0/-5)
tests/mir_test_doubles/mock_timer.cpp (+40/-19)
tests/mir_test_doubles/nested_mock_egl.cpp (+0/-66)
tests/mir_test_doubles/platform_factory.cpp (+1/-1)
tests/mir_test_doubles/test_protobuf_client.cpp (+2/-1)
tests/mir_test_doubles/triggered_main_loop.cpp (+4/-3)
tests/mir_test_framework/CMakeLists.txt (+22/-42)
tests/mir_test_framework/async_server_runner.cpp (+5/-5)
tests/mir_test_framework/connected_client_with_a_surface.cpp (+9/-6)
tests/mir_test_framework/cross_process_sync.cpp (+12/-12)
tests/mir_test_framework/fake_event_hub_server_configuration.cpp (+1/-13)
tests/mir_test_framework/fake_input_device_impl.cpp (+0/-304)
tests/mir_test_framework/fake_input_device_impl.h (+0/-87)
tests/mir_test_framework/headless_nested_server_runner.cpp (+0/-28)
tests/mir_test_framework/headless_test.cpp (+0/-1)
tests/mir_test_framework/input_testing_server_options.cpp (+17/-0)
tests/mir_test_framework/interprocess_client_server_test.cpp (+1/-3)
tests/mir_test_framework/placement_applying_shell.cpp (+0/-59)
tests/mir_test_framework/stub_client_platform_factory.cpp (+2/-2)
tests/mir_test_framework/stub_input.cpp (+0/-66)
tests/mir_test_framework/stub_input_platform.cpp (+0/-91)
tests/mir_test_framework/stub_input_platform.h (+0/-62)
tests/mir_test_framework/stub_server_platform_factory.cpp (+7/-24)
tests/mir_test_framework/stubbed_graphics_platform.cpp (+0/-5)
tests/mir_test_framework/stubbed_server_configuration.cpp (+13/-3)
tests/mir_test_framework/symbols-server.map (+1/-1)
tests/mir_test_framework/symbols-stub-input.map (+0/-7)
tests/mir_test_framework/testing_server_options.cpp (+2/-3)
tests/performance-tests/CMakeLists.txt (+2/-3)
tests/privileged-tests/CMakeLists.txt (+0/-27)
tests/privileged-tests/README (+0/-2)
tests/privileged-tests/test_input_events.cpp (+0/-290)
tests/unit-tests/CMakeLists.txt (+12/-26)
tests/unit-tests/android_input/input_reader.cpp (+14/-1)
tests/unit-tests/android_input/test_eventhub.cpp (+5/-56)
tests/unit-tests/client/android/test_android_native_window.cpp (+0/-9)
tests/unit-tests/client/android/test_egl_native_surface_interpreter.cpp (+0/-21)
tests/unit-tests/client/input/CMakeLists.txt (+1/-0)
tests/unit-tests/client/input/test_android_input_receiver.cpp (+110/-152)
tests/unit-tests/client/input/test_android_input_receiver_thread.cpp (+162/-0)
tests/unit-tests/client/input/test_xkb_mapper.cpp (+39/-21)
tests/unit-tests/client/mesa/test_client_platform.cpp (+1/-1)
tests/unit-tests/client/test_client_buffer_depository.cpp (+15/-67)
tests/unit-tests/client/test_client_buffer_stream.cpp (+3/-0)
tests/unit-tests/client/test_client_mir_surface.cpp (+45/-68)
tests/unit-tests/client/test_event_distributor.cpp (+2/-2)
tests/unit-tests/client/test_mir_connection.cpp (+12/-2)
tests/unit-tests/client/test_mir_screencast.cpp (+3/-0)
tests/unit-tests/client/test_protobuf_rpc_channel.cpp (+0/-1)
tests/unit-tests/client/test_stream_transport.cpp (+26/-144)
tests/unit-tests/compositor/CMakeLists.txt (+0/-1)
tests/unit-tests/compositor/test_buffer_queue.cpp (+9/-0)
tests/unit-tests/compositor/test_buffer_stream.cpp (+2/-46)
tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp (+25/-19)
tests/unit-tests/compositor/test_gl_program_family.cpp (+0/-49)
tests/unit-tests/compositor/test_gl_renderer.cpp (+38/-12)
tests/unit-tests/compositor/test_multi_threaded_compositor.cpp (+50/-126)
tests/unit-tests/compositor/test_screencast_display_buffer.cpp (+10/-1)
tests/unit-tests/compositor/test_timeout_frame_dropping_policy.cpp (+71/-54)
tests/unit-tests/dispatch/CMakeLists.txt (+0/-1)
tests/unit-tests/dispatch/test_action_queue.cpp (+0/-81)
tests/unit-tests/dispatch/test_simple_dispatch_thread.cpp (+33/-139)
tests/unit-tests/examples/test_demo_compositor.cpp (+7/-2)
tests/unit-tests/examples/test_demo_renderer.cpp (+3/-3)
tests/unit-tests/frontend/stress_protobuf_communicator.cpp (+1/-1)
tests/unit-tests/frontend/test_client_buffer_tracker.cpp (+85/-85)
tests/unit-tests/frontend/test_event_sender.cpp (+1/-1)
tests/unit-tests/frontend/test_protobuf_message_processor.cpp (+0/-2)
tests/unit-tests/frontend/test_published_socket_connector.cpp (+2/-1)
tests/unit-tests/frontend/test_session_mediator.cpp (+53/-102)
tests/unit-tests/graphics/CMakeLists.txt (+0/-1)
tests/unit-tests/graphics/android/CMakeLists.txt (+0/-1)
tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp (+0/-55)
tests/unit-tests/graphics/android/test_buffer.cpp (+16/-120)
tests/unit-tests/graphics/android/test_display.cpp (+75/-90)
tests/unit-tests/graphics/android/test_display_buffer.cpp (+43/-16)
tests/unit-tests/graphics/android/test_display_group.cpp (+0/-84)
tests/unit-tests/graphics/android/test_display_hotplug.cpp (+8/-9)
tests/unit-tests/graphics/android/test_fb_device.cpp (+16/-7)
tests/unit-tests/graphics/android/test_fb_simple_swapper.cpp (+7/-5)
tests/unit-tests/graphics/android/test_hwc_configuration.cpp (+41/-99)
tests/unit-tests/graphics/android/test_hwc_device.cpp (+46/-51)
tests/unit-tests/graphics/android/test_hwc_fb_device.cpp (+2/-3)
tests/unit-tests/graphics/android/test_hwc_layerlist.cpp (+1/-1)
tests/unit-tests/graphics/android/test_hwc_logger.cpp (+18/-36)
tests/unit-tests/graphics/android/test_output_builder.cpp (+0/-35)
tests/unit-tests/graphics/android/test_platform.cpp (+1/-1)
tests/unit-tests/graphics/android/test_server_interpreter.cpp (+66/-20)
tests/unit-tests/graphics/mesa/test_buffer_allocator.cpp (+0/-66)
tests/unit-tests/graphics/mesa/test_display.cpp (+16/-19)
tests/unit-tests/graphics/mesa/test_display_buffer.cpp (+20/-30)
tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp (+6/-4)
tests/unit-tests/graphics/mesa/test_kms_page_flipper.cpp (+1/-20)
tests/unit-tests/graphics/nested/CMakeLists.txt (+1/-1)
tests/unit-tests/graphics/nested/test_nested_cursor.cpp (+0/-88)
tests/unit-tests/graphics/nested/test_nested_display.cpp (+5/-27)
tests/unit-tests/graphics/nested/test_nested_display_buffer.cpp (+81/-0)
tests/unit-tests/graphics/offscreen/test_offscreen_display.cpp (+9/-9)
tests/unit-tests/graphics/test_display.cpp (+2/-6)
tests/unit-tests/graphics/test_egl_error.cpp (+0/-115)
tests/unit-tests/graphics/test_program_factory.cpp (+1/-0)
tests/unit-tests/graphics/test_software_cursor.cpp (+13/-0)
tests/unit-tests/input/CMakeLists.txt (+0/-2)
tests/unit-tests/input/android/CMakeLists.txt (+1/-3)
tests/unit-tests/input/android/test_android_input_application_handle.cpp (+2/-1)
tests/unit-tests/input/android/test_android_input_dispatcher.cpp (+31/-16)
tests/unit-tests/input/android/test_android_input_lexicon.cpp (+36/-9)
tests/unit-tests/input/android/test_android_input_manager.cpp (+124/-3)
tests/unit-tests/input/android/test_android_input_sender.cpp (+4/-4)
tests/unit-tests/input/android/test_android_input_targeter.cpp (+9/-10)
tests/unit-tests/input/android/test_android_input_window_handle.cpp (+2/-1)
tests/unit-tests/input/android/test_android_pointer_controller.cpp (+3/-1)
tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp (+2/-8)
tests/unit-tests/input/android/test_input_dispatcher.cpp (+0/-125)
tests/unit-tests/input/android/test_input_reader_dispatchable.cpp (+0/-51)
tests/unit-tests/input/android/test_input_translator.cpp (+61/-30)
tests/unit-tests/input/test_cursor_controller.cpp (+15/-9)
tests/unit-tests/input/test_default_input_device_hub.cpp (+0/-382)
tests/unit-tests/input/test_default_input_manager.cpp (+0/-152)
tests/unit-tests/input/test_display_input_region.cpp (+14/-11)
tests/unit-tests/input/test_event_builders.cpp (+40/-92)
tests/unit-tests/input/test_event_filter_chain.cpp (+4/-3)
tests/unit-tests/input/test_input_event.cpp (+82/-69)
tests/unit-tests/input/test_xcursor_loader.cpp (+0/-1)
tests/unit-tests/library_example.cpp (+0/-37)
tests/unit-tests/library_example.h (+0/-38)
tests/unit-tests/logging/test_display_report.cpp (+11/-27)
tests/unit-tests/scene/CMakeLists.txt (+1/-1)
tests/unit-tests/scene/test_abstract_shell.cpp (+0/-447)
tests/unit-tests/scene/test_application_session.cpp (+48/-218)
tests/unit-tests/scene/test_basic_surface.cpp (+45/-36)
tests/unit-tests/scene/test_default_shell.cpp (+14/-22)
tests/unit-tests/scene/test_legacy_scene_change_notification.cpp (+0/-17)
tests/unit-tests/scene/test_session_manager.cpp (+5/-14)
tests/unit-tests/scene/test_surface.cpp (+84/-6)
tests/unit-tests/scene/test_surface_controller.cpp (+10/-10)
tests/unit-tests/scene/test_surface_impl.cpp (+30/-4)
tests/unit-tests/scene/test_surface_stack.cpp (+3/-168)
tests/unit-tests/shell/CMakeLists.txt (+0/-1)
tests/unit-tests/shell/test_graphics_display_layout.cpp (+0/-1)
tests/unit-tests/test_flags.cpp (+0/-93)
tests/unit-tests/test_glib_main_loop.cpp (+64/-91)
tests/unit-tests/test_lockable_callback.cpp (+0/-69)
tests/unit-tests/test_module_deleter.cpp (+0/-46)
tools/discover_gtests.sh (+0/-71)
tools/run_ctests.sh (+0/-59)
tools/update_package_abis.sh (+0/-256)
To merge this branch: bzr merge lp:~andreas-pokorny/mir/reworked-external-output-centering-integration-branch
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+251357@code.launchpad.net

Commit message

just for silo-009

Description of the change

reworked centering

To post a comment you must log in.
2332. By Andreas Pokorny

merge changes to lp:mir but leaving out all abi affecting changes

2333. By Andreas Pokorny

tweaking cursor size

2334. By Andreas Pokorny

synchronizing changelog

2335. By Andreas Pokorny

offset touch position with the display position

2336. By Andreas Pokorny

make test cases run

2337. By Andreas Pokorny

some debug output for usc

2338. By Andreas Pokorny

merged lp:mir

2339. By Andreas Pokorny

use top_left to offset touch coordinates

2340. By Andreas Pokorny

update to current lp:mir

2341. By Andreas Pokorny

updated to current lp:mir without integrating the changes

2342. By Andreas Pokorny

* integrate changes of for 0.12.1

2343. By Andreas Pokorny

merge lp:mir by essentially omitting most of the changes

2344. By Andreas Pokorny

fix changelog

2345. By Andreas Pokorny

update to current lp:mir

2346. By Andreas Pokorny

platform version 7 is expected

2347. By Andreas Pokorny

revert back to older server platform abi version

2348. By Andreas Pokorny

fix test case

2349. By Andreas Pokorny

rebasing ontop of lp:mir

2350. By Andreas Pokorny

rebase on lp:mir

2351. By Andreas Pokorny

rebase lp:mir

Unmerged revisions

2351. By Andreas Pokorny

rebase lp:mir

2350. By Andreas Pokorny

rebase on lp:mir

2349. By Andreas Pokorny

rebasing ontop of lp:mir

2348. By Andreas Pokorny

fix test case

2347. By Andreas Pokorny

revert back to older server platform abi version

2346. By Andreas Pokorny

platform version 7 is expected

2345. By Andreas Pokorny

update to current lp:mir

2344. By Andreas Pokorny

fix changelog

2343. By Andreas Pokorny

merge lp:mir by essentially omitting most of the changes

2342. By Andreas Pokorny

* integrate changes of for 0.12.1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '3rd_party/CMakeLists.txt'
--- 3rd_party/CMakeLists.txt 2015-05-07 09:06:20 +0000
+++ 3rd_party/CMakeLists.txt 2015-05-20 14:01:27 +0000
@@ -7,12 +7,17 @@
7 ${CMAKE_CURRENT_SOURCE_DIR}/android-deps7 ${CMAKE_CURRENT_SOURCE_DIR}/android-deps
8 )8 )
99
10add_library(
11 3rd_party
12
13 ${MIR_3RD_PARTY_SOURCES}
14)
15
10set(MIR_3RD_PARTY_INCLUDE_DIRECTORIES ${MIR_3RD_PARTY_INCLUDE_DIRECTORIES} PARENT_SCOPE)16set(MIR_3RD_PARTY_INCLUDE_DIRECTORIES ${MIR_3RD_PARTY_INCLUDE_DIRECTORIES} PARENT_SCOPE)
11set(MIR_INPUT_ANDROID_COMPILE_FLAGS ${MIR_INPUT_ANDROID_COMPILE_FLAGS}17set(MIR_INPUT_ANDROID_COMPILE_FLAGS ${MIR_INPUT_ANDROID_COMPILE_FLAGS}
12 PARENT_SCOPE)18 PARENT_SCOPE)
1319
14include_directories(${PROJECT_SOURCE_DIR}/src/include/common)20include_directories(${PROJECT_SOURCE_DIR}/src/include/common)
15include_directories(${PROJECT_SOURCE_DIR}/src/include/platform)
16include_directories(${CMAKE_CURRENT_SOURCE_DIR}/android-deps)21include_directories(${CMAKE_CURRENT_SOURCE_DIR}/android-deps)
17add_subdirectory(android-input)22add_subdirectory(android-input)
1823
@@ -29,3 +34,10 @@
29)34)
3035
31set(MIR_XCURSOR_INCLUDE_DIRECTORIES ${MIR_XCURSOR_INCLUDE_DIRECTORIES} PARENT_SCOPE)36set(MIR_XCURSOR_INCLUDE_DIRECTORIES ${MIR_XCURSOR_INCLUDE_DIRECTORIES} PARENT_SCOPE)
37
38target_link_libraries(
39 3rd_party
40
41 android-input
42 xcursorloader
43)
3244
=== modified file '3rd_party/android-deps/std/Thread.h'
--- 3rd_party/android-deps/std/Thread.h 2015-03-31 02:35:42 +0000
+++ 3rd_party/android-deps/std/Thread.h 2015-05-20 14:01:27 +0000
@@ -61,10 +61,7 @@
61 status.store(NO_ERROR);61 status.store(NO_ERROR);
62 exit_pending.store(false);62 exit_pending.store(false);
6363
64 // Avoid data races by doing a move capture instead of copy capture,64 thread = std::thread([name_str,this]() -> void
65 // since libstdc++ is using a copy-on-write implementation of std::string
66 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21334#c45
67 thread = std::thread([name_str = std::move(name_str),this]
68 {65 {
69 mir::set_thread_name(name_str);66 mir::set_thread_name(name_str);
70 try67 try
7168
=== modified file '3rd_party/android-input/android/CMakeLists.txt'
--- 3rd_party/android-input/android/CMakeLists.txt 2015-05-07 09:06:20 +0000
+++ 3rd_party/android-input/android/CMakeLists.txt 2015-05-20 14:01:27 +0000
@@ -26,7 +26,7 @@
2626
2727
28add_library(28add_library(
29 android-input-static STATIC29 android-input STATIC
30 # The stuff that we want30 # The stuff that we want
31 frameworks/base/services/input/EventHub.cpp31 frameworks/base/services/input/EventHub.cpp
32 frameworks/base/services/input/InputApplication.cpp32 frameworks/base/services/input/InputApplication.cpp
@@ -58,19 +58,19 @@
58#we don't have binder or skia available on hybris/linux platforms58#we don't have binder or skia available on hybris/linux platforms
59if(MIR_USE_BIONIC)59if(MIR_USE_BIONIC)
60 target_link_libraries(60 target_link_libraries(
61 android-input-static61 android-input
62 binder62 binder
63 skia)63 skia)
64endif()64endif()
6565
66target_link_libraries(66target_link_libraries(
67 android-input-static67 android-input
6868
69 ${Boost_LIBRARIES}69 ${Boost_LIBRARIES}
70)70)
7171
72set_target_properties(72set_target_properties(
73 android-input-static73 android-input
74 PROPERTIES74 PROPERTIES
75 COMPILE_FLAGS ${ANDROID_INPUT_COMPILE_FLAGS}75 COMPILE_FLAGS ${ANDROID_INPUT_COMPILE_FLAGS}
76)76)
7777
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp 2015-05-07 09:06:20 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp 2015-05-20 14:01:27 +0000
@@ -52,7 +52,6 @@
52#include <sys/inotify.h>52#include <sys/inotify.h>
53#include <sys/epoll.h>53#include <sys/epoll.h>
54#include <sys/ioctl.h>54#include <sys/ioctl.h>
55#include <sys/timerfd.h>
56// <mir changes>55// <mir changes>
57// Needed to build on android platform (PATH_MAX)56// Needed to build on android platform (PATH_MAX)
58#ifdef HAVE_ANDROID_OS57#ifdef HAVE_ANDROID_OS
@@ -209,7 +208,6 @@
209208
210const uint32_t EventHub::EPOLL_ID_UDEV;209const uint32_t EventHub::EPOLL_ID_UDEV;
211const uint32_t EventHub::EPOLL_ID_WAKE;210const uint32_t EventHub::EPOLL_ID_WAKE;
212const uint32_t EventHub::EPOLL_ID_TIMER;
213const int EventHub::EPOLL_SIZE_HINT;211const int EventHub::EPOLL_SIZE_HINT;
214const int EventHub::EPOLL_MAX_EVENTS;212const int EventHub::EPOLL_MAX_EVENTS;
215213
@@ -220,13 +218,11 @@
220 mOpeningDevices(0), mClosingDevices(0),218 mOpeningDevices(0), mClosingDevices(0),
221 mNeedToSendFinishedDeviceScan(false),219 mNeedToSendFinishedDeviceScan(false),
222 mNeedToReopenDevices(false), mNeedToScanDevices(true),220 mNeedToReopenDevices(false), mNeedToScanDevices(true),
223 mEpollFd{epoll_create(EPOLL_SIZE_HINT)},
224 mTimerFd{timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK|TFD_CLOEXEC)},
225 mPendingEventCount(0), mPendingEventIndex(0), mPendingUdevEvent(false) {221 mPendingEventCount(0), mPendingEventIndex(0), mPendingUdevEvent(false) {
226 acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);222 acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
227223
224 mEpollFd = epoll_create(EPOLL_SIZE_HINT);
228 LOG_ALWAYS_FATAL_IF(mEpollFd < 0, "Could not create epoll instance. errno=%d", errno);225 LOG_ALWAYS_FATAL_IF(mEpollFd < 0, "Could not create epoll instance. errno=%d", errno);
229 LOG_ALWAYS_FATAL_IF(mTimerFd < 0, "Could not create timerfd. errno=%d", errno);
230226
231 device_listener->filter_by_subsystem("input");227 device_listener->filter_by_subsystem("input");
232 device_listener->enable();228 device_listener->enable();
@@ -258,11 +254,6 @@
258 result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, mWakeReadPipeFd, &eventItem);254 result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, mWakeReadPipeFd, &eventItem);
259 LOG_ALWAYS_FATAL_IF(result != 0, "Could not add wake read pipe to epoll instance. errno=%d",255 LOG_ALWAYS_FATAL_IF(result != 0, "Could not add wake read pipe to epoll instance. errno=%d",
260 errno);256 errno);
261
262 eventItem.data.u32 = EPOLL_ID_TIMER;
263 result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, mTimerFd, &eventItem);
264 LOG_ALWAYS_FATAL_IF(result != 0, "Could not add timer fd to epoll instance. errno=%d",
265 errno);
266}257}
267258
268EventHub::~EventHub(void) {259EventHub::~EventHub(void) {
@@ -274,6 +265,7 @@
274 delete device;265 delete device;
275 }266 }
276267
268 ::close(mEpollFd);
277 ::close(mWakeReadPipeFd);269 ::close(mWakeReadPipeFd);
278 ::close(mWakeWritePipeFd);270 ::close(mWakeWritePipeFd);
279271
@@ -662,7 +654,7 @@
662 return NULL;654 return NULL;
663}655}
664656
665size_t EventHub::getEvents(RawEvent* buffer, size_t bufferSize) {657size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) {
666 ALOG_ASSERT(bufferSize >= 1);658 ALOG_ASSERT(bufferSize >= 1);
667659
668 AutoMutex _l(mLock);660 AutoMutex _l(mLock);
@@ -763,19 +755,6 @@
763 continue;755 continue;
764 }756 }
765757
766 if (eventItem.data.u32 == EPOLL_ID_TIMER) {
767 if (eventItem.events & EPOLLIN) {
768 ALOGV("awoken after wakeIn()");
769 awoken = true;
770 uint64_t timeout_count;
771 read(mTimerFd, &timeout_count, sizeof timeout_count);
772 } else {
773 ALOGW("Received unexpected epoll event 0x%08x for wake read pipe.",
774 eventItem.events);
775 }
776 continue;
777 }
778
779 ssize_t deviceIndex = mDevices.indexOfKey(eventItem.data.u32);758 ssize_t deviceIndex = mDevices.indexOfKey(eventItem.data.u32);
780 if (deviceIndex < 0) {759 if (deviceIndex < 0) {
781 ALOGW("Received unexpected epoll event 0x%08x for unknown device id %d.",760 ALOGW("Received unexpected epoll event 0x%08x for unknown device id %d.",
@@ -884,13 +863,15 @@
884 // when this happens, the EventHub holds onto its own user wake lock while the client863 // when this happens, the EventHub holds onto its own user wake lock while the client
885 // is processing events. Thus the system can only sleep if there are no events864 // is processing events. Thus the system can only sleep if there are no events
886 // pending or currently being processed.865 // pending or currently being processed.
866 //
867 // The timeout is advisory only. If the device is asleep, it will not wake just to
868 // service the timeout.
887 mPendingEventIndex = 0;869 mPendingEventIndex = 0;
888870
889 mLock.unlock(); // release lock before poll, must be before release_wake_lock871 mLock.unlock(); // release lock before poll, must be before release_wake_lock
890 release_wake_lock(WAKE_LOCK_ID);872 release_wake_lock(WAKE_LOCK_ID);
891873
892 // non blocking call to epoll_wait - blocking happens in dispatch threads874 int pollResult = epoll_wait(mEpollFd, mPendingEventItems, EPOLL_MAX_EVENTS, timeoutMillis);
893 int pollResult = epoll_wait(mEpollFd, mPendingEventItems, EPOLL_MAX_EVENTS, 0);
894875
895 acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);876 acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
896 mLock.lock(); // reacquire lock after poll, must be after acquire_wake_lock877 mLock.lock(); // reacquire lock after poll, must be after acquire_wake_lock
@@ -921,15 +902,6 @@
921 return event - buffer;902 return event - buffer;
922}903}
923904
924void EventHub::wakeIn(int32_t timeoutMillis) {
925 itimerspec delay;
926 std::memset(&delay, 0, sizeof delay);
927
928 delay.it_value.tv_sec = timeoutMillis / 1000;
929 delay.it_value.tv_nsec = (timeoutMillis % 1000) * 1000000LL;
930 timerfd_settime(mTimerFd, 0, &delay, nullptr);
931}
932
933void EventHub::wake() {905void EventHub::wake() {
934 ALOGV("wake() called");906 ALOGV("wake() called");
935907
@@ -1365,7 +1337,7 @@
1365}1337}
13661338
1367bool EventHub::hasKeycodeLocked(Device* device, int keycode) const {1339bool EventHub::hasKeycodeLocked(Device* device, int keycode) const {
1368 if (!device->keyMap.haveKeyLayout()) {1340 if (!device->keyMap.haveKeyLayout() || !device->keyBitmask) {
1369 return false;1341 return false;
1370 }1342 }
1371 1343
@@ -1528,9 +1500,4 @@
1528 return false;1500 return false;
1529}1501}
15301502
1531mir::Fd EventHub::fd()
1532{
1533 return mEpollFd;
1534}
1535
1536}; // namespace android1503}; // namespace android
15371504
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/EventHub.h'
--- 3rd_party/android-input/android/frameworks/base/services/input/EventHub.h 2015-05-07 09:06:20 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/EventHub.h 2015-05-20 14:01:27 +0000
@@ -32,8 +32,6 @@
32#include <std/Vector.h>32#include <std/Vector.h>
33#include <std/KeyedVector.h>33#include <std/KeyedVector.h>
3434
35#include "mir/fd.h"
36
37#include <linux/input.h>35#include <linux/input.h>
38#include <sys/epoll.h>36#include <sys/epoll.h>
3937
@@ -196,15 +194,18 @@
196 virtual void setExcludedDevices(const Vector<String8>& devices) = 0;194 virtual void setExcludedDevices(const Vector<String8>& devices) = 0;
197195
198 /*196 /*
199 * Tests for available events and returns them.197 * Wait for events to become available and returns them.
200 * After returning, the EventHub holds onto a wake lock until the next call to getEvent.198 * After returning, the EventHub holds onto a wake lock until the next call to getEvent.
201 * This ensures that the device will not go to sleep while the event is being processed.199 * This ensures that the device will not go to sleep while the event is being processed.
202 * If the device needs to remain awake longer than that, then the caller is responsible200 * If the device needs to remain awake longer than that, then the caller is responsible
203 * for taking care of it (say, by poking the power manager user activity timer).201 * for taking care of it (say, by poking the power manager user activity timer).
204 *202 *
205 * Returns the number of events obtained.203 * The timeout is advisory only. If the device is asleep, it will not wake just to
204 * service the timeout.
205 *
206 * Returns the number of events obtained, or 0 if the timeout expired.
206 */207 */
207 virtual size_t getEvents(RawEvent* buffer, size_t bufferSize) = 0;208 virtual size_t getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) = 0;
208209
209 /*210 /*
210 * Query current input state.211 * Query current input state.
@@ -241,9 +242,6 @@
241 /* Wakes up getEvents() if it is blocked on a read. */242 /* Wakes up getEvents() if it is blocked on a read. */
242 virtual void wake() = 0;243 virtual void wake() = 0;
243244
244 /* Ensures that fd() readable after given timeout */
245 virtual void wakeIn(int32_t timeout) = 0;
246
247 /* Dump EventHub state to a string. */245 /* Dump EventHub state to a string. */
248 virtual void dump(String8& dump) = 0;246 virtual void dump(String8& dump) = 0;
249247
@@ -252,9 +250,6 @@
252250
253 /* Flush all pending events not yet read from the input devices */251 /* Flush all pending events not yet read from the input devices */
254 virtual void flush() = 0;252 virtual void flush() = 0;
255
256 /* Epoll fd used by EventHub */
257 virtual mir::Fd fd() = 0;
258};253};
259254
260class EventHub : public EventHubInterface255class EventHub : public EventHubInterface
@@ -291,7 +286,7 @@
291 virtual bool markSupportedKeyCodes(int32_t deviceId, size_t numCodes,286 virtual bool markSupportedKeyCodes(int32_t deviceId, size_t numCodes,
292 const int32_t* keyCodes, uint8_t* outFlags) const;287 const int32_t* keyCodes, uint8_t* outFlags) const;
293288
294 virtual size_t getEvents(RawEvent* buffer, size_t bufferSize);289 virtual size_t getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize);
295290
296 virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const;291 virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const;
297 virtual bool hasLed(int32_t deviceId, int32_t led) const;292 virtual bool hasLed(int32_t deviceId, int32_t led) const;
@@ -309,19 +304,13 @@
309 virtual void requestReopenDevices();304 virtual void requestReopenDevices();
310305
311 virtual void wake();306 virtual void wake();
312 virtual void wakeIn(int32_t timeout);
313307
314 virtual void dump(String8& dump);308 virtual void dump(String8& dump);
315 virtual void monitor();309 virtual void monitor();
316 virtual void flush();310 virtual void flush();
317 virtual mir::Fd fd();
318311
319 virtual ~EventHub();312 virtual ~EventHub();
320313
321 // Ids used for epoll notifications not associated with devices.
322 static const uint32_t EPOLL_ID_UDEV = 0x80000001;
323 static const uint32_t EPOLL_ID_WAKE = 0x80000002;
324 static const uint32_t EPOLL_ID_TIMER = 0x80000003;
325private:314private:
326 std::shared_ptr<mir::input::InputReport> const input_report;315 std::shared_ptr<mir::input::InputReport> const input_report;
327316
@@ -416,12 +405,15 @@
416 bool mNeedToScanDevices;405 bool mNeedToScanDevices;
417 Vector<String8> mExcludedDevices;406 Vector<String8> mExcludedDevices;
418407
419 mir::Fd mEpollFd;408 int mEpollFd;
420 mir::Fd mTimerFd;
421 std::unique_ptr<mir::udev::Monitor> const device_listener;409 std::unique_ptr<mir::udev::Monitor> const device_listener;
422 int mWakeReadPipeFd;410 int mWakeReadPipeFd;
423 int mWakeWritePipeFd;411 int mWakeWritePipeFd;
424412
413 // Ids used for epoll notifications not associated with devices.
414 static const uint32_t EPOLL_ID_UDEV = 0x80000001;
415 static const uint32_t EPOLL_ID_WAKE = 0x80000002;
416
425 // Epoll FD list size hint.417 // Epoll FD list size hint.
426 static const int EPOLL_SIZE_HINT = 8;418 static const int EPOLL_SIZE_HINT = 8;
427419
428420
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp 2015-05-07 09:06:20 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp 2015-05-20 14:01:27 +0000
@@ -43,8 +43,6 @@
43// Log debug messages about hover events.43// Log debug messages about hover events.
44#define DEBUG_HOVER 044#define DEBUG_HOVER 0
4545
46#define ENABLE_APP_SWITCH_OPTIMIZATION 0
47
48#include "InputDispatcher.h"46#include "InputDispatcher.h"
4947
50#include "mir/input/input_report.h"48#include "mir/input/input_report.h"
@@ -375,7 +373,6 @@
375373
376 switch (entry->type) {374 switch (entry->type) {
377 case EventEntry::TYPE_KEY: {375 case EventEntry::TYPE_KEY: {
378#if ENABLE_APP_SWITCH_OPTIMIZATION == 1
379 // Optimize app switch latency.376 // Optimize app switch latency.
380 // If the application takes too long to catch up then we drop all events preceding377 // If the application takes too long to catch up then we drop all events preceding
381 // the app switch key.378 // the app switch key.
@@ -394,7 +391,6 @@
394 }391 }
395 }392 }
396 }393 }
397#endif
398 break;394 break;
399 }395 }
400396
@@ -667,7 +663,7 @@
667 && (entry->policyFlags & POLICY_FLAG_TRUSTED)663 && (entry->policyFlags & POLICY_FLAG_TRUSTED)
668 && (!(entry->policyFlags & POLICY_FLAG_DISABLE_KEY_REPEAT))) {664 && (!(entry->policyFlags & POLICY_FLAG_DISABLE_KEY_REPEAT))) {
669 if (mKeyRepeatState.lastKeyEntry665 if (mKeyRepeatState.lastKeyEntry
670 && mKeyRepeatState.lastKeyEntry->is_same_key(entry)) {666 && mKeyRepeatState.lastKeyEntry->keyCode == entry->keyCode) {
671 // We have seen two identical key downs in a row which indicates that the device667 // We have seen two identical key downs in a row which indicates that the device
672 // driver is automatically generating key repeats itself. We take note of the668 // driver is automatically generating key repeats itself. We take note of the
673 // repeat here, but we disable our own next key repeat timer since it is clear that669 // repeat here, but we disable our own next key repeat timer since it is clear that
@@ -3743,12 +3739,6 @@
3743 interceptKeyWakeupTime = std::chrono::nanoseconds(0);3739 interceptKeyWakeupTime = std::chrono::nanoseconds(0);
3744}3740}
37453741
3746bool InputDispatcher::KeyEntry::is_same_key(KeyEntry* other) const {
3747 if (keyCode != 0)
3748 return keyCode == other->keyCode;
3749 else
3750 return scanCode == other->scanCode;
3751}
37523742
3753// --- InputDispatcher::MotionEntry ---3743// --- InputDispatcher::MotionEntry ---
37543744
37553745
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.h'
--- 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.h 2015-05-07 09:06:20 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.h 2015-05-20 14:01:27 +0000
@@ -516,8 +516,6 @@
516 virtual void appendDescription(String8& msg) const;516 virtual void appendDescription(String8& msg) const;
517 void recycle();517 void recycle();
518518
519 bool is_same_key(KeyEntry* other) const;
520
521 protected:519 protected:
522 virtual ~KeyEntry();520 virtual ~KeyEntry();
523 };521 };
524522
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp 2015-05-07 09:06:20 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp 2015-05-20 14:01:27 +0000
@@ -269,23 +269,27 @@
269269
270void InputReader::loopOnce() {270void InputReader::loopOnce() {
271 int32_t oldGeneration;271 int32_t oldGeneration;
272 int32_t timeoutMillis;
272 bool inputDevicesChanged = false;273 bool inputDevicesChanged = false;
273 Vector<InputDeviceInfo> inputDevices;274 Vector<InputDeviceInfo> inputDevices;
274 { // acquire lock275 { // acquire lock
275 AutoMutex _l(mLock);276 AutoMutex _l(mLock);
276277
277 oldGeneration = mGeneration;278 oldGeneration = mGeneration;
279 timeoutMillis = -1;
278280
279 uint32_t changes = mConfigurationChangesToRefresh;281 uint32_t changes = mConfigurationChangesToRefresh;
280 if (changes) {282 if (changes) {
281 if (0 == (changes & InputReaderConfiguration::CHANGE_MUST_REOPEN))
282 mEventHub->wake();
283 mConfigurationChangesToRefresh = 0;283 mConfigurationChangesToRefresh = 0;
284 timeoutMillis = 0;
284 refreshConfigurationLocked(changes);285 refreshConfigurationLocked(changes);
286 } else if (mNextTimeout != std::chrono::nanoseconds(LLONG_MAX)) {
287 std::chrono::nanoseconds now = systemTime(SYSTEM_TIME_MONOTONIC);
288 timeoutMillis = toMillisecondTimeoutDelay(now, mNextTimeout);
285 }289 }
286 } // release lock290 } // release lock
287291
288 size_t count = mEventHub->getEvents(mEventBuffer, EVENT_BUFFER_SIZE);292 size_t count = mEventHub->getEvents(timeoutMillis, mEventBuffer, EVENT_BUFFER_SIZE);
289293
290 { // acquire lock294 { // acquire lock
291 AutoMutex _l(mLock);295 AutoMutex _l(mLock);
@@ -570,8 +574,7 @@
570void InputReader::requestTimeoutAtTimeLocked(std::chrono::nanoseconds when) {574void InputReader::requestTimeoutAtTimeLocked(std::chrono::nanoseconds when) {
571 if (when < mNextTimeout) {575 if (when < mNextTimeout) {
572 mNextTimeout = when;576 mNextTimeout = when;
573 std::chrono::nanoseconds now = systemTime(SYSTEM_TIME_MONOTONIC);577 mEventHub->wake();
574 mEventHub->wakeIn(toMillisecondTimeoutDelay(now, mNextTimeout));
575 }578 }
576}579}
577580
@@ -3934,6 +3937,15 @@
3934void TouchInputMapper::cookPointerData() {3937void TouchInputMapper::cookPointerData() {
3935 uint32_t currentPointerCount = mCurrentRawPointerData.pointerCount;3938 uint32_t currentPointerCount = mCurrentRawPointerData.pointerCount;
39363939
3940 // hack
3941 auto pointer = mPointerController;
3942
3943 float display_x = 0, display_y = 0;
3944 if (pointer == nullptr)
3945 pointer = getPolicy()->obtainPointerController(getDeviceId());
3946
3947 if (pointer != nullptr)
3948 pointer->getDisplayPosition(display_x, display_y);
3937 mCurrentCookedPointerData.clear();3949 mCurrentCookedPointerData.clear();
3938 mCurrentCookedPointerData.pointerCount = currentPointerCount;3950 mCurrentCookedPointerData.pointerCount = currentPointerCount;
3939 mCurrentCookedPointerData.hoveringIds = mCurrentRawPointerData.hoveringIds;3951 mCurrentCookedPointerData.hoveringIds = mCurrentRawPointerData.hoveringIds;
@@ -4079,8 +4091,8 @@
4079 }4091 }
40804092
4081 // X and Y4093 // X and Y
4094 float x, y;
4082 // Adjust coords for surface orientation.4095 // Adjust coords for surface orientation.
4083 float x, y;
4084 switch (mSurfaceOrientation) {4096 switch (mSurfaceOrientation) {
4085 case DISPLAY_ORIENTATION_90:4097 case DISPLAY_ORIENTATION_90:
4086 x = float(in.y - mRawPointerAxes.y.minValue) * mYScale;4098 x = float(in.y - mRawPointerAxes.y.minValue) * mYScale;
@@ -4108,6 +4120,10 @@
4108 break;4120 break;
4109 }4121 }
41104122
4123 // offset to input region
4124 x -= display_x;
4125 y -= display_y;
4126
4111 // Write output coords.4127 // Write output coords.
4112 PointerCoords& out = mCurrentCookedPointerData.pointerCoords[i];4128 PointerCoords& out = mCurrentCookedPointerData.pointerCoords[i];
4113 out.clear();4129 out.clear();
41144130
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/MirLog.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/MirLog.cpp 2015-03-31 02:35:42 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/MirLog.cpp 2015-05-20 14:01:27 +0000
@@ -42,8 +42,6 @@
42#include <cstdlib>42#include <cstdlib>
43#include <cstring>43#include <cstring>
4444
45#include <atomic>
46
47#define kMaxTagLen 16 /* from the long-dead utils/Log.cpp */45#define kMaxTagLen 16 /* from the long-dead utils/Log.cpp */
48#define kTagSetSize 16 /* arbitrary */46#define kTagSetSize 16 /* arbitrary */
4947
@@ -51,14 +49,14 @@
51{49{
52 struct LogState {50 struct LogState {
53 /* global minimum priority */51 /* global minimum priority */
54 std::atomic<int> globalMinPriority{ANDROID_LOG_UNKNOWN};52 int globalMinPriority;
5553
56 /* tags and priorities */54 /* tags and priorities */
57 struct {55 struct {
58 char tag[kMaxTagLen];56 char tag[kMaxTagLen];
59 std::atomic<int> minPriority;57 int minPriority;
60 } tagSet[kTagSetSize];58 } tagSet[kTagSetSize];
61 } gLogState = {};59 } gLogState = { .globalMinPriority = ANDROID_LOG_UNKNOWN };
62}60}
6361
64/*62/*
6563
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/PointerController.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/PointerController.cpp 2014-03-06 06:05:17 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/PointerController.cpp 2015-05-20 14:01:27 +0000
@@ -273,4 +273,9 @@
273 // TODO: Implement273 // TODO: Implement
274}274}
275275
276void PointerController::getDisplayPosition(float &x, float &y) const {
277 x = 0;
278 y = 0;
279}
280
276} // namespace android281} // namespace android
277282
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/PointerController.h'
--- 3rd_party/android-input/android/frameworks/base/services/input/PointerController.h 2014-03-06 06:05:17 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/PointerController.h 2015-05-20 14:01:27 +0000
@@ -68,6 +68,9 @@
68 /* Gets the absolute location of the pointer. */68 /* Gets the absolute location of the pointer. */
69 virtual void getPosition(float* outX, float* outY) const = 0;69 virtual void getPosition(float* outX, float* outY) const = 0;
7070
71 // hack
72 virtual void getDisplayPosition(float &x, float& y) const = 0;
73
71 enum Transition {74 enum Transition {
72 // Fade/unfade immediately.75 // Fade/unfade immediately.
73 TRANSITION_IMMEDIATE,76 TRANSITION_IMMEDIATE,
@@ -142,6 +145,7 @@
142145
143 void setDisplaySize(int32_t width, int32_t height);146 void setDisplaySize(int32_t width, int32_t height);
144 void setDisplayOrientation(int32_t orientation);147 void setDisplayOrientation(int32_t orientation);
148 void getDisplayPosition(float &x, float& y) const override;
145149
146private:150private:
147 mutable Mutex mLock;151 mutable Mutex mLock;
148152
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp 2015-03-31 02:35:42 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp 2015-05-20 14:01:27 +0000
@@ -70,7 +70,7 @@
7070
71 float vx, vy;71 float vx, vy;
72 float scale = mParameters.scale;72 float scale = mParameters.scale;
73 if (mVelocityTracker.getVelocity(0, &vx, &vy)) {73 if (mVelocityTracker.getVelocity(1, &vx, &vy)) {
74 float speed = hypotf(vx, vy) * scale;74 float speed = hypotf(vx, vy) * scale;
75 if (speed >= mParameters.highThreshold) {75 if (speed >= mParameters.highThreshold) {
76 // Apply full acceleration above the high speed threshold.76 // Apply full acceleration above the high speed threshold.
7777
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp 2015-03-31 02:35:42 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp 2015-05-20 14:01:27 +0000
@@ -65,36 +65,31 @@
6565
66#if DEBUG_STRATEGY || DEBUG_VELOCITY66#if DEBUG_STRATEGY || DEBUG_VELOCITY
67static String8 vectorToString(const float* a, uint32_t m) {67static String8 vectorToString(const float* a, uint32_t m) {
68 String8 str;68 std::stringstream str;
69 str.append("[");69 str << '[';
70 while (m--) {70 while (m--) {
71 str.appendFormat(" %f", *(a++));71 str << *a++;
72 if (m) {72 if (m)
73 str.append(",");73 str << ',';
74 }
75 }74 }
76 str.append(" ]");75 str << ']';
77 return str;76 return str.str();
78}77}
7978
80static String8 matrixToString(const float* a, uint32_t m, uint32_t n, bool rowMajor) {79static String8 matrixToString(const float* a, uint32_t m, uint32_t n, bool rowMajor) {
81 String8 str;80 std::stringstream str;
82 str.append("[");81 str << '[';
83 for (size_t i = 0; i < m; i++) {82 for (size_t i = 0; i < m; i++) {
84 if (i) {83 if (i) str << ',';
85 str.append(",");84 str << " [";
86 }
87 str.append(" [");
88 for (size_t j = 0; j < n; j++) {85 for (size_t j = 0; j < n; j++) {
89 if (j) {86 if (j) str << ',';
90 str.append(",");87 str << ' ' << a[rowMajor ? i * n + j : j * m + i];
91 }
92 str.appendFormat(" %f", a[rowMajor ? i * n + j : j * m + i]);
93 }88 }
94 str.append(" ]");89 str << " ]";
95 }90 }
96 str.append(" ]");91 str << " ]";
97 return str;92 return str.str();
98}93}
99#endif94#endif
10095
@@ -249,11 +244,11 @@
249 "estimator (degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f)",244 "estimator (degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f)",
250 id, positions[index].x, positions[index].y,245 id, positions[index].x, positions[index].y,
251 int(estimator.degree),246 int(estimator.degree),
252 vectorToString(estimator.xCoeff, estimator.degree + 1).string(),247 vectorToString(estimator.xCoeff, estimator.degree + 1).c_str(),
253 vectorToString(estimator.yCoeff, estimator.degree + 1).string(),248 vectorToString(estimator.yCoeff, estimator.degree + 1).c_str(),
254 estimator.confidence);249 estimator.confidence);
255 ++index;250 ++index;
256 }251 });
257#endif252#endif
258}253}
259254
@@ -436,8 +431,8 @@
436 const float* w, uint32_t m, uint32_t n, float* outB, float* outDet) {431 const float* w, uint32_t m, uint32_t n, float* outB, float* outDet) {
437#if DEBUG_STRATEGY432#if DEBUG_STRATEGY
438 ALOGD("solveLeastSquares: m=%d, n=%d, x=%s, y=%s, w=%s", int(m), int(n),433 ALOGD("solveLeastSquares: m=%d, n=%d, x=%s, y=%s, w=%s", int(m), int(n),
439 vectorToString(x, m).string(), vectorToString(y, m).string(),434 vectorToString(x, m).c_str(), vectorToString(y, m).c_str(),
440 vectorToString(w, m).string());435 vectorToString(w, m).c_str());
441#endif436#endif
442437
443 // Expand the X vector to a matrix A, pre-multiplied by the weights.438 // Expand the X vector to a matrix A, pre-multiplied by the weights.
@@ -449,7 +444,7 @@
449 }444 }
450 }445 }
451#if DEBUG_STRATEGY446#if DEBUG_STRATEGY
452 ALOGD(" - a=%s", matrixToString(&a[0][0], m, n, false /*rowMajor*/).string());447 ALOGD(" - a=%s", matrixToString(&a[0][0], m, n, false /*rowMajor*/).c_str());
453#endif448#endif
454449
455 // Apply the Gram-Schmidt process to A to obtain its QR decomposition.450 // Apply the Gram-Schmidt process to A to obtain its QR decomposition.
@@ -484,8 +479,8 @@
484 }479 }
485 }480 }
486#if DEBUG_STRATEGY481#if DEBUG_STRATEGY
487 ALOGD(" - q=%s", matrixToString(&q[0][0], m, n, false /*rowMajor*/).string());482 ALOGD(" - q=%s", matrixToString(&q[0][0], m, n, false /*rowMajor*/).c_str());
488 ALOGD(" - r=%s", matrixToString(&r[0][0], n, n, true /*rowMajor*/).string());483 ALOGD(" - r=%s", matrixToString(&r[0][0], n, n, true /*rowMajor*/).c_str());
489484
490 // calculate QR, if we factored A correctly then QR should equal A485 // calculate QR, if we factored A correctly then QR should equal A
491 float qr[n][m];486 float qr[n][m];
@@ -497,7 +492,7 @@
497 }492 }
498 }493 }
499 }494 }
500 ALOGD(" - qr=%s", matrixToString(&qr[0][0], m, n, false /*rowMajor*/).string());495 ALOGD(" - qr=%s", matrixToString(&qr[0][0], m, n, false /*rowMajor*/).c_str());
501#endif496#endif
502497
503 // Solve R B = Qt W Y to find B. This is easy because R is upper triangular.498 // Solve R B = Qt W Y to find B. This is easy because R is upper triangular.
@@ -514,7 +509,7 @@
514 outB[i] /= r[i][i];509 outB[i] /= r[i][i];
515 }510 }
516#if DEBUG_STRATEGY511#if DEBUG_STRATEGY
517 ALOGD(" - b=%s", vectorToString(outB, n).string());512 ALOGD(" - b=%s", vectorToString(outB, n).c_str());
518#endif513#endif
519514
520 // Calculate the coefficient of determination as 1 - (SSerr / SStot) where515 // Calculate the coefficient of determination as 1 - (SSerr / SStot) where
@@ -598,10 +593,10 @@
598 outEstimator->degree = degree;593 outEstimator->degree = degree;
599 outEstimator->confidence = xdet * ydet;594 outEstimator->confidence = xdet * ydet;
600#if DEBUG_STRATEGY595#if DEBUG_STRATEGY
601 ALOGD("estimate: degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f",596 ALOGD("estimate : degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f",
602 int(outEstimator->degree),597 int(outEstimator->degree),
603 vectorToString(outEstimator->xCoeff, n).string(),598 vectorToString(outEstimator->xCoeff, n).c_str(),
604 vectorToString(outEstimator->yCoeff, n).string(),599 vectorToString(outEstimator->yCoeff, n).c_str(),
605 outEstimator->confidence);600 outEstimator->confidence);
606#endif601#endif
607 return true;602 return true;
608603
=== modified file '3rd_party/xcursor/CMakeLists.txt'
--- 3rd_party/xcursor/CMakeLists.txt 2015-05-07 09:06:20 +0000
+++ 3rd_party/xcursor/CMakeLists.txt 2015-05-20 14:01:27 +0000
@@ -5,7 +5,7 @@
5)5)
66
7add_library(7add_library(
8 xcursorloader-static STATIC8 xcursorloader STATIC
99
10 ${XCURSOR_SOURCES}10 ${XCURSOR_SOURCES}
11)11)
1212
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-05-19 04:37:02 +0000
+++ CMakeLists.txt 2015-05-20 14:01:27 +0000
@@ -23,12 +23,12 @@
2323
24cmake_policy(SET CMP0015 NEW)24cmake_policy(SET CMP0015 NEW)
2525
26set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)26set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
27set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${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 14) # This should change at least with every MIRSERVER_ABI30set(MIR_VERSION_MINOR 12) # This should change at least with every MIRSERVER_ABI
31set(MIR_VERSION_PATCH 0)31set(MIR_VERSION_PATCH 1)
3232
33add_definitions(-DMIR_VERSION_MAJOR=${MIR_VERSION_MAJOR})33add_definitions(-DMIR_VERSION_MAJOR=${MIR_VERSION_MAJOR})
34add_definitions(-DMIR_VERSION_MINOR=${MIR_VERSION_MINOR})34add_definitions(-DMIR_VERSION_MINOR=${MIR_VERSION_MINOR})
@@ -215,20 +215,17 @@
215215
216if (MIR_ENABLE_TESTS)216if (MIR_ENABLE_TESTS)
217 find_package(GtestGmock REQUIRED)217 find_package(GtestGmock REQUIRED)
218 pkg_check_modules(LIBEVDEV REQUIRED libevdev)
219 include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR})218 include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR})
220 add_subdirectory(tests/)219 add_subdirectory(tests/)
221220
222 # There's no nice way to format this. Thanks CMake.221 # There's no nice way to format this. Thanks CMake.
223 mir_add_test(NAME LGPL-required222 add_test(LGPL-required
224 COMMAND /bin/sh -c "! grep -rl 'GNU General' ${PROJECT_SOURCE_DIR}/src/client ${PROJECT_SOURCE_DIR}/include/client ${PROJECT_SOURCE_DIR}/src/common ${PROJECT_SOURCE_DIR}/include/common ${PROJECT_SOURCE_DIR}/src/include/common ${PROJECT_SOURCE_DIR}/src/platform ${PROJECT_SOURCE_DIR}/include/platform ${PROJECT_SOURCE_DIR}/src/include/platform"223 /bin/sh -c "! grep -rl 'GNU General' ${PROJECT_SOURCE_DIR}/src/client ${PROJECT_SOURCE_DIR}/include/client ${PROJECT_SOURCE_DIR}/src/common ${PROJECT_SOURCE_DIR}/include/common ${PROJECT_SOURCE_DIR}/src/include/common ${PROJECT_SOURCE_DIR}/src/platform ${PROJECT_SOURCE_DIR}/include/platform ${PROJECT_SOURCE_DIR}/src/include/platform"
225 )224 )
226 mir_add_test(NAME GPL-required225 add_test(GPL-required
227 COMMAND /bin/sh -c "! grep -rl 'GNU Lesser' ${PROJECT_SOURCE_DIR}/src/server ${PROJECT_SOURCE_DIR}/include/server ${PROJECT_SOURCE_DIR}/src/include/server ${PROJECT_SOURCE_DIR}/tests ${PROJECT_SOURCE_DIR}/examples"226 /bin/sh -c "! grep -rl 'GNU Lesser' ${PROJECT_SOURCE_DIR}/src/server ${PROJECT_SOURCE_DIR}/include/server ${PROJECT_SOURCE_DIR}/src/include/server ${PROJECT_SOURCE_DIR}/tests ${PROJECT_SOURCE_DIR}/examples"
228 )227 )
229228
230 mir_add_test(NAME package-abis
231 COMMAND /bin/sh -c "cd ${PROJECT_SOURCE_DIR} && tools/update_package_abis.sh --check --verbose")
232endif ()229endif ()
233230
234enable_coverage_report(mirserver)231enable_coverage_report(mirserver)
@@ -236,7 +233,3 @@
236include (cmake/ABICheck.cmake)233include (cmake/ABICheck.cmake)
237234
238add_subdirectory(snappy)235add_subdirectory(snappy)
239
240add_custom_target(ptest
241 COMMAND "${CMAKE_SOURCE_DIR}/tools/run_ctests.sh" "--cost-file" "${CMAKE_BINARY_DIR}/ptest_ctest_cost_data.txt" "sh ${CMAKE_BINARY_DIR}/discover_all_tests.sh" "--" "$$ARGS"
242 )
243236
=== modified file 'benchmarks/android-input/CMakeLists.txt'
--- benchmarks/android-input/CMakeLists.txt 2015-05-07 09:06:20 +0000
+++ benchmarks/android-input/CMakeLists.txt 2015-05-20 14:01:27 +0000
@@ -14,8 +14,8 @@
14target_link_libraries(14target_link_libraries(
15 input-reader-perf15 input-reader-perf
1616
17 android-input-static17 android-input
18 mir-test-doubles-static18 mir-test-doubles
19 mirserver19 mirserver
20 )20 )
2121
2222
=== modified file 'benchmarks/benchmark_multiplexing_dispatchable.cpp'
--- benchmarks/benchmark_multiplexing_dispatchable.cpp 2015-05-07 09:06:20 +0000
+++ benchmarks/benchmark_multiplexing_dispatchable.cpp 2015-05-20 14:01:27 +0000
@@ -20,6 +20,7 @@
20#include "mir/dispatch/simple_dispatch_thread.h"20#include "mir/dispatch/simple_dispatch_thread.h"
2121
22#include <iostream>22#include <iostream>
23#include <atomic>
23#include <vector>24#include <vector>
24#include <memory>25#include <memory>
25#include <chrono>26#include <chrono>
2627
=== modified file 'benchmarks/frame-uniformity/CMakeLists.txt'
--- benchmarks/frame-uniformity/CMakeLists.txt 2015-05-07 09:06:20 +0000
+++ benchmarks/frame-uniformity/CMakeLists.txt 2015-05-20 14:01:27 +0000
@@ -23,13 +23,17 @@
23target_link_libraries(frame_uniformity_test_client23target_link_libraries(frame_uniformity_test_client
24 mirserver24 mirserver
25 mirclient25 mirclient
26
27 mir-test
28 mir-test-framework
29 mir-test-doubles
30 mir-test-doubles-platform
31
32 # Why does this have to come after mir-test-framework here but not in tests/acceptance-tests/
33 # /CMakeLists.txt? ~racarr
26 mirplatform34 mirplatform
27
28 mir-test-static
29 mir-test-framework-static
30 mir-test-doubles-static
31 mir-test-doubles-platform-static
3235
36 3rd_party
33 ${PROTOBUF_LIBRARIES}37 ${PROTOBUF_LIBRARIES}
34 ${Boost_LIBRARIES}38 ${Boost_LIBRARIES}
35 ${GTEST_BOTH_LIBRARIES}39 ${GTEST_BOTH_LIBRARIES}
3640
=== modified file 'benchmarks/frame-uniformity/main.cpp'
--- benchmarks/frame-uniformity/main.cpp 2015-03-31 02:35:42 +0000
+++ benchmarks/frame-uniformity/main.cpp 2015-05-20 14:01:27 +0000
@@ -18,7 +18,6 @@
1818
19#include "frame_uniformity_test.h"19#include "frame_uniformity_test.h"
20#include "mir_test_framework/executable_path.h"20#include "mir_test_framework/executable_path.h"
21#include "mir/geometry/displacement.h"
2221
23#include <assert.h>22#include <assert.h>
24#include <cmath>23#include <cmath>
@@ -47,7 +46,9 @@
4746
48 double alpha = elapsed_interval / total_interval;47 double alpha = elapsed_interval / total_interval;
49 48
50 return touch_start + alpha*(touch_end-touch_start);49 auto ix = touch_start.x.as_int() + (touch_end.x.as_int()-touch_start.x.as_int())*alpha;
50 auto iy = touch_start.y.as_int() + (touch_end.y.as_int()-touch_start.y.as_int())*alpha;
51 return {ix, iy};
51}52}
5253
53double pixel_lag_for_sample_at_time(geom::Point touch_start_point, geom::Point touch_end_point,54double pixel_lag_for_sample_at_time(geom::Point touch_start_point, geom::Point touch_end_point,
@@ -57,12 +58,10 @@
57{58{
58 auto expected_point = interpolated_touch_at_time(touch_start_point, touch_end_point, touch_start_time,59 auto expected_point = interpolated_touch_at_time(touch_start_point, touch_end_point, touch_start_time,
59 touch_end_time, sample.frame_time);60 touch_end_time, sample.frame_time);
6061 auto dx = sample.x - expected_point.x.as_int();
61 geom::Displacement const displacement{62 auto dy = sample.y - expected_point.y.as_int();
62 sample.x - expected_point.x.as_int(),63 auto distance = std::sqrt(dx*dx+dy*dy);
63 sample.y - expected_point.y.as_int()};64 return distance;
64
65 return std::sqrt(displacement.length_squared());
66}65}
6766
68double compute_average_frame_offset(std::vector<TouchSamples::Sample> const& results,67double compute_average_frame_offset(std::vector<TouchSamples::Sample> const& results,
6968
=== modified file 'benchmarks/frame-uniformity/touch_measuring_client.cpp'
--- benchmarks/frame-uniformity/touch_measuring_client.cpp 2015-05-07 09:06:20 +0000
+++ benchmarks/frame-uniformity/touch_measuring_client.cpp 2015-05-20 14:01:27 +0000
@@ -22,7 +22,12 @@
2222
23#include "mir_toolkit/mir_client_library.h"23#include "mir_toolkit/mir_client_library.h"
2424
25#include <chrono>
26#include <memory>
27#include <vector>
28
25#include <iostream>29#include <iostream>
30#include <assert.h>
2631
27namespace mt = mir::test;32namespace mt = mir::test;
2833
@@ -34,15 +39,13 @@
34 MirPixelFormat pixel_format;39 MirPixelFormat pixel_format;
35 unsigned int valid_formats;40 unsigned int valid_formats;
36 mir_connection_get_available_surface_formats(connection, &pixel_format, 1, &valid_formats);41 mir_connection_get_available_surface_formats(connection, &pixel_format, 1, &valid_formats);
3742 MirSurfaceParameters const surface_params = { "frame-uniformity-test",
38 auto const spec = mir_connection_create_spec_for_normal_surface(43 1024, 1024, /* TODO: Ensure fullscreen? */
39 connection, 1024, 1024, pixel_format);44 pixel_format,
40 mir_surface_spec_set_name(spec, "frame-uniformity-test");45 mir_buffer_usage_hardware,
41 mir_surface_spec_set_buffer_usage(spec, mir_buffer_usage_hardware);46 mir_display_output_id_invalid};
42
43 auto surface = mir_surface_create_sync(spec);
44 mir_surface_spec_release(spec);
45 47
48 auto surface = mir_connection_create_surface_sync(connection, &surface_params);
46 if (!mir_surface_is_valid(surface))49 if (!mir_surface_is_valid(surface))
47 {50 {
48 std::cerr << "Surface creation failed: " << mir_surface_get_error_message(surface) << std::endl;51 std::cerr << "Surface creation failed: " << mir_surface_get_error_message(surface) << std::endl;
@@ -61,7 +64,8 @@
6164
62void collect_input_and_frame_timing(MirSurface *surface, mt::Barrier& client_ready, std::chrono::high_resolution_clock::duration duration, std::shared_ptr<TouchSamples> const& results)65void collect_input_and_frame_timing(MirSurface *surface, mt::Barrier& client_ready, std::chrono::high_resolution_clock::duration duration, std::shared_ptr<TouchSamples> const& results)
63{66{
64 mir_surface_set_event_handler(surface, input_callback, results.get());67 MirEventDelegate event_handler = { input_callback, results.get() };
68 mir_surface_set_event_handler(surface, &event_handler);
65 69
66 client_ready.ready();70 client_ready.ready();
6771
6872
=== modified file 'benchmarks/frame-uniformity/touch_measuring_client.h'
--- benchmarks/frame-uniformity/touch_measuring_client.h 2015-05-07 09:06:20 +0000
+++ benchmarks/frame-uniformity/touch_measuring_client.h 2015-05-20 14:01:27 +0000
@@ -23,8 +23,13 @@
2323
24#include "mir_test/barrier.h"24#include "mir_test/barrier.h"
2525
26#include "mir_toolkit/mir_client_library.h"
27
26#include <chrono>28#include <chrono>
27#include <memory>29#include <memory>
30#include <vector>
31#include <string>
32#include <mutex>
2833
29class TouchMeasuringClient34class TouchMeasuringClient
30{35{
3136
=== modified file 'benchmarks/frame-uniformity/touch_producing_server.cpp'
--- benchmarks/frame-uniformity/touch_producing_server.cpp 2015-03-31 02:35:42 +0000
+++ benchmarks/frame-uniformity/touch_producing_server.cpp 2015-05-20 14:01:27 +0000
@@ -21,7 +21,6 @@
2121
22#include "mir_test/event_factory.h"22#include "mir_test/event_factory.h"
23#include "mir_test/fake_event_hub.h"23#include "mir_test/fake_event_hub.h"
24#include "mir/geometry/displacement.h"
2524
26#include <functional>25#include <functional>
2726
@@ -102,7 +101,8 @@
102 touch_end_time = now;101 touch_end_time = now;
103 102
104 double alpha = (now.time_since_epoch().count()-start.time_since_epoch().count()) / static_cast<double>(end.time_since_epoch().count()-start.time_since_epoch().count());103 double alpha = (now.time_since_epoch().count()-start.time_since_epoch().count()) / static_cast<double>(end.time_since_epoch().count()-start.time_since_epoch().count());
105 auto point = touch_start + alpha*(touch_end-touch_start);104 auto point = geom::Point{touch_start.x.as_int()+(touch_end.x.as_int()-touch_start.x.as_int())*alpha,
105 touch_start.y.as_int()+(touch_end.y.as_int()-touch_start.y.as_int())*alpha};
106 synthesize_event_at(point);106 synthesize_event_at(point);
107 }107 }
108}108}
109109
=== modified file 'benchmarks/frame-uniformity/touch_samples.cpp'
--- benchmarks/frame-uniformity/touch_samples.cpp 2015-04-09 08:57:24 +0000
+++ benchmarks/frame-uniformity/touch_samples.cpp 2015-05-20 14:01:27 +0000
@@ -16,6 +16,8 @@
16 * Authored by: Robert Carr <robert.carr@canonical.com>16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */17 */
1818
19#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
20
19#include "touch_samples.h"21#include "touch_samples.h"
2022
21void TouchSamples::record_frame_time(std::chrono::high_resolution_clock::time_point time)23void TouchSamples::record_frame_time(std::chrono::high_resolution_clock::time_point time)
@@ -34,26 +36,21 @@
34{36{
35 std::unique_lock<std::mutex> lg(guard);37 std::unique_lock<std::mutex> lg(guard);
3638
37 if (mir_event_get_type(&event) != mir_event_type_input)39 if (event.type != mir_event_type_motion)
38 return;40 return;
39 auto iev = mir_event_get_input_event(&event);41
40 if (mir_input_event_get_type(iev) != mir_input_event_type_touch)42 auto const& mev = event.motion;
41 return;43 if (mev.action != mir_motion_action_down &&
42 auto tev = mir_input_event_get_touch_event(iev);44 mev.action != mir_motion_action_up &&
4345 mev.action != mir_motion_action_move)
46 {
47 return;
48 }
44 // We could support multitouch, etc...49 // We could support multitouch, etc...
45 size_t touch_index = 0;50 auto const& coordinates = mev.pointer_coordinates[0];
46 auto action = mir_touch_event_action(tev, touch_index);51
47 if (action != mir_touch_action_down &&
48 action != mir_touch_action_up &&
49 action != mir_touch_action_change)
50 {
51 return;
52 }
53 auto x = mir_touch_event_axis_value(tev, 0, mir_touch_axis_x);
54 auto y = mir_touch_event_axis_value(tev, 0, mir_touch_axis_y);
55 // TODO: Record both event time and reception time52 // TODO: Record both event time and reception time
56 samples_being_prepared.push_back(Sample{x, y, reception_time, {}});53 samples_being_prepared.push_back(Sample{coordinates.x, coordinates.y, reception_time, {}});
57}54}
5855
59std::vector<TouchSamples::Sample> TouchSamples::get()56std::vector<TouchSamples::Sample> TouchSamples::get()
6057
=== modified file 'benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp'
--- benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp 2015-03-31 02:35:42 +0000
+++ benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp 2015-05-20 14:01:27 +0000
@@ -36,21 +36,20 @@
36namespace36namespace
37{37{
3838
39struct StubDisplaySyncGroup : mg::DisplaySyncGroup39struct StubDisplayBuffer : mtd::StubDisplayBuffer
40{40{
41 StubDisplaySyncGroup(geom::Size output_size, int vsync_rate_in_hz) :41 StubDisplayBuffer(geom::Size output_size, int vsync_rate_in_hz)
42 vsync_rate_in_hz(vsync_rate_in_hz),42 : mtd::StubDisplayBuffer({{0, 0}, output_size}),
43 last_sync(std::chrono::high_resolution_clock::now()),43 vsync_rate_in_hz(vsync_rate_in_hz),
44 buffer({{0, 0}, output_size})44 last_sync(std::chrono::high_resolution_clock::now())
45 {45 {
46 }46 }
4747
48 void for_each_display_buffer(std::function<void(mg::DisplayBuffer&)> const& exec) override48 void gl_swap_buffers() override
49 {49 {
50 exec(buffer);50 }
51 }51
5252 void flip() override
53 void post() override
54 {53 {
55 auto now = std::chrono::high_resolution_clock::now();54 auto now = std::chrono::high_resolution_clock::now();
56 auto next_sync = last_sync + std::chrono::seconds(1) / vsync_rate_in_hz;55 auto next_sync = last_sync + std::chrono::seconds(1) / vsync_rate_in_hz;
@@ -64,24 +63,22 @@
64 double const vsync_rate_in_hz;63 double const vsync_rate_in_hz;
6564
66 std::chrono::high_resolution_clock::time_point last_sync;65 std::chrono::high_resolution_clock::time_point last_sync;
67
68 mtd::StubDisplayBuffer buffer;
69};66};
7067
71struct StubDisplay : public mtd::StubDisplay68struct StubDisplay : public mtd::StubDisplay
72{69{
73 StubDisplay(geom::Size output_size, int vsync_rate_in_hz) :70 StubDisplay(geom::Size output_size, int vsync_rate_in_hz)
74 mtd::StubDisplay({{{0,0}, output_size}}),71 : mtd::StubDisplay({{{0,0}, output_size}}),
75 group(output_size, vsync_rate_in_hz)72 buffer(output_size, vsync_rate_in_hz)
76 {73 {
77 }74 }
78 75
79 void for_each_display_sync_group(std::function<void(mg::DisplaySyncGroup&)> const& exec) override76 void for_each_display_buffer(std::function<void(mg::DisplayBuffer&)> const& exec) override
80 {77 {
81 exec(group);78 exec(buffer);
82 }79 }
8380
84 StubDisplaySyncGroup group;81 StubDisplayBuffer buffer;
85};82};
8683
87}84}
8885
=== modified file 'cmake/ABICheck.cmake'
--- cmake/ABICheck.cmake 2015-05-07 09:06:20 +0000
+++ cmake/ABICheck.cmake 2015-05-20 14:01:27 +0000
@@ -80,14 +80,10 @@
80make_lib_descriptor(server)80make_lib_descriptor(server)
81make_lib_descriptor(common INCLUDE_PRIVATE EXCLUDE_HEADERS ${mircommon-exclude-headers})81make_lib_descriptor(common INCLUDE_PRIVATE EXCLUDE_HEADERS ${mircommon-exclude-headers})
82make_lib_descriptor(platform INCLUDE_PRIVATE EXCLUDE_HEADERS ${mirplatform-exclude-headers})82make_lib_descriptor(platform INCLUDE_PRIVATE EXCLUDE_HEADERS ${mirplatform-exclude-headers})
83if(MIR_BUILD_PLATFORM_MESA)
84make_lib_descriptor(clientplatformmesa LIBRARY_HEADER ${CMAKE_SOURCE_DIR}/src/include/client/mir/client_platform_factory.h)83make_lib_descriptor(clientplatformmesa LIBRARY_HEADER ${CMAKE_SOURCE_DIR}/src/include/client/mir/client_platform_factory.h)
84make_lib_descriptor(clientplatformandroid LIBRARY_HEADER ${CMAKE_SOURCE_DIR}/src/include/client/mir/client_platform_factory.h)
85make_lib_descriptor(platformgraphicsmesa LIBRARY_HEADER ${CMAKE_SOURCE_DIR}/include/platform/mir/graphics/platform.h)85make_lib_descriptor(platformgraphicsmesa LIBRARY_HEADER ${CMAKE_SOURCE_DIR}/include/platform/mir/graphics/platform.h)
86endif()
87if(MIR_BUILD_PLATFORM_ANDROID)
88make_lib_descriptor(clientplatformandroid LIBRARY_HEADER ${CMAKE_SOURCE_DIR}/src/include/client/mir/client_platform_factory.h)
89make_lib_descriptor(platformgraphicsandroid LIBRARY_HEADER ${CMAKE_SOURCE_DIR}/include/platform/mir/graphics/platform.h)86make_lib_descriptor(platformgraphicsandroid LIBRARY_HEADER ${CMAKE_SOURCE_DIR}/include/platform/mir/graphics/platform.h)
90endif()
9187
92add_custom_target(abi-release-dump88add_custom_target(abi-release-dump
93 COMMAND /bin/sh -c '${CMAKE_SOURCE_DIR}/tools/generate-abi-base-dump.sh ${CMAKE_SOURCE_DIR}'89 COMMAND /bin/sh -c '${CMAKE_SOURCE_DIR}/tools/generate-abi-base-dump.sh ${CMAKE_SOURCE_DIR}'
@@ -124,13 +120,7 @@
124 )120 )
125endmacro(_define_abi_check_for)121endmacro(_define_abi_check_for)
126122
127set(the_libs mirserver mirclient mircommon mirplatform)123set(the_libs mirserver mirclient mircommon mirplatform mirclientplatformmesa mirclientplatformandroid mirplatformgraphicsmesa mirplatformgraphicsandroid)
128if(MIR_BUILD_PLATFORM_MESA)
129 set(the_libs ${the_libs} mirclientplatformmesa mirplatformgraphicsmesa)
130endif()
131if(MIR_BUILD_PLATFORM_ANDROID)
132 set(the_libs ${the_libs} mirclientplatformandroid mirplatformgraphicsandroid)
133endif()
134124
135foreach(libname ${the_libs})125foreach(libname ${the_libs})
136 _define_abi_dump_for(${libname})126 _define_abi_dump_for(${libname})
137127
=== modified file 'cmake/FindGtestGmock.cmake'
--- cmake/FindGtestGmock.cmake 2015-03-31 02:35:42 +0000
+++ cmake/FindGtestGmock.cmake 2015-05-20 14:01:27 +0000
@@ -26,8 +26,6 @@
26endif()26endif()
2727
28set(GTEST_CMAKE_ARGS "-DCMAKE_CXX_FLAGS=${GTEST_CXX_FLAGS}")28set(GTEST_CMAKE_ARGS "-DCMAKE_CXX_FLAGS=${GTEST_CXX_FLAGS}")
29list(APPEND GTEST_CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
30list(APPEND GTEST_CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER})
31if (${CMAKE_CROSSCOMPILING})29if (${CMAKE_CROSSCOMPILING})
32 list(APPEND GTEST_CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_MODULE_PATH}/LinuxCrossCompile.cmake)30 list(APPEND GTEST_CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_MODULE_PATH}/LinuxCrossCompile.cmake)
33endif()31endif()
3432
=== modified file 'cmake/MirCommon.cmake'
--- cmake/MirCommon.cmake 2015-05-07 09:06:20 +0000
+++ cmake/MirCommon.cmake 2015-05-20 14:01:27 +0000
@@ -1,9 +1,14 @@
1cmake_minimum_required (VERSION 2.6)1cmake_minimum_required (VERSION 2.6)
2# Create target to discover tests2# Create target to discover tests
3include (CMakeParseArguments)
43
5include(CMakeDependentOption)4include(CMakeDependentOption)
6file(REMOVE ${CMAKE_BINARY_DIR}/discover_all_tests.sh)5
6CMAKE_DEPENDENT_OPTION(
7 DISABLE_GTEST_TEST_DISCOVERY
8 "If set to ON, disables fancy test autodiscovery and switches back to classic add_test behavior"
9 OFF
10 "NOT CMAKE_CROSSCOMPILING"
11 ON)
712
8option(13option(
9 ENABLE_MEMCHECK_OPTION14 ENABLE_MEMCHECK_OPTION
@@ -23,82 +28,128 @@
23 valgrind)28 valgrind)
2429
25 if(VALGRIND_EXECUTABLE)30 if(VALGRIND_EXECUTABLE)
26 set(VALGRIND_CMD "${VALGRIND_EXECUTABLE}" "--error-exitcode=1" "--trace-children=yes" "--leak-check=full" "--show-leak-kinds=definite" "--errors-for-leak-kinds=definite")31 set(VALGRIND_ARGS "--error-exitcode=1" "--trace-children=yes" "--leak-check=full" "--show-leak-kinds=definite" "--errors-for-leak-kinds=definite")
27 set(VALGRIND_CMD ${VALGRIND_CMD} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_generic")32 set(VALGRIND_ARGS ${VALGRIND_ARGS} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_generic")
28 set(VALGRIND_CMD ${VALGRIND_CMD} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_glibc_2.21")33 set(VALGRIND_ARGS ${VALGRIND_ARGS} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_glibc_2.21")
34 set(DISCOVER_FLAGS "--enable-memcheck")
35 set(DISCOVER_FLAGS ${DISCOVER_FLAGS} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_generic")
36 set(DISCOVER_FLAGS ${DISCOVER_FLAGS} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_glibc_2.21")
29 if (TARGET_ARCH STREQUAL "arm-linux-gnueabihf")37 if (TARGET_ARCH STREQUAL "arm-linux-gnueabihf")
30 set(VALGRIND_CMD ${VALGRIND_CMD} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_armhf")38 set(VALGRIND_ARGS ${VALGRIND_ARGS} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_armhf")
39 set(DISCOVER_FLAGS ${DISCOVER_FLAGS} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_armhf")
31 endif()40 endif()
32 else(VALGRIND_EXECUTABLE)41 else(VALGRIND_EXECUTABLE)
33 message("Not enabling memcheck as valgrind is missing on your system")42 message("Not enabling memcheck as valgrind is missing on your system")
34 endif(VALGRIND_EXECUTABLE)43 endif(VALGRIND_EXECUTABLE)
35endif(ENABLE_MEMCHECK_OPTION)44endif(ENABLE_MEMCHECK_OPTION)
3645
37function (list_to_string LIST_VAR PREFIX STR_VAR)
38 foreach (value ${LIST_VAR})
39 set(tmp_str "${tmp_str} ${PREFIX} ${value}")
40 endforeach()
41 set(${STR_VAR} "${tmp_str}" PARENT_SCOPE)
42endfunction()
43
44function (mir_discover_tests EXECUTABLE)46function (mir_discover_tests EXECUTABLE)
45 # Set vars47 if(DISABLE_GTEST_TEST_DISCOVERY)
46 set(test_cmd_no_memcheck "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${EXECUTABLE}")48 execute_process(
47 set(test_cmd "${test_cmd_no_memcheck}")49 COMMAND uname -r
48 set(test_env ${ARGN})50 OUTPUT_VARIABLE KERNEL_VERSION_FULL
49 set(test_name ${EXECUTABLE})51 OUTPUT_STRIP_TRAILING_WHITESPACE
50 set(test_no_memcheck_filter)52 )
51 set(test_exclusion_filter)53 string(REGEX MATCH "^[0-9]+[.][0-9]+" KERNEL_VERSION ${KERNEL_VERSION_FULL})
5254 message(STATUS "Kernel version detected: " ${KERNEL_VERSION})
53 if(ENABLE_MEMCHECK_OPTION)55 # Some tests expect kernel version 3.11 and up
54 set(test_cmd ${VALGRIND_CMD} ${test_cmd_no_memcheck})56 if (${KERNEL_VERSION} VERSION_LESS "3.11")
55 set(test_no_memcheck_filter "*DeathTest.*")57 add_test(${EXECUTABLE} ${VALGRIND_EXECUTABLE} ${VALGRIND_ARGS} ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE}
56 endif()58 "--gtest_filter=-*DeathTest.*:AnonymousShmFile.*:MesaBufferAllocatorTest.software_buffers_dont_bypass:MesaBufferAllocatorTest.creates_software_rendering_buffer")
5759 else()
58 if(cmake_build_type_lower MATCHES "threadsanitizer")60 add_test(${EXECUTABLE} ${VALGRIND_EXECUTABLE} ${VALGRIND_ARGS} ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE}
59 find_program(LLVM_SYMBOLIZER llvm-symbolizer-3.6)61 "--gtest_filter=-*DeathTest.*")
60 if (LLVM_SYMBOLIZER)62 endif()
61 set(TSAN_EXTRA_OPTIONS "external_symbolizer_path=${LLVM_SYMBOLIZER}")63
62 endif()64 add_test(${EXECUTABLE}_death_tests ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE} "--gtest_filter=*DeathTest.*")
63 # Space after ${TSAN_EXTRA_OPTIONS} works around bug in TSAN env. variable parsing 65 if (${ARGC} GREATER 1)
64 list(APPEND test_env "TSAN_OPTIONS=\"suppressions=${CMAKE_SOURCE_DIR}/tools/tsan-suppressions second_deadlock_stack=1 halt_on_error=1 history_size=7 ${TSAN_EXTRA_OPTIONS} \"")66 set_property(TEST ${EXECUTABLE} PROPERTY ENVIRONMENT ${ARGN})
65 # TSan does not support multi-threaded fork67 set_property(TEST ${EXECUTABLE}_death_tests PROPERTY ENVIRONMENT ${ARGN})
66 # TSan may open fds so "surface_creation_does_not_leak_fds" will not work as written68 endif()
67 # TSan deadlocks when running StreamTransportTest/0.SendsFullMessagesWhenInterrupted - disable it until understood69 else()
68 set(test_exclusion_filter "UnresponsiveClient.does_not_hang_server:DemoInProcessServerWithStubClientPlatform.surface_creation_does_not_leak_fds:StreamTransportTest/0.SendsFullMessagesWhenInterrupted")70 set(CHECK_TEST_DISCOVERY_TARGET_NAME "check_discover_tests_in_${EXECUTABLE}")
69 endif()71 set(TEST_DISCOVERY_TARGET_NAME "discover_tests_in_${EXECUTABLE}")
7072 message(STATUS "Defining targets: ${CHECK_TEST_DISCOVERY_TARGET_NAME} and ${TEST_DISCOVERY_TARGET_NAME}")
71 # Final commands73
72 set(test_cmd "${test_cmd}" "--gtest_filter=-${test_no_memcheck_filter}:${test_exclusion_filter}")74 # These targets are always considered out-of-date, and are always run (at least for normal builds, except for make test/install).
73 set(test_cmd_no_memcheck "${test_cmd_no_memcheck}" "--gtest_filter=${test_no_memcheck_filter}:-${test_exclusion_filter}")75 add_custom_target(
7476 ${CHECK_TEST_DISCOVERY_TARGET_NAME} ALL
75 # Normal77 ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE} --gtest_list_tests > /dev/null
76 add_test(${test_name} ${test_cmd})78 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
77 set_property(TEST ${test_name} PROPERTY ENVIRONMENT ${test_env})79 COMMENT "Check that discovering Tests in ${EXECUTABLE} works")
78 if (test_no_memcheck_filter)80
79 add_test(${test_name}_no_memcheck ${test_cmd_no_memcheck})81 if (MIR_BUILD_PLATFORM_ANDROID)
80 set_property(TEST ${test_name}_no_memcheck PROPERTY ENVIRONMENT ${test_env})82 add_dependencies(${CHECK_TEST_DISCOVERY_TARGET_NAME} mirplatformgraphicsandroid)
81 endif()83 endif()
8284
83 # ptest85 if (MIR_BUILD_PLATFORM_MESA)
84 list_to_string("${test_env}" "--env" discover_env)86 add_dependencies(${CHECK_TEST_DISCOVERY_TARGET_NAME} mirplatformgraphicsmesa)
85 list_to_string("${test_cmd}" "" discover_cmd)87 endif()
86 list_to_string("${test_cmd_no_memcheck}" "" discover_cmd_no_memcheck)88
8789 if (${ARGC} GREATER 1)
88 file(APPEND ${CMAKE_BINARY_DIR}/discover_all_tests.sh90 foreach (env ${ARGN})
89 "sh ${CMAKE_SOURCE_DIR}/tools/discover_gtests.sh ${discover_env} -- ${discover_cmd}\n")91 list(APPEND EXTRA_ENV_FLAGS "--add-environment" "${env}")
90 if (test_no_memcheck_filter)92 endforeach()
91 file(APPEND ${CMAKE_BINARY_DIR}/discover_all_tests.sh93 endif()
92 "sh ${CMAKE_SOURCE_DIR}/tools/discover_gtests.sh ${discover_env} -- ${discover_cmd_no_memcheck}\n")94
95 if(cmake_build_type_lower MATCHES "threadsanitizer")
96 find_program(LLVM_SYMBOLIZER llvm-symbolizer-3.6)
97 if (LLVM_SYMBOLIZER)
98 set(TSAN_EXTRA_OPTIONS "external_symbolizer_path=${LLVM_SYMBOLIZER}")
99 endif()
100 list(APPEND EXTRA_ENV_FLAGS "--add-environment" "TSAN_OPTIONS=suppressions=${CMAKE_SOURCE_DIR}/tools/tsan-suppressions second_deadlock_stack=1 halt_on_error=1 history_size=7 ${TSAN_EXTRA_OPTIONS}")
101 # TSan does not support multi-threaded fork
102 # TSan may open fds so "surface_creation_does_not_leak_fds" will not work as written
103 # TSan deadlocks when running StreamTransportTest/0.SendsFullMessagesWhenInterrupted - disable it until understood
104 set(EXCLUDED_TESTS "UnresponsiveClient.does_not_hang_server:DemoInProcessServerWithStubClientPlatform.surface_creation_does_not_leak_fds:StreamTransportTest/0.SendsFullMessagesWhenInterrupted")
105 endif()
106
107 add_custom_target(
108 ${TEST_DISCOVERY_TARGET_NAME} ALL
109 ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE} --gtest_list_tests | ${CMAKE_BINARY_DIR}/mir_gtest/mir_discover_gtest_tests --executable=${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE} --exclusions=${EXCLUDED_TESTS} ${DISCOVER_FLAGS}
110 ${EXTRA_ENV_FLAGS}
111 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
112 COMMENT "Discovering Tests in ${EXECUTABLE}" VERBATIM)
113
114 add_dependencies(
115 ${CHECK_TEST_DISCOVERY_TARGET_NAME}
116 ${EXECUTABLE})
117
118 add_dependencies(
119 ${TEST_DISCOVERY_TARGET_NAME}
120
121 ${CHECK_TEST_DISCOVERY_TARGET_NAME}
122 ${EXECUTABLE}
123 mir_discover_gtest_tests)
124
93 endif()125 endif()
94endfunction ()126endfunction ()
95127
96function (mir_add_memcheck_test)128function (mir_add_memcheck_test)
97 if (ENABLE_MEMCHECK_OPTION)129 if (ENABLE_MEMCHECK_OPTION)
98 add_custom_target(memcheck_test ALL)130 if(DISABLE_GTEST_TEST_DISCOVERY)
99 mir_add_test(NAME "memcheck-test"131 add_custom_target(
100 COMMAND ${CMAKE_BINARY_DIR}/mir_gtest/fail_on_success.sh ${VALGRIND_CMD} ${CMAKE_BINARY_DIR}/mir_gtest/mir_test_memory_error)132 memcheck_test ALL
101 add_dependencies(memcheck_test mir_test_memory_error)133 )
134 ADD_TEST("memcheck-test" ${CMAKE_BINARY_DIR}/mir_gtest/fail_on_success.sh ${VALGRIND_EXECUTABLE} ${VALGRIND_ARGS} ${CMAKE_BINARY_DIR}/mir_gtest/mir_test_memory_error)
135 add_dependencies(
136 memcheck_test
137
138 mir_test_memory_error
139 )
140 else()
141 add_custom_target(
142 memcheck_test ALL
143 ${CMAKE_BINARY_DIR}/mir_gtest/mir_discover_gtest_tests --executable=${CMAKE_BINARY_DIR}/mir_gtest/mir_test_memory_error --memcheck-test ${DISCOVER_FLAGS}
144 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
145 COMMENT "Adding memcheck test" VERBATIM)
146
147 add_dependencies(
148 memcheck_test
149
150 mir_discover_gtest_tests
151 mir_test_memory_error)
152 endif()
102 endif()153 endif()
103endfunction()154endfunction()
104155
@@ -139,7 +190,7 @@
139 if ("${modifier}" STREQUAL "NOINSTALL")190 if ("${modifier}" STREQUAL "NOINSTALL")
140 list(REMOVE_AT ARGN 0)191 list(REMOVE_AT ARGN 0)
141 else()192 else()
142 install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${REAL_EXECUTABLE}193 install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/${REAL_EXECUTABLE}
143 DESTINATION ${CMAKE_INSTALL_BINDIR}194 DESTINATION ${CMAKE_INSTALL_BINDIR}
144 RENAME ${TARGET}195 RENAME ${TARGET}
145 )196 )
@@ -152,29 +203,7 @@
152 )203 )
153204
154 add_custom_target(${TARGET}-wrapped205 add_custom_target(${TARGET}-wrapped
155 ln -fs wrapper ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}206 ln -fs wrapper ${CMAKE_BINARY_DIR}/bin/${TARGET}
156 )207 )
157 add_dependencies(${TARGET} ${TARGET}-wrapped)208 add_dependencies(${TARGET} ${TARGET}-wrapped)
158endfunction()209endfunction()
159
160function (mir_add_test)
161 # Add test normally
162 add_test(${ARGN})
163
164 # Add to to discovery for parallel test running
165 set(one_value_args "NAME" WORKING_DIRECTORY)
166 set(multi_value_args "COMMAND")
167 cmake_parse_arguments(MAT "" "${one_value_args}" "${multi_value_args}" ${ARGN})
168
169 foreach (cmd ${MAT_COMMAND})
170 set(cmdstr "${cmdstr} \\\"${cmd}\\\"")
171 endforeach()
172
173 file(APPEND ${CMAKE_BINARY_DIR}/discover_all_tests.sh
174 "echo \"add_test(${MAT_NAME} ${cmdstr})\"\n")
175
176 if (MAT_WORKING_DIRECTORY)
177 file(APPEND ${CMAKE_BINARY_DIR}/discover_all_tests.sh
178 "echo \"set_tests_properties(${MAT_NAME} PROPERTIES WORKING_DIRECTORY \\\"${MAT_WORKING_DIRECTORY}\\\")\"\n")
179 endif()
180endfunction()
181210
=== modified file 'cmake/src/mir/CMakeLists.txt'
--- cmake/src/mir/CMakeLists.txt 2015-05-07 09:06:20 +0000
+++ cmake/src/mir/CMakeLists.txt 2015-05-20 14:01:27 +0000
@@ -1,4 +1,14 @@
1add_executable(1add_executable(
2 mir_discover_gtest_tests
3 EXCLUDE_FROM_ALL
4 ${CMAKE_CURRENT_SOURCE_DIR}/mir_discover_gtest_tests.cpp)
5
6set_target_properties(
7 mir_discover_gtest_tests PROPERTIES
8 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/mir_gtest
9)
10
11add_executable(
2 mir_test_memory_error12 mir_test_memory_error
3 EXCLUDE_FROM_ALL13 EXCLUDE_FROM_ALL
4 ${CMAKE_CURRENT_SOURCE_DIR}/mir_test_memory_error.cpp)14 ${CMAKE_CURRENT_SOURCE_DIR}/mir_test_memory_error.cpp)
515
=== added file 'cmake/src/mir/mir_discover_gtest_tests.cpp'
--- cmake/src/mir/mir_discover_gtest_tests.cpp 1970-01-01 00:00:00 +0000
+++ cmake/src/mir/mir_discover_gtest_tests.cpp 2015-05-20 14:01:27 +0000
@@ -0,0 +1,405 @@
1#include <algorithm>
2#include <cassert>
3#include <cstring>
4#include <map>
5#include <set>
6#include <string>
7#include <istream>
8#include <ostream>
9#include <fstream>
10#include <sstream>
11#include <iterator>
12#include <iostream>
13#include <vector>
14#include <libgen.h>
15
16#include <getopt.h>
17#include <sys/ioctl.h>
18#include <unistd.h>
19#ifndef _GNU_SOURCE
20// Needed for O_TMPFILE
21#define _GNU_SOURCE
22#endif
23#include <fcntl.h>
24
25using namespace std;
26
27namespace
28{
29enum DescriptorType
30{
31 test_case,
32 test_suite
33};
34
35DescriptorType check_line_for_test_case_or_suite(const string& line)
36{
37 if (line.find(" ") == 0)
38 return test_case;
39
40 return test_suite;
41}
42
43int get_output_width()
44{
45 const int fd_out{fileno(stdout)};
46 const int max_width{65535};
47
48 int width{max_width};
49
50 if (isatty(fd_out))
51 {
52 struct winsize w;
53 if (ioctl(fd_out, TIOCGWINSZ, &w) != -1)
54 width = w.ws_col;
55 }
56
57 return width;
58}
59
60string ordinary_cmd_line_pattern()
61{
62 static const char* pattern = "ADD_TEST(\"%s.%s\" \"%s\" \"--gtest_filter=%s:-%s\")\n";
63 return pattern;
64}
65
66vector<string> valgrind_cmd_patterns(vector<string> const& suppressions)
67{
68 vector<string> patterns{
69 "valgrind",
70 "--error-exitcode=1",
71 "--trace-children=yes"
72 };
73
74 for (auto const& sup : suppressions)
75 patterns.push_back(std::string("--suppressions=") + sup);
76
77 vector<string> gtest_patterns{
78 "%s",
79 "--gtest_death_test_use_fork",
80 "--gtest_filter=%s:-%s"
81 };
82
83 patterns.insert(patterns.end(), gtest_patterns.begin(), gtest_patterns.end());
84
85 return patterns;
86}
87
88string memcheck_cmd_line_pattern(vector<string> const& suppressions)
89{
90 stringstream ss;
91
92 ss << "ADD_TEST(\"memcheck(%s.%s)\"";
93 for (auto& s : valgrind_cmd_patterns(suppressions))
94 ss << " \"" << s << "\"";
95 ss << ")" << endl;
96
97 return ss.str();
98}
99
100std::string elide_string_left(const std::string& in, std::size_t max_size)
101{
102 assert(max_size >= 3);
103
104 if (in.size() <= max_size)
105 return in;
106
107 std::string result(in.begin() + (in.size() - max_size), in.end());
108
109 *(result.begin()) = '.';
110 *(result.begin()+1) = '.';
111 *(result.begin()+2) = '.';
112
113 return result;
114}
115
116struct Configuration
117{
118 Configuration() : executable(NULL),
119 enable_memcheck(false),
120 memcheck_test(false)
121 {
122 }
123
124 std::string exclusions_for(string const& test)
125 {
126 if (test.size() < 2)
127 return {};
128
129 // assuming test name is Foo.*
130 std::string test_name{test.substr(0, test.size() - 2)};
131 if (exclusions.find(test_name) != std::string::npos)
132 return exclusions;
133
134 return {};
135 }
136
137 const char* executable;
138 bool enable_memcheck;
139 bool memcheck_test;
140 std::vector<std::pair<std::string, std::string>> extra_environment;
141 std::vector<std::string> suppressions;
142 std::string exclusions;
143};
144
145bool parse_configuration_from_cmd_line(int argc, char** argv, Configuration& config)
146{
147 static struct option long_options[] = {
148 {"executable", required_argument, 0, 0},
149 {"enable-memcheck", no_argument, 0, 0},
150 {"memcheck-test", no_argument, 0, 0},
151 {"add-environment", required_argument, 0, 0},
152 {"suppressions", required_argument, 0, 0},
153 {"exclusions", required_argument, 0, 0},
154 {0, 0, 0, 0}
155 };
156
157 while(1)
158 {
159 int option_index = -1;
160 const char *optname = "";
161 int c = getopt_long(
162 argc,
163 argv,
164 "e:m",
165 long_options,
166 &option_index);
167
168 /* Detect the end of the options. */
169 if (c == -1)
170 break;
171
172 /* Detect an error in the passed options */
173 if (c == ':' || c == '?')
174 return false;
175
176 /* Check if we got a long option and get its name */
177 if (option_index != -1)
178 optname = long_options[option_index].name;
179
180 /* Handle options */
181 if (c == 'e' || !strcmp(optname, "executable"))
182 config.executable = optarg;
183 else if (c == 'm' || !strcmp(optname, "enable-memcheck"))
184 config.enable_memcheck = true;
185 else if (!strcmp(optname, "memcheck-test"))
186 config.memcheck_test = true;
187 else if (!strcmp(optname, "add-environment"))
188 {
189 char const* equal_pos = strchr(optarg, '=');
190 if (!equal_pos)
191 return false;
192 config.extra_environment.push_back(std::make_pair(std::string(optarg, equal_pos - optarg), std::string(equal_pos + 1)));
193 }
194 else if (!strcmp(optname, "suppressions"))
195 {
196 config.suppressions.push_back(std::string(optarg));
197 }
198 else if (!strcmp(optname, "exclusions"))
199 {
200 config.exclusions = optarg;
201 }
202
203 }
204
205 return true;
206}
207
208string prepareMemcheckTestLine(string const& exe, vector<string> const& suppressions, std::string const& exclusions)
209{
210 stringstream ss;
211
212 ss << "ADD_TEST(\"memcheck-test\" \"sh\" \"-c\" \"";
213 for (auto& s : valgrind_cmd_patterns(suppressions))
214 ss << s << " ";
215 ss << "; if [ $? != 0 ]; then exit 0; else exit 1; fi\")";
216
217 char cmd_line[1024] = "";
218 snprintf(cmd_line,
219 sizeof(cmd_line),
220 ss.str().c_str(),
221 exe.c_str(),
222 "*",
223 exclusions.c_str()
224 );
225
226 return cmd_line;
227}
228
229void emitMemcheckTest(string const& exe, vector<string> const& suppressions, std::string const& exclusions)
230{
231 ifstream CTestTestfile("CTestTestfile.cmake", ifstream::in);
232 bool need_memcheck_test = true;
233 string line;
234
235 string memcheckTestLine = prepareMemcheckTestLine(exe, suppressions, exclusions);
236
237 if (CTestTestfile.is_open())
238 {
239 while (CTestTestfile.good())
240 {
241 getline(CTestTestfile, line);
242
243 if (line == memcheckTestLine)
244 need_memcheck_test = false;
245 }
246
247 CTestTestfile.close();
248 }
249
250 if (need_memcheck_test)
251 {
252 ofstream CTestTestfileW ("CTestTestfile.cmake", ofstream::app | ofstream::out);
253
254 if (CTestTestfileW.is_open())
255 {
256 CTestTestfileW << memcheckTestLine << endl;
257 CTestTestfileW.close();
258 }
259 }
260}
261
262bool is_death_test(string const& test)
263{
264 // precondition: test will match Foo.*
265 // assumption: death tests will match FooDeathTest.*
266 bool death_test = false;
267 if (test.size() > strlen("DeathTest.*"))
268 death_test = test.substr(test.size() - strlen("DeathTest.*"),
269 strlen("DeathTest")) == "DeathTest";
270
271 return death_test;
272}
273
274}
275
276int main (int argc, char **argv)
277{
278 int output_width = get_output_width();
279
280 cin >> noskipws;
281
282 Configuration config;
283 if (!parse_configuration_from_cmd_line(argc, argv, config) || config.executable == NULL)
284 {
285 cout << "Usage: PATH_TO_TEST_BINARY --gtest_list_tests | " << basename(argv[0])
286 << " --executable PATH_TO_TEST_BINARY [--enable-memcheck]" << std::endl
287 << " or " << std::endl << basename(argv[0])
288 << " --executable PATH_TO_MEMCHECK_BINARY --memcheck-test" << std::endl;
289 return 1;
290 }
291
292 if (config.memcheck_test)
293 {
294 emitMemcheckTest(config.executable, config.suppressions, config.exclusions);
295 return 0;
296 }
297
298 set<string> tests;
299 string line;
300 string current_test;
301
302 while (getline (cin, line))
303 {
304 switch(check_line_for_test_case_or_suite(line))
305 {
306 case test_case:
307 tests.insert(current_test + "*");
308 break;
309 case test_suite:
310 auto suite_end = line.find(' ');
311 if (suite_end != std::string::npos)
312 {
313 line = line.substr(0, suite_end);
314 }
315 current_test = line;
316 break;
317 }
318 }
319
320 ofstream testfilecmake;
321 char* executable_copy = strdup(config.executable);
322 string test_suite(basename(executable_copy));
323 free(executable_copy);
324
325 testfilecmake.open(string(test_suite + "_test.cmake").c_str(), ios::out | ios::trunc);
326 if (testfilecmake.is_open())
327 {
328 for (auto& env_pair : config.extra_environment)
329 {
330 testfilecmake << "SET( ENV{"<<env_pair.first<<"} \""<<env_pair.second<<"\" )"<<std::endl;
331 }
332
333 int ret = open("/dev/shm", O_TMPFILE | O_RDWR | O_EXCL, S_IRWXU);
334 bool kernel_supports_O_TMPFILE = (ret != -1);
335 if (kernel_supports_O_TMPFILE) close(ret);
336
337 for (auto test = tests.begin(); test != tests.end(); ++ test)
338 {
339 static char cmd_line[1024] = "";
340
341
342 if (!kernel_supports_O_TMPFILE)
343 {
344 // Don't run AnonymousShmFile.* tests on older kernels
345 if (*test == "AnonymousShmFile.*")
346 continue;
347 if (*test == "MesaBufferAllocatorTest.*")
348 config.exclusions.append("MesaBufferAllocatorTest.software_buffers_dont_bypass:MesaBufferAllocatorTest.creates_software_rendering_buffer");
349 }
350
351 snprintf(
352 cmd_line,
353 sizeof(cmd_line),
354 (config.enable_memcheck && !is_death_test(*test)) ?
355 memcheck_cmd_line_pattern(config.suppressions).c_str() :
356 ordinary_cmd_line_pattern().c_str(),
357 test_suite.c_str(),
358 elide_string_left(*test, output_width/2).c_str(),
359 config.executable,
360 test->c_str(),
361 config.exclusions_for(*test).c_str());
362
363 if (testfilecmake.good())
364 {
365 testfilecmake << cmd_line;
366 }
367 }
368
369 testfilecmake.close();
370 }
371
372 ifstream CTestTestfile("CTestTestfile.cmake", ifstream::in);
373 bool need_include = true;
374 line.clear();
375
376 string includeLine = string ("INCLUDE (") +
377 test_suite +
378 string ("_test.cmake)");
379
380 if (CTestTestfile.is_open())
381 {
382 while (CTestTestfile.good())
383 {
384 getline(CTestTestfile, line);
385
386 if (line == includeLine)
387 need_include = false;
388 }
389
390 CTestTestfile.close();
391 }
392
393 if (need_include)
394 {
395 ofstream CTestTestfileW ("CTestTestfile.cmake", ofstream::app | ofstream::out);
396
397 if (CTestTestfileW.is_open())
398 {
399 CTestTestfileW << includeLine << endl;
400 CTestTestfileW.close();
401 }
402 }
403
404 return 0;
405}
0406
=== modified file 'debian/changelog'
--- debian/changelog 2015-05-19 14:51:07 +0000
+++ debian/changelog 2015-05-20 14:01:27 +0000
@@ -1,170 +1,15 @@
1mir (0.13.0+15.04.20150512-0ubuntu1) vivid; urgency=medium1mir (0.12.1-0ubuntu2) UNRELEASED; urgency=medium
22
3 [ Alan Griffiths ]3 * demo changes on top of 0.12.1
4 * New upstream release 0.13.0 (https://launchpad.net/mir/+milestone/0.13.0)
5 - Very large release as the previous 0.12 series contained only minimal
6 bug fixes...
7 - Enhancements:4 - Enhancements:
8 . New demo clients for input testing: mir_demo_client_eglsquare and5 . usage of external display in mirror mode
9 mir_demo_client_target.6 . output centering on external display
10 . Demo clients: mir_demo_client_tooltip, mir_demo_client_animated_cursor7 . orientation override for user input
11 . mir_demo_client_fingerpaint now processes input asynchronously to8
12 drawing for a more fluid experience.9 -- Andreas Pokorny <andreas.pokorny@canonical.com> Sun, 01 Mar 2015 15:09:13 +0100
13 . New, default window manager in mir_demo_server10
14 . mir_demo_server option (--arw-file) to make socket filename globally rw11mir (0.12.1-0ubuntu1) UNRELEASED; urgency=medium
15 . mir_demo_server demonstrates use of config file12
16 . Added support to mir_proving_server for rendering window title strings
17 . Demo servers (mir_proving_server, mir_demo_server): Introduce support
18 for Alt+` switching of windows in multi-window clients.
19 . Added client API support for constructing input method surfaces.
20 . Introduce "buffer streams" properly. This is a generalization of the
21 most basic functionality of a surface.
22 . Log useful OpenGL information on server start-up.
23 . Add support for HWC 1.4
24 . Add display and fencing information to the layers in the HWC report
25 . Add a report_vsync method to display report
26 . Support for second display when running on "android" driver stack
27 . Server buffering strategy is configurable by --nbuffers=N
28 (or environment MIR_SERVER_NBUFFERS=N)
29 . Explicit support for configuring window management in libmirserver.
30 . Remove surface configurator & placement strategy configuration points
31 . Added experimental environment variable MIR_CLIENT_INPUT_RATE=Hz for
32 tweaking the input resampling rate a client experiences (0 = off).
33 Also raised the default input rate from 55Hz to 59Hz for visibly
34 smoother touch scrolling.
35 . Added keymap setting support for surfaces.
36 . Improved automated testing of latency.
37 . Replaced and rewrote automated ABI checking.
38 . New client APIs for basic window management; setting window titles,
39 self-resizing, size constraints and changing type.
40 . Introduced dynamically loadable input platforms.
41 . Work towards libinput integration
42 . Added proof-of-concept support for Snappy packaging for Ubuntu Core.
43 . Drop support for C++11. Now C++14 is required to build Mir.
44 . Deprecated MirEventDelegate. Now you just pass the two fields as
45 parameters directly to mir_surface_set_event_handler().
46 . Legacy functions for creating surfaces marked deprecated
47 . Minor redesign of the new input event API introduced in 0.10/11,
48 so that identifiers are shorter and less convoluted.
49 . Drop libmirclient dependency on client-platform drivers
50 . Drop libmirserver dependency on client-platform drivers
51 . Use the ABI version in platform library names and packages
52 . Rework to reduce "abstraction leaks" in the graphics platform
53 . Add thread sanitizer build option
54 . Update KVM Instructions
55 . Update CMAKE to use CMAKE_*_OUTPUT_DIRECTORY
56 - ABI summary: Servers need rebuilding, but clients do not;
57 . Mirclient ABI unchanged at 8
58 . Mircommon ABI bumped to 4
59 . Mirplatform ABI bumped to 7
60 . Mirserver ABI bumped to 31
61 - Bug fixes:
62 . vivid fails to build Mir as of 2015-03-22: error: #warning "_BSD_SOURCE
63 and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Werror=cpp]
64 (LP: #1435127)
65 . [regression] Mir servers freeze on startup (mouse and keyboard not
66 responsive) (LP: #1444061)
67 . [enhancement] Add support for video/HDMI output on Android
68 (LP: #1296538)
69 . [enhancement] Set custom cursors (LP: #1380463)
70 . [regression] mali, powervr locks up with around the introduction or
71 removal of a third overlay (LP: #1413211)
72 . [regression] Client functions residing in libmircommon (LP: #1415321)
73 . USC - mouse cursor on AMD graphics is drawing incorrectly (LP: #1417581)
74 . [testsfail] SurfaceSwapBuffers.does_not_block_when_surface_is_not_composited
75 fails in CI (LP: #1418002)
76 . Compositing is triggered continously and needlessly when there are
77 occluded surfaces with available buffers (LP: #1418081)
78 . mir_demo_server doesn't emit hover_exit events (LP: #1418569)
79 . SessionMediator locks mutexes in one thread and unlocks them in another
80 (LP: #1427976)
81 . ProtobufResponder::send_response_result race (LP: #1428402)
82 . Some protobuf Closure objects can access dead objects (LP: #1433330)
83 . valgrind on armhf fails with with many errors (LP: #1435186)
84 . [regression] QtMir and USC can't build with lp:mir -
85 fatal error: mir/events/event_builders.h (LP: #1436212)
86 . [regression] mir_acceptance_tests.TestClientInput is hanging
87 (LP: #1436644)
88 . [regression] libmirclient crashes when calling
89 mir_surface_set_event_handler() twice [InputTransport.cpp:110:
90 android::InputChannel::InputChannel(const String8&, int): Assertion
91 `false && "\"result != 0\""' failed.] (LP: #1438160)
92 . [regression] Surfaces can't overlap screen edges any more (LP: #1438660)
93 . losing touches in arale when home button is pressed (LP: #1439285)
94 . [krillin] mirscreencast only creates a still picture, not a playable
95 movie (LP: #1439549)
96 . [regression] Unity8 doesn't detect input sent from USC with latest mir
97 development code (LP: #1439719)
98 . Intermittent CI failures in tests expecting created surfaces to have
99 specific size (LP: #1440088)
100 . [regression] [testsfail] failure in CI on
101 SimpleDispatchThreadTest.keeps_dispatching_after_signal_interruption
102 (LP: #1441620)
103 . [android] Screencasting causes other clients to stop rendering
104 (LP: #1441759)
105 . Intermittent CI failures in
106 MultiThreadedCompositor.does_not_block_in_start_when_compositor_thread_fails
107 (LP: #1442020)
108 . Flickering showing stale buffers on Krillin (LP: #1444047)
109 . Acceptance tests link with static versions of client library and server
110 components (LP: #1445473)
111 . [regression] mir_acceptance_tests:
112 TestClientCursorAPI.cursor_passed_through_nested_server is crashing most
113 of the time (LP: #1447430)
114 . [regression] Clients log verbose info on startup:
115 "Loader: Loading module: ..." (LP: #1414883)
116 . [enhancement] Missing client function for surface resizing
117 (LP: #1420573)
118 . [regression] [multimonitor] Clients (sometimes) run at double frame rate
119 if overlapping two monitors. (LP: #1420678)
120 . [enhancement] Need a client API to specify resize limitations
121 (LP: #1421591)
122 . [enhancement] Add surface morph client API (LP: #1422522)
123 . The process for updating packaging for ABI changes is cumbersome and
124 error-prone (LP: #1427207)
125 . [regression] mir_acceptance_tests.NestedServer failure in clang CI
126 (LP: #1430000)
127 . DisplayConfigurationOutput.physical_size_mm is undefined/zero
128 (LP: #1430315)
129 . Dragging objects in a nested server or a client stutters slightly
130 (LP: #1436192)
131 . [regression] mir_proving_server: Super+N/Super+C does nothing now
132 (LP: #1437166)
133 . [regression] "Playground" event filters get registered twice
134 (LP: #1437174)
135 . [regression] <WARNING> Platform Probing: Failed to probe module.
136 (LP: #1438536)
137 . [regression] Move/resizing in mir_proving_server freezes if the cursor
138 is outside the window (LP: #1438621)
139 . [testsfail] CI failure in ClientLibraryErrorsDeathTest.
140 creating_surface_synchronosly_on_malconstructed_connection_is_fatal
141 (LP: #1438702)
142 . Exceptions thrown due to EGL failures don't include EGL error codes
143 (LP: #1444938)
144 . Can't switch between sibling windows of multi-window apps (LP: #1445538)
145 . [regression] specifying -DMIR_PLATFORM to one platform causes cmake
146 failure (LP: #1447729)
147 . mir_demo_server(_minimal): Can't move surfaces to overlap screen edges
148 (LP: #1447882)
149 . [regression] mir_demo_standalone_render_surfaces fails to start on
150 krillin (LP: #1449198)
151 . [regression] MIR_CLIENT_PERF_REPORT=log now shows "0" for the surface
152 name (LP: #1415305)
153 . Nested display leaks its EGLContext (LP: #1418910)
154 . SimpleDispatchThreadTest.doesnt_call_dispatch_after_first_false_return
155 fails when run repeatedly (LP: #1440005)
156 . Surfaces are not properly released in CustomWindowManagement.
157 state_change_requests_are_associated_with_correct_surface
158 (LP: #1445418)
159 . android reports that the gpu can only support 1 simultaneous output
160 (LP: #1446304)
161 . Support dynamic mouse cursor icons (LP: #1447839)
162
163 -- CI Train Bot <ci-train-bot@canonical.com> Tue, 12 May 2015 13:12:55 +0000
164
165mir (0.12.1+15.04.20150324-0ubuntu1) vivid; urgency=medium
166
167 [ Alexandros Frantzis ]
168 * New upstream release 0.12.1 (https://launchpad.net/mir/+milestone/0.12.1)13 * New upstream release 0.12.1 (https://launchpad.net/mir/+milestone/0.12.1)
169 - Bug fixes:14 - Bug fixes:
170 . [regression] mali, powervr locks up with around the introduction or15 . [regression] mali, powervr locks up with around the introduction or
@@ -183,7 +28,7 @@
183 [-Werror=cpp] (LP: #1435127)28 [-Werror=cpp] (LP: #1435127)
184 . valgrind on armhf fails with with many errors (LP: #1435186)29 . valgrind on armhf fails with with many errors (LP: #1435186)
18530
186 -- CI Train Bot <ci-train-bot@canonical.com> Tue, 24 Mar 2015 16:09:54 +000031 -- Alexandros Frantzis <alexandros.frantzis@canonical.com> Tue, 24 Mar 2015 11:07:41 +0200
18732
188mir (0.12.0+15.04.20150228-0ubuntu1) vivid; urgency=medium33mir (0.12.0+15.04.20150228-0ubuntu1) vivid; urgency=medium
18934
19035
=== modified file 'debian/control'
--- debian/control 2015-05-19 04:37:02 +0000
+++ debian/control 2015-05-20 14:01:27 +0000
@@ -10,6 +10,10 @@
10 doxygen,10 doxygen,
11 xsltproc,11 xsltproc,
12 graphviz,12 graphviz,
13# We rely on C++11 features, and to prevent from ABI breaks
14# in libstdc++ causing us issues, we explicitly select a G++
15# version.
16 g++-4.9,
13 libboost-dev,17 libboost-dev,
14 libboost-date-time-dev,18 libboost-date-time-dev,
15 libboost-program-options-dev,19 libboost-program-options-dev,
@@ -32,13 +36,9 @@
32 libumockdev-dev (>= 0.6),36 libumockdev-dev (>= 0.6),
33 umockdev (>= 0.8.7),37 umockdev (>= 0.8.7),
34 libudev-dev,38 libudev-dev,
35 libgtest-dev,
36 google-mock (>= 1.6.0+svn437),39 google-mock (>= 1.6.0+svn437),
37 valgrind [!arm64],40 valgrind [!arm64],
38 libglib2.0-dev,41 libglib2.0-dev,
39 libfreetype6-dev,
40 abi-compliance-checker,
41 libevdev-dev,
42Standards-Version: 3.9.442Standards-Version: 3.9.4
43Homepage: https://launchpad.net/mir43Homepage: https://launchpad.net/mir
44# If you aren't a member of ~mir-team but need to upload packaging changes,44# If you aren't a member of ~mir-team but need to upload packaging changes,
@@ -61,13 +61,14 @@
6161
62#TODO: Packaging infrastructure for better dependency generation,62#TODO: Packaging infrastructure for better dependency generation,
63# ala pkg-xorg's xviddriver:Provides and ABI detection.63# ala pkg-xorg's xviddriver:Provides and ABI detection.
64Package: libmirserver3264Package: libmirserver30
65Section: libs65Section: libs
66Architecture: i386 amd64 armhf arm6466Architecture: i386 amd64 armhf arm64
67Multi-Arch: same67Multi-Arch: same
68Pre-Depends: ${misc:Pre-Depends}68Pre-Depends: ${misc:Pre-Depends}
69Depends: ${misc:Depends},69Depends: ${misc:Depends},
70 ${shlibs:Depends},70 ${shlibs:Depends},
71 mir-platform-graphics-mesa1 | mir-platform-graphics-android1,
71Description: Display server for Ubuntu - server library72Description: Display server for Ubuntu - server library
72 Mir is a display server running on linux systems, with a focus on efficiency,73 Mir is a display server running on linux systems, with a focus on efficiency,
73 robust operation and a well-defined driver model.74 robust operation and a well-defined driver model.
@@ -93,7 +94,7 @@
93Architecture: i386 amd64 armhf arm6494Architecture: i386 amd64 armhf arm64
94Multi-Arch: same95Multi-Arch: same
95Pre-Depends: ${misc:Pre-Depends}96Pre-Depends: ${misc:Pre-Depends}
96Depends: libmircommon4 (= ${binary:Version}), 97Depends: libmircommon3 (= ${binary:Version}),
97 libprotobuf-dev (>= 2.4.1),98 libprotobuf-dev (>= 2.4.1),
98 libxkbcommon-dev,99 libxkbcommon-dev,
99 ${misc:Depends},100 ${misc:Depends},
@@ -127,7 +128,7 @@
127Architecture: i386 amd64 armhf arm64128Architecture: i386 amd64 armhf arm64
128Multi-Arch: same129Multi-Arch: same
129Pre-Depends: ${misc:Pre-Depends}130Pre-Depends: ${misc:Pre-Depends}
130Depends: libmirserver32 (= ${binary:Version}),131Depends: libmirserver30 (= ${binary:Version}),
131 libmirplatform-dev (= ${binary:Version}),132 libmirplatform-dev (= ${binary:Version}),
132 libmircommon-dev (= ${binary:Version}),133 libmircommon-dev (= ${binary:Version}),
133 libglm-dev,134 libglm-dev,
@@ -145,6 +146,7 @@
145Pre-Depends: ${misc:Pre-Depends}146Pre-Depends: ${misc:Pre-Depends}
146Depends: ${misc:Depends},147Depends: ${misc:Depends},
147 ${shlibs:Depends},148 ${shlibs:Depends},
149 mir-client-platform-mesa2 | mir-client-platform-android2,
148Description: Display server for Ubuntu - client library150Description: Display server for Ubuntu - client library
149 Mir is a display server running on linux systems, with a focus on efficiency,151 Mir is a display server running on linux systems, with a focus on efficiency,
150 robust operation and a well-defined driver model.152 robust operation and a well-defined driver model.
@@ -216,7 +218,6 @@
216Architecture: i386 amd64 armhf arm64218Architecture: i386 amd64 armhf arm64
217Depends: ${misc:Depends},219Depends: ${misc:Depends},
218 ${shlibs:Depends},220 ${shlibs:Depends},
219Recommends: fonts-liberation
220Description: Display server for Ubuntu - demonstration programs221Description: Display server for Ubuntu - demonstration programs
221 Mir is a display server running on linux systems, with a focus on efficiency,222 Mir is a display server running on linux systems, with a focus on efficiency,
222 robust operation and a well-defined driver model.223 robust operation and a well-defined driver model.
@@ -253,7 +254,7 @@
253 .254 .
254 Contains a tool for stress testing the Mir display server255 Contains a tool for stress testing the Mir display server
255256
256Package: libmircommon4257Package: libmircommon3
257Section: libs258Section: libs
258Architecture: i386 amd64 armhf arm64259Architecture: i386 amd64 armhf arm64
259Multi-Arch: same260Multi-Arch: same
@@ -267,7 +268,7 @@
267 Contains the shared libraries required for the Mir server and client.268 Contains the shared libraries required for the Mir server and client.
268269
269# Longer-term these drivers should move out-of-tree270# Longer-term these drivers should move out-of-tree
270Package: mir-platform-graphics-mesa2271Package: mir-platform-graphics-mesa1
271Section: libs272Section: libs
272Architecture: i386 amd64 armhf arm64273Architecture: i386 amd64 armhf arm64
273Multi-Arch: same274Multi-Arch: same
@@ -281,7 +282,7 @@
281 Contains the shared libraries required for the Mir server to interact with282 Contains the shared libraries required for the Mir server to interact with
282 the hardware platform using the Mesa drivers.283 the hardware platform using the Mesa drivers.
283284
284Package: mir-platform-graphics-android2285Package: mir-platform-graphics-android1
285Section: libs286Section: libs
286Architecture: i386 amd64 armhf287Architecture: i386 amd64 armhf
287Multi-Arch: same288Multi-Arch: same
@@ -343,7 +344,7 @@
343Multi-Arch: same344Multi-Arch: same
344Pre-Depends: ${misc:Pre-Depends}345Pre-Depends: ${misc:Pre-Depends}
345Depends: ${misc:Depends},346Depends: ${misc:Depends},
346 mir-platform-graphics-mesa2,347 mir-platform-graphics-mesa1,
347 mir-client-platform-mesa2,348 mir-client-platform-mesa2,
348Description: Display server for Ubuntu - desktop driver metapackage349Description: Display server for Ubuntu - desktop driver metapackage
349 Mir is a display server running on linux systems, with a focus on efficiency,350 Mir is a display server running on linux systems, with a focus on efficiency,
@@ -358,7 +359,7 @@
358Multi-Arch: same359Multi-Arch: same
359Pre-Depends: ${misc:Pre-Depends}360Pre-Depends: ${misc:Pre-Depends}
360Depends: ${misc:Depends},361Depends: ${misc:Depends},
361 mir-platform-graphics-android2,362 mir-platform-graphics-android1,
362 mir-client-platform-android2,363 mir-client-platform-android2,
363Description: Display server for Ubuntu - android driver metapackage364Description: Display server for Ubuntu - android driver metapackage
364 Mir is a display server running on linux systems, with a focus on efficiency,365 Mir is a display server running on linux systems, with a focus on efficiency,
365366
=== modified file 'debian/libmirclient-debug-extension1.install'
--- debian/libmirclient-debug-extension1.install 2015-03-31 02:35:42 +0000
+++ debian/libmirclient-debug-extension1.install 2015-05-20 14:01:27 +0000
@@ -1,1 +1,1 @@
1usr/lib/*/libmirclient-debug-extension.so.11usr/lib/*/libmirclient-debug-extension.so.*
22
=== modified file 'debian/libmirclient-dev.install'
--- debian/libmirclient-dev.install 2015-05-07 09:06:20 +0000
+++ debian/libmirclient-dev.install 2015-05-20 14:01:27 +0000
@@ -1,6 +1,3 @@
1usr/include/mirclient/mir_toolkit/*.h1usr/include/mirclient/mir_toolkit/*.h
2usr/include/mirclient/mir/events/*.h
3usr/include/mirclient/mir/event_printer.h
4usr/include/mirclient/mir_toolkit/events
5usr/lib/*/pkgconfig/mirclient.pc2usr/lib/*/pkgconfig/mirclient.pc
6usr/lib/*/libmirclient.so3usr/lib/*/libmirclient.so
74
=== renamed file 'debian/libmircommon4.install' => 'debian/libmircommon3.install'
--- debian/libmircommon4.install 2015-03-31 02:35:42 +0000
+++ debian/libmircommon3.install 2015-05-20 14:01:27 +0000
@@ -1,1 +1,1 @@
1usr/lib/*/libmircommon.so.41usr/lib/*/libmircommon.so.3
22
=== renamed file 'debian/libmirserver32.install' => 'debian/libmirserver30.install'
--- debian/libmirserver32.install 2015-05-12 06:58:52 +0000
+++ debian/libmirserver30.install 2015-05-20 14:01:27 +0000
@@ -1,1 +1,1 @@
1usr/lib/*/libmirserver.so.321usr/lib/*/libmirserver.so.30
22
=== modified file 'debian/mir-demos.install'
--- debian/mir-demos.install 2015-05-15 11:44:45 +0000
+++ debian/mir-demos.install 2015-05-20 14:01:27 +0000
@@ -1,3 +1,2 @@
1usr/bin/mir_demo_*1usr/bin/mir_demo_*
2usr/bin/mir_proving_*2usr/bin/mir_proving_*
3usr/lib/*/libmir_demo_*
4\ No newline at end of file3\ No newline at end of file
54
=== renamed file 'debian/mir-platform-graphics-android2.install' => 'debian/mir-platform-graphics-android1.install'
--- debian/mir-platform-graphics-android2.install 2015-05-07 09:06:20 +0000
+++ debian/mir-platform-graphics-android1.install 2015-05-20 14:01:27 +0000
@@ -1,1 +1,1 @@
1usr/lib/*/mir/server-platform/graphics-android.so.21usr/lib/*/mir/server-platform/graphics-android.so.1
22
=== renamed file 'debian/mir-platform-graphics-mesa2.install' => 'debian/mir-platform-graphics-mesa1.install'
--- debian/mir-platform-graphics-mesa2.install 2015-05-07 09:06:20 +0000
+++ debian/mir-platform-graphics-mesa1.install 2015-05-20 14:01:27 +0000
@@ -1,1 +1,1 @@
1usr/lib/*/mir/server-platform/graphics-mesa.so.21usr/lib/*/mir/server-platform/graphics-mesa.so.1
22
=== modified file 'debian/mir-test-tools.install'
--- debian/mir-test-tools.install 2015-05-19 04:37:02 +0000
+++ debian/mir-test-tools.install 2015-05-20 14:01:27 +0000
@@ -3,9 +3,7 @@
3usr/bin/mir_acceptance_tests3usr/bin/mir_acceptance_tests
4usr/bin/mir_integration_tests4usr/bin/mir_integration_tests
5usr/bin/mir_performance_tests5usr/bin/mir_performance_tests
6usr/bin/mir_privileged_tests
7usr/lib/*/mir/tools/libmirclientlttng.so6usr/lib/*/mir/tools/libmirclientlttng.so
8usr/lib/*/mir/tools/libmirserverlttng.so7usr/lib/*/mir/tools/libmirserverlttng.so
9usr/lib/*/mir/server-platform/graphics-dummy.so8usr/lib/*/mir/server-platform/graphics-dummy.so
10usr/lib/*/mir/server-platform/input-stub.so
11usr/lib/*/mir/client-platform/dummy.so9usr/lib/*/mir/client-platform/dummy.so
1210
=== modified file 'debian/rules'
--- debian/rules 2015-05-12 06:58:52 +0000
+++ debian/rules 2015-05-20 14:01:27 +0000
@@ -6,11 +6,17 @@
66
7export DPKG_GENSYMBOLS_CHECK_LEVEL = 47export DPKG_GENSYMBOLS_CHECK_LEVEL = 4
88
9include /usr/share/dpkg/default.mk
10
11# Explicitly selecting a G{CC,++}-version here to avoid accidental
12# ABI breaks introduced by toolchain updates.
13export CC=$(DEB_HOST_GNU_TYPE)-gcc-4.9
14export CXX=$(DEB_HOST_GNU_TYPE)-g++-4.9
15
9%:16%:
10 dh $@ --parallel --fail-missing17 dh $@ --parallel --fail-missing
1118
12# Enable verbose debugging output from the testsuite19#overrding dh_auto_test to get rid of --parallel during testing
13export MIR_SERVER_LOGGING = on
14override_dh_auto_test:20override_dh_auto_test:
15 GTEST_OUTPUT=xml:./ dh_auto_test --max-parallel=1 -- ARGS="-V"21 GTEST_OUTPUT=xml:./ dh_auto_test --max-parallel=1 -- ARGS="-V"
1622
1723
=== modified file 'doc/component_reports.md'
--- doc/component_reports.md 2015-03-31 02:35:42 +0000
+++ doc/component_reports.md 2015-05-20 14:01:27 +0000
@@ -16,17 +16,15 @@
16are prefixed with `MIR_SERVER_` and contain underscores ('_') instead of dashes16are prefixed with `MIR_SERVER_` and contain underscores ('_') instead of dashes
17('-'). The available component reports and handlers for the server are:17('-'). The available component reports and handlers for the server are:
1818
19Report | Handlers19Report | Handlers
20---------------------------- | --------20----------------------- | --------
21connector-report | log,lttng21connector-report | log,lttng
22compositor-report | log,lttng22display-report | log,lttng
23display-report | log,lttng23input-report | log,lttng
24input-report | log,lttng24legacy-input-report | log
25legacy-input-report | log25msg-processor-report | log,lttng
26msg-processor-report | log,lttng26session-mediator-report | log,lttng
27session-mediator-report | log,lttng27scene-report | log,lttng
28scene-report | log,lttng
29shared-library-prober-report | log,lttng
3028
31For example, to enable the LTTng input report, one could either use the29For example, to enable the LTTng input report, one could either use the
32`--input-report=lttng` command-line option to the server, or set the30`--input-report=lttng` command-line option to the server, or set the
@@ -39,12 +37,10 @@
39environment variables are prefixed with `MIR_CLIENT_` and contain only37environment variables are prefixed with `MIR_CLIENT_` and contain only
40underscores. The available reports and handlers for the client are:38underscores. The available reports and handlers for the client are:
4139
42Report | Handlers40Report | Handlers
43--------------------- | --------41------------------- | --------
44rpc-report | log,lttng42rpc-report | log,lttng
45input-receiver-report | log,lttng43input-receiver | log,lttng
46shared-library-prober-report | log,lttng
47perf-report | log,lttng
4844
49For example, to enable the logging RPC report, one should set the45For example, to enable the logging RPC report, one should set the
50`MIR_CLIENT_RPC_REPORT=log` environment variable.46`MIR_CLIENT_RPC_REPORT=log` environment variable.
5147
=== modified file 'doc/demo_shell_controls.md'
--- doc/demo_shell_controls.md 2015-05-07 09:06:20 +0000
+++ doc/demo_shell_controls.md 2015-05-20 14:01:27 +0000
@@ -34,7 +34,6 @@
34 - Switch back to X: *Ctrl-Alt-F7*34 - Switch back to X: *Ctrl-Alt-F7*
35 - Switch virtual terminals (VTs): *Ctrl-Alt-(F1-F12)*35 - Switch virtual terminals (VTs): *Ctrl-Alt-(F1-F12)*
36 - Switch apps: *Alt-Tab* or *4-finger swipe left/right*36 - Switch apps: *Alt-Tab* or *4-finger swipe left/right*
37 - Switch windows of the current app: *Alt-grave*
38 - Ask an app to close: *Alt-F4* (it may refuse or not understand)37 - Ask an app to close: *Alt-F4* (it may refuse or not understand)
39 - Move window: *Alt-leftmousebutton* or *3-finger drag*38 - Move window: *Alt-leftmousebutton* or *3-finger drag*
40 - Resize window: *Alt-middlemousebutton* or *3-finger pinch/zoom*39 - Resize window: *Alt-middlemousebutton* or *3-finger pinch/zoom*
4140
=== modified file 'doc/footer.html.in'
--- doc/footer.html.in 2015-05-07 09:06:20 +0000
+++ doc/footer.html.in 2015-05-20 14:01:27 +0000
@@ -1,5 +1,5 @@
1<hr>1<hr>
2<p align="center">Copyright &copy; 2012-2015 Canonical Ltd. <br />2<p align="center">Copyright &copy; 2012,2013 Canonical Ltd. <br />
3Generated on @DATE_TODAY@</p>3Generated on @DATE_TODAY@</p>
4</body>4</body>
5</html>5</html>
66
=== modified file 'doc/mainpage.md'
--- doc/mainpage.md 2015-05-07 09:06:20 +0000
+++ doc/mainpage.md 2015-05-20 14:01:27 +0000
@@ -93,16 +93,10 @@
93 "server_example_input_filter.cpp: print input events to stdout"93 "server_example_input_filter.cpp: print input events to stdout"
94 - \subpage server_example_log_options.cpp 94 - \subpage server_example_log_options.cpp
95 "server_example_log_options.cpp: replace Mir logger with glog"95 "server_example_log_options.cpp: replace Mir logger with glog"
96 - \subpage server_example_basic_window_manager.h 96 - \subpage server_example_window_manager.cpp
97 "server_example_basic_window_manager.h: How to wire up a window manager"97 "server_example_window_manager.cpp: How to wire up a window manager"
98 - \subpage server_example_window_management.cpp 98 - \subpage server_example_window_management.cpp
99 "server_example_window_management.cpp: simple window management examples"99 "server_example_window_management.cpp: simple window management examples"
100 - \subpage server_example_canonical_window_manager.cpp
101 "server_example_canonical_window_manager.cpp: canonical window management policy"
102 - \subpage server_example_tiling_window_manager.cpp
103 "server_example_tiling_window_manager.cpp: an alternative window management policy"
104 - \subpage server_example_custom_compositor.cpp
105 "server_example_custom_compositor.cpp: demonstrate writing an alternative GL rendering code"
106100
107Working on Mir code101Working on Mir code
108-------------------102-------------------
109103
=== modified file 'examples/CMakeLists.txt'
--- examples/CMakeLists.txt 2015-05-18 21:30:28 +0000
+++ examples/CMakeLists.txt 2015-05-20 14:01:27 +0000
@@ -16,29 +16,22 @@
16)16)
1717
18add_library(exampleserverconfig STATIC18add_library(exampleserverconfig STATIC
19 server_example_canonical_window_manager.cpp19 server_example_generic_shell.cpp
20 server_example_display_configuration_policy.cpp20 server_example_display_configuration_policy.cpp
21 server_example_input_event_filter.cpp21 server_example_input_event_filter.cpp
22 server_example_log_options.cpp22 server_example_log_options.cpp
23 server_example_input_filter.cpp23 server_example_input_filter.cpp
24 server_example_fullscreen_placement_strategy.cpp
24 server_example_host_lifecycle_event.cpp25 server_example_host_lifecycle_event.cpp
25 server_example_tiling_window_manager.cpp26 server_example_tiling_window_manager.cpp
26 server_example_window_management.cpp27 server_example_window_management.cpp
27 server_example_custom_compositor.cpp28 server_example_shell.cpp
28 server_example_adorning_compositor.cpp
29)29)
3030
31target_link_libraries(eglapp31target_link_libraries(eglapp
32 mirclient32 mirclient
33 ${EGL_LIBRARIES}33 ${EGL_LIBRARIES}
34 ${GLESv2_LIBRARIES}34 ${GLESv2_LIBRARIES}
35 )
36
37mir_add_wrapped_executable(mir_demo_client_animated_cursor
38 animated_cursor_demo_client.c
39)
40target_link_libraries(mir_demo_client_animated_cursor
41 eglapp
42)35)
43mir_add_wrapped_executable(mir_demo_client_eglflash36mir_add_wrapped_executable(mir_demo_client_eglflash
44 eglflash.c37 eglflash.c
@@ -52,12 +45,6 @@
52target_link_libraries(mir_demo_client_egltriangle45target_link_libraries(mir_demo_client_egltriangle
53 eglapp46 eglapp
54)47)
55mir_add_wrapped_executable(mir_demo_client_target
56 target.c
57)
58target_link_libraries(mir_demo_client_target
59 eglapp
60)
61mir_add_wrapped_executable(mir_demo_client_eglcounter48mir_add_wrapped_executable(mir_demo_client_eglcounter
62 eglcounter.cpp49 eglcounter.cpp
63)50)
@@ -117,9 +104,6 @@
117mir_add_wrapped_executable(mir_demo_client_display_config demo_client_display_config.c)104mir_add_wrapped_executable(mir_demo_client_display_config demo_client_display_config.c)
118target_link_libraries(mir_demo_client_display_config eglapp)105target_link_libraries(mir_demo_client_display_config eglapp)
119106
120mir_add_wrapped_executable(mir_demo_client_eglsquare eglsquare.cpp)
121target_link_libraries(mir_demo_client_eglsquare eglapp)
122
123mir_add_wrapped_executable(mir_demo_client_flicker107mir_add_wrapped_executable(mir_demo_client_flicker
124 flicker.c108 flicker.c
125)109)
@@ -185,32 +169,6 @@
185 ${Boost_LIBRARIES}169 ${Boost_LIBRARIES}
186)170)
187171
188add_library(mir_demo_server_loadable MODULE
189 server_example.cpp
190 glog_logger.cpp
191 server_example_test_client.cpp
192)
193
194target_link_libraries(mir_demo_server_loadable
195 mirserver
196 exampleserverconfig
197 ${GLog_LIBRARY}
198 ${GFlags_LIBRARY}
199 ${Boost_LIBRARIES}
200)
201
202install(TARGETS mir_demo_server_loadable
203 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
204)
205
206mir_add_wrapped_executable(mir_demo_server_loader
207 mir_demo_server_loader.cpp
208)
209
210target_link_libraries(mir_demo_server_loader
211 dl
212)
213
214mir_add_wrapped_executable(mir_demo_server_minimal server_minimal.cpp)172mir_add_wrapped_executable(mir_demo_server_minimal server_minimal.cpp)
215target_link_libraries(mir_demo_server_minimal mirserver)173target_link_libraries(mir_demo_server_minimal mirserver)
216174
@@ -223,27 +181,19 @@
223 mircommon181 mircommon
224)182)
225183
226if (MIR_ENABLE_TESTS)184# FIXME: Bug not fixed yet.
185if (MIR_ENABLE_TESTS AND MIR_TEST_CLIENT_ABI)
227 # Regression tests for LP: #1415321186 # Regression tests for LP: #1415321
228187
229 # To see reasons for failure: ctest -V -R Clients-only-use-client-symbols188 # To see reasons for failure: ctest -V -R Clients-only-use-client-symbols
230 mir_add_test(NAME Clients-only-use-client-symbols189 add_test(NAME Clients-only-use-client-symbols
231 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin190 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
232 COMMAND /bin/sh -c "!(nm -u .mir_demo_client_* mir_demo_client* | grep -v @@MIR_CLIENT | grep 'U mir_')"191 COMMAND /bin/sh -c "!(nm -u .mir_demo_client_* mir_demo_client* | grep -v @@MIR_CLIENT | grep 'U mir_')"
233 )192 )
234193
235# We use a slightly weaker version of the test with clang as that generates spurious NEEDED
236if (NOT "${CMAKE_CXX_COMPILER}" MATCHES "clang")
237 # To see reasons for failure: ctest -V -R Clients-only-use-client-ABI194 # To see reasons for failure: ctest -V -R Clients-only-use-client-ABI
238 mir_add_test(NAME Clients-only-use-client-ABI195 add_test(NAME Clients-only-use-client-ABI
239 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin196 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
240 COMMAND /bin/sh -c "!(objdump -p .mir_demo_client_* mir_demo_client* | grep NEEDED | grep libmir | grep -v libmirclient)"197 COMMAND /bin/sh -c "!(objdump -p .mir_demo_client_* mir_demo_client* | grep NEEDED | grep libmir | grep -v libmirclient)"
241 )198 )
242else()
243 # To see reasons for failure: ctest -V -R Clients-only-use-client-ABI
244 mir_add_test(NAME Clients-only-use-client-ABI
245 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
246 COMMAND /bin/sh -c "!(nm -u .mir_demo_client_* mir_demo_client* | grep -v @@MIR_CLIENT | grep @@MIR_)"
247 )
248endif ()
249endif ()199endif ()
250200
=== removed file 'examples/animated_cursor_demo_client.c'
--- examples/animated_cursor_demo_client.c 2015-02-25 22:10:35 +0000
+++ examples/animated_cursor_demo_client.c 1970-01-01 00:00:00 +0000
@@ -1,90 +0,0 @@
1/*
2 * Copyright © 2015 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 * Author: Robert Carr <robert.carr@canonical.com>
17 */
18
19#define _GNU_SOURCE // for nanosleep
20
21#include "eglapp.h"
22
23#include "mir_toolkit/mir_client_library.h"
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <unistd.h>
29#include <sys/time.h>
30#include <sys/types.h>
31#include <time.h>
32#include <GLES2/gl2.h>
33
34void animate_cursor(MirBufferStream *stream)
35{
36 static double alpha = 0.0;
37 char fill_color = 0xff * alpha;
38
39 MirGraphicsRegion region;
40 mir_buffer_stream_get_graphics_region(stream, &region);
41
42 memset(region.vaddr, fill_color, region.stride*region.height);
43
44 mir_buffer_stream_swap_buffers_sync(stream);
45 alpha += 0.01;
46 if (alpha >= 1.0)
47 alpha = 0.0;
48
49}
50
51MirBufferStream* make_cursor_stream(MirConnection *connection, MirSurface *surface)
52{
53 MirBufferStream* stream = mir_connection_create_buffer_stream_sync(connection,
54 24, 24, mir_pixel_format_argb_8888, mir_buffer_usage_software);
55
56 MirCursorConfiguration* conf = mir_cursor_configuration_from_buffer_stream(stream, 0, 0);
57 mir_wait_for(mir_surface_configure_cursor(surface, conf));
58 mir_cursor_configuration_destroy(conf);
59
60 return stream;
61}
62
63int main(int argc, char *argv[])
64{
65 unsigned int width = 128, height = 128;
66
67 if (!mir_eglapp_init(argc, argv, &width, &height))
68 return 1;
69
70 glClearColor(0.5, 0.5, 0.5, mir_eglapp_background_opacity);
71 glClear(GL_COLOR_BUFFER_BIT);
72 mir_eglapp_swap_buffers();
73
74 MirBufferStream* stream = make_cursor_stream(mir_eglapp_native_connection(),
75 mir_eglapp_native_surface());
76
77 struct timespec onehundred_millis = {
78 0, 100*1000000
79 };
80
81 while (mir_eglapp_running())
82 {
83 nanosleep(&onehundred_millis, &onehundred_millis);
84 animate_cursor(stream);
85 }
86
87 mir_eglapp_shutdown();
88
89 return 0;
90}
910
=== modified file 'examples/demo_client_display_config.c'
--- examples/demo_client_display_config.c 2015-03-31 02:35:42 +0000
+++ examples/demo_client_display_config.c 2015-05-20 14:01:27 +0000
@@ -295,11 +295,11 @@
295 ctx->reconfigure = 1;295 ctx->reconfigure = 1;
296}296}
297297
298static void handle_keyboard_event(struct ClientContext *ctx, MirKeyboardEvent const* event)298static void handle_key_input_event(struct ClientContext *ctx, MirKeyInputEvent const* event)
299{299{
300 if (mir_keyboard_event_action(event) != mir_keyboard_action_up)300 if (mir_key_input_event_get_action(event) != mir_key_input_event_action_up)
301 return;301 return;
302 xkb_keysym_t key_code = mir_keyboard_event_key_code(event);302 xkb_keysym_t key_code = mir_key_input_event_get_key_code(event);
303303
304 if (key_code >= XKB_KEY_1 &&304 if (key_code >= XKB_KEY_1 &&
305 key_code <= XKB_KEY_9)305 key_code <= XKB_KEY_9)
@@ -340,7 +340,7 @@
340 if (mir_input_event_get_type(input_event) != mir_input_event_type_key)340 if (mir_input_event_get_type(input_event) != mir_input_event_type_key)
341 return;341 return;
342 342
343 handle_keyboard_event(ctx, mir_input_event_get_keyboard_event(input_event));343 handle_key_input_event(ctx, mir_input_event_get_key_input_event(input_event));
344}344}
345345
346int main(int argc, char *argv[])346int main(int argc, char *argv[])
@@ -368,7 +368,8 @@
368 mir_connection_set_display_config_change_callback(368 mir_connection_set_display_config_change_callback(
369 connection, display_change_callback, &ctx);369 connection, display_change_callback, &ctx);
370370
371 mir_surface_set_event_handler(surface, event_callback, &ctx);371 struct MirEventDelegate ed = {event_callback, &ctx};
372 mir_surface_set_event_handler(surface, &ed);
372373
373 time_t start = time(NULL);374 time_t start = time(NULL);
374375
375376
=== modified file 'examples/eglapp.c'
--- examples/eglapp.c 2015-04-09 08:57:24 +0000
+++ examples/eglapp.c 2015-05-20 14:01:27 +0000
@@ -16,6 +16,8 @@
16 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>16 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */17 */
1818
19#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
20
19#include "eglapp.h"21#include "eglapp.h"
20#include "mir_toolkit/mir_client_library.h"22#include "mir_toolkit/mir_client_library.h"
21#include <stdio.h>23#include <stdio.h>
@@ -94,10 +96,10 @@
94{96{
95 if (mir_input_event_get_type(event) != mir_input_event_type_key)97 if (mir_input_event_get_type(event) != mir_input_event_type_key)
96 return;98 return;
97 MirKeyboardEvent const* kev = mir_input_event_get_keyboard_event(event);99 MirKeyInputEvent const* kev = mir_input_event_get_key_input_event(event);
98 if (mir_keyboard_event_action(kev) != mir_keyboard_action_up)100 if (mir_key_input_event_get_action(kev) != mir_key_input_event_action_up)
99 return;101 return;
100 if (mir_keyboard_event_key_code(kev) != XKB_KEY_q)102 if (mir_key_input_event_get_key_code(kev) != XKB_KEY_q)
101 return;103 return;
102 104
103 running = 0;105 running = 0;
@@ -142,12 +144,7 @@
142 * support for event queuing (directing them to another thread) or144 * support for event queuing (directing them to another thread) or
143 * full single-threaded callbacks. (LP: #1194384).145 * full single-threaded callbacks. (LP: #1194384).
144 */146 */
145 {147 printf("Resized to %dx%d\n", ev->resize.width, ev->resize.height);
146 MirResizeEvent const* resize = mir_event_get_resize_event(ev);
147 printf("Resized to %dx%d\n",
148 mir_resize_event_get_width(resize),
149 mir_resize_event_get_height(resize));
150 }
151 break;148 break;
152 case mir_event_type_close_surface:149 case mir_event_type_close_surface:
153 printf("Received close event from server.\n");150 printf("Received close event from server.\n");
@@ -189,6 +186,11 @@
189 EGL_CONTEXT_CLIENT_VERSION, 2,186 EGL_CONTEXT_CLIENT_VERSION, 2,
190 EGL_NONE187 EGL_NONE
191 };188 };
189 MirEventDelegate delegate =
190 {
191 mir_eglapp_handle_event,
192 NULL
193 };
192 EGLConfig eglconfig;194 EGLConfig eglconfig;
193 EGLint neglconfigs;195 EGLint neglconfigs;
194 EGLContext eglctx;196 EGLContext eglctx;
@@ -386,14 +388,7 @@
386388
387 CHECK(spec != NULL, "Can't create a surface spec");389 CHECK(spec != NULL, "Can't create a surface spec");
388390
389 char const* name = argv[0];391 mir_surface_spec_set_name(spec, "eglappsurface");
390 for (char const* p = name; *p; p++)
391 {
392 if (*p == '/')
393 name = p + 1;
394 }
395 mir_surface_spec_set_name(spec, name);
396
397 if (output_id != mir_display_output_id_invalid)392 if (output_id != mir_display_output_id_invalid)
398 mir_surface_spec_set_fullscreen_on_output(spec, output_id);393 mir_surface_spec_set_fullscreen_on_output(spec, output_id);
399394
@@ -402,7 +397,7 @@
402397
403 CHECK(mir_surface_is_valid(surface), "Can't create a surface");398 CHECK(mir_surface_is_valid(surface), "Can't create a surface");
404399
405 mir_surface_set_event_handler(surface, mir_eglapp_handle_event, NULL);400 mir_surface_set_event_handler(surface, &delegate);
406 401
407 MirCursorConfiguration *conf = mir_cursor_configuration_from_name(cursor_name);402 MirCursorConfiguration *conf = mir_cursor_configuration_from_name(cursor_name);
408 mir_surface_configure_cursor(surface, conf);403 mir_surface_configure_cursor(surface, conf);
409404
=== removed file 'examples/eglsquare.cpp'
--- examples/eglsquare.cpp 2015-05-07 09:06:20 +0000
+++ examples/eglsquare.cpp 1970-01-01 00:00:00 +0000
@@ -1,417 +0,0 @@
1/*
2 * Copyright © 2015 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "mir_toolkit/mir_client_library.h"
20#include <EGL/egl.h>
21#include <GLES2/gl2.h>
22#include <thread>
23#include <memory>
24#include <chrono>
25#include <iostream>
26#include <cstring>
27#include <unistd.h>
28#include <signal.h>
29
30namespace
31{
32class Connection
33{
34public:
35 Connection(char const* socket_file) :
36 connection(mir_connect_sync(socket_file, __PRETTY_FUNCTION__))
37 {
38 if (!mir_connection_is_valid(connection))
39 throw std::runtime_error(std::string("could not connect to server: ") +
40 mir_connection_get_error_message(connection));
41 }
42 ~Connection()
43 {
44 mir_connection_release(connection);
45 }
46 operator MirConnection*() { return connection; }
47 Connection(Connection const&) = delete;
48 Connection& operator=(Connection const&) = delete;
49private:
50 MirConnection* connection;
51};
52
53class Context
54{
55public:
56 Context(Connection& connection, MirSurface* surface, int swap_interval) :
57 native_display(reinterpret_cast<EGLNativeDisplayType>(
58 mir_connection_get_egl_native_display(connection))),
59 native_window(reinterpret_cast<EGLNativeWindowType>(
60 mir_buffer_stream_get_egl_native_window(mir_surface_get_buffer_stream(surface)))),
61 display(native_display),
62 config(chooseconfig(display.disp)),
63 surface(display.disp, config, native_window),
64 context(display.disp, config)
65 {
66 make_current();
67 eglSwapInterval(display.disp, swap_interval);
68 }
69 void make_current()
70 {
71 if (eglMakeCurrent(display.disp, surface.surface, surface.surface, context.context) == EGL_FALSE)
72 throw(std::runtime_error("could not makecurrent"));
73 }
74 void release_current()
75 {
76 if (eglMakeCurrent(display.disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) == EGL_FALSE)
77 throw(std::runtime_error("could not makecurrent"));
78 }
79 void swapbuffers()
80 {
81 if (eglSwapBuffers(display.disp, surface.surface) == EGL_FALSE)
82 throw(std::runtime_error("could not swapbuffers"));
83 }
84 Context(Context const&) = delete;
85 Context& operator=(Context const&) = delete;
86private:
87 EGLConfig chooseconfig(EGLDisplay disp)
88 {
89 int n{0};
90 EGLConfig egl_config;
91 EGLint attribs[] = {
92 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
93 EGL_RED_SIZE, 8,
94 EGL_GREEN_SIZE, 8,
95 EGL_BLUE_SIZE, 8,
96 EGL_ALPHA_SIZE, 8,
97 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
98 EGL_NONE };
99 if (eglChooseConfig(disp, attribs, &egl_config, 1, &n) != EGL_TRUE || n != 1)
100 throw std::runtime_error("could not find egl config");
101 return egl_config;
102 }
103 EGLNativeDisplayType native_display;
104 EGLNativeWindowType native_window;
105 struct Display
106 {
107 Display(EGLNativeDisplayType native) :
108 disp(eglGetDisplay(native))
109 {
110 int major{0}, minor{0};
111 if (disp == EGL_NO_DISPLAY)
112 throw std::runtime_error("no egl display");
113 if (eglInitialize(disp, &major, &minor) != EGL_TRUE || major != 1 || minor != 4)
114 throw std::runtime_error("could not init egl");
115 }
116 ~Display()
117 {
118 eglTerminate(disp);
119 }
120 EGLDisplay disp;
121 } display;
122 EGLConfig config;
123 struct Surface
124 {
125 Surface(EGLDisplay display, EGLConfig config, EGLNativeWindowType native_window) :
126 disp(display),
127 surface(eglCreateWindowSurface(disp, config, native_window, NULL))
128 {
129 if (surface == EGL_NO_SURFACE)
130 throw std::runtime_error("could not create egl surface");
131 }
132 ~Surface() {
133 if (eglGetCurrentSurface(EGL_DRAW) == surface)
134 eglMakeCurrent(disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
135 eglDestroySurface(disp, surface);
136 }
137 EGLDisplay disp;
138 EGLSurface surface;
139 } surface;
140 struct EglContext
141 {
142 EglContext(EGLDisplay disp, EGLConfig config) :
143 disp(disp),
144 context(eglCreateContext(disp, config, EGL_NO_CONTEXT, context_attribs))
145 {
146 if (context == EGL_NO_CONTEXT)
147 throw std::runtime_error("could not create egl context");
148 }
149 ~EglContext()
150 {
151 eglDestroyContext(disp, context);
152 }
153 EGLint context_attribs[3] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
154 EGLDisplay disp;
155 EGLContext context;
156 } context;
157};
158
159class RenderProgram
160{
161public:
162 RenderProgram(Context& context, unsigned int width, unsigned int height) :
163 vertex(&vtex_shader_src, GL_VERTEX_SHADER),
164 fragment(&frag_shader_src, GL_FRAGMENT_SHADER),
165 program(vertex, fragment)
166 {
167 float square_side = 400.0f;
168 float scale[2] {square_side/width, square_side/height};
169 glUseProgram(program.program);
170 vPositionAttr = glGetAttribLocation(program.program, "vPosition");
171 glVertexAttribPointer(vPositionAttr, 4, GL_FLOAT, GL_FALSE, 0, vertex_data);
172 posUniform = glGetUniformLocation(program.program, "pos");
173 glClearColor(0.1, 0.1, 0.4, 1.0); //light blue
174 glClear(GL_COLOR_BUFFER_BIT);
175 auto scaleUniform = glGetUniformLocation(program.program, "scale");
176 glUniform2fv(scaleUniform, 1, scale);
177
178 context.swapbuffers();
179 context.release_current();
180 }
181
182 void draw(float x, float y)
183 {
184 float pos[2] = {x, y};
185 glUseProgram(program.program);
186 glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
187 glUniform2fv(posUniform, 1, pos);
188 glEnableVertexAttribArray(vPositionAttr);
189 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
190 glDisableVertexAttribArray(vPositionAttr);
191 }
192
193 RenderProgram(RenderProgram const&) = delete;
194 RenderProgram& operator=(RenderProgram const&) = delete;
195private:
196 GLchar const*const frag_shader_src =
197 {
198 "precision mediump float;"
199 "void main() {"
200 " gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);"
201 "}"
202 };
203 GLchar const*const vtex_shader_src =
204 {
205 "attribute vec4 vPosition;"
206 "uniform vec2 pos;"
207 "uniform vec2 scale;"
208 "void main() {"
209 " gl_Position = vec4(vPosition.xy * scale + pos, 0.0, 1.0);"
210 "}"
211 };
212 struct Shader
213 {
214 Shader(GLchar const* const* src, GLuint type) :
215 shader(glCreateShader(type))
216 {
217 glShaderSource(shader, 1, src, 0);
218 glCompileShader(shader);
219 }
220 ~Shader()
221 {
222 glDeleteShader(shader);
223 }
224 GLuint shader;
225 } vertex, fragment;
226 struct Program
227 {
228 Program(Shader& vertex, Shader& fragment) :
229 program(glCreateProgram())
230 {
231 glAttachShader(program, vertex.shader);
232 glAttachShader(program, fragment.shader);
233 glLinkProgram(program);
234 }
235 ~Program()
236 {
237 glDeleteProgram(program);
238 }
239 GLuint program;
240 } program;
241 GLfloat vertex_data[16]
242 {
243 -1.0, -1.0f, 0.0f, 1.0f,
244 -1.0f, 1.0f, 0.0f, 1.0f,
245 1.0f, -1.0f, 0.0f, 1.0f,
246 1.0f, 1.0f, 0.0f, 1.0f,
247 };
248 GLuint vPositionAttr;
249 GLuint posUniform;
250};
251
252class Surface
253{
254public:
255 Surface(Connection& connection, int swap_interval) :
256 dimensions(active_output_dimensions(connection)),
257 surface{create_surface(connection, dimensions), surface_deleter},
258 context{connection, surface.get(), swap_interval},
259 program{context, dimensions.width, dimensions.height}
260 {
261 }
262
263 void on_event(MirEvent const* ev)
264 {
265 if (mir_event_get_type(ev) != mir_event_type_input)
266 return;
267 float x{0.0f};
268 float y{0.0f};
269 auto ievent = mir_event_get_input_event(ev);
270 if (mir_input_event_get_type(ievent) == mir_input_event_type_touch)
271 {
272 auto tev = mir_input_event_get_touch_event(ievent);
273 x = mir_touch_event_axis_value(tev, 0, mir_touch_axis_x);
274 y = mir_touch_event_axis_value(tev, 0, mir_touch_axis_y);
275 }
276 else if (mir_input_event_get_type(ievent) == mir_input_event_type_pointer)
277 {
278 auto pev = mir_input_event_get_pointer_event(ievent);
279 x = mir_pointer_event_axis_value(pev, mir_pointer_axis_x);
280 y = mir_pointer_event_axis_value(pev, mir_pointer_axis_y);
281 }
282 else
283 {
284 return;
285 }
286 context.make_current();
287 program.draw(
288 x/static_cast<float>(dimensions.width)*2.0 - 1.0,
289 y/static_cast<float>(dimensions.height)*-2.0 + 1.0);
290 context.swapbuffers();
291 }
292
293 Surface(Surface const&) = delete;
294 Surface& operator=(Surface const&) = delete;
295private:
296 struct OutputDimensions
297 {
298 unsigned int const width;
299 unsigned int const height;
300 } const dimensions;
301
302
303 std::function<void(MirSurface*)> const surface_deleter{
304 [](MirSurface* surface)
305 {
306 mir_surface_release_sync(surface);
307 }
308 };
309 std::unique_ptr<MirSurface, decltype(surface_deleter)> surface;
310 Context context;
311 RenderProgram program;
312
313 OutputDimensions active_output_dimensions(MirConnection* connection)
314 {
315 unsigned int width{0};
316 unsigned int height{0};
317 auto display_config = mir_connection_create_display_config(connection);
318 for (auto i = 0u; i < display_config->num_outputs; i++)
319 {
320 MirDisplayOutput const* out = display_config->outputs + i;
321 if (out->used &&
322 out->connected &&
323 out->num_modes &&
324 out->current_mode < out->num_modes)
325 {
326 width = out->modes[out->current_mode].horizontal_resolution;
327 height = out->modes[out->current_mode].vertical_resolution;
328 break;
329 }
330 }
331 mir_display_config_destroy(display_config);
332 if (width == 0 || height == 0)
333 throw std::logic_error("could not determine display size");
334 return {width, height};
335 }
336
337 MirSurface* create_surface(MirConnection* connection, OutputDimensions const& dim)
338 {
339 MirPixelFormat selected_format;
340 unsigned int valid_formats{0};
341 MirPixelFormat pixel_formats[mir_pixel_formats];
342 mir_connection_get_available_surface_formats(connection, pixel_formats, mir_pixel_formats, &valid_formats);
343 if (valid_formats == 0)
344 throw std::runtime_error("no pixel formats for surface");
345 selected_format = pixel_formats[0];
346 //select an 8 bit opaque format if we can
347 for(auto i = 0u; i < valid_formats; i++)
348 {
349 if (pixel_formats[i] == mir_pixel_format_xbgr_8888 ||
350 pixel_formats[i] == mir_pixel_format_xrgb_8888)
351 {
352 selected_format = pixel_formats[i];
353 break;
354 }
355 }
356
357 auto deleter = [](MirSurfaceSpec *spec) { mir_surface_spec_release(spec); };
358 std::unique_ptr<MirSurfaceSpec, decltype(deleter)> spec{
359 mir_connection_create_spec_for_normal_surface(connection, dim.width, dim.height, selected_format),
360 deleter
361 };
362
363 mir_surface_spec_set_name(spec.get(), __PRETTY_FUNCTION__);
364 mir_surface_spec_set_buffer_usage(spec.get(), mir_buffer_usage_hardware);
365 auto surface = mir_surface_create_sync(spec.get());
366 mir_surface_set_event_handler(surface, &on_event, this);
367 return surface;
368 }
369 static void on_event(MirSurface*, const MirEvent *event, void *context)
370 {
371 auto surface = reinterpret_cast<Surface*>(context);
372 if (surface) surface->on_event(event);
373 }
374};
375
376}
377
378int main(int argc, char *argv[])
379try
380{
381 using namespace std::literals::chrono_literals;
382
383 auto arg = 0;
384 char const* socket_file = nullptr;
385 int swap_interval = 1;
386 while ((arg = getopt (argc, argv, "nm:")) != -1)
387 {
388 switch (arg)
389 {
390 case 'm':
391 socket_file = optarg;
392 break;
393 case 'n':
394 swap_interval = 0;
395 break;
396 default:
397 throw std::invalid_argument("invalid command line argument");
398 }
399 }
400
401 Connection connection(socket_file);
402 Surface surface(connection, swap_interval);
403
404 sigset_t sigset;
405 siginfo_t siginfo;
406 sigemptyset(&sigset);
407 sigaddset(&sigset, SIGTERM);
408 sigaddset(&sigset, SIGINT);
409 sigprocmask(SIG_BLOCK, &sigset, nullptr);
410 sigwaitinfo(&sigset, &siginfo);
411 return 0;
412}
413catch(std::exception& e)
414{
415 std::cerr << "error : " << e.what() << std::endl;
416 return 1;
417}
4180
=== modified file 'examples/fingerpaint.c'
--- examples/fingerpaint.c 2015-05-07 09:06:20 +0000
+++ examples/fingerpaint.c 2015-05-20 14:01:27 +0000
@@ -16,8 +16,6 @@
16 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>16 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */17 */
1818
19#define _POSIX_C_SOURCE 200112L // for setenv() from stdlib.h
20
21#include "mir_toolkit/mir_client_library.h"19#include "mir_toolkit/mir_client_library.h"
22#include "mir_toolkit/events/input/input_event.h"20#include "mir_toolkit/events/input/input_event.h"
2321
@@ -27,7 +25,6 @@
27#include <stdlib.h>25#include <stdlib.h>
28#include <unistd.h> /* sleep() */26#include <unistd.h> /* sleep() */
29#include <string.h>27#include <string.h>
30#include <pthread.h>
3128
32#define BYTES_PER_PIXEL(f) ((f) == mir_pixel_format_bgr_888 ? 3 : 4)29#define BYTES_PER_PIXEL(f) ((f) == mir_pixel_format_bgr_888 ? 3 : 4)
33#define MIN(a, b) ((a) <= (b) ? (a) : (b))30#define MIN(a, b) ((a) <= (b) ? (a) : (b))
@@ -37,19 +34,13 @@
37 uint8_t r, g, b, a;34 uint8_t r, g, b, a;
38} Color;35} Color;
3936
40static volatile bool running = true;37static volatile sig_atomic_t running = 1;
41
42static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
43static pthread_cond_t change = PTHREAD_COND_INITIALIZER;
44static bool changed = true;
4538
46static void shutdown(int signum)39static void shutdown(int signum)
47{40{
48 if (running)41 if (running)
49 {42 {
50 running = false;43 running = 0;
51 changed = true;
52 pthread_cond_signal(&change);
53 printf("Signal %d received. Good night.\n", signum);44 printf("Signal %d received. Good night.\n", signum);
54 }45 }
55}46}
@@ -183,9 +174,20 @@
183 }174 }
184}175}
185176
177static void redraw(MirSurface *surface, const MirGraphicsRegion *canvas)
178{
179 MirGraphicsRegion backbuffer;
180 MirBufferStream *bs = mir_surface_get_buffer_stream(surface);
181
182 mir_buffer_stream_get_graphics_region(
183 bs, &backbuffer);
184 copy_region(&backbuffer, canvas);
185 mir_buffer_stream_swap_buffers_sync(
186 bs);
187}
188
186static void on_event(MirSurface *surface, const MirEvent *event, void *context)189static void on_event(MirSurface *surface, const MirEvent *event, void *context)
187{190{
188 (void)surface;
189 MirGraphicsRegion *canvas = (MirGraphicsRegion*)context;191 MirGraphicsRegion *canvas = (MirGraphicsRegion*)context;
190192
191 static const Color color[] =193 static const Color color[] =
@@ -206,8 +208,6 @@
206 208
207 MirEventType event_type = mir_event_get_type(event);209 MirEventType event_type = mir_event_get_type(event);
208210
209 pthread_mutex_lock(&mutex);
210
211 if (event_type == mir_event_type_input)211 if (event_type == mir_event_type_input)
212 {212 {
213 static size_t base_color = 0;213 static size_t base_color = 0;
@@ -215,8 +215,8 @@
215 static float max_pressure = 1.0f;215 static float max_pressure = 1.0f;
216216
217 MirInputEvent const* input_event = mir_event_get_input_event(event);217 MirInputEvent const* input_event = mir_event_get_input_event(event);
218 MirTouchEvent const* tev = NULL;218 MirTouchInputEvent const* tev = NULL;
219 MirPointerEvent const* pev = NULL;219 MirPointerInputEvent const* pev = NULL;
220 unsigned touch_count = 0;220 unsigned touch_count = 0;
221 bool ended = false;221 bool ended = false;
222 MirInputEventType type = mir_input_event_get_type(input_event);222 MirInputEventType type = mir_input_event_get_type(input_event);
@@ -224,17 +224,18 @@
224 switch (type)224 switch (type)
225 {225 {
226 case mir_input_event_type_touch:226 case mir_input_event_type_touch:
227 tev = mir_input_event_get_touch_event(input_event);227 tev = mir_input_event_get_touch_input_event(input_event);
228 touch_count = mir_touch_event_point_count(tev);228 touch_count = mir_touch_input_event_get_touch_count(tev);
229 ended = touch_count == 1 &&229 ended = touch_count == 1 &&
230 (mir_touch_event_action(tev, 0) == mir_touch_action_up);230 (mir_touch_input_event_get_touch_action(tev, 0) ==
231 mir_touch_input_event_action_up);
231 break;232 break;
232 case mir_input_event_type_pointer:233 case mir_input_event_type_pointer:
233 pev = mir_input_event_get_pointer_event(input_event);234 pev = mir_input_event_get_pointer_input_event(input_event);
234 ended = mir_pointer_event_action(pev) ==235 ended = mir_pointer_input_event_get_action(pev) ==
235 mir_pointer_action_button_up;236 mir_pointer_input_event_action_button_up;
236 touch_count = mir_pointer_event_button_state(pev,237 touch_count = mir_pointer_input_event_get_button_state(pev,
237 mir_pointer_button_primary) ? 1 : 0;238 mir_pointer_input_button_primary) ? 1 : 0;
238 default:239 default:
239 break;240 break;
240 }241 }
@@ -261,18 +262,22 @@
261262
262 if (tev != NULL)263 if (tev != NULL)
263 {264 {
264 x = mir_touch_event_axis_value(tev, p, mir_touch_axis_x);265 x = mir_touch_input_event_get_touch_axis_value(tev, p,
265 y = mir_touch_event_axis_value(tev, p, mir_touch_axis_y);266 mir_touch_input_axis_x);
266 float size = mir_touch_event_axis_value(tev, p,267 y = mir_touch_input_event_get_touch_axis_value(tev, p,
267 mir_touch_axis_size);268 mir_touch_input_axis_y);
268 pressure = mir_touch_event_axis_value(tev, p,269 float size = mir_touch_input_event_get_touch_axis_value(
269 mir_touch_axis_pressure);270 tev, p, mir_touch_input_axis_size);
271 pressure = mir_touch_input_event_get_touch_axis_value(tev,
272 p, mir_touch_input_axis_pressure);
270 radius = size * 50.0f + 1.0f;273 radius = size * 50.0f + 1.0f;
271 }274 }
272 else if (pev != NULL)275 else if (pev != NULL)
273 {276 {
274 x = mir_pointer_event_axis_value(pev, mir_pointer_axis_x);277 x = mir_pointer_input_event_get_axis_value(pev,
275 y = mir_pointer_event_axis_value(pev, mir_pointer_axis_y);278 mir_pointer_input_axis_x);
279 y = mir_pointer_input_event_get_axis_value(pev,
280 mir_pointer_input_axis_y);
276 pressure = 0.5f;281 pressure = 0.5f;
277 radius = 5;282 radius = 5;
278 }283 }
@@ -289,7 +294,7 @@
289 draw_box(canvas, x - radius, y - radius, 2*radius, &tone);294 draw_box(canvas, x - radius, y - radius, 2*radius, &tone);
290 }295 }
291 296
292 changed = true;297 redraw(surface, canvas);
293 }298 }
294 }299 }
295 else if (event_type == mir_event_type_close_surface)300 else if (event_type == mir_event_type_close_surface)
@@ -302,17 +307,21 @@
302 else if (closing > 1)307 else if (closing > 1)
303 {308 {
304 printf("Oh I forgot you can't save your work. Quitting now...\n");309 printf("Oh I forgot you can't save your work. Quitting now...\n");
305 running = false;310 running = 0;
306 changed = true;
307 }311 }
308 }312 }
309 else if (event_type == mir_event_type_resize)313 else if (event_type == mir_event_type_resize)
310 {314 {
311 changed = true;315 /* FIXME: https://bugs.launchpad.net/mir/+bug/1194384
316 * mir_event_type_resize will arrive in a different thread to that of
317 * mir_event_type_motion, so we cannot safely redraw from this thread.
318 * Either the callbacks will need to become thread-safe, or we'd have
319 * to employ some non-trivial event queuing and inter-thread signals,
320 * which I think is beyond the scope of this example code.
321 *
322 * redraw(surface, canvas);
323 */
312 }324 }
313
314 pthread_cond_signal(&change);
315 pthread_mutex_unlock(&mutex);
316}325}
317326
318static const MirDisplayOutput *find_active_output(327static const MirDisplayOutput *find_active_output(
@@ -344,6 +353,7 @@
344 MirConnection *conn;353 MirConnection *conn;
345 MirSurface *surf;354 MirSurface *surf;
346 MirGraphicsRegion canvas;355 MirGraphicsRegion canvas;
356 MirEventDelegate delegate = {&on_event, &canvas};
347 unsigned int f;357 unsigned int f;
348 int swap_interval = 0;358 int swap_interval = 0;
349359
@@ -390,14 +400,10 @@
390 }400 }
391 }401 }
392402
393 // We do our own resampling now. We can keep up with raw input...
394 // TODO: Replace setenv with a proper Mir function (LP: #1439590)
395 setenv("MIR_CLIENT_INPUT_RATE", "0", 0);
396
397 conn = mir_connect_sync(mir_socket, argv[0]);403 conn = mir_connect_sync(mir_socket, argv[0]);
398 if (!mir_connection_is_valid(conn))404 if (!mir_connection_is_valid(conn))
399 {405 {
400 fprintf(stderr, "Could not connect to a display server: %s\n", mir_connection_get_error_message(conn));406 fprintf(stderr, "Could not connect to a display server.\n");
401 return 1;407 return 1;
402 }408 }
403409
@@ -441,7 +447,7 @@
441 mir_display_config_destroy(display_config);447 mir_display_config_destroy(display_config);
442448
443 MirSurfaceSpec *spec = mir_connection_create_spec_for_normal_surface(conn, width, height, pixel_format);449 MirSurfaceSpec *spec = mir_connection_create_spec_for_normal_surface(conn, width, height, pixel_format);
444 mir_surface_spec_set_name(spec, "Mir Fingerpaint");450 mir_surface_spec_set_name(spec, "Paint Canvas");
445 mir_surface_spec_set_buffer_usage(spec, mir_buffer_usage_software);451 mir_surface_spec_set_buffer_usage(spec, mir_buffer_usage_software);
446452
447 surf = mir_surface_create_sync(spec);453 surf = mir_surface_create_sync(spec);
@@ -450,7 +456,7 @@
450 if (surf != NULL)456 if (surf != NULL)
451 {457 {
452 mir_surface_set_swapinterval(surf, swap_interval);458 mir_surface_set_swapinterval(surf, swap_interval);
453 mir_surface_set_event_handler(surf, &on_event, &canvas);459 mir_surface_set_event_handler(surf, &delegate);
454 460
455 canvas.width = width;461 canvas.width = width;
456 canvas.height = height;462 canvas.height = height;
@@ -465,26 +471,15 @@
465 signal(SIGHUP, shutdown);471 signal(SIGHUP, shutdown);
466 472
467 clear_region(&canvas, &background);473 clear_region(&canvas, &background);
474 redraw(surf, &canvas);
468 475
469 MirBufferStream *bs = mir_surface_get_buffer_stream(surf);
470
471 while (running)476 while (running)
472 {477 {
473 MirGraphicsRegion backbuffer;478 sleep(1); /* Is there a better way yet? */
474 mir_buffer_stream_get_graphics_region(bs, &backbuffer);
475
476 pthread_mutex_lock(&mutex);
477 while (!changed)
478 pthread_cond_wait(&change, &mutex);
479 changed = false;
480 copy_region(&backbuffer, &canvas);
481 pthread_mutex_unlock(&mutex);
482
483 mir_buffer_stream_swap_buffers_sync(bs);
484 }479 }
485480
486 /* Ensure canvas won't be used after it's freed */481 /* Ensure canvas won't be used after it's freed */
487 mir_surface_set_event_handler(surf, NULL, NULL);482 mir_surface_set_event_handler(surf, NULL);
488 free(canvas.vaddr);483 free(canvas.vaddr);
489 }484 }
490 else485 else
491486
=== removed file 'examples/mir_demo_server_loader.cpp'
--- examples/mir_demo_server_loader.cpp 2015-05-15 11:46:49 +0000
+++ examples/mir_demo_server_loader.cpp 1970-01-01 00:00:00 +0000
@@ -1,46 +0,0 @@
1/*
2 * Copyright © 2015 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: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#include <dlfcn.h>
20#include <stdexcept>
21#include <iostream>
22
23namespace
24{
25const char* const library = "libmir_demo_server_loadable.so";
26const char* const entry = "main";
27}
28
29int main(int argc, char const* argv[])
30try
31{
32 auto const so = dlopen(library, RTLD_NOW|RTLD_LOCAL);
33 if (!so) throw std::runtime_error(dlerror());
34
35 int (*loaded_main)(int, char const*[]){nullptr};
36
37 (void*&)loaded_main = dlsym(so, entry);
38 if (!loaded_main) throw std::runtime_error(dlerror());
39
40 return loaded_main(argc, argv);
41
42}
43catch(std::exception const& x)
44{
45 std::cerr << "Error:" << x.what() << std::endl;
46}
470
=== modified file 'examples/multiwin.c'
--- examples/multiwin.c 2015-05-07 09:06:20 +0000
+++ examples/multiwin.c 2015-05-20 14:01:27 +0000
@@ -21,7 +21,6 @@
21#include <signal.h>21#include <signal.h>
22#include <stdint.h>22#include <stdint.h>
23#include <getopt.h>23#include <getopt.h>
24#include <stdlib.h>
2524
26typedef struct25typedef struct
27{26{
@@ -134,18 +133,13 @@
134 MirConnection *conn;133 MirConnection *conn;
135 Window win[3];134 Window win[3];
136 unsigned int f;135 unsigned int f;
137 int alpha = 0x50;
138136
139 int arg;137 int arg;
140 opterr = 0;138 opterr = 0;
141 while ((arg = getopt (argc, argv, "hm:a:")) != -1)139 while ((arg = getopt (argc, argv, "hm:")) != -1)
142 {140 {
143 switch (arg)141 switch (arg)
144 {142 {
145 case 'a':
146 alpha = atoi(optarg);
147 break;
148
149 case 'm':143 case 'm':
150 socket_file = optarg;144 socket_file = optarg;
151 break;145 break;
@@ -156,7 +150,6 @@
156 puts(argv[0]);150 puts(argv[0]);
157 puts("Usage:");151 puts("Usage:");
158 puts(" -m <Mir server socket>");152 puts(" -m <Mir server socket>");
159 puts(" -a Alpha for surfaces");
160 puts(" -h: this help text");153 puts(" -h: this help text");
161 return -1;154 return -1;
162 }155 }
@@ -165,7 +158,7 @@
165 conn = mir_connect_sync(socket_file, argv[0]);158 conn = mir_connect_sync(socket_file, argv[0]);
166 if (!mir_connection_is_valid(conn))159 if (!mir_connection_is_valid(conn))
167 {160 {
168 fprintf(stderr, "Could not connect to a display server: %s\n", mir_connection_get_error_message(conn));161 fprintf(stderr, "Could not connect to a display server.\n");
169 return 1;162 return 1;
170 }163 }
171164
@@ -207,7 +200,7 @@
207 win[0].fill.r = 0xff;200 win[0].fill.r = 0xff;
208 win[0].fill.g = 0x00;201 win[0].fill.g = 0x00;
209 win[0].fill.b = 0x00;202 win[0].fill.b = 0x00;
210 win[0].fill.a = alpha;203 win[0].fill.a = 0x50;
211 premultiply_alpha(&win[0].fill);204 premultiply_alpha(&win[0].fill);
212205
213 mir_surface_spec_set_name(spec, "green");206 mir_surface_spec_set_name(spec, "green");
@@ -217,7 +210,7 @@
217 win[1].fill.r = 0x00;210 win[1].fill.r = 0x00;
218 win[1].fill.g = 0xff;211 win[1].fill.g = 0xff;
219 win[1].fill.b = 0x00;212 win[1].fill.b = 0x00;
220 win[1].fill.a = alpha;213 win[1].fill.a = 0x50;
221 premultiply_alpha(&win[1].fill);214 premultiply_alpha(&win[1].fill);
222215
223 mir_surface_spec_set_name(spec, "blue");216 mir_surface_spec_set_name(spec, "blue");
@@ -227,7 +220,7 @@
227 win[2].fill.r = 0x00;220 win[2].fill.r = 0x00;
228 win[2].fill.g = 0x00;221 win[2].fill.g = 0x00;
229 win[2].fill.b = 0xff;222 win[2].fill.b = 0xff;
230 win[2].fill.a = alpha;223 win[2].fill.a = 0x50;
231 premultiply_alpha(&win[2].fill);224 premultiply_alpha(&win[2].fill);
232225
233 mir_surface_spec_release(spec);226 mir_surface_spec_release(spec);
234227
=== modified file 'examples/progressbar.c'
--- examples/progressbar.c 2015-05-07 09:06:20 +0000
+++ examples/progressbar.c 2015-05-20 14:01:27 +0000
@@ -201,7 +201,7 @@
201 unsigned int const pf_size = 32;201 unsigned int const pf_size = 32;
202 MirPixelFormat formats[pf_size];202 MirPixelFormat formats[pf_size];
203 unsigned int valid_formats;203 unsigned int valid_formats;
204 int hz = 20;204 int sleep_usec = 50000;
205205
206 if (argc > 1)206 if (argc > 1)
207 {207 {
@@ -209,13 +209,13 @@
209209
210 if (sscanf(argv[1], "%d", &rate) == 1 && rate > 0)210 if (sscanf(argv[1], "%d", &rate) == 1 && rate > 0)
211 {211 {
212 hz = rate;212 sleep_usec = 1000000 / rate;
213 }213 }
214 else214 else
215 {215 {
216 fprintf(stderr, "Usage: %s [repeat rate in Hz]\n"216 fprintf(stderr, "Usage: %s [repeat rate in Hz]\n"
217 "Default repeat rate is %d\n",217 "Default repeat rate is %d\n",
218 argv[0], hz);218 argv[0], 1000000 / sleep_usec);
219219
220 return 1;220 return 1;
221 }221 }
@@ -224,7 +224,7 @@
224 conn = mir_connect_sync(NULL, argv[0]);224 conn = mir_connect_sync(NULL, argv[0]);
225 if (!mir_connection_is_valid(conn))225 if (!mir_connection_is_valid(conn))
226 {226 {
227 fprintf(stderr, "Could not connect to a display server: %s\n", mir_connection_get_error_message(conn));227 fprintf(stderr, "Could not connect to a display server.\n");
228 return 1;228 return 1;
229 }229 }
230230
@@ -259,13 +259,7 @@
259 return 1;259 return 1;
260 }260 }
261261
262 {262 mir_surface_spec_set_name(spec, "Progress Bars");
263 char name[128];
264 snprintf(name, sizeof(name)-1, "Progress Bars (%dHz)", hz);
265 name[sizeof(name)-1] = '\0';
266 mir_surface_spec_set_name(spec, name);
267 }
268
269 mir_surface_spec_set_buffer_usage(spec, mir_buffer_usage_software);263 mir_surface_spec_set_buffer_usage(spec, mir_buffer_usage_software);
270264
271 surf = mir_surface_create_sync(spec);265 surf = mir_surface_create_sync(spec);
@@ -305,7 +299,7 @@
305 draw_box(&canvas, x, y, box_width, foreground);299 draw_box(&canvas, x, y, box_width, foreground);
306300
307 redraw(surf, &canvas);301 redraw(surf, &canvas);
308 usleep(1000000 / hz);302 usleep(sleep_usec);
309 }303 }
310304
311 free(canvas.vaddr);305 free(canvas.vaddr);
312306
=== modified file 'examples/render_overlays.cpp'
--- examples/render_overlays.cpp 2015-03-31 02:35:42 +0000
+++ examples/render_overlays.cpp 2015-05-20 14:01:27 +0000
@@ -194,7 +194,7 @@
194 auto client2 = std::make_shared<DemoOverlayClient>(194 auto client2 = std::make_shared<DemoOverlayClient>(
195 *buffer_allocator, buffer_properties, 0xFFFFFF00);195 *buffer_allocator, buffer_properties, 0xFFFFFF00);
196196
197 mg::RenderableList renderlist197 std::list<std::shared_ptr<mg::Renderable>> renderlist
198 {198 {
199 std::make_shared<DemoRenderable>(client1, geom::Rectangle{{0,0} , buffer_properties.size}),199 std::make_shared<DemoRenderable>(client1, geom::Rectangle{{0,0} , buffer_properties.size}),
200 std::make_shared<DemoRenderable>(client2, geom::Rectangle{{80,80} , buffer_properties.size})200 std::make_shared<DemoRenderable>(client2, geom::Rectangle{{80,80} , buffer_properties.size})
@@ -202,16 +202,12 @@
202202
203 while (running)203 while (running)
204 {204 {
205 client1->update_green_channel();205 display->for_each_display_buffer([&](mg::DisplayBuffer& buffer)
206 client2->update_green_channel();
207 display->for_each_display_sync_group([&](mg::DisplaySyncGroup& group)
208 {206 {
209 group.for_each_display_buffer([&](mg::DisplayBuffer& buffer)207 buffer.make_current();
210 {208 client1->update_green_channel();
211 buffer.make_current();209 client2->update_green_channel();
212 buffer.post_renderables_if_optimizable(renderlist);210 buffer.post_renderables_if_optimizable(renderlist);
213 });
214 group.post();
215 });211 });
216 }212 }
217}213}
218214
=== modified file 'examples/render_surfaces.cpp'
--- examples/render_surfaces.cpp 2015-05-18 21:30:28 +0000
+++ examples/render_surfaces.cpp 2015-05-20 14:01:27 +0000
@@ -30,8 +30,6 @@
30#include "mir/options/option.h"30#include "mir/options/option.h"
31#include "mir/scene/surface.h"31#include "mir/scene/surface.h"
32#include "mir/scene/surface_coordinator.h"32#include "mir/scene/surface_coordinator.h"
33#include "mir/scene/buffer_stream_factory.h"
34#include "mir/scene/surface_factory.h"
35#include "mir/server.h"33#include "mir/server.h"
36#include "mir/report_exception.h"34#include "mir/report_exception.h"
3735
@@ -141,10 +139,10 @@
141 Moveable(std::shared_ptr<ms::Surface> const& s, const geom::Size& display_size,139 Moveable(std::shared_ptr<ms::Surface> const& s, const geom::Size& display_size,
142 float dx, float dy, const glm::vec3& rotation_axis, float alpha_offset)140 float dx, float dy, const glm::vec3& rotation_axis, float alpha_offset)
143 : surface(s), display_size(display_size),141 : surface(s), display_size(display_size),
144 x{s->top_left().x.as_float()},142 x{static_cast<float>(s->top_left().x.as_uint32_t())},
145 y{s->top_left().y.as_float()},143 y{static_cast<float>(s->top_left().y.as_uint32_t())},
146 w{s->size().width.as_float()},144 w{static_cast<float>(s->size().width.as_uint32_t())},
147 h{s->size().height.as_float()},145 h{static_cast<float>(s->size().height.as_uint32_t())},
148 dx{dx},146 dx{dx},
149 dy{dy},147 dy{dy},
150 rotation_axis(rotation_axis),148 rotation_axis(rotation_axis),
@@ -251,6 +249,7 @@
251 stop_watch.restart();249 stop_watch.restart();
252 }250 }
253251
252 glClearColor(0.0, 1.0, 0.0, 1.0);
254 db_compositor->composite(std::move(scene_sequence));253 db_compositor->composite(std::move(scene_sequence));
255254
256 for (auto& m : moveables)255 for (auto& m : moveables)
@@ -333,19 +332,14 @@
333 std::cout << "Rendering " << moveables.size() << " surfaces" << std::endl;332 std::cout << "Rendering " << moveables.size() << " surfaces" << std::endl;
334333
335 auto const display = the_display();334 auto const display = the_display();
336 auto const buffer_stream_factory = the_buffer_stream_factory();
337 auto const surface_factory = the_surface_factory();
338 auto const surface_coordinator = the_surface_coordinator();335 auto const surface_coordinator = the_surface_coordinator();
339 auto const gl_context = the_display()->create_gl_context();336 auto const gl_context = the_display()->create_gl_context();
340337
341 /* TODO: Get proper configuration */338 /* TODO: Get proper configuration */
342 geom::Rectangles view_area;339 geom::Rectangles view_area;
343 display->for_each_display_sync_group([&](mg::DisplaySyncGroup& group)340 display->for_each_display_buffer([&view_area](mg::DisplayBuffer const& db)
344 {341 {
345 group.for_each_display_buffer([&](mg::DisplayBuffer& db)342 view_area.add(db.view_area());
346 {
347 view_area.add(db.view_area());
348 });
349 });343 });
350 geom::Size const display_size{view_area.bounding_rectangle().size};344 geom::Size const display_size{view_area.bounding_rectangle().size};
351 uint32_t const surface_side{300};345 uint32_t const surface_side{300};
@@ -359,19 +353,16 @@
359 int i = 0;353 int i = 0;
360 for (auto& m : moveables)354 for (auto& m : moveables)
361 {355 {
362 auto params = ms::a_surface()356 auto const s = surface_coordinator->add_surface(
363 .of_size(surface_size)357 ms::a_surface().of_size(surface_size)
364 .of_pixel_format(surface_pf)358 .of_pixel_format(surface_pf)
365 .of_buffer_usage(mg::BufferUsage::hardware);359 .of_buffer_usage(mg::BufferUsage::hardware),
366 mg::BufferProperties properties{params.size, params.pixel_format, params.buffer_usage};360 nullptr);
367 auto const stream = buffer_stream_factory->create_buffer_stream(properties);
368 auto const surface = surface_factory->create_surface(stream, params);
369 surface_coordinator->add_surface(surface, params.depth, params.input_mode, nullptr);
370361
371 {362 {
372 mg::Buffer* buffer{nullptr};363 mg::Buffer* buffer{nullptr};
373 auto const complete = [&](mg::Buffer* new_buf){ buffer = new_buf; };364 auto const complete = [&](mg::Buffer* new_buf){ buffer = new_buf; };
374 surface->primary_buffer_stream()->swap_buffers(buffer, complete); // Fetch buffer for rendering365 s->swap_buffers(buffer, complete); // Fetch buffer for rendering
375 {366 {
376 gl_context->make_current();367 gl_context->make_current();
377368
@@ -384,7 +375,7 @@
384375
385 gl_context->release_current();376 gl_context->release_current();
386 }377 }
387 surface->primary_buffer_stream()->swap_buffers(buffer, complete); // Post rendered buffer378 s->swap_buffers(buffer, complete); // Post rendered buffer
388 }379 }
389380
390 /*381 /*
@@ -394,8 +385,8 @@
394 uint32_t const x = w * (0.5 + 0.25 * cos(i * angular_step)) - surface_side / 2.0;385 uint32_t const x = w * (0.5 + 0.25 * cos(i * angular_step)) - surface_side / 2.0;
395 uint32_t const y = h * (0.5 + 0.25 * sin(i * angular_step)) - surface_side / 2.0;386 uint32_t const y = h * (0.5 + 0.25 * sin(i * angular_step)) - surface_side / 2.0;
396387
397 surface->move_to({x, y});388 s->move_to({x, y});
398 m = Moveable(surface, display_size,389 m = Moveable(s, display_size,
399 cos(0.1f + i * M_PI / 6.0f) * w / 3.0f,390 cos(0.1f + i * M_PI / 6.0f) * w / 3.0f,
400 sin(0.1f + i * M_PI / 6.0f) * h / 3.0f,391 sin(0.1f + i * M_PI / 6.0f) * h / 3.0f,
401 glm::vec3{(i % 3 == 0) * 1.0f, (i % 3 == 1) * 1.0f, (i % 3 == 2) * 1.0f},392 glm::vec3{(i % 3 == 0) * 1.0f, (i % 3 == 1) * 1.0f, (i % 3 == 2) * 1.0f},
402393
=== modified file 'examples/render_to_fb.cpp'
--- examples/render_to_fb.cpp 2015-03-31 02:35:42 +0000
+++ examples/render_to_fb.cpp 2015-05-20 14:01:27 +0000
@@ -53,26 +53,22 @@
5353
54 mir::draw::glAnimationBasic gl_animation;54 mir::draw::glAnimationBasic gl_animation;
5555
56 display->for_each_display_sync_group([&](mg::DisplaySyncGroup& group)56 display->for_each_display_buffer([&](mg::DisplayBuffer& buffer)
57 {57 {
58 group.for_each_display_buffer([&](mg::DisplayBuffer& buffer)58 buffer.make_current();
59 {59 gl_animation.init_gl();
60 buffer.make_current();
61 gl_animation.init_gl();
62 });
63 });60 });
6461
65 while (running)62 while (running)
66 {63 {
67 display->for_each_display_sync_group([&](mg::DisplaySyncGroup& group)64 display->for_each_display_buffer([&](mg::DisplayBuffer& buffer)
68 {65 {
69 group.for_each_display_buffer([&](mg::DisplayBuffer& buffer)66 buffer.make_current();
70 {67
71 buffer.make_current();68 gl_animation.render_gl();
72 gl_animation.render_gl();69
73 buffer.gl_swap_buffers();70 buffer.gl_swap_buffers();
74 });71 buffer.flip();
75 group.post();
76 });72 });
7773
78 gl_animation.step();74 gl_animation.step();
7975
=== modified file 'examples/server_example.cpp'
--- examples/server_example.cpp 2015-05-07 09:06:20 +0000
+++ examples/server_example.cpp 2015-05-20 14:01:27 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012-2015 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * 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 as5 * it under the terms of the GNU General Public License version 3 as
@@ -22,7 +22,6 @@
22#include "server_example_display_configuration_policy.h"22#include "server_example_display_configuration_policy.h"
23#include "server_example_host_lifecycle_event_listener.h"23#include "server_example_host_lifecycle_event_listener.h"
24#include "server_example_window_management.h"24#include "server_example_window_management.h"
25#include "server_example_custom_compositor.h"
26#include "server_example_test_client.h"25#include "server_example_test_client.h"
2726
28#include "mir/server.h"27#include "mir/server.h"
@@ -65,13 +64,14 @@
6564
66 server.add_configuration_option(timeout_opt, timeout_descr, mir::OptionType::integer);65 server.add_configuration_option(timeout_opt, timeout_descr, mir::OptionType::integer);
6766
68 server.add_init_callback([&server]67 server.add_init_callback([&]
69 {68 {
70 const auto options = server.get_options();69 const auto options = server.get_options();
71 if (options->is_set(timeout_opt))70 if (options->is_set(timeout_opt))
72 {71 {
73 static auto const exit_action = server.the_main_loop()->create_alarm([&server] { server.stop(); });72 static auto const exit_action = server.the_main_loop()->notify_in(
74 exit_action->reschedule_in(std::chrono::seconds(options->get<int>(timeout_opt)));73 std::chrono::seconds(options->get<int>(timeout_opt)),
74 [&] { server.stop(); });
75 }75 }
76 });76 });
77}77}
@@ -82,15 +82,11 @@
82{82{
83 mir::Server server;83 mir::Server server;
8484
85 // Use config options file in e.g. ~/.config/mir/mir_demo_server.config
86 server.set_config_filename("mir/mir_demo_server.config");
87
88 // Add example options for display layout, logging, launching clients and timeout85 // Add example options for display layout, logging, launching clients and timeout
89 me::add_display_configuration_options_to(server);86 me::add_display_configuration_options_to(server);
90 me::add_log_host_lifecycle_option_to(server);87 me::add_log_host_lifecycle_option_to(server);
91 me::add_glog_options_to(server);88 me::add_glog_options_to(server);
92 me::add_window_manager_option_to(server);89 me::add_window_manager_option_to(server);
93 me::add_custom_compositor_option_to(server);
94 add_launcher_option_to(server);90 add_launcher_option_to(server);
95 add_timeout_option_to(server);91 add_timeout_option_to(server);
9692
9793
=== removed file 'examples/server_example_adorning_compositor.cpp'
--- examples/server_example_adorning_compositor.cpp 2015-04-07 13:19:22 +0000
+++ examples/server_example_adorning_compositor.cpp 1970-01-01 00:00:00 +0000
@@ -1,163 +0,0 @@
1/*
2 * Copyright © 2015 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "server_example_adorning_compositor.h"
20#include "mir/graphics/display_buffer.h"
21#include "mir/graphics/buffer.h"
22#include "mir/compositor/scene_element.h"
23#include <GLES2/gl2.h>
24
25namespace me = mir::examples;
26namespace mg = mir::graphics;
27namespace mc = mir::compositor;
28
29bool make_current(mg::DisplayBuffer& db)
30{
31 db.make_current();
32 return true;
33}
34
35me::AdorningDisplayBufferCompositor::Shader::Shader(GLchar const* const* src, GLuint type) :
36 shader(glCreateShader(type))
37{
38 glShaderSource(shader, 1, src, 0);
39 glCompileShader(shader);
40}
41
42me::AdorningDisplayBufferCompositor::Shader::~Shader()
43{
44 glDeleteShader(shader);
45}
46
47me::AdorningDisplayBufferCompositor::Program::Program(Shader& vertex, Shader& fragment) :
48 program(glCreateProgram())
49{
50 glAttachShader(program, vertex.shader);
51 glAttachShader(program, fragment.shader);
52 glLinkProgram(program);
53}
54
55me::AdorningDisplayBufferCompositor::Program::~Program()
56{
57 glDeleteProgram(program);
58}
59
60me::AdorningDisplayBufferCompositor::AdorningDisplayBufferCompositor(
61 mg::DisplayBuffer& display_buffer,
62 std::tuple<float, float, float> const& background_rgb) :
63 db{display_buffer},
64 vert_shader_src{
65 "attribute vec4 vPosition;"
66 "uniform vec2 pos;"
67 "uniform vec2 scale;"
68 "attribute vec2 uvCoord;"
69 "varying vec2 texcoord;"
70 "void main() {"
71 " gl_Position = vec4(vPosition.xy * scale + pos, 0.0, 1.0);"
72 " texcoord = uvCoord.xy;"
73 "}"
74 },
75 frag_shader_src{
76 "precision mediump float;"
77 "varying vec2 texcoord;"
78 "uniform sampler2D tex;"
79 "uniform float alpha;"
80 "void main() {"
81 " gl_FragColor = texture2D(tex, texcoord) * alpha;"
82 "}"
83 },
84 current(make_current(db)),
85 vertex(&vert_shader_src, GL_VERTEX_SHADER),
86 fragment(&frag_shader_src, GL_FRAGMENT_SHADER),
87 program(vertex, fragment)
88{
89 glUseProgram(program.program);
90 vPositionAttr = glGetAttribLocation(program.program, "vPosition");
91 glVertexAttribPointer(vPositionAttr, 4, GL_FLOAT, GL_FALSE, 0, vertex_data);
92 uvCoord = glGetAttribLocation(program.program, "uvCoord");
93 glVertexAttribPointer(uvCoord, 2, GL_FLOAT, GL_FALSE, 0, uv_data);
94 posUniform = glGetUniformLocation(program.program, "pos");
95 glClearColor(std::get<0>(background_rgb), std::get<1>(background_rgb), std::get<2>(background_rgb), 1.0);
96 scaleUniform = glGetUniformLocation(program.program, "scale");
97 alphaUniform = glGetUniformLocation(program.program, "alpha");
98
99 glGenTextures(1, &texture);
100 glBindTexture(GL_TEXTURE_2D, texture);
101 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
102 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
103 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
104 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
105 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
106}
107
108void me::AdorningDisplayBufferCompositor::composite(compositor::SceneElementSequence&& scene_sequence)
109{
110 //note: If what should be drawn is expressible as a SceneElementSequence,
111 // mg::DisplayBuffer::post_renderables_if_optimizable() should be used,
112 // to give the the display hardware a chance at an optimized render of
113 // the scene. In this example though, we want some custom elements, so
114 // we'll always use GLES.
115 db.make_current();
116
117 auto display_width = db.view_area().size.width.as_float();
118 auto display_height = db.view_area().size.height.as_float();
119
120 glUseProgram(program.program);
121 glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
122
123 for(auto& element : scene_sequence)
124 {
125 //courteously inform the client that its rendered
126 //if something is not to be rendered, mc::SceneElementSequence::occluded() should be called
127 element->rendered();
128
129 auto const renderable = element->renderable();
130 float width = renderable->screen_position().size.width.as_float();
131 float height = renderable->screen_position().size.height.as_float();
132 float x = renderable->screen_position().top_left.x.as_float() - db.view_area().top_left.x.as_float();
133 float y = renderable->screen_position().top_left.y.as_float() - db.view_area().top_left.y.as_float();
134 float scale[2] {
135 width/display_width * 2,
136 height/display_height * -2};
137 float position[2] {
138 (x / display_width * 2.0f) - 1.0f,
139 1.0f - (y / display_height * 2.0f)
140 };
141 float const plane_alpha = renderable->alpha();
142 if (renderable->shaped() || plane_alpha < 1.0)
143 glEnable(GL_BLEND);
144 else
145 glDisable(GL_BLEND);
146
147 glUniform2fv(posUniform, 1, position);
148 glUniform2fv(scaleUniform, 1, scale);
149 glUniform1fv(alphaUniform, 1, &plane_alpha);
150
151 glActiveTexture(GL_TEXTURE0);
152 glBindTexture(GL_TEXTURE_2D, texture);
153 renderable->buffer()->gl_bind_to_texture();
154
155 glEnableVertexAttribArray(vPositionAttr);
156 glEnableVertexAttribArray(uvCoord);
157 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
158 glDisableVertexAttribArray(uvCoord);
159 glDisableVertexAttribArray(vPositionAttr);
160 }
161
162 db.gl_swap_buffers();
163}
1640
=== removed file 'examples/server_example_adorning_compositor.h'
--- examples/server_example_adorning_compositor.h 2015-04-07 12:43:16 +0000
+++ examples/server_example_adorning_compositor.h 1970-01-01 00:00:00 +0000
@@ -1,82 +0,0 @@
1/*
2 * Copyright © 2015 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_EXAMPLES_ADORNING_COMPOSITOR_H_
20#define MIR_EXAMPLES_ADORNING_COMPOSITOR_H_
21#include "mir/compositor/display_buffer_compositor.h"
22#include <GLES2/gl2.h>
23#include <tuple>
24
25namespace mir
26{
27namespace graphics
28{
29class DisplayBuffer;
30}
31namespace examples
32{
33class AdorningDisplayBufferCompositor : public compositor::DisplayBufferCompositor
34{
35public:
36 AdorningDisplayBufferCompositor(graphics::DisplayBuffer&, std::tuple<float, float, float> const& background_rgb);
37 void composite(compositor::SceneElementSequence&& scene_sequence) override;
38private:
39 graphics::DisplayBuffer& db;
40 GLchar const*const vert_shader_src;
41 GLchar const*const frag_shader_src;
42 bool current;
43 struct Shader
44 {
45 Shader(GLchar const* const* src, GLuint type);
46 ~Shader();
47 GLuint shader;
48 } vertex, fragment;
49 struct Program
50 {
51 Program(Shader& vertex, Shader& fragment);
52 ~Program();
53 GLuint program;
54 } program;
55
56 GLfloat vertex_data[16]
57 {
58 0.0f, 0.0f, 0.0f, 1.0f,
59 0.0f, 1.0f, 0.0f, 1.0f,
60 1.0f, 0.0f, 0.0f, 1.0f,
61 1.0f, 1.0f, 0.0f, 1.0f,
62 };
63 GLfloat uv_data[8]
64 {
65 0.0f, 0.0f,
66 0.0f, 1.0f,
67 1.0f, 0.0f,
68 1.0f, 1.0f,
69
70 };
71
72 GLuint vPositionAttr;
73 GLuint uvCoord;
74 GLuint scaleUniform;
75 GLuint posUniform;
76 GLuint alphaUniform;
77 GLuint texture;
78};
79}
80}
81
82#endif /* MIR_EXAMPLES_ADORNING_COMPOSITOR_H_ */
830
=== modified file 'examples/server_example_basic_window_manager.h'
--- examples/server_example_basic_window_manager.h 2015-05-07 09:06:20 +0000
+++ examples/server_example_basic_window_manager.h 2015-05-20 14:01:27 +0000
@@ -19,12 +19,11 @@
19#ifndef MIR_EXAMPLE_BASIC_WINDOW_MANAGER_H_19#ifndef MIR_EXAMPLE_BASIC_WINDOW_MANAGER_H_
20#define MIR_EXAMPLE_BASIC_WINDOW_MANAGER_H_20#define MIR_EXAMPLE_BASIC_WINDOW_MANAGER_H_
2121
22#include "server_example_generic_shell.h"
23
22#include "mir/geometry/rectangles.h"24#include "mir/geometry/rectangles.h"
23#include "mir/scene/session.h"25#include "mir/scene/session.h"
24#include "mir/scene/surface.h"
25#include "mir/scene/surface_creation_parameters.h"26#include "mir/scene/surface_creation_parameters.h"
26#include "mir/shell/abstract_shell.h"
27#include "mir/shell/window_manager.h"
2827
29#include <map>28#include <map>
30#include <mutex>29#include <mutex>
@@ -36,8 +35,6 @@
36{35{
37namespace examples36namespace examples
38{37{
39using shell::SurfaceSet;
40
41template<typename Info>38template<typename Info>
42struct SurfaceTo39struct SurfaceTo
43{40{
@@ -53,9 +50,8 @@
53/// The interface through which the policy instructs the controller.50/// The interface through which the policy instructs the controller.
54/// These functions assume that the BasicWindowManager data structures can be accessed freely.51/// These functions assume that the BasicWindowManager data structures can be accessed freely.
55/// I.e. should only be invoked by the policy handle_... methods (where any necessary locks are held).52/// I.e. should only be invoked by the policy handle_... methods (where any necessary locks are held).
56// TODO extract commonality with FocusController (once that's separated from shell::FocusController)
57template<typename SessionInfo, typename SurfaceInfo>53template<typename SessionInfo, typename SurfaceInfo>
58class BasicWindowManagerToolsCopy54class BasicWindowManagerTools
59{55{
60public:56public:
61 virtual auto find_session(std::function<bool(SessionInfo const& info)> const& predicate)57 virtual auto find_session(std::function<bool(SessionInfo const& info)> const& predicate)
@@ -65,26 +61,16 @@
6561
66 virtual auto info_for(std::weak_ptr<scene::Surface> const& surface) const -> SurfaceInfo& = 0;62 virtual auto info_for(std::weak_ptr<scene::Surface> const& surface) const -> SurfaceInfo& = 0;
6763
68 virtual std::shared_ptr<scene::Session> focused_session() const = 0;64 virtual std::weak_ptr<scene::Session> focussed_application() const = 0;
6965
70 virtual std::shared_ptr<scene::Surface> focused_surface() const = 0;66 virtual void focus_next() = 0;
7167
72 virtual void focus_next_session() = 0;68 virtual void set_focus_to(std::shared_ptr<scene::Session> const& focus) = 0;
7369
74 virtual void set_focus_to(70 virtual ~BasicWindowManagerTools() = default;
75 std::shared_ptr<scene::Session> const& focus,71 BasicWindowManagerTools() = default;
76 std::shared_ptr<scene::Surface> const& surface) = 0;72 BasicWindowManagerTools(BasicWindowManagerTools const&) = delete;
7773 BasicWindowManagerTools& operator=(BasicWindowManagerTools const&) = delete;
78 virtual auto surface_at(geometry::Point cursor) const -> std::shared_ptr<scene::Surface> = 0;
79
80 virtual void raise(SurfaceSet const& surfaces) = 0;
81
82 virtual auto active_display() -> geometry::Rectangle const = 0;
83
84 virtual ~BasicWindowManagerToolsCopy() = default;
85 BasicWindowManagerToolsCopy() = default;
86 BasicWindowManagerToolsCopy(BasicWindowManagerToolsCopy const&) = delete;
87 BasicWindowManagerToolsCopy& operator=(BasicWindowManagerToolsCopy const&) = delete;
88};74};
8975
90/// A policy based window manager.76/// A policy based window manager.
@@ -100,20 +86,20 @@
100/// - void handle_new_surface(std::shared_ptr<ms::Session> const& session, std::shared_ptr<ms::Surface> const& surface);86/// - void handle_new_surface(std::shared_ptr<ms::Session> const& session, std::shared_ptr<ms::Surface> const& surface);
101/// - void handle_delete_surface(std::shared_ptr<ms::Session> const& /*session*/, std::weak_ptr<ms::Surface> const& /*surface*/);87/// - void handle_delete_surface(std::shared_ptr<ms::Session> const& /*session*/, std::weak_ptr<ms::Surface> const& /*surface*/);
102/// - int handle_set_state(std::shared_ptr<ms::Surface> const& surface, MirSurfaceState value);88/// - int handle_set_state(std::shared_ptr<ms::Surface> const& surface, MirSurfaceState value);
103/// - bool handle_keyboard_event(MirKeyboardEvent const* event);89/// - bool handle_key_event(MirKeyInputEvent const* event);
104/// - bool handle_touch_event(MirTouchEvent const* event);90/// - bool handle_touch_event(MirTouchInputEvent const* event);
105/// - bool handle_pointer_event(MirPointerEvent const* event);91/// - bool handle_pointer_event(MirPointerInputEvent const* event);
106///92///
107/// \tparam SessionInfo must be default constructable.93/// \tparam SessionInfo must be default constructable.
108///94///
109/// \tparam SurfaceInfo must be constructable from (std::shared_ptr<ms::Session>, std::shared_ptr<ms::Surface>, ms::SurfaceCreationParameters const& params)95/// \tparam SurfaceInfo must be constructable from (std::shared_ptr<ms::Session>, std::shared_ptr<ms::Surface>)
110template<typename WindowManagementPolicy, typename SessionInfo, typename SurfaceInfo>96template<typename WindowManagementPolicy, typename SessionInfo, typename SurfaceInfo>
111class BasicWindowManagerCopy : public shell::WindowManager,97class BasicWindowManager : public WindowManager,
112 private BasicWindowManagerToolsCopy<SessionInfo, SurfaceInfo>98 private BasicWindowManagerTools<SessionInfo, SurfaceInfo>
113{99{
114public:100public:
115 template <typename... PolicyArgs>101 template <typename... PolicyArgs>
116 BasicWindowManagerCopy(102 BasicWindowManager(
117 shell::FocusController* focus_controller,103 shell::FocusController* focus_controller,
118 PolicyArgs&&... policy_args) :104 PolicyArgs&&... policy_args) :
119 focus_controller(focus_controller),105 focus_controller(focus_controller),
@@ -145,24 +131,14 @@
145 scene::SurfaceCreationParameters const placed_params = policy.handle_place_new_surface(session, params);131 scene::SurfaceCreationParameters const placed_params = policy.handle_place_new_surface(session, params);
146 auto const result = build(session, placed_params);132 auto const result = build(session, placed_params);
147 auto const surface = session->surface(result);133 auto const surface = session->surface(result);
148 surface_info.emplace(surface, SurfaceInfo{session, surface, placed_params});
149 policy.handle_new_surface(session, surface);134 policy.handle_new_surface(session, surface);
150 policy.generate_decorations_for(session, surface, surface_info);135 surface_info.emplace(surface, SurfaceInfo{session, surface});
151 return result;136 return result;
152 }137 }
153138
154 void modify_surface(
155 std::shared_ptr<scene::Session> const& session,
156 std::shared_ptr<scene::Surface> const& surface,
157 shell::SurfaceSpecification const& modifications) override
158 {
159 std::lock_guard<decltype(mutex)> lock(mutex);
160 policy.handle_modify_surface(session, surface, modifications);
161 }
162
163 void remove_surface(139 void remove_surface(
164 std::shared_ptr<scene::Session> const& session,140 std::weak_ptr<scene::Surface> const& surface,
165 std::weak_ptr<scene::Surface> const& surface) override141 std::shared_ptr<scene::Session> const& session) override
166 {142 {
167 std::lock_guard<decltype(mutex)> lock(mutex);143 std::lock_guard<decltype(mutex)> lock(mutex);
168 policy.handle_delete_surface(session, surface);144 policy.handle_delete_surface(session, surface);
@@ -184,46 +160,28 @@
184 policy.handle_displays_updated(session_info, displays);160 policy.handle_displays_updated(session_info, displays);
185 }161 }
186162
187 bool handle_keyboard_event(MirKeyboardEvent const* event) override163 bool handle_key_event(MirKeyInputEvent const* event) override
188 {164 {
189 std::lock_guard<decltype(mutex)> lock(mutex);165 std::lock_guard<decltype(mutex)> lock(mutex);
190 return policy.handle_keyboard_event(event);166 return policy.handle_key_event(event);
191 }167 }
192168
193 bool handle_touch_event(MirTouchEvent const* event) override169 bool handle_touch_event(MirTouchInputEvent const* event) override
194 {170 {
195 std::lock_guard<decltype(mutex)> lock(mutex);171 std::lock_guard<decltype(mutex)> lock(mutex);
196 return policy.handle_touch_event(event);172 return policy.handle_touch_event(event);
197 }173 }
198174
199 bool handle_pointer_event(MirPointerEvent const* event) override175 bool handle_pointer_event(MirPointerInputEvent const* event) override
200 {176 {
201 std::lock_guard<decltype(mutex)> lock(mutex);177 std::lock_guard<decltype(mutex)> lock(mutex);
202
203 cursor = {
204 mir_pointer_event_axis_value(event, mir_pointer_axis_x),
205 mir_pointer_event_axis_value(event, mir_pointer_axis_y)};
206
207 return policy.handle_pointer_event(event);178 return policy.handle_pointer_event(event);
208 }179 }
209180
210 int set_surface_attribute(181 int handle_set_state(std::shared_ptr<scene::Surface> const& surface, MirSurfaceState value) override
211 std::shared_ptr<scene::Session> const& /*session*/,
212 std::shared_ptr<scene::Surface> const& surface,
213 MirSurfaceAttrib attrib,
214 int value) override
215 {182 {
216 std::lock_guard<decltype(mutex)> lock(mutex);183 std::lock_guard<decltype(mutex)> lock(mutex);
217 switch (attrib)184 return policy.handle_set_state(surface, value);
218 {
219 case mir_surface_attrib_state:
220 {
221 auto const state = policy.handle_set_state(surface, MirSurfaceState(value));
222 return surface->configure(attrib, state);
223 }
224 default:
225 return surface->configure(attrib, value);
226 }
227 }185 }
228186
229 auto find_session(std::function<bool(SessionInfo const& info)> const& predicate)187 auto find_session(std::function<bool(SessionInfo const& info)> const& predicate)
@@ -250,83 +208,19 @@
250 return const_cast<SurfaceInfo&>(surface_info.at(surface));208 return const_cast<SurfaceInfo&>(surface_info.at(surface));
251 }209 }
252210
253 std::shared_ptr<scene::Session> focused_session() const override211 std::weak_ptr<scene::Session> focussed_application() const override
254 {212 {
255 return focus_controller->focused_session();213 return focus_controller->focussed_application();
256 }214 }
257215
258 std::shared_ptr<scene::Surface> focused_surface() const override216 void focus_next() override
259 {217 {
260 return focus_controller->focused_surface();218 focus_controller->focus_next();
261 }219 }
262220
263 void focus_next_session() override221 void set_focus_to(std::shared_ptr<scene::Session> const& focus) override
264 {222 {
265 focus_controller->focus_next_session();223 focus_controller->set_focus_to(focus);
266 }
267
268 void set_focus_to(
269 std::shared_ptr<scene::Session> const& focus,
270 std::shared_ptr<scene::Surface> const& surface) override
271 {
272 focus_controller->set_focus_to(focus, surface);
273 }
274
275 auto surface_at(geometry::Point cursor) const -> std::shared_ptr<scene::Surface> override
276 {
277 return focus_controller->surface_at(cursor);
278 }
279
280 void raise(SurfaceSet const& surfaces) override
281 {
282 focus_controller->raise(surfaces);
283 }
284
285 auto active_display() -> geometry::Rectangle const override
286 {
287 geometry::Rectangle result;
288
289 // 1. If a window has input focus, whichever display contains the largest
290 // proportion of the area of that window.
291 if (auto const surface = focused_surface())
292 {
293 auto const surface_rect = surface->input_bounds();
294 int max_overlap_area = -1;
295
296 for (auto const& display : displays)
297 {
298 auto const intersection = surface_rect.intersection_with(display).size;
299 if (intersection.width.as_int()*intersection.height.as_int() > max_overlap_area)
300 {
301 max_overlap_area = intersection.width.as_int()*intersection.height.as_int();
302 result = display;
303 }
304 }
305 return result;
306 }
307
308 // 2. Otherwise, if any window previously had input focus, for the window that had
309 // it most recently, the display that contained the largest proportion of the
310 // area of that window at the moment it closed, as long as that display is still
311 // available.
312
313 // 3. Otherwise, the display that contains the pointer, if there is one.
314 for (auto const& display : displays)
315 {
316 if (display.contains(cursor))
317 {
318 // Ignore the (unspecified) possiblity of overlapping displays
319 return display;
320 }
321 }
322
323 // 4. Otherwise, the primary display, if there is one (for example, the laptop display).
324
325 // 5. Otherwise, the first display.
326 if (displays.size())
327 result = *displays.begin();
328
329 return result;
330 }224 }
331225
332 shell::FocusController* const focus_controller;226 shell::FocusController* const focus_controller;
@@ -336,7 +230,6 @@
336 typename SessionTo<SessionInfo>::type session_info;230 typename SessionTo<SessionInfo>::type session_info;
337 typename SurfaceTo<SurfaceInfo>::type surface_info;231 typename SurfaceTo<SurfaceInfo>::type surface_info;
338 geometry::Rectangles displays;232 geometry::Rectangles displays;
339 geometry::Point cursor;
340};233};
341}234}
342}235}
343236
=== removed file 'examples/server_example_canonical_window_manager.cpp'
--- examples/server_example_canonical_window_manager.cpp 2015-05-19 21:42:19 +0000
+++ examples/server_example_canonical_window_manager.cpp 1970-01-01 00:00:00 +0000
@@ -1,948 +0,0 @@
1/*
2 * Copyright © 2015 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#include "server_example_canonical_window_manager.h"
20
21#include "mir/scene/surface.h"
22#include "mir/scene/null_surface_observer.h"
23#include "mir/shell/display_layout.h"
24#include "mir/shell/surface_specification.h"
25#include "mir/shell/surface_ready_observer.h"
26#include "mir/geometry/displacement.h"
27
28#include "mir/graphics/buffer.h"
29
30#include <linux/input.h>
31#include <csignal>
32#include <mutex>
33#include <condition_variable>
34#include <algorithm>
35
36namespace me = mir::examples;
37namespace ms = mir::scene;
38using namespace mir::geometry;
39
40///\example server_example_canonical_window_manager.cpp
41// Based on "Mir and Unity: Surfaces, input, and displays (v0.3)"
42
43namespace
44{
45int const title_bar_height = 10;
46Size titlebar_size_for_window(Size window_size)
47{
48 return {window_size.width, Height{title_bar_height}};
49}
50
51Point titlebar_position_for_window(Point window_position)
52{
53 return {
54 window_position.x,
55 window_position.y - DeltaY(title_bar_height)
56 };
57}
58}
59
60me::CanonicalSurfaceInfoCopy::CanonicalSurfaceInfoCopy(
61 std::shared_ptr<scene::Session> const& session,
62 std::shared_ptr<scene::Surface> const& surface,
63 scene::SurfaceCreationParameters const& params) :
64 state{mir_surface_state_restored},
65 restore_rect{surface->top_left(), surface->size()},
66 session{session},
67 parent{params.parent},
68 min_width{params.min_width},
69 min_height{params.min_height},
70 max_width{params.max_width},
71 max_height{params.max_height},
72 width_inc{params.width_inc},
73 height_inc{params.height_inc},
74 min_aspect{params.min_aspect},
75 max_aspect{params.max_aspect}
76{
77}
78
79me::CanonicalWindowManagerPolicyCopy::CanonicalWindowManagerPolicyCopy(
80 Tools* const tools,
81 std::shared_ptr<shell::DisplayLayout> const& display_layout) :
82 tools{tools},
83 display_layout{display_layout}
84{
85}
86
87void me::CanonicalWindowManagerPolicyCopy::click(Point cursor)
88{
89 if (auto const surface = tools->surface_at(cursor))
90 select_active_surface(surface);
91
92 old_cursor = cursor;
93}
94
95void me::CanonicalWindowManagerPolicyCopy::handle_session_info_updated(CanonicalSessionInfoMap& /*session_info*/, Rectangles const& /*displays*/)
96{
97}
98
99void me::CanonicalWindowManagerPolicyCopy::handle_displays_updated(CanonicalSessionInfoMap& /*session_info*/, Rectangles const& displays)
100{
101 display_area = displays.bounding_rectangle();
102}
103
104void me::CanonicalWindowManagerPolicyCopy::resize(Point cursor)
105{
106 select_active_surface(tools->surface_at(old_cursor));
107 resize(active_surface(), cursor, old_cursor, display_area);
108 old_cursor = cursor;
109}
110
111auto me::CanonicalWindowManagerPolicyCopy::handle_place_new_surface(
112 std::shared_ptr<ms::Session> const& session,
113 ms::SurfaceCreationParameters const& request_parameters)
114-> ms::SurfaceCreationParameters
115{
116 auto parameters = request_parameters;
117 parameters.size.height = parameters.size.height + DeltaY{title_bar_height};
118
119 auto const active_display = tools->active_display();
120
121 auto const width = parameters.size.width.as_int();
122 auto const height = parameters.size.height.as_int();
123
124 bool positioned = false;
125
126 auto const parent = parameters.parent.lock();
127
128 if (parameters.output_id != mir::graphics::DisplayConfigurationOutputId{0})
129 {
130 Rectangle rect{parameters.top_left, parameters.size};
131 display_layout->place_in_output(parameters.output_id, rect);
132 parameters.top_left = rect.top_left;
133 parameters.size = rect.size;
134 parameters.state = mir_surface_state_fullscreen;
135 positioned = true;
136 }
137 else if (!parent) // No parent => client can't suggest positioning
138 {
139 if (auto const default_surface = session->default_surface())
140 {
141 static Displacement const offset{title_bar_height, title_bar_height};
142
143 parameters.top_left = default_surface->top_left() + offset;
144
145 geometry::Rectangle display_for_app{default_surface->top_left(), default_surface->size()};
146
147 display_layout->size_to_output(display_for_app);
148
149 positioned = display_for_app.overlaps(Rectangle{parameters.top_left, parameters.size});
150 }
151 }
152
153 if (parent && parameters.aux_rect.is_set() && parameters.edge_attachment.is_set())
154 {
155 auto const edge_attachment = parameters.edge_attachment.value();
156 auto const aux_rect = parameters.aux_rect.value();
157 auto const parent_top_left = parent->top_left();
158 auto const top_left = aux_rect.top_left -Point{} + parent_top_left;
159 auto const top_right= aux_rect.top_right() -Point{} + parent_top_left;
160 auto const bot_left = aux_rect.bottom_left()-Point{} + parent_top_left;
161
162 if (edge_attachment && mir_edge_attachment_vertical)
163 {
164 if (active_display.contains(top_right + Displacement{width, height}))
165 {
166 parameters.top_left = top_right;
167 positioned = true;
168 }
169 else if (active_display.contains(top_left + Displacement{-width, height}))
170 {
171 parameters.top_left = top_left + Displacement{-width, 0};
172 positioned = true;
173 }
174 }
175
176 if (edge_attachment && mir_edge_attachment_horizontal)
177 {
178 if (active_display.contains(bot_left + Displacement{width, height}))
179 {
180 parameters.top_left = bot_left;
181 positioned = true;
182 }
183 else if (active_display.contains(top_left + Displacement{width, -height}))
184 {
185 parameters.top_left = top_left + Displacement{0, -height};
186 positioned = true;
187 }
188 }
189 }
190
191 if (!positioned)
192 {
193 auto centred = active_display.top_left + 0.5*(
194 as_displacement(active_display.size) - as_displacement(parameters.size));
195
196 parameters.top_left = centred - DeltaY{(active_display.size.height.as_int()-height)/6};
197
198 if (parameters.top_left.y < display_area.top_left.y)
199 parameters.top_left.y = display_area.top_left.y;
200 }
201
202 parameters.top_left.y = parameters.top_left.y + DeltaY{title_bar_height};
203 parameters.size.height = parameters.size.height - DeltaY{title_bar_height};
204 return parameters;
205}
206
207//TODO: provide an easier way for the server to write to a surface!
208//TODO: this is painful to use mg::Buffer::write()
209namespace
210{
211void swap_buffers(
212 std::shared_ptr<ms::Surface> const& surface,
213 mir::graphics::Buffer*& surface_buffer)
214{
215 std::mutex mut;
216 std::condition_variable cv;
217
218 auto const callback = [&](mir::graphics::Buffer* buffer)
219 {
220 std::unique_lock<decltype(mut)> lk(mut);
221 surface_buffer = buffer;
222 cv.notify_one();
223 };
224
225 auto const old_buffer = surface_buffer;
226
227 surface->primary_buffer_stream()->swap_buffers(surface_buffer, callback);
228
229 std::unique_lock<decltype(mut)> lk(mut);
230 cv.wait(lk, [&]{return old_buffer != surface_buffer;});
231}
232
233void paint_titlebar(
234 std::shared_ptr<ms::Surface> const& titlebar,
235 mir::examples::CanonicalSurfaceInfoCopy& titlebar_info,
236 int intensity)
237{
238 auto stream = titlebar->primary_buffer_stream();
239 auto const format = stream->pixel_format();
240
241 if (!titlebar_info.buffer)
242 swap_buffers(titlebar, titlebar_info.buffer);
243
244 auto const sz = titlebar_info.buffer->size().height.as_int() *
245 titlebar_info.buffer->size().width.as_int() * MIR_BYTES_PER_PIXEL(format);
246
247 std::vector<unsigned char> pixels(sz, intensity);
248 titlebar_info.buffer->write(pixels.data(), sz);
249
250 swap_buffers(titlebar, titlebar_info.buffer);
251}
252}
253
254void me::CanonicalWindowManagerPolicyCopy::generate_decorations_for(
255 std::shared_ptr<scene::Session> const& session,
256 std::shared_ptr<scene::Surface> const& surface,
257 CanonicalSurfaceInfoMap& surface_map)
258{
259 auto format = mir_pixel_format_xrgb_8888;
260 ms::SurfaceCreationParameters params;
261 params.of_size(titlebar_size_for_window(surface->size()))
262 .of_name("decoration")
263 .of_pixel_format(format)
264 .of_buffer_usage(mir::graphics::BufferUsage::software)
265 .of_position(titlebar_position_for_window(surface->top_left()))
266 .of_type(mir_surface_type_gloss);
267 auto id = session->create_surface(params);
268 auto titlebar = session->surface(id);
269 titlebar->set_alpha(0.9);
270
271 auto& surface_info = tools->info_for(surface);
272 surface_info.titlebar = titlebar;
273 surface_info.children.push_back(titlebar);
274
275 CanonicalSurfaceInfoCopy titlebar_info{session, titlebar, ms::SurfaceCreationParameters{}};
276 titlebar_info.is_titlebar = true;
277 titlebar_info.parent = surface;
278
279 paint_titlebar(titlebar, titlebar_info, 0x3F);
280
281 surface_map.emplace(titlebar, std::move(titlebar_info));
282}
283
284void me::CanonicalWindowManagerPolicyCopy::handle_new_surface(std::shared_ptr<ms::Session> const& session, std::shared_ptr<ms::Surface> const& surface)
285{
286 if (auto const parent = surface->parent())
287 {
288 tools->info_for(parent).children.push_back(surface);
289 }
290
291 tools->info_for(session).surfaces++;
292
293 switch (surface->type())
294 {
295 case mir_surface_type_normal: /**< AKA "regular" */
296 case mir_surface_type_utility: /**< AKA "floating" */
297 case mir_surface_type_dialog:
298 case mir_surface_type_satellite: /**< AKA "toolbox"/"toolbar" */
299 case mir_surface_type_freestyle:
300 case mir_surface_type_menu:
301 case mir_surface_type_inputmethod: /**< AKA "OSK" or handwriting etc. */
302 // TODO There's currently no way to insert surfaces into an active (or inactive)
303 // TODO window tree while keeping the order stable or consistent with spec.
304 // TODO Nor is there a way to update the "default surface" when appropriate!!
305 surface->add_observer(std::make_shared<shell::SurfaceReadyObserver>(
306 [this](std::shared_ptr<scene::Session> const& /*session*/,
307 std::shared_ptr<scene::Surface> const& surface)
308 {
309 select_active_surface(surface);
310 },
311 session,
312 surface));
313 break;
314
315 case mir_surface_type_gloss:
316 case mir_surface_type_tip: /**< AKA "tooltip" */
317 default:
318 // Cannot have input focus
319 break;
320 }
321}
322
323void me::CanonicalWindowManagerPolicyCopy::handle_modify_surface(
324 std::shared_ptr<scene::Session> const& /*session*/,
325 std::shared_ptr<scene::Surface> const& surface,
326 shell::SurfaceSpecification const& modifications)
327{
328 auto& surface_info = tools->info_for(surface);
329
330 #define COPY_IF_SET(field)\
331 if (modifications.field.is_set())\
332 surface_info.field = modifications.field
333
334 COPY_IF_SET(min_width);
335 COPY_IF_SET(min_height);
336 COPY_IF_SET(max_width);
337 COPY_IF_SET(max_height);
338 COPY_IF_SET(min_width);
339 COPY_IF_SET(width_inc);
340 COPY_IF_SET(height_inc);
341 COPY_IF_SET(min_aspect);
342 COPY_IF_SET(max_aspect);
343
344 #undef COPY_IF_SET
345
346 if (modifications.name.is_set())
347 surface->rename(modifications.name.value());
348
349 if (modifications.width.is_set() || modifications.height.is_set())
350 {
351 auto new_size = surface->size();
352
353 if (modifications.width.is_set())
354 new_size.width = modifications.width.value();
355
356 if (modifications.height.is_set())
357 new_size.height = modifications.height.value();
358
359 constrained_resize(
360 surface,
361 surface->top_left(),
362 new_size,
363 false,
364 false,
365 display_area);
366 }
367}
368
369void me::CanonicalWindowManagerPolicyCopy::handle_delete_surface(std::shared_ptr<ms::Session> const& session, std::weak_ptr<ms::Surface> const& surface)
370{
371 if (auto const parent = tools->info_for(surface).parent.lock())
372 {
373 auto& siblings = tools->info_for(parent).children;
374
375 for (auto i = begin(siblings); i != end(siblings); ++i)
376 {
377 if (surface.lock() == i->lock())
378 {
379 siblings.erase(i);
380 break;
381 }
382 }
383 }
384
385 if (!--tools->info_for(session).surfaces && session == tools->focused_session())
386 {
387 active_surface_.reset();
388 tools->focus_next_session();
389 select_active_surface(tools->focused_surface());
390 }
391}
392
393int me::CanonicalWindowManagerPolicyCopy::handle_set_state(std::shared_ptr<ms::Surface> const& surface, MirSurfaceState value)
394{
395 auto& info = tools->info_for(surface);
396
397 switch (value)
398 {
399 case mir_surface_state_restored:
400 case mir_surface_state_maximized:
401 case mir_surface_state_vertmaximized:
402 case mir_surface_state_horizmaximized:
403 case mir_surface_state_fullscreen:
404 break;
405
406 default:
407 return info.state;
408 }
409
410 if (info.state == mir_surface_state_restored)
411 {
412 info.restore_rect = {surface->top_left(), surface->size()};
413 }
414
415 if (info.state == value)
416 {
417 return info.state;
418 }
419
420 auto const old_pos = surface->top_left();
421 Displacement movement;
422
423 switch (value)
424 {
425 case mir_surface_state_restored:
426 movement = info.restore_rect.top_left - old_pos;
427 surface->resize(info.restore_rect.size);
428 info.titlebar->resize(titlebar_size_for_window(info.restore_rect.size));
429 info.titlebar->show();
430 break;
431
432 case mir_surface_state_maximized:
433 movement = display_area.top_left - old_pos;
434 surface->resize(display_area.size);
435 info.titlebar->hide();
436 break;
437
438 case mir_surface_state_horizmaximized:
439 movement = Point{display_area.top_left.x, info.restore_rect.top_left.y} - old_pos;
440 surface->resize({display_area.size.width, info.restore_rect.size.height});
441 info.titlebar->resize(titlebar_size_for_window({display_area.size.width, info.restore_rect.size.height}));
442 info.titlebar->show();
443 break;
444
445 case mir_surface_state_vertmaximized:
446 movement = Point{info.restore_rect.top_left.x, display_area.top_left.y} - old_pos;
447 surface->resize({info.restore_rect.size.width, display_area.size.height});
448 info.titlebar->hide();
449 break;
450
451 case mir_surface_state_fullscreen:
452 {
453 Rectangle rect{old_pos, surface->size()};
454 display_layout->size_to_output(rect);
455 movement = rect.top_left - old_pos;
456 surface->resize(rect.size);
457 }
458
459 default:
460 break;
461 }
462
463 // TODO It is rather simplistic to move a tree WRT the top_left of the root
464 // TODO when resizing. But for more sophistication we would need to encode
465 // TODO some sensible layout rules.
466 move_tree(surface, movement);
467
468 return info.state = value;
469}
470
471void me::CanonicalWindowManagerPolicyCopy::drag(Point cursor)
472{
473 select_active_surface(tools->surface_at(old_cursor));
474 drag(active_surface(), cursor, old_cursor, display_area);
475 old_cursor = cursor;
476}
477
478bool me::CanonicalWindowManagerPolicyCopy::handle_keyboard_event(MirKeyboardEvent const* event)
479{
480 auto const action = mir_keyboard_event_action(event);
481 auto const scan_code = mir_keyboard_event_scan_code(event);
482 auto const modifiers = mir_keyboard_event_modifiers(event) & modifier_mask;
483
484 if (action == mir_keyboard_action_down && scan_code == KEY_F11)
485 {
486 switch (modifiers)
487 {
488 case mir_input_event_modifier_alt:
489 toggle(mir_surface_state_maximized);
490 return true;
491
492 case mir_input_event_modifier_shift:
493 toggle(mir_surface_state_vertmaximized);
494 return true;
495
496 case mir_input_event_modifier_ctrl:
497 toggle(mir_surface_state_horizmaximized);
498 return true;
499
500 default:
501 break;
502 }
503 }
504 else if (action == mir_keyboard_action_down && scan_code == KEY_F4)
505 {
506 if (auto const session = tools->focused_session())
507 {
508 switch (modifiers)
509 {
510 case mir_input_event_modifier_alt:
511 kill(session->process_id(), SIGTERM);
512 return true;
513
514 case mir_input_event_modifier_ctrl:
515 if (auto const surf = session->default_surface())
516 {
517 surf->request_client_surface_close();
518 return true;
519 }
520
521 default:
522 break;
523 }
524 }
525 }
526 else if (action == mir_keyboard_action_down &&
527 modifiers == mir_input_event_modifier_alt &&
528 scan_code == KEY_TAB)
529 {
530 tools->focus_next_session();
531 if (auto const surface = tools->focused_surface())
532 select_active_surface(surface);
533
534 return true;
535 }
536 else if (action == mir_keyboard_action_down &&
537 modifiers == mir_input_event_modifier_alt &&
538 scan_code == KEY_GRAVE)
539 {
540 if (auto const prev = tools->focused_surface())
541 {
542 if (auto const app = tools->focused_session())
543 select_active_surface(app->surface_after(prev));
544 }
545
546 return true;
547 }
548
549 return false;
550}
551
552bool me::CanonicalWindowManagerPolicyCopy::handle_touch_event(MirTouchEvent const* event)
553{
554 auto const count = mir_touch_event_point_count(event);
555
556 long total_x = 0;
557 long total_y = 0;
558
559 for (auto i = 0U; i != count; ++i)
560 {
561 total_x += mir_touch_event_axis_value(event, i, mir_touch_axis_x);
562 total_y += mir_touch_event_axis_value(event, i, mir_touch_axis_y);
563 }
564
565 Point const cursor{total_x/count, total_y/count};
566
567 bool is_drag = true;
568 for (auto i = 0U; i != count; ++i)
569 {
570 switch (mir_touch_event_action(event, i))
571 {
572 case mir_touch_action_up:
573 return false;
574
575 case mir_touch_action_down:
576 is_drag = false;
577
578 case mir_touch_action_change:
579 continue;
580 }
581 }
582
583 if (is_drag && count == 3)
584 {
585 drag(cursor);
586 return true;
587 }
588 else
589 {
590 click(cursor);
591 return false;
592 }
593}
594
595bool me::CanonicalWindowManagerPolicyCopy::handle_pointer_event(MirPointerEvent const* event)
596{
597 auto const action = mir_pointer_event_action(event);
598 auto const modifiers = mir_pointer_event_modifiers(event) & modifier_mask;
599 Point const cursor{
600 mir_pointer_event_axis_value(event, mir_pointer_axis_x),
601 mir_pointer_event_axis_value(event, mir_pointer_axis_y)};
602
603 if (action == mir_pointer_action_button_down)
604 {
605 click(cursor);
606 return false;
607 }
608 else if (action == mir_pointer_action_motion &&
609 modifiers == mir_input_event_modifier_alt)
610 {
611 if (mir_pointer_event_button_state(event, mir_pointer_button_primary))
612 {
613 drag(cursor);
614 return true;
615 }
616
617 if (mir_pointer_event_button_state(event, mir_pointer_button_tertiary))
618 {
619 resize(cursor);
620 return true;
621 }
622 }
623 else if (action == mir_pointer_action_motion && !modifiers)
624 {
625 if (mir_pointer_event_button_state(event, mir_pointer_button_primary))
626 {
627 if (auto const possible_titlebar = tools->surface_at(old_cursor))
628 {
629 if (tools->info_for(possible_titlebar).is_titlebar)
630 {
631 drag(cursor);
632 return true;
633 }
634 }
635 }
636 }
637
638 return false;
639}
640
641void me::CanonicalWindowManagerPolicyCopy::toggle(MirSurfaceState state)
642{
643 if (auto const surface = active_surface())
644 {
645 auto& info = tools->info_for(surface);
646
647 if (info.state == state)
648 state = mir_surface_state_restored;
649
650 auto const value = handle_set_state(surface, MirSurfaceState(state));
651 surface->configure(mir_surface_attrib_state, value);
652 }
653}
654
655void me::CanonicalWindowManagerPolicyCopy::select_active_surface(std::shared_ptr<ms::Surface> const& surface)
656{
657 if (surface == active_surface_.lock())
658 return;
659
660 if (!surface)
661 {
662 if (auto const active_surface = active_surface_.lock())
663 {
664 if (auto const titlebar = tools->info_for(active_surface).titlebar)
665 {
666 paint_titlebar(titlebar, tools->info_for(titlebar), 0x3F);
667 }
668 }
669
670 if (active_surface_.lock())
671 tools->set_focus_to({}, {});
672
673 active_surface_.reset();
674 return;
675 }
676
677 auto const& info_for = tools->info_for(surface);
678
679 switch (surface->type())
680 {
681 case mir_surface_type_normal: /**< AKA "regular" */
682 case mir_surface_type_utility: /**< AKA "floating" */
683 case mir_surface_type_dialog:
684 case mir_surface_type_satellite: /**< AKA "toolbox"/"toolbar" */
685 case mir_surface_type_freestyle:
686 case mir_surface_type_menu:
687 case mir_surface_type_inputmethod: /**< AKA "OSK" or handwriting etc. */
688 if (auto const active_surface = active_surface_.lock())
689 {
690 if (auto const titlebar = tools->info_for(active_surface).titlebar)
691 {
692 paint_titlebar(titlebar, tools->info_for(titlebar), 0x3F);
693 }
694 }
695 if (auto const titlebar = tools->info_for(surface).titlebar)
696 {
697 paint_titlebar(titlebar, tools->info_for(titlebar), 0xFF);
698 }
699 tools->set_focus_to(info_for.session.lock(), surface);
700 raise_tree(surface);
701 active_surface_ = surface;
702 break;
703
704 case mir_surface_type_gloss:
705 case mir_surface_type_tip: /**< AKA "tooltip" */
706 default:
707 // Cannot have input focus - try the parent
708 if (auto const parent = info_for.parent.lock())
709 select_active_surface(parent);
710 break;
711 }
712}
713
714auto me::CanonicalWindowManagerPolicyCopy::active_surface() const
715-> std::shared_ptr<ms::Surface>
716{
717 if (auto const surface = active_surface_.lock())
718 return surface;
719
720 if (auto const session = tools->focused_session())
721 {
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches