Mir

Merge lp:~alan-griffiths/mir/drag-and-drop into lp:mir

Proposed by Alan Griffiths
Status: Merged
Merged at revision: 4100
Proposed branch: lp:~alan-griffiths/mir/drag-and-drop
Merge into: lp:mir
Diff against target: 2159 lines (+1040/-26)
77 files modified
examples/server_example_basic_window_manager.cpp (+8/-0)
examples/server_example_basic_window_manager.h (+5/-0)
include/client/mir/events/event_builders.h (+2/-0)
include/client/mir_toolkit/extensions/drag_and_drop.h (+68/-0)
include/core/mir_toolkit/common.h (+2/-0)
include/server/mir/scene/null_surface_observer.h (+1/-0)
include/server/mir/scene/surface.h (+1/-0)
include/server/mir/scene/surface_observer.h (+2/-0)
include/server/mir/shell/abstract_shell.h (+8/-0)
include/server/mir/shell/focus_controller.h (+5/-0)
include/server/mir/shell/input_targeter.h (+5/-0)
include/server/mir/shell/shell.h (+4/-0)
include/server/mir/shell/shell_wrapper.h (+8/-0)
include/server/mir/shell/system_compositor_window_manager.h (+5/-0)
include/server/mir/shell/window_manager.h (+5/-0)
include/test/mir/test/doubles/mock_window_manager.h (+1/-0)
include/test/mir/test/doubles/stub_surface.h (+1/-0)
include/test/mir_test_framework/observant_shell.h (+8/-0)
src/capnproto/mir_event.capnp (+5/-1)
src/client/CMakeLists.txt (+2/-0)
src/client/drag_and_drop.cpp (+67/-0)
src/client/drag_and_drop.h (+32/-0)
src/client/events/event_builders.cpp (+25/-0)
src/client/mir_blob.cpp (+1/-8)
src/client/mir_connection.cpp (+4/-0)
src/client/mir_surface.cpp (+17/-0)
src/client/mir_surface.h (+1/-0)
src/client/rpc/mir_display_server.cpp (+9/-0)
src/client/rpc/mir_display_server.h (+4/-0)
src/client/symbols.map (+2/-0)
src/common/events/pointer_event.cpp (+41/-3)
src/common/events/surface_event.cpp (+39/-1)
src/common/symbols.map (+4/-0)
src/include/common/mir/events/pointer_event.h (+6/-1)
src/include/common/mir/events/surface_event.h (+6/-1)
src/include/common/mir/protobuf/display_server.h (+4/-0)
src/include/common/mir_blob.h (+32/-0)
src/include/server/mir/frontend/shell.h (+5/-0)
src/include/server/mir/scene/surface_event_source.h (+1/-0)
src/include/server/mir/scene/surface_observers.h (+1/-0)
src/include/server/mir/shell/basic_window_manager.h (+15/-0)
src/include/server/mir/shell/canonical_window_manager.h (+4/-0)
src/protobuf/mir_protobuf.proto (+5/-0)
src/protobuf/symbols.map (+26/-0)
src/server/frontend/protobuf_message_processor.cpp (+4/-0)
src/server/frontend/session_mediator.cpp (+20/-1)
src/server/frontend/session_mediator.h (+4/-0)
src/server/frontend/shell_wrapper.cpp (+8/-0)
src/server/frontend/shell_wrapper.h (+5/-0)
src/server/input/null_input_targeter.h (+3/-0)
src/server/input/surface_input_dispatcher.cpp (+32/-6)
src/server/input/surface_input_dispatcher.h (+5/-1)
src/server/scene/basic_surface.cpp (+12/-0)
src/server/scene/basic_surface.h (+1/-0)
src/server/scene/legacy_surface_change_notification.cpp (+4/-0)
src/server/scene/legacy_surface_change_notification.h (+1/-0)
src/server/scene/null_surface_observer.cpp (+1/-0)
src/server/scene/surface_event_source.cpp (+5/-0)
src/server/shell/abstract_shell.cpp (+17/-0)
src/server/shell/basic_window_manager.cpp (+21/-0)
src/server/shell/canonical_window_manager.cpp (+13/-0)
src/server/shell/frontend_shell.cpp (+10/-0)
src/server/shell/frontend_shell.h (+5/-0)
src/server/shell/shell_wrapper.cpp (+18/-0)
src/server/shell/system_compositor_window_manager.cpp (+7/-0)
src/server/symbols.map (+10/-0)
tests/acceptance-tests/CMakeLists.txt (+2/-0)
tests/acceptance-tests/drag_and_drop.cpp (+293/-0)
tests/acceptance-tests/test_client_cursor_api.cpp (+1/-0)
tests/include/mir/test/doubles/mock_input_targeter.h (+3/-0)
tests/include/mir/test/doubles/mock_shell.h (+3/-0)
tests/include/mir/test/doubles/stub_display_server.h (+4/-0)
tests/include/mir/test/doubles/stub_input_targeter.h (+3/-0)
tests/include/mir/test/doubles/stub_scene_surface.h (+1/-0)
tests/mir_test_framework/observant_shell.cpp (+21/-2)
tests/mir_test_framework/stub_surface.cpp (+4/-0)
tests/unit-tests/client/test_client_mir_surface.cpp (+2/-1)
To merge this branch: bzr merge lp:~alan-griffiths/mir/drag-and-drop
Reviewer Review Type Date Requested Status
Alan Griffiths Abstain
Mir CI Bot continuous-integration Needs Fixing
Kevin DuBois (community) Approve
Review via email: mp+319581@code.launchpad.net

Commit message

Initial support for Drag and Drop: tests (and implementation for) starting drag

Description of the change

Initial support for Drag and Drop: tests (and implementation for) starting drag

This covers the first few interactions of https://goo.gl/AfG5v2

More to come...

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :
Download full text (24.2 KiB)

LP:1613523

Oh! This one seems new...

15:13:59 [ RUN ] MirClientSurfaceTest.attributes_set_on_surface_creation
15:13:59
15:13:59 GMOCK WARNING:
15:13:59 Uninteresting mock function call - returning directly.
15:13:59 Function call: adopted_by(0x9af56b0)
15:13:59 NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md#knowing-when-to-expect for details.
15:13:59
15:13:59 GMOCK WARNING:
15:13:59 Uninteresting mock function call - taking default action specified at:
15:13:59 /<<BUILDDIR>>/mir-0.26.0+zesty4276bzr4104/tests/unit-tests/client/test_client_mir_surface.cpp:271:
15:13:59 Function call: swap_interval()
15:13:59 Returns: 1
15:13:59 NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md#knowing-when-to-expect for details.
15:13:59 ==11697== Conditional jump or move depends on uninitialised value(s)
15:13:59 ==11697== at 0x1CDDEB1: testing::AssertionResult testing::internal::CmpHelperEQ<int, int>(char const*, char const*, int const&, int const&) (gtest.h:1392)
15:13:59 ==11697== by 0x1CD3C33: testing::AssertionResult testing::internal::EqHelper<false>::Compare<int, int>(char const*, char const*, int const&, int const&) (gtest.h:1421)
15:13:59 ==11697== by 0x1E8F58F: MirClientSurfaceTest_attributes_set_on_surface_creation_Test::TestBody() (test_client_mir_surface.cpp:372)
15:13:59 ==11697== by 0x2D929FD: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /<<BUILDDIR>>/mir-0.26.0+zesty4276bzr4104/obj-x86_64-linux-gnu/bin/mir_unit_tests.bin)
15:13:59 ==11697== by 0x2D7EF8A: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /<<BUILDDIR>>/mir-0.26.0+zesty4276bzr4104/obj-x86_64-linux-gnu/bin/mir_unit_tests.bin)
15:13:59 ==11697== by 0x2D64405: testing::Test::Run() (in /<<BUILDDIR>>/mir-0.26.0+zesty4276bzr4104/obj-x86_64-linux-gnu/bin/mir_unit_tests.bin)
15:13:59 ==11697== by 0x2D65372: testing::TestInfo::Run() (in /<<BUILDDIR>>/mir-0.26.0+zesty4276bzr4104/obj-x86_64-linux-gnu/bin/mir_unit_tests.bin)
15:13:59 ==11697== by 0x2D65B7B: testing::TestCase::Run() (in /<<BUILDDIR>>/mir-0.26.0+zesty4276bzr4104/obj-x86_64-linux-gnu/bin/mir_unit_tests.bin)
15:13:59 ==11697== by 0x2D6DD20: testing::internal::UnitTestImpl::RunAllTests() (in /<<BUILDDIR>>/mir-0.26.0+zesty4276bzr4104/obj-x86_64-linux-gnu/bin/mir_unit_tests.bin)
15:13:59 ==11697== by 0x2D95F2D: bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (in /<<BUILDDIR>>/mir-0.26.0+zesty4276bzr4104/obj-x86_64-linux-gnu/bin/mir_unit_tests.bin)
15:13:59 ==11697== by 0x2D8111A: bool testin...

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Oh! This one seems new...
>
> 15:13:59 [ RUN ] MirClientSurfaceTest.attributes_set_on_surface_creation

Fixed

review: Abstain
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:4105
https://mir-jenkins.ubuntu.com/job/mir-ci/3130/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/4202/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4289
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/4279
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4279
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4279
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4229
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4229/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4229
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4229/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4229
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4229/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4229/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4229/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4229
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4229/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3130/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I had almost forgotten about g++-4.9 - and I don't have a system with it to experiment on any longer.

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4106
https://mir-jenkins.ubuntu.com/job/mir-ci/3132/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/4204
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4291
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/4281
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4281
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4281
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4231
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4231/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4231
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4231/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4231
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4231/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4231
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4231/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4231
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4231/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4231
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4231/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3132/rebuild

review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

nits:
+struct MyMirBlob : MirBlob
DnDBlob?

+ //std::copy(reader.begin(), reader.end(), back_inserter(blob->data_));
why commented out?

lgtm otherwise

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> nits:
> +struct MyMirBlob : MirBlob
> DnDBlob?

Is that clearer?

> + //std::copy(reader.begin(), reader.end(), back_inserter(blob->data_));
> why commented out?

Because that's what I would write if capnp would let it compile. ;)

I guess I can delete it, the code is clear enough without.

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:4108
https://mir-jenkins.ubuntu.com/job/mir-ci/3141/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/4215/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4302
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/4292
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4292
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4292
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4242
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4242/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4242/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4242/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4242
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4242/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4242
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4242/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4242
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4242/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3141/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

18:37:58 11: [ RUN ] DragAndDrop.during_drag_when_user_moves_mouse_client_receives_handle
...
18:39:30 11: /<<BUILDDIR>>/mir-0.26.0+xenial4292bzr4108/tests/acceptance-tests/drag_and_drop.cpp:191: Failure
18:39:30 11: Value of: have_cookie.wait_for(receive_event_timeout)
18:39:30 11: Expected: is equal to true
18:39:30 11: Actual: false (of type bool)
18:39:30 11: ==27856== Invalid read of size 8

The memory errors and FD leaks that follow result from following the resulting nullptr.

~~~~

18:20:22 12: [ FAILED ] ClientLatency.dropping_latency_is_closer_to_zero_than_one
18:20:22 12: [ FAILED ] ClientLatency.async_swap_dropping_latency_is_closer_to_zero_than_one

lp:1640366

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:4109
https://mir-jenkins.ubuntu.com/job/mir-ci/3150/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/4229/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4316
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/4306
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4306
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4306
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4256/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4256
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4256/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4256
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4256/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4256
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4256/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4256
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4256/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4256
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4256/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3150/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK, that's a better failure mode.

I'm hoping the follow-up fixes the race that causes this, in which case I'll merge the MPs and resubmit.

11:34:50 9: [ RUN ] DragAndDrop.during_drag_when_user_moves_mouse_client_receives_handle
11:34:50 9: [2017-03-14 11:34:50.894056] mirserver: Starting
11:34:50 9: [2017-03-14 11:34:50.897709] mirserver: Selected driver: mir:stub-graphics (version 0.27.0)
11:34:50 9: [2017-03-14 11:34:50.919402] mirserver: Using software cursor
11:34:51 9: [2017-03-14 11:34:51.080386] mirserver: Selected input driver: mir:stub-input (version: 0.27.0)
11:34:51 9: [2017-03-14 11:34:51.096963] mirserver: Mir version 0.27.0
11:34:51 9: [2017-03-14 11:34:51.103497] mirserver: Initial display configuration:
11:34:51 9: [2017-03-14 11:34:51.103792] mirserver: Output 1: VGA connected, used
11:34:51 9: [2017-03-14 11:34:51.104124] mirserver: Physical size 0.0" 0x0mm
11:34:51 9: [2017-03-14 11:34:51.104267] mirserver: Power is on
11:34:51 9: [2017-03-14 11:34:51.104432] mirserver: Current mode 800x600 60.00Hz
11:34:51 9: [2017-03-14 11:34:51.104592] mirserver: Preferred mode 800x600 60.00Hz
11:34:51 9: [2017-03-14 11:34:51.104726] mirserver: Orientation normal
11:34:51 9: [2017-03-14 11:34:51.104871] mirserver: Logical size 800x600
11:34:51 9: [2017-03-14 11:34:51.105010] mirserver: Logical position +0+0
11:34:51 9: [2017-03-14 11:34:51.105154] mirserver: Scaling factor: 1.00
11:36:21 9: /<<BUILDDIR>>/mir-0.26.1+17.04.20170209.1+zesty4306bzr4109/tests/acceptance-tests/drag_and_drop.cpp:191: Failure
11:36:21 9: Value of: have_cookie.wait_for(receive_event_timeout)
11:36:21 9: Expected: is equal to true
11:36:21 9: Actual: false (of type bool)
11:36:21 9: /<<BUILDDIR>>/mir-0.26.1+17.04.20170209.1+zesty4306bzr4109/tests/acceptance-tests/drag_and_drop.cpp:286: Failure
11:36:21 9: Value of: cookie.get()
11:36:21 9: Expected: isn't NULL
11:36:21 9: Actual: NULL (of type MirCookie const*)
11:36:21 9: [2017-03-14 11:36:21.680766] mirserver: Stopping
11:36:21 9: [ FAILED ] DragAndDrop.during_drag_when_user_moves_mouse_client_receives_handle (90835 ms)

review: Abstain

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/server_example_basic_window_manager.cpp'
--- examples/server_example_basic_window_manager.cpp 2017-01-18 02:29:37 +0000
+++ examples/server_example_basic_window_manager.cpp 2017-03-14 11:00:58 +0000
@@ -136,6 +136,14 @@
136 policy->handle_raise_surface(session, surface);136 policy->handle_raise_surface(session, surface);
137}137}
138138
139void me::BasicWindowManager::handle_request_drag_and_drop(
140 std::shared_ptr<scene::Session> const& /*session*/,
141 std::shared_ptr<scene::Surface> const& /*surface*/,
142 uint64_t /*timestamp*/)
143{
144 // Not supported in example servers
145}
146
139int me::BasicWindowManager::set_surface_attribute(147int me::BasicWindowManager::set_surface_attribute(
140 std::shared_ptr<scene::Session> const& /*session*/,148 std::shared_ptr<scene::Session> const& /*session*/,
141 std::shared_ptr<scene::Surface> const& surface,149 std::shared_ptr<scene::Surface> const& surface,
142150
=== modified file 'examples/server_example_basic_window_manager.h'
--- examples/server_example_basic_window_manager.h 2017-01-18 02:29:37 +0000
+++ examples/server_example_basic_window_manager.h 2017-03-14 11:00:58 +0000
@@ -174,6 +174,11 @@
174 std::shared_ptr<scene::Surface> const& surface,174 std::shared_ptr<scene::Surface> const& surface,
175 uint64_t timestamp) override;175 uint64_t timestamp) override;
176176
177 void handle_request_drag_and_drop(
178 std::shared_ptr<scene::Session> const& session,
179 std::shared_ptr<scene::Surface> const& surface,
180 uint64_t timestamp) override;
181
177 int set_surface_attribute(182 int set_surface_attribute(
178 std::shared_ptr<scene::Session> const& /*session*/,183 std::shared_ptr<scene::Session> const& /*session*/,
179 std::shared_ptr<scene::Surface> const& surface,184 std::shared_ptr<scene::Surface> const& surface,
180185
=== modified file 'include/client/mir/events/event_builders.h'
--- include/client/mir/events/event_builders.h 2017-02-15 13:36:35 +0000
+++ include/client/mir/events/event_builders.h 2017-03-14 11:00:58 +0000
@@ -161,6 +161,8 @@
161void transform_positions(MirEvent& event, mir::geometry::Displacement const& movement);161void transform_positions(MirEvent& event, mir::geometry::Displacement const& movement);
162void set_window_id(MirEvent& event, int window_id);162void set_window_id(MirEvent& event, int window_id);
163163
164EventUPtr make_start_drag_and_drop_event(frontend::SurfaceId const& surface_id, std::vector<uint8_t> const& handle);
165void set_drag_and_drop_handle(MirEvent& event, std::vector<uint8_t> const& handle);
164}166}
165}167}
166168
167169
=== added file 'include/client/mir_toolkit/extensions/drag_and_drop.h'
--- include/client/mir_toolkit/extensions/drag_and_drop.h 1970-01-01 00:00:00 +0000
+++ include/client/mir_toolkit/extensions/drag_and_drop.h 2017-03-14 11:00:58 +0000
@@ -0,0 +1,68 @@
1/*
2 * Copyright © 2017 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIR_DRAG_AND_DROP_H
20#define MIR_DRAG_AND_DROP_H
21
22#include "mir_toolkit/mir_extension_core.h"
23#include "mir_toolkit/client_types.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29typedef struct MirDragAndDropV1
30{
31 /**
32 * Request drag and drop. If the request succeeds a window event with a
33 * "start drag" handle will be received.
34 *
35 * \warning An invalid cookie will terminate the client connection.
36 *
37 * \param [in] window The source window
38 * \param [in] cookie A cookie instance obtained from an input event.
39 */
40 void (*request_drag_and_drop)(MirWindow* window, MirCookie const* cookie);
41
42 /**
43 * Retrieve any "drag & drop" handle associated with the event
44 *
45 * \param [in] event The event
46 * \return The associated drag handle or NULL
47 */
48 MirBlob* (*start_drag_and_drop)(MirWindowEvent const* event);
49
50 /**
51 * Retrieve any "drag & drop" handle associated with the event.
52 *
53 * \param [in] event The event
54 * \return The associated drag handle or NULL
55 */
56 MirBlob* (*pointer_drag_and_drop)(MirPointerEvent const* event);
57
58} MirDragAndDropV1;
59
60static inline MirDragAndDropV1 const* mir_drag_and_drop_v1(MirConnection* connection)
61{
62 return (MirDragAndDropV1 const*) mir_connection_request_extension(connection, "mir_drag_and_drop", 1);
63}
64
65#ifdef __cplusplus
66}
67#endif
68#endif //MIR_DRAG_AND_DROP_H
0\ No newline at end of file69\ No newline at end of file
170
=== modified file 'include/core/mir_toolkit/common.h'
--- include/core/mir_toolkit/common.h 2017-01-23 22:29:00 +0000
+++ include/core/mir_toolkit/common.h 2017-03-14 11:00:58 +0000
@@ -63,6 +63,7 @@
63 mir_surface_attrib_dpi,63 mir_surface_attrib_dpi,
64 mir_surface_attrib_visibility,64 mir_surface_attrib_visibility,
65 mir_surface_attrib_preferred_orientation,65 mir_surface_attrib_preferred_orientation,
66 mir_surface_attrib_drag_and_drop_handle,
66 /* Must be last */67 /* Must be last */
67 mir_surface_attribs68 mir_surface_attribs
68} MirSurfaceAttrib __attribute__ ((deprecated("use MirWindowAttrib")));69} MirSurfaceAttrib __attribute__ ((deprecated("use MirWindowAttrib")));
@@ -84,6 +85,7 @@
84 mir_window_attrib_dpi,85 mir_window_attrib_dpi,
85 mir_window_attrib_visibility,86 mir_window_attrib_visibility,
86 mir_window_attrib_preferred_orientation,87 mir_window_attrib_preferred_orientation,
88 mir_window_attrib_drag_and_drop_handle,
87 /* Must be last */89 /* Must be last */
88 mir_window_attribs90 mir_window_attribs
89} MirWindowAttrib;91} MirWindowAttrib;
9092
=== modified file 'include/server/mir/scene/null_surface_observer.h'
--- include/server/mir/scene/null_surface_observer.h 2017-02-15 13:36:35 +0000
+++ include/server/mir/scene/null_surface_observer.h 2017-03-14 11:00:58 +0000
@@ -47,6 +47,7 @@
47 void cursor_image_removed() override;47 void cursor_image_removed() override;
48 void placed_relative(geometry::Rectangle const& placement) override;48 void placed_relative(geometry::Rectangle const& placement) override;
49 void input_consumed(MirEvent const* event) override;49 void input_consumed(MirEvent const* event) override;
50 void start_drag_and_drop(std::vector<uint8_t> const& handle) override;
5051
51protected:52protected:
52 NullSurfaceObserver(NullSurfaceObserver const&) = delete;53 NullSurfaceObserver(NullSurfaceObserver const&) = delete;
5354
=== modified file 'include/server/mir/scene/surface.h'
--- include/server/mir/scene/surface.h 2017-02-15 14:45:41 +0000
+++ include/server/mir/scene/surface.h 2017-03-14 11:00:58 +0000
@@ -116,6 +116,7 @@
116 virtual MirPointerConfinementState confine_pointer_state() const = 0;116 virtual MirPointerConfinementState confine_pointer_state() const = 0;
117117
118 virtual void placed_relative(geometry::Rectangle const& placement) = 0;118 virtual void placed_relative(geometry::Rectangle const& placement) = 0;
119 virtual void start_drag_and_drop(std::vector<uint8_t> const& handle) = 0;
119};120};
120}121}
121}122}
122123
=== modified file 'include/server/mir/scene/surface_observer.h'
--- include/server/mir/scene/surface_observer.h 2017-02-15 13:36:35 +0000
+++ include/server/mir/scene/surface_observer.h 2017-03-14 11:00:58 +0000
@@ -27,6 +27,7 @@
2727
28#include <glm/glm.hpp>28#include <glm/glm.hpp>
29#include <string>29#include <string>
30#include <vector>
3031
31namespace mir32namespace mir
32{33{
@@ -62,6 +63,7 @@
62 virtual void cursor_image_removed() = 0;63 virtual void cursor_image_removed() = 0;
63 virtual void placed_relative(geometry::Rectangle const& placement) = 0;64 virtual void placed_relative(geometry::Rectangle const& placement) = 0;
64 virtual void input_consumed(MirEvent const* event) = 0;65 virtual void input_consumed(MirEvent const* event) = 0;
66 virtual void start_drag_and_drop(std::vector<uint8_t> const& handle) = 0;
6567
66protected:68protected:
67 SurfaceObserver() = default;69 SurfaceObserver() = default;
6870
=== modified file 'include/server/mir/shell/abstract_shell.h'
--- include/server/mir/shell/abstract_shell.h 2017-01-18 02:29:37 +0000
+++ include/server/mir/shell/abstract_shell.h 2017-03-14 11:00:58 +0000
@@ -82,6 +82,11 @@
82 std::shared_ptr<scene::Surface> const& surface,82 std::shared_ptr<scene::Surface> const& surface,
83 uint64_t timestamp) override;83 uint64_t timestamp) override;
8484
85 void request_drag_and_drop(
86 std::shared_ptr<scene::Session> const& session,
87 std::shared_ptr<scene::Surface> const& surface,
88 uint64_t timestamp) override;
89
85 std::shared_ptr<scene::PromptSession> start_prompt_session_for(90 std::shared_ptr<scene::PromptSession> start_prompt_session_for(
86 std::shared_ptr<scene::Session> const& session,91 std::shared_ptr<scene::Session> const& session,
87 scene::PromptSessionCreationParameters const& params) override;92 scene::PromptSessionCreationParameters const& params) override;
@@ -124,6 +129,9 @@
124129
125 void update_focused_surface_confined_region();130 void update_focused_surface_confined_region();
126131
132 void set_drag_and_drop_handle(std::vector<uint8_t> const& handle) override;
133 void clear_drag_and_drop_handle() override;
134
127protected:135protected:
128 std::shared_ptr<InputTargeter> const input_targeter;136 std::shared_ptr<InputTargeter> const input_targeter;
129 std::shared_ptr<SurfaceStack> const surface_stack;137 std::shared_ptr<SurfaceStack> const surface_stack;
130138
=== modified file 'include/server/mir/shell/focus_controller.h'
--- include/server/mir/shell/focus_controller.h 2016-01-29 08:18:22 +0000
+++ include/server/mir/shell/focus_controller.h 2017-03-14 11:00:58 +0000
@@ -19,8 +19,10 @@
19#ifndef MIR_SHELL_FOCUS_CONTROLLER_H_19#ifndef MIR_SHELL_FOCUS_CONTROLLER_H_
20#define MIR_SHELL_FOCUS_CONTROLLER_H_20#define MIR_SHELL_FOCUS_CONTROLLER_H_
2121
22#include <stddef.h>
22#include <memory>23#include <memory>
23#include <set>24#include <set>
25#include <vector>
2426
25namespace mir27namespace mir
26{28{
@@ -54,6 +56,9 @@
5456
55 virtual void raise(SurfaceSet const& surfaces) = 0;57 virtual void raise(SurfaceSet const& surfaces) = 0;
5658
59 virtual void set_drag_and_drop_handle(std::vector<uint8_t> const& handle) = 0;
60 virtual void clear_drag_and_drop_handle() = 0;
61
57protected:62protected:
58 FocusController() = default;63 FocusController() = default;
59 FocusController(FocusController const&) = delete;64 FocusController(FocusController const&) = delete;
6065
=== modified file 'include/server/mir/shell/input_targeter.h'
--- include/server/mir/shell/input_targeter.h 2015-06-18 02:46:16 +0000
+++ include/server/mir/shell/input_targeter.h 2017-03-14 11:00:58 +0000
@@ -19,7 +19,9 @@
19#ifndef MIR_SHELL_INPUT_TARGETER_H_19#ifndef MIR_SHELL_INPUT_TARGETER_H_
20#define MIR_SHELL_INPUT_TARGETER_H_20#define MIR_SHELL_INPUT_TARGETER_H_
2121
22#include <stddef.h>
22#include <memory>23#include <memory>
24#include <vector>
2325
24namespace mir26namespace mir
25{27{
@@ -40,6 +42,9 @@
40 virtual void set_focus(std::shared_ptr<input::Surface> const& focus_surface) = 0;42 virtual void set_focus(std::shared_ptr<input::Surface> const& focus_surface) = 0;
41 virtual void clear_focus() = 0;43 virtual void clear_focus() = 0;
4244
45 virtual void set_drag_and_drop_handle(std::vector<uint8_t> const& handle) = 0;
46 virtual void clear_drag_and_drop_handle() = 0;
47
43protected:48protected:
44 InputTargeter() = default;49 InputTargeter() = default;
45 InputTargeter(InputTargeter const&) = delete;50 InputTargeter(InputTargeter const&) = delete;
4651
=== modified file 'include/server/mir/shell/shell.h'
--- include/server/mir/shell/shell.h 2017-01-19 00:27:55 +0000
+++ include/server/mir/shell/shell.h 2017-03-14 11:00:58 +0000
@@ -100,6 +100,10 @@
100 std::shared_ptr<scene::Surface> const& surface,100 std::shared_ptr<scene::Surface> const& surface,
101 uint64_t timestamp) = 0;101 uint64_t timestamp) = 0;
102102
103 virtual void request_drag_and_drop(
104 std::shared_ptr<scene::Session> const& session,
105 std::shared_ptr<scene::Surface> const& surface,
106 uint64_t timestamp) = 0;
103/** @} */107/** @} */
104};108};
105}109}
106110
=== modified file 'include/server/mir/shell/shell_wrapper.h'
--- include/server/mir/shell/shell_wrapper.h 2017-01-18 02:29:37 +0000
+++ include/server/mir/shell/shell_wrapper.h 2017-03-14 11:00:58 +0000
@@ -85,11 +85,19 @@
85 std::shared_ptr<scene::Surface> const& surface,85 std::shared_ptr<scene::Surface> const& surface,
86 uint64_t timestamp) override;86 uint64_t timestamp) override;
8787
88 void request_drag_and_drop(
89 std::shared_ptr<scene::Session> const& session,
90 std::shared_ptr<scene::Surface> const& surface,
91 uint64_t timestamp) override;
92
88 void add_display(geometry::Rectangle const& area) override;93 void add_display(geometry::Rectangle const& area) override;
89 void remove_display(geometry::Rectangle const& area) override;94 void remove_display(geometry::Rectangle const& area) override;
9095
91 bool handle(MirEvent const& event) override;96 bool handle(MirEvent const& event) override;
9297
98 void set_drag_and_drop_handle(std::vector<uint8_t> const& handle) override;
99 void clear_drag_and_drop_handle() override;
100
93protected:101protected:
94 std::shared_ptr<Shell> const wrapped;102 std::shared_ptr<Shell> const wrapped;
95};103};
96104
=== modified file 'include/server/mir/shell/system_compositor_window_manager.h'
--- include/server/mir/shell/system_compositor_window_manager.h 2017-01-18 02:29:37 +0000
+++ include/server/mir/shell/system_compositor_window_manager.h 2017-03-14 11:00:58 +0000
@@ -95,6 +95,11 @@
95 std::shared_ptr<scene::Surface> const& surface,95 std::shared_ptr<scene::Surface> const& surface,
96 uint64_t timestamp) override;96 uint64_t timestamp) override;
9797
98 void handle_request_drag_and_drop(
99 std::shared_ptr<scene::Session> const& session,
100 std::shared_ptr<scene::Surface> const& surface,
101 uint64_t timestamp) override;
102
98 int set_surface_attribute(103 int set_surface_attribute(
99 std::shared_ptr<scene::Session> const& session,104 std::shared_ptr<scene::Session> const& session,
100 std::shared_ptr<scene::Surface> const& surface,105 std::shared_ptr<scene::Surface> const& surface,
101106
=== modified file 'include/server/mir/shell/window_manager.h'
--- include/server/mir/shell/window_manager.h 2017-01-18 02:29:37 +0000
+++ include/server/mir/shell/window_manager.h 2017-03-14 11:00:58 +0000
@@ -76,6 +76,11 @@
76 std::shared_ptr<scene::Surface> const& surface,76 std::shared_ptr<scene::Surface> const& surface,
77 uint64_t timestamp) = 0;77 uint64_t timestamp) = 0;
7878
79 virtual void handle_request_drag_and_drop(
80 std::shared_ptr<scene::Session> const& session,
81 std::shared_ptr<scene::Surface> const& surface,
82 uint64_t timestamp) = 0;
83
79 virtual ~WindowManager() = default;84 virtual ~WindowManager() = default;
80 WindowManager() = default;85 WindowManager() = default;
81 WindowManager(WindowManager const&) = delete;86 WindowManager(WindowManager const&) = delete;
8287
=== modified file 'include/test/mir/test/doubles/mock_window_manager.h'
--- include/test/mir/test/doubles/mock_window_manager.h 2017-01-18 02:29:37 +0000
+++ include/test/mir/test/doubles/mock_window_manager.h 2017-03-14 11:00:58 +0000
@@ -58,6 +58,7 @@
58 MOCK_METHOD1(handle_pointer_event, bool(MirPointerEvent const*));58 MOCK_METHOD1(handle_pointer_event, bool(MirPointerEvent const*));
5959
60 MOCK_METHOD3(handle_raise_surface, void(std::shared_ptr<scene::Session> const&, std::shared_ptr<scene::Surface> const&, uint64_t));60 MOCK_METHOD3(handle_raise_surface, void(std::shared_ptr<scene::Session> const&, std::shared_ptr<scene::Surface> const&, uint64_t));
61 MOCK_METHOD3(handle_request_drag_and_drop, void(std::shared_ptr<scene::Session> const&, std::shared_ptr<scene::Surface> const&, uint64_t));
6162
62 MOCK_METHOD4(set_surface_attribute,63 MOCK_METHOD4(set_surface_attribute,
63 int(std::shared_ptr<scene::Session> const& session,64 int(std::shared_ptr<scene::Session> const& session,
6465
=== modified file 'include/test/mir/test/doubles/stub_surface.h'
--- include/test/mir/test/doubles/stub_surface.h 2017-02-15 14:45:41 +0000
+++ include/test/mir/test/doubles/stub_surface.h 2017-03-14 11:00:58 +0000
@@ -70,6 +70,7 @@
70 void set_confine_pointer_state(MirPointerConfinementState state) override;70 void set_confine_pointer_state(MirPointerConfinementState state) override;
71 MirPointerConfinementState confine_pointer_state() const override;71 MirPointerConfinementState confine_pointer_state() const override;
72 void placed_relative(geometry::Rectangle const& placement) override;72 void placed_relative(geometry::Rectangle const& placement) override;
73 void start_drag_and_drop(std::vector<uint8_t> const& handle) override;
73};74};
74}75}
75}76}
7677
=== modified file 'include/test/mir_test_framework/observant_shell.h'
--- include/test/mir_test_framework/observant_shell.h 2017-01-20 00:01:50 +0000
+++ include/test/mir_test_framework/observant_shell.h 2017-03-14 11:00:58 +0000
@@ -96,6 +96,14 @@
96 std::shared_ptr<mir::scene::Surface> const& window,96 std::shared_ptr<mir::scene::Surface> const& window,
97 uint64_t timestamp) override;97 uint64_t timestamp) override;
9898
99 void request_drag_and_drop(
100 std::shared_ptr<mir::scene::Session> const& session,
101 std::shared_ptr<mir::scene::Surface> const& window,
102 uint64_t timestamp) override;
103
104 void set_drag_and_drop_handle(std::vector<uint8_t> const& handle) override;
105 void clear_drag_and_drop_handle() override;
106
99private:107private:
100 std::shared_ptr<mir::shell::Shell> const wrapped;108 std::shared_ptr<mir::shell::Shell> const wrapped;
101 std::shared_ptr<mir::scene::SurfaceObserver> const surface_observer;109 std::shared_ptr<mir::scene::SurfaceObserver> const surface_observer;
102110
=== modified file 'src/capnproto/mir_event.capnp'
--- src/capnproto/mir_event.capnp 2017-02-17 08:46:05 +0000
+++ src/capnproto/mir_event.capnp 2017-03-14 11:00:58 +0000
@@ -104,6 +104,8 @@
104104
105 buttons @7 :UInt32;105 buttons @7 :UInt32;
106106
107 dndHandle @8 :List(UInt8);
108
107 enum PointerAction109 enum PointerAction
108 {110 {
109 up @0;111 up @0;
@@ -149,6 +151,7 @@
149 id @0 :Int32;151 id @0 :Int32;
150 attrib @1 :Attrib;152 attrib @1 :Attrib;
151 value @2 :Int32;153 value @2 :Int32;
154 dndHandle @3 :List(UInt8);
152155
153 enum Attrib156 enum Attrib
154 {157 {
@@ -160,8 +163,9 @@
160 dpi @4;163 dpi @4;
161 visibility @5;164 visibility @5;
162 preferredOrientation @6;165 preferredOrientation @6;
166 startDragAndDrop @7;
163 # Must be last167 # Must be last
164 surfaceAttrib @7;168 surfaceAttrib @8;
165 }169 }
166}170}
167171
168172
=== modified file 'src/client/CMakeLists.txt'
--- src/client/CMakeLists.txt 2017-01-24 13:43:12 +0000
+++ src/client/CMakeLists.txt 2017-03-14 11:00:58 +0000
@@ -49,6 +49,7 @@
49add_library(mirclientobjects OBJECT49add_library(mirclientobjects OBJECT
5050
51 display_configuration.cpp51 display_configuration.cpp
52 drag_and_drop.cpp drag_and_drop.h
52 error_connections.cpp53 error_connections.cpp
53 event.cpp54 event.cpp
54 event_printer.cpp55 event_printer.cpp
@@ -105,6 +106,7 @@
105 ${CMAKE_SOURCE_DIR}/include/client/mir_toolkit/mir_error.h106 ${CMAKE_SOURCE_DIR}/include/client/mir_toolkit/mir_error.h
106 mir_extension_core.cpp107 mir_extension_core.cpp
107 ${CMAKE_SOURCE_DIR}/include/client/mir_toolkit/mir_extension_core.h108 ${CMAKE_SOURCE_DIR}/include/client/mir_toolkit/mir_extension_core.h
109 ${CMAKE_SOURCE_DIR}/include/client/mir_toolkit/extensions/drag_and_drop.h
108)110)
109111
110# Ensure protobuf C++ headers have been produced before112# Ensure protobuf C++ headers have been produced before
111113
=== added file 'src/client/drag_and_drop.cpp'
--- src/client/drag_and_drop.cpp 1970-01-01 00:00:00 +0000
+++ src/client/drag_and_drop.cpp 2017-03-14 11:00:58 +0000
@@ -0,0 +1,67 @@
1/*
2 * Copyright © 2017 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#include "drag_and_drop.h"
20#include "mir_toolkit/extensions/drag_and_drop.h"
21
22#include "mir/uncaught.h"
23#include "mir/events/surface_event.h"
24#include "mir/events/pointer_event.h"
25
26#include "mir_surface.h"
27
28namespace
29{
30
31void request_drag_and_drop(MirWindow* window, MirCookie const* cookie)
32try
33{
34 window->request_drag_and_drop(cookie);
35}
36catch (std::exception const& e)
37{
38 MIR_LOG_UNCAUGHT_EXCEPTION(e);
39 abort();
40}
41
42MirBlob* start_drag_and_drop(MirWindowEvent const* event)
43try
44{
45 return event->dnd_handle();
46}
47catch (std::exception const& e)
48{
49 MIR_LOG_UNCAUGHT_EXCEPTION(e);
50 abort();
51}
52
53MirBlob* pointer_drag_and_drop(MirPointerEvent const* event)
54try
55{
56 return event->dnd_handle();
57}
58catch (std::exception const& e)
59{
60 MIR_LOG_UNCAUGHT_EXCEPTION(e);
61 abort();
62}
63
64MirDragAndDropV1 const impl{&request_drag_and_drop, &start_drag_and_drop, &pointer_drag_and_drop};
65}
66
67MirDragAndDropV1 const* const mir::drag_and_drop::v1 = &impl;
068
=== added file 'src/client/drag_and_drop.h'
--- src/client/drag_and_drop.h 1970-01-01 00:00:00 +0000
+++ src/client/drag_and_drop.h 2017-03-14 11:00:58 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright © 2017 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIR_DRAG_AND_DROP_V1_H
20#define MIR_DRAG_AND_DROP_V1_H
21
22typedef struct MirDragAndDropV1 MirDragAndDropV1;
23
24namespace mir
25{
26namespace drag_and_drop
27{
28extern MirDragAndDropV1 const* const v1;
29}
30}
31
32#endif //MIR_DRAG_AND_DROP_V1_H
033
=== modified file 'src/client/events/event_builders.cpp'
--- src/client/events/event_builders.cpp 2017-02-15 13:36:35 +0000
+++ src/client/events/event_builders.cpp 2017-03-14 11:00:58 +0000
@@ -110,6 +110,20 @@
110 return make_uptr_event(e);110 return make_uptr_event(e);
111}111}
112112
113auto mev::make_start_drag_and_drop_event(frontend::SurfaceId const& surface_id, std::vector<uint8_t> const& handle)
114 -> EventUPtr
115{
116 auto e = new_event<MirWindowEvent>();
117
118 e->set_id(surface_id.as_value());
119 e->set_attrib(mir_window_attrib_drag_and_drop_handle);
120 e->set_value(0);
121 e->set_dnd_handle(handle);
122
123 return make_uptr_event(e);
124
125}
126
113mir::EventUPtr mev::make_event(mf::SurfaceId const& surface_id)127mir::EventUPtr mev::make_event(mf::SurfaceId const& surface_id)
114{128{
115 auto e = new_event<MirCloseWindowEvent>();129 auto e = new_event<MirCloseWindowEvent>();
@@ -450,3 +464,14 @@
450 BOOST_THROW_EXCEPTION(std::invalid_argument("Event has no window id."));464 BOOST_THROW_EXCEPTION(std::invalid_argument("Event has no window id."));
451 }465 }
452}466}
467
468void mev::set_drag_and_drop_handle(MirEvent& event, std::vector<uint8_t> const& handle)
469{
470 if (event.type() == mir_event_type_input)
471 {
472 auto const input_event = event.to_input();
473 if (mir_input_event_get_type(input_event) == mir_input_event_type_pointer)
474 const_cast<MirPointerEvent*>(mir_input_event_get_pointer_event(input_event))->set_dnd_handle(handle);
475 }
476}
477
453478
=== modified file 'src/client/mir_blob.cpp'
--- src/client/mir_blob.cpp 2017-01-18 02:29:37 +0000
+++ src/client/mir_blob.cpp 2017-03-14 11:00:58 +0000
@@ -16,6 +16,7 @@
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */17 */
1818
19#include "mir_blob.h"
19#include "display_configuration.h"20#include "display_configuration.h"
2021
21#include "mir_toolkit/mir_blob.h"22#include "mir_toolkit/mir_blob.h"
@@ -25,14 +26,6 @@
2526
26namespace mp = mir::protobuf;27namespace mp = mir::protobuf;
2728
28struct MirBlob
29{
30 virtual size_t size() const = 0;
31 virtual void const* data() const = 0;
32
33 virtual ~MirBlob() = default;
34};
35
36namespace29namespace
37{30{
38struct MirManagedBlob : MirBlob31struct MirManagedBlob : MirBlob
3932
=== modified file 'src/client/mir_connection.cpp'
--- src/client/mir_connection.cpp 2017-03-14 04:41:33 +0000
+++ src/client/mir_connection.cpp 2017-03-14 11:00:58 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "mir_connection.h"19#include "mir_connection.h"
20#include "drag_and_drop.h"
20#include "mir_surface.h"21#include "mir_surface.h"
21#include "mir_prompt_session.h"22#include "mir_prompt_session.h"
22#include "mir_toolkit/extensions/graphics_module.h"23#include "mir_toolkit/extensions/graphics_module.h"
@@ -1451,6 +1452,9 @@
1451 if (!strcmp(name, "mir_extension_graphics_module") && (version == 1) && graphics_module_extension.is_set())1452 if (!strcmp(name, "mir_extension_graphics_module") && (version == 1) && graphics_module_extension.is_set())
1452 return &graphics_module_extension.value();1453 return &graphics_module_extension.value();
14531454
1455 if (!strcmp(name, "mir_drag_and_drop") && (version == 1))
1456 return const_cast<MirDragAndDropV1*>(mir::drag_and_drop::v1);
1457
1454 return platform->request_interface(name, version);1458 return platform->request_interface(name, version);
1455}1459}
14561460
14571461
=== modified file 'src/client/mir_surface.cpp'
--- src/client/mir_surface.cpp 2017-03-14 04:41:33 +0000
+++ src/client/mir_surface.cpp 2017-03-14 11:00:58 +0000
@@ -598,6 +598,23 @@
598 google::protobuf::NewCallback(google::protobuf::DoNothing));598 google::protobuf::NewCallback(google::protobuf::DoNothing));
599}599}
600600
601void MirSurface::request_drag_and_drop(MirCookie const* cookie)
602{
603 mp::RequestAuthority authority;
604
605 std::unique_lock<decltype(mutex)> lock(mutex);
606 authority.mutable_surface_id()->set_value(surface->id().value());
607
608 auto const event_cookie = authority.mutable_cookie();
609
610 event_cookie->set_cookie(cookie->cookie().data(), cookie->size());
611
612 server->request_drag_and_drop(
613 &authority,
614 void_response.get(),
615 google::protobuf::NewCallback(google::protobuf::DoNothing));
616}
617
601MirBufferStream* MirSurface::get_buffer_stream()618MirBufferStream* MirSurface::get_buffer_stream()
602{619{
603 std::lock_guard<decltype(mutex)> lock(mutex);620 std::lock_guard<decltype(mutex)> lock(mutex);
604621
=== modified file 'src/client/mir_surface.h'
--- src/client/mir_surface.h 2017-02-15 14:45:41 +0000
+++ src/client/mir_surface.h 2017-03-14 11:00:58 +0000
@@ -200,6 +200,7 @@
200 MirWaitHandle* set_preferred_orientation(MirOrientationMode mode);200 MirWaitHandle* set_preferred_orientation(MirOrientationMode mode);
201201
202 void raise_surface(MirCookie const* cookie);202 void raise_surface(MirCookie const* cookie);
203 void request_drag_and_drop(MirCookie const* cookie);
203204
204 MirWaitHandle* configure_cursor(MirCursorConfiguration const* cursor);205 MirWaitHandle* configure_cursor(MirCursorConfiguration const* cursor);
205206
206207
=== modified file 'src/client/rpc/mir_display_server.cpp'
--- src/client/rpc/mir_display_server.cpp 2017-02-15 07:38:33 +0000
+++ src/client/rpc/mir_display_server.cpp 2017-03-14 11:00:58 +0000
@@ -238,6 +238,15 @@
238{238{
239 channel->call_method(std::string(__func__), request, response, done);239 channel->call_method(std::string(__func__), request, response, done);
240}240}
241
242void mclr::DisplayServer::request_drag_and_drop(
243 mir::protobuf::RequestAuthority const* request,
244 mir::protobuf::Void* response,
245 google::protobuf::Closure* done)
246{
247 channel->call_method(std::string(__func__), request, response, done);
248}
249
241void mclr::DisplayServer::apply_input_configuration(250void mclr::DisplayServer::apply_input_configuration(
242 mir::protobuf::InputConfigurationRequest const* request,251 mir::protobuf::InputConfigurationRequest const* request,
243 mir::protobuf::Void* response,252 mir::protobuf::Void* response,
244253
=== modified file 'src/client/rpc/mir_display_server.h'
--- src/client/rpc/mir_display_server.h 2017-02-15 07:38:33 +0000
+++ src/client/rpc/mir_display_server.h 2017-03-14 11:00:58 +0000
@@ -155,6 +155,10 @@
155 mir::protobuf::RaiseRequest const* request,155 mir::protobuf::RaiseRequest const* request,
156 mir::protobuf::Void* response,156 mir::protobuf::Void* response,
157 google::protobuf::Closure* done) override;157 google::protobuf::Closure* done) override;
158 void request_drag_and_drop(
159 mir::protobuf::RequestAuthority const* request,
160 mir::protobuf::Void* response,
161 google::protobuf::Closure* done) override;
158 void apply_input_configuration(162 void apply_input_configuration(
159 mir::protobuf::InputConfigurationRequest const* request,163 mir::protobuf::InputConfigurationRequest const* request,
160 mir::protobuf::Void* response,164 mir::protobuf::Void* response,
161165
=== modified file 'src/client/symbols.map'
--- src/client/symbols.map 2017-03-14 04:41:33 +0000
+++ src/client/symbols.map 2017-03-14 11:00:58 +0000
@@ -604,6 +604,8 @@
604 global:604 global:
605 extern "C++" {605 extern "C++" {
606 mir::events::set_window_id*;606 mir::events::set_window_id*;
607 mir::events::make_start_drag_and_drop_event*;
608 mir::events::set_drag_and_drop_handle*;
607 };609 };
608} MIR_CLIENT_DETAIL_0.26.1;610} MIR_CLIENT_DETAIL_0.26.1;
609611
610612
=== modified file 'src/common/events/pointer_event.cpp'
--- src/common/events/pointer_event.cpp 2016-11-07 23:02:26 +0000
+++ src/common/events/pointer_event.cpp 2017-03-14 11:00:58 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2016 Canonical Ltd.2 * Copyright © 2016-2017 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,5 * under the terms of the GNU Lesser General Public License version 3,
@@ -16,10 +16,11 @@
16 * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>16 * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
17 */17 */
1818
19#include "mir/events/pointer_event.h"
20#include "mir_blob.h"
21
19#include <boost/throw_exception.hpp>22#include <boost/throw_exception.hpp>
2023
21#include "mir/events/pointer_event.h"
22
23MirPointerEvent::MirPointerEvent()24MirPointerEvent::MirPointerEvent()
24{25{
25 event.initInput();26 event.initInput();
@@ -132,3 +133,40 @@
132{133{
133 event.getInput().getPointer().setAction(static_cast<mir::capnp::PointerEvent::PointerAction>(action));134 event.getInput().getPointer().setAction(static_cast<mir::capnp::PointerEvent::PointerAction>(action));
134}135}
136
137void MirPointerEvent::set_dnd_handle(std::vector<uint8_t> const& handle)
138{
139 event.getInput().getPointer().initDndHandle(handle.size());
140 event.getInput().getPointer().setDndHandle(::kj::ArrayPtr<uint8_t const>{&*begin(handle), &*end(handle)});
141}
142
143namespace
144{
145struct MyMirBlob : MirBlob
146{
147
148 size_t size() const override { return data_.size(); }
149 virtual void const* data() const override { return data_.data(); }
150
151 std::vector<uint8_t> data_;
152};
153}
154
155MirBlob* MirPointerEvent::dnd_handle() const
156{
157 auto const reader = event.asReader().getInput().getPointer();
158
159 if (!reader.hasDndHandle())
160 return nullptr;
161
162 auto const dnd_handle = reader.getDndHandle();
163
164 auto blob = std::make_unique<MyMirBlob>();
165 blob->data_.reserve(dnd_handle.size());
166
167 //std::copy(dnd_handle.begin(), dnd_handle.end(), back_inserter(blob->data_));
168 for (auto p = dnd_handle.begin(); p != dnd_handle.end(); ++p)
169 blob->data_.push_back(*p);
170
171 return blob.release();
172}
135173
=== modified file 'src/common/events/surface_event.cpp'
--- src/common/events/surface_event.cpp 2017-01-23 03:38:33 +0000
+++ src/common/events/surface_event.cpp 2017-03-14 11:00:58 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2016 Canonical Ltd.2 * Copyright © 2016-2017 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,5 * under the terms of the GNU Lesser General Public License version 3,
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "mir/events/surface_event.h"19#include "mir/events/surface_event.h"
20#include "mir_blob.h"
2021
21// MirSurfaceEvent is a deprecated type, but we need to implement it22// MirSurfaceEvent is a deprecated type, but we need to implement it
22#pragma GCC diagnostic ignored "-Wdeprecated-declarations"23#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -55,3 +56,40 @@
55{56{
56 event.getSurface().setValue(value);57 event.getSurface().setValue(value);
57}58}
59
60void MirSurfaceEvent::set_dnd_handle(std::vector<uint8_t> const& handle)
61{
62 event.getSurface().initDndHandle(handle.size());
63 event.getSurface().setDndHandle(::kj::ArrayPtr<uint8_t const>{&*begin(handle), &*end(handle)});
64}
65
66namespace
67{
68struct MyMirBlob : MirBlob
69{
70
71 size_t size() const override { return data_.size(); }
72 virtual void const* data() const override { return data_.data(); }
73
74 std::vector<uint8_t> data_;
75};
76}
77
78MirBlob* MirSurfaceEvent::dnd_handle() const
79{
80 if (!event.asReader().getSurface().hasDndHandle())
81 return nullptr;
82
83 auto blob = std::make_unique<MyMirBlob>();
84
85 auto reader = event.asReader().getSurface().getDndHandle();
86
87 blob->data_.reserve(reader.size());
88
89 // Can't use std::copy() as the CapnP iterators don't provide an iterator category
90 for (auto p = reader.begin(); p != reader.end(); ++p)
91 blob->data_.push_back(*p);
92
93 return blob.release();
94}
95
5896
=== modified file 'src/common/symbols.map'
--- src/common/symbols.map 2017-02-28 08:53:57 +0000
+++ src/common/symbols.map 2017-03-14 11:00:58 +0000
@@ -432,5 +432,9 @@
432 MirInputEvent::window_id*;432 MirInputEvent::window_id*;
433 MirKeyboardEvent::set_text*;433 MirKeyboardEvent::set_text*;
434 MirKeyboardEvent::text*;434 MirKeyboardEvent::text*;
435 MirPointerEvent::dnd_handle*;
436 MirPointerEvent::set_dnd_handle*;
437 MirSurfaceEvent::dnd_handle*;
438 MirSurfaceEvent::set_dnd_handle*;
435 };439 };
436} MIR_COMMON_0.26;440} MIR_COMMON_0.26;
437441
=== modified file 'src/include/common/mir/events/pointer_event.h'
--- src/include/common/mir/events/pointer_event.h 2016-09-22 19:21:34 +0000
+++ src/include/common/mir/events/pointer_event.h 2017-03-14 11:00:58 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2016 Canonical Ltd.2 * Copyright © 2016-2017 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,5 * under the terms of the GNU Lesser General Public License version 3,
@@ -21,6 +21,8 @@
2121
22#include "mir/events/input_event.h"22#include "mir/events/input_event.h"
2323
24typedef struct MirBlob MirBlob;
25
24struct MirPointerEvent : MirInputEvent26struct MirPointerEvent : MirInputEvent
25{27{
26 MirPointerEvent();28 MirPointerEvent();
@@ -60,6 +62,9 @@
6062
61 MirPointerButtons buttons() const;63 MirPointerButtons buttons() const;
62 void set_buttons(MirPointerButtons buttons);64 void set_buttons(MirPointerButtons buttons);
65
66 void set_dnd_handle(std::vector<uint8_t> const& handle);
67 MirBlob* dnd_handle() const;
63private:68private:
64};69};
6570
6671
=== modified file 'src/include/common/mir/events/surface_event.h'
--- src/include/common/mir/events/surface_event.h 2017-01-18 02:29:37 +0000
+++ src/include/common/mir/events/surface_event.h 2017-03-14 11:00:58 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2016 Canonical Ltd.2 * Copyright © 2016-2017 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,5 * under the terms of the GNU Lesser General Public License version 3,
@@ -21,6 +21,8 @@
2121
22#include "mir/events/event.h"22#include "mir/events/event.h"
2323
24typedef struct MirBlob MirBlob;
25
24struct MirSurfaceEvent : MirEvent26struct MirSurfaceEvent : MirEvent
25{27{
26 MirSurfaceEvent();28 MirSurfaceEvent();
@@ -33,6 +35,9 @@
3335
34 int value() const;36 int value() const;
35 void set_value(int value);37 void set_value(int value);
38
39 void set_dnd_handle(std::vector<uint8_t> const& handle);
40 MirBlob* dnd_handle() const;
36};41};
3742
38#endif /* MIR_COMMON_SURFACE_EVENT_H_ */43#endif /* MIR_COMMON_SURFACE_EVENT_H_ */
3944
=== modified file 'src/include/common/mir/protobuf/display_server.h'
--- src/include/common/mir/protobuf/display_server.h 2017-02-15 07:38:33 +0000
+++ src/include/common/mir/protobuf/display_server.h 2017-03-14 11:00:58 +0000
@@ -151,6 +151,10 @@
151 mir::protobuf::RaiseRequest const* request,151 mir::protobuf::RaiseRequest const* request,
152 mir::protobuf::Void* response,152 mir::protobuf::Void* response,
153 google::protobuf::Closure* done) = 0;153 google::protobuf::Closure* done) = 0;
154 virtual void request_drag_and_drop(
155 mir::protobuf::RequestAuthority const* request,
156 mir::protobuf::Void* response,
157 google::protobuf::Closure* done) = 0;
154 virtual void apply_input_configuration(158 virtual void apply_input_configuration(
155 mir::protobuf::InputConfigurationRequest const* request,159 mir::protobuf::InputConfigurationRequest const* request,
156 mir::protobuf::Void* response,160 mir::protobuf::Void* response,
157161
=== added file 'src/include/common/mir_blob.h'
--- src/include/common/mir_blob.h 1970-01-01 00:00:00 +0000
+++ src/include/common/mir_blob.h 2017-03-14 11:00:58 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright © 2017 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIR_MIR_BLOB_H_H
20#define MIR_MIR_BLOB_H_H
21
22#include <stddef.h>
23
24struct MirBlob
25{
26 virtual size_t size() const = 0;
27 virtual void const* data() const = 0;
28
29 virtual ~MirBlob() = default;
30};
31
32#endif //MIR_MIR_BLOB_H_H
033
=== modified file 'src/include/server/mir/frontend/shell.h'
--- src/include/server/mir/frontend/shell.h 2017-01-18 02:29:37 +0000
+++ src/include/server/mir/frontend/shell.h 2017-03-14 11:00:58 +0000
@@ -87,6 +87,11 @@
87 SurfaceId surface_id,87 SurfaceId surface_id,
88 uint64_t timestamp) = 0;88 uint64_t timestamp) = 0;
8989
90 virtual void request_drag_and_drop(
91 std::shared_ptr<Session> const& session,
92 SurfaceId surface_id,
93 uint64_t timestamp) = 0;
94
90protected:95protected:
91 Shell() = default;96 Shell() = default;
92 Shell(const Shell&) = delete;97 Shell(const Shell&) = delete;
9398
=== modified file 'src/include/server/mir/scene/surface_event_source.h'
--- src/include/server/mir/scene/surface_event_source.h 2017-02-15 13:36:35 +0000
+++ src/include/server/mir/scene/surface_event_source.h 2017-03-14 11:00:58 +0000
@@ -51,6 +51,7 @@
51 std::string const& variant, std::string const& options) override;51 std::string const& variant, std::string const& options) override;
52 void placed_relative(geometry::Rectangle const& placement) override;52 void placed_relative(geometry::Rectangle const& placement) override;
53 void input_consumed(MirEvent const* event) override;53 void input_consumed(MirEvent const* event) override;
54 void start_drag_and_drop(std::vector<uint8_t> const& handle) override;
5455
55private:56private:
56 frontend::SurfaceId const id;57 frontend::SurfaceId const id;
5758
=== modified file 'src/include/server/mir/scene/surface_observers.h'
--- src/include/server/mir/scene/surface_observers.h 2017-02-15 13:36:35 +0000
+++ src/include/server/mir/scene/surface_observers.h 2017-03-14 11:00:58 +0000
@@ -51,6 +51,7 @@
51 void cursor_image_removed() override;51 void cursor_image_removed() override;
52 void placed_relative(geometry::Rectangle const& placement) override;52 void placed_relative(geometry::Rectangle const& placement) override;
53 void input_consumed(MirEvent const* event) override;53 void input_consumed(MirEvent const* event) override;
54 void start_drag_and_drop(std::vector<uint8_t> const& handle) override;
54};55};
5556
56}57}
5758
=== modified file 'src/include/server/mir/shell/basic_window_manager.h'
--- src/include/server/mir/shell/basic_window_manager.h 2017-01-18 02:29:37 +0000
+++ src/include/server/mir/shell/basic_window_manager.h 2017-03-14 11:00:58 +0000
@@ -65,6 +65,9 @@
6565
66 virtual void raise_tree(std::shared_ptr<scene::Surface> const& root) = 0;66 virtual void raise_tree(std::shared_ptr<scene::Surface> const& root) = 0;
6767
68 virtual void set_drag_and_drop_handle(std::vector<uint8_t> const& handle) = 0;
69 virtual void clear_drag_and_drop_handle() = 0;
70
68 virtual ~WindowManagerTools() = default;71 virtual ~WindowManagerTools() = default;
69 WindowManagerTools() = default;72 WindowManagerTools() = default;
70 WindowManagerTools(WindowManagerTools const&) = delete;73 WindowManagerTools(WindowManagerTools const&) = delete;
@@ -107,6 +110,10 @@
107 std::shared_ptr<scene::Session> const& session,110 std::shared_ptr<scene::Session> const& session,
108 std::shared_ptr<scene::Surface> const& surface) = 0;111 std::shared_ptr<scene::Surface> const& surface) = 0;
109112
113 virtual void handle_request_drag_and_drop(
114 std::shared_ptr<scene::Session> const& session,
115 std::shared_ptr<scene::Surface> const& surface) = 0;
116
110 virtual ~WindowManagementPolicy() = default;117 virtual ~WindowManagementPolicy() = default;
111 WindowManagementPolicy() = default;118 WindowManagementPolicy() = default;
112 WindowManagementPolicy(WindowManagementPolicy const&) = delete;119 WindowManagementPolicy(WindowManagementPolicy const&) = delete;
@@ -163,6 +170,11 @@
163 std::shared_ptr<scene::Surface> const& surface,170 std::shared_ptr<scene::Surface> const& surface,
164 uint64_t timestamp) override;171 uint64_t timestamp) override;
165172
173 void handle_request_drag_and_drop(
174 std::shared_ptr<scene::Session> const& session,
175 std::shared_ptr<scene::Surface> const& surface,
176 uint64_t timestamp) override;
177
166 int set_surface_attribute(178 int set_surface_attribute(
167 std::shared_ptr<scene::Session> const& /*session*/,179 std::shared_ptr<scene::Session> const& /*session*/,
168 std::shared_ptr<scene::Surface> const& surface,180 std::shared_ptr<scene::Surface> const& surface,
@@ -192,6 +204,9 @@
192204
193 void raise_tree(std::shared_ptr<scene::Surface> const& root) override;205 void raise_tree(std::shared_ptr<scene::Surface> const& root) override;
194206
207 void set_drag_and_drop_handle(std::vector<uint8_t> const& handle) override;
208 void clear_drag_and_drop_handle() override;
209
195private:210private:
196 shell::FocusController* const focus_controller;211 shell::FocusController* const focus_controller;
197 std::unique_ptr<WindowManagementPolicy> const policy;212 std::unique_ptr<WindowManagementPolicy> const policy;
198213
=== modified file 'src/include/server/mir/shell/canonical_window_manager.h'
--- src/include/server/mir/shell/canonical_window_manager.h 2017-01-18 02:29:37 +0000
+++ src/include/server/mir/shell/canonical_window_manager.h 2017-03-14 11:00:58 +0000
@@ -75,6 +75,10 @@
75 std::shared_ptr<scene::Session> const& session,75 std::shared_ptr<scene::Session> const& session,
76 std::shared_ptr<scene::Surface> const& surface) override;76 std::shared_ptr<scene::Surface> const& surface) override;
7777
78 void handle_request_drag_and_drop(
79 std::shared_ptr<scene::Session> const& session,
80 std::shared_ptr<scene::Surface> const& surface) override;
81
78private:82private:
79 static const int modifier_mask =83 static const int modifier_mask =
80 mir_input_event_modifier_alt |84 mir_input_event_modifier_alt |
8185
=== modified file 'src/protobuf/mir_protobuf.proto'
--- src/protobuf/mir_protobuf.proto 2017-03-14 04:41:33 +0000
+++ src/protobuf/mir_protobuf.proto 2017-03-14 11:00:58 +0000
@@ -444,6 +444,11 @@
444 required SurfaceId surface_id = 2;444 required SurfaceId surface_id = 2;
445}445}
446446
447message RequestAuthority {
448 required Cookie cookie = 1;
449 required SurfaceId surface_id = 2;
450}
451
447message InputDevices {452message InputDevices {
448 repeated InputDeviceInfo device_info = 1;453 repeated InputDeviceInfo device_info = 1;
449}454}
450455
=== modified file 'src/protobuf/symbols.map'
--- src/protobuf/symbols.map 2017-02-15 07:38:33 +0000
+++ src/protobuf/symbols.map 2017-03-14 11:00:58 +0000
@@ -1112,3 +1112,29 @@
1112 vtable?for?mir::protobuf::PromptSession;1112 vtable?for?mir::protobuf::PromptSession;
1113 };1113 };
1114} MIR_PROTOBUF_0.22;1114} MIR_PROTOBUF_0.22;
1115
1116MIR_PROTOBUF_0.27 {
1117 global:
1118 extern "C++" {
1119 mir::protobuf::RequestAuthority::ByteSize*;
1120 mir::protobuf::RequestAuthority::CheckTypeAndMergeFrom*;
1121 mir::protobuf::RequestAuthority::Clear*;
1122 mir::protobuf::RequestAuthority::CopyFrom*;
1123 mir::protobuf::RequestAuthority::default_instance*;
1124 mir::protobuf::RequestAuthority::DiscardUnknownFields*;
1125 mir::protobuf::RequestAuthority::GetTypeName*;
1126 mir::protobuf::RequestAuthority::IsInitialized*;
1127 mir::protobuf::RequestAuthority::kCookieFieldNumber*;
1128 mir::protobuf::RequestAuthority::kSurfaceIdFieldNumber*;
1129 mir::protobuf::RequestAuthority::MergeFrom*;
1130 mir::protobuf::RequestAuthority::MergePartialFromCodedStream*;
1131 mir::protobuf::RequestAuthority::New*;
1132 mir::protobuf::RequestAuthority::?RequestAuthority*;
1133 mir::protobuf::RequestAuthority::RequestAuthority*;
1134 mir::protobuf::RequestAuthority::SerializeWithCachedSizes*;
1135 mir::protobuf::RequestAuthority::Swap*;
1136 non-virtual?thunk?to?mir::protobuf::RequestAuthority::?RequestAuthority*;
1137 typeinfo?for?mir::protobuf::RequestAuthority;
1138 vtable?for?mir::protobuf::RequestAuthority;
1139 };
1140} MIR_PROTOBUF_0.26;
11151141
=== modified file 'src/server/frontend/protobuf_message_processor.cpp'
--- src/server/frontend/protobuf_message_processor.cpp 2017-02-15 07:38:33 +0000
+++ src/server/frontend/protobuf_message_processor.cpp 2017-03-14 11:00:58 +0000
@@ -305,6 +305,10 @@
305 {305 {
306 invoke(this, display_server.get(), &protobuf::DisplayServer::stop_prompt_session, invocation);306 invoke(this, display_server.get(), &protobuf::DisplayServer::stop_prompt_session, invocation);
307 }307 }
308 else if ("request_drag_and_drop" == invocation.method_name())
309 {
310 invoke(this, display_server.get(), &protobuf::DisplayServer::request_drag_and_drop, invocation);
311 }
308 else if ("disconnect" == invocation.method_name())312 else if ("disconnect" == invocation.method_name())
309 {313 {
310 invoke(this, display_server.get(), &DisplayServer::disconnect, invocation);314 invoke(this, display_server.get(), &DisplayServer::disconnect, invocation);
311315
=== modified file 'src/server/frontend/session_mediator.cpp'
--- src/server/frontend/session_mediator.cpp 2017-03-14 04:41:33 +0000
+++ src/server/frontend/session_mediator.cpp 2017-03-14 11:00:58 +0000
@@ -1175,6 +1175,26 @@
1175 done->Run();1175 done->Run();
1176}1176}
11771177
1178void mir::frontend::SessionMediator::request_drag_and_drop(mir::protobuf::RequestAuthority const* request,
1179 mir::protobuf::Void*, google::protobuf::Closure* done)
1180{
1181 auto const session = weak_session.lock();
1182 if (!session)
1183 BOOST_THROW_EXCEPTION(std::logic_error("Invalid application session"));
1184
1185 auto const cookie = request->cookie();
1186 auto const surface_id = request->surface_id();
1187
1188 auto cookie_string = cookie.cookie();
1189
1190 std::vector<uint8_t> cookie_bytes(cookie_string.begin(), cookie_string.end());
1191 auto const cookie_ptr = cookie_authority->make_cookie(cookie_bytes);
1192
1193 shell->request_drag_and_drop(session, mf::SurfaceId{surface_id.value()}, cookie_ptr->timestamp());
1194
1195 done->Run();
1196}
1197
1178void mf::SessionMediator::apply_input_configuration(1198void mf::SessionMediator::apply_input_configuration(
1179 mir::protobuf::InputConfigurationRequest const* request,1199 mir::protobuf::InputConfigurationRequest const* request,
1180 mir::protobuf::Void*,1200 mir::protobuf::Void*,
@@ -1254,7 +1274,6 @@
1254 screencast_buffer_tracker.remove_session(id);1274 screencast_buffer_tracker.remove_session(id);
1255}1275}
12561276
1257
1258auto mf::detail::PromptSessionStore::insert(std::shared_ptr<PromptSession> const& session) -> PromptSessionId1277auto mf::detail::PromptSessionStore::insert(std::shared_ptr<PromptSession> const& session) -> PromptSessionId
1259{1278{
1260 std::lock_guard<decltype(mutex)> lock{mutex};1279 std::lock_guard<decltype(mutex)> lock{mutex};
12611280
=== modified file 'src/server/frontend/session_mediator.h'
--- src/server/frontend/session_mediator.h 2017-03-14 02:26:28 +0000
+++ src/server/frontend/session_mediator.h 2017-03-14 11:00:58 +0000
@@ -249,6 +249,10 @@
249 mir::protobuf::RaiseRequest const* request,249 mir::protobuf::RaiseRequest const* request,
250 mir::protobuf::Void*,250 mir::protobuf::Void*,
251 google::protobuf::Closure* done) override;251 google::protobuf::Closure* done) override;
252 void request_drag_and_drop(
253 mir::protobuf::RequestAuthority const* request,
254 mir::protobuf::Void*,
255 google::protobuf::Closure* done) override;
252 void apply_input_configuration(256 void apply_input_configuration(
253 mir::protobuf::InputConfigurationRequest const* request,257 mir::protobuf::InputConfigurationRequest const* request,
254 mir::protobuf::Void* response,258 mir::protobuf::Void* response,
255259
=== modified file 'src/server/frontend/shell_wrapper.cpp'
--- src/server/frontend/shell_wrapper.cpp 2017-01-18 02:29:37 +0000
+++ src/server/frontend/shell_wrapper.cpp 2017-03-14 11:00:58 +0000
@@ -106,3 +106,11 @@
106{106{
107 wrapped->raise_surface(session, surface_id, timestamp);107 wrapped->raise_surface(session, surface_id, timestamp);
108}108}
109
110void mf::ShellWrapper::request_drag_and_drop(
111 std::shared_ptr<Session> const& session,
112 SurfaceId surface_id,
113 uint64_t timestamp)
114{
115 wrapped->request_drag_and_drop(session, surface_id, timestamp);
116}
109117
=== modified file 'src/server/frontend/shell_wrapper.h'
--- src/server/frontend/shell_wrapper.h 2017-01-18 02:29:37 +0000
+++ src/server/frontend/shell_wrapper.h 2017-03-14 11:00:58 +0000
@@ -80,6 +80,11 @@
80 SurfaceId surface_id,80 SurfaceId surface_id,
81 uint64_t timestamp) override;81 uint64_t timestamp) override;
8282
83 void request_drag_and_drop(
84 std::shared_ptr<Session> const& session,
85 SurfaceId surface_id,
86 uint64_t timestamp) override;
87
83protected:88protected:
84 std::shared_ptr<Shell> const wrapped;89 std::shared_ptr<Shell> const wrapped;
85};90};
8691
=== modified file 'src/server/input/null_input_targeter.h'
--- src/server/input/null_input_targeter.h 2017-02-15 14:45:41 +0000
+++ src/server/input/null_input_targeter.h 2017-03-14 11:00:58 +0000
@@ -38,6 +38,9 @@
38 void clear_focus() override38 void clear_focus() override
39 {39 {
40 }40 }
41
42 void set_drag_and_drop_handle(std::vector<uint8_t> const&) override {}
43 void clear_drag_and_drop_handle() override {}
41};44};
4245
43}46}
4447
=== modified file 'src/server/input/surface_input_dispatcher.cpp'
--- src/server/input/surface_input_dispatcher.cpp 2017-01-18 02:29:37 +0000
+++ src/server/input/surface_input_dispatcher.cpp 2017-03-14 11:00:58 +0000
@@ -70,7 +70,10 @@
70 std::function<void(ms::Surface*)> const on_removed;70 std::function<void(ms::Surface*)> const on_removed;
71};71};
7272
73void deliver_without_relative_motion(std::shared_ptr<mi::Surface> const& surface, MirEvent const* ev)73void deliver_without_relative_motion(
74 std::shared_ptr<mi::Surface> const& surface,
75 MirEvent const* ev,
76 std::vector<uint8_t> const& drag_and_drop_handle)
74{77{
75 auto const* input_ev = mir_event_get_input_event(ev);78 auto const* input_ev = mir_event_get_input_event(ev);
76 auto const* pev = mir_input_event_get_pointer_event(input_ev);79 auto const* pev = mir_input_event_get_pointer_event(input_ev);
@@ -98,12 +101,21 @@
98 0.0f);101 0.0f);
99102
100 mev::transform_positions(*to_deliver, geom::Displacement{bounds.top_left.x.as_int(), bounds.top_left.y.as_int()});103 mev::transform_positions(*to_deliver, geom::Displacement{bounds.top_left.x.as_int(), bounds.top_left.y.as_int()});
104 if (!drag_and_drop_handle.empty())
105 mev::set_drag_and_drop_handle(*to_deliver, drag_and_drop_handle);
101 surface->consume(to_deliver.get());106 surface->consume(to_deliver.get());
102}107}
103108
104void deliver(std::shared_ptr<mi::Surface> const& surface, MirEvent const* ev)109void deliver(
110 std::shared_ptr<mi::Surface> const& surface,
111 MirEvent const* ev,
112 std::vector<uint8_t> const& drag_and_drop_handle)
105{113{
106 auto to_deliver = mev::clone_event(*ev);114 auto to_deliver = mev::clone_event(*ev);
115
116 if (!drag_and_drop_handle.empty())
117 mev::set_drag_and_drop_handle(*to_deliver, drag_and_drop_handle);
118
107 auto const& bounds = surface->input_bounds();119 auto const& bounds = surface->input_bounds();
108 mev::transform_positions(*to_deliver, geom::Displacement{bounds.top_left.x.as_int(), bounds.top_left.y.as_int()});120 mev::transform_positions(*to_deliver, geom::Displacement{bounds.top_left.x.as_int(), bounds.top_left.y.as_int()});
109 surface->consume(to_deliver.get());121 surface->consume(to_deliver.get());
@@ -243,6 +255,8 @@
243 mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_x),255 mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_x),
244 mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_y));256 mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_y));
245257
258 if (!drag_and_drop_handle.empty())
259 mev::set_drag_and_drop_handle(*event, drag_and_drop_handle);
246 surface->consume(event.get());260 surface->consume(event.get());
247}261}
248262
@@ -270,7 +284,7 @@
270284
271 if (pointer_state.gesture_owner)285 if (pointer_state.gesture_owner)
272 {286 {
273 deliver(pointer_state.gesture_owner, ev);287 deliver(pointer_state.gesture_owner, ev, drag_and_drop_handle);
274288
275 if (is_gesture_terminator(pev))289 if (is_gesture_terminator(pev))
276 {290 {
@@ -323,11 +337,11 @@
323 if (sent_ev)337 if (sent_ev)
324 {338 {
325 if (action != mir_pointer_action_motion)339 if (action != mir_pointer_action_motion)
326 deliver_without_relative_motion(target, ev);340 deliver_without_relative_motion(target, ev, drag_and_drop_handle);
327 }341 }
328 else342 else
329 {343 {
330 deliver(target, ev);344 deliver(target, ev, drag_and_drop_handle);
331 }345 }
332 return true;346 return true;
333 }347 }
@@ -383,7 +397,7 @@
383397
384 if (gesture_owner)398 if (gesture_owner)
385 {399 {
386 deliver(gesture_owner, ev);400 deliver(gesture_owner, ev, drag_and_drop_handle);
387401
388 if (is_gesture_end(tev))402 if (is_gesture_end(tev))
389 gesture_owner.reset();403 gesture_owner.reset();
@@ -450,3 +464,15 @@
450 set_focus_locked(lg, nullptr);464 set_focus_locked(lg, nullptr);
451}465}
452466
467void mir::input::SurfaceInputDispatcher::set_drag_and_drop_handle(std::vector<uint8_t> const& handle)
468{
469 std::lock_guard<std::mutex> lg(dispatcher_mutex);
470 drag_and_drop_handle = handle;
471}
472
473void mir::input::SurfaceInputDispatcher::clear_drag_and_drop_handle()
474{
475 std::lock_guard<std::mutex> lg(dispatcher_mutex);
476 drag_and_drop_handle.clear();
477}
478
453479
=== modified file 'src/server/input/surface_input_dispatcher.h'
--- src/server/input/surface_input_dispatcher.h 2016-10-05 13:18:38 +0000
+++ src/server/input/surface_input_dispatcher.h 2017-03-14 11:00:58 +0000
@@ -54,7 +54,10 @@
54 // InputTargeter54 // InputTargeter
55 void set_focus(std::shared_ptr<input::Surface> const& target) override;55 void set_focus(std::shared_ptr<input::Surface> const& target) override;
56 void clear_focus() override;56 void clear_focus() override;
57 57
58 void set_drag_and_drop_handle(std::vector<uint8_t> const& handle) override;
59 void clear_drag_and_drop_handle() override;
60
58private:61private:
59 void device_reset(MirInputDeviceId reset_device_id, std::chrono::nanoseconds when);62 void device_reset(MirInputDeviceId reset_device_id, std::chrono::nanoseconds when);
60 bool dispatch_key(MirEvent const* kev);63 bool dispatch_key(MirEvent const* kev);
@@ -92,6 +95,7 @@
9295
93 std::mutex dispatcher_mutex;96 std::mutex dispatcher_mutex;
94 std::weak_ptr<input::Surface> focus_surface;97 std::weak_ptr<input::Surface> focus_surface;
98 std::vector<uint8_t> drag_and_drop_handle;
95 bool started;99 bool started;
96};100};
97101
98102
=== modified file 'src/server/scene/basic_surface.cpp'
--- src/server/scene/basic_surface.cpp 2017-02-15 14:45:41 +0000
+++ src/server/scene/basic_surface.cpp 2017-03-14 11:00:58 +0000
@@ -144,6 +144,12 @@
144 { observer->input_consumed(event); });144 { observer->input_consumed(event); });
145}145}
146146
147void ms::SurfaceObservers::start_drag_and_drop(std::vector<uint8_t> const& handle)
148{
149 for_each([&](std::shared_ptr<SurfaceObserver> const& observer)
150 { observer->start_drag_and_drop(handle); });
151}
152
147153
148struct ms::CursorStreamImageAdapter154struct ms::CursorStreamImageAdapter
149{155{
@@ -590,6 +596,7 @@
590 case mir_window_attrib_dpi: return dpi_;596 case mir_window_attrib_dpi: return dpi_;
591 case mir_window_attrib_visibility: return visibility_;597 case mir_window_attrib_visibility: return visibility_;
592 case mir_window_attrib_preferred_orientation: return pref_orientation_mode;598 case mir_window_attrib_preferred_orientation: return pref_orientation_mode;
599 case mir_window_attrib_drag_and_drop_handle: return 0;
593 default: BOOST_THROW_EXCEPTION(std::logic_error("Invalid surface "600 default: BOOST_THROW_EXCEPTION(std::logic_error("Invalid surface "
594 "attribute."));601 "attribute."));
595 }602 }
@@ -923,3 +930,8 @@
923{930{
924 observers.placed_relative(placement);931 observers.placed_relative(placement);
925}932}
933
934void mir::scene::BasicSurface::start_drag_and_drop(std::vector<uint8_t> const& handle)
935{
936 observers.start_drag_and_drop(handle);
937}
926938
=== modified file 'src/server/scene/basic_surface.h'
--- src/server/scene/basic_surface.h 2017-02-15 14:45:41 +0000
+++ src/server/scene/basic_surface.h 2017-03-14 11:00:58 +0000
@@ -139,6 +139,7 @@
139 void set_confine_pointer_state(MirPointerConfinementState state) override;139 void set_confine_pointer_state(MirPointerConfinementState state) override;
140 MirPointerConfinementState confine_pointer_state() const override;140 MirPointerConfinementState confine_pointer_state() const override;
141 void placed_relative(geometry::Rectangle const& placement) override;141 void placed_relative(geometry::Rectangle const& placement) override;
142 void start_drag_and_drop(std::vector<uint8_t> const& handle) override;
142143
143private:144private:
144 bool visible(std::unique_lock<std::mutex>&) const;145 bool visible(std::unique_lock<std::mutex>&) const;
145146
=== modified file 'src/server/scene/legacy_surface_change_notification.cpp'
--- src/server/scene/legacy_surface_change_notification.cpp 2017-02-15 13:36:35 +0000
+++ src/server/scene/legacy_surface_change_notification.cpp 2017-03-14 11:00:58 +0000
@@ -108,3 +108,7 @@
108void ms::LegacySurfaceChangeNotification::input_consumed(MirEvent const*)108void ms::LegacySurfaceChangeNotification::input_consumed(MirEvent const*)
109{109{
110}110}
111
112void ms::LegacySurfaceChangeNotification::start_drag_and_drop(std::vector<uint8_t> const& /*handle*/)
113{
114}
111\ No newline at end of file115\ No newline at end of file
112116
=== modified file 'src/server/scene/legacy_surface_change_notification.h'
--- src/server/scene/legacy_surface_change_notification.h 2017-02-15 13:36:35 +0000
+++ src/server/scene/legacy_surface_change_notification.h 2017-03-14 11:00:58 +0000
@@ -51,6 +51,7 @@
51 void cursor_image_removed() override;51 void cursor_image_removed() override;
52 void placed_relative(geometry::Rectangle const& placement) override;52 void placed_relative(geometry::Rectangle const& placement) override;
53 void input_consumed(MirEvent const* event) override;53 void input_consumed(MirEvent const* event) override;
54 void start_drag_and_drop(std::vector<uint8_t> const& handle) override;
5455
55private:56private:
56 std::function<void()> const notify_scene_change;57 std::function<void()> const notify_scene_change;
5758
=== modified file 'src/server/scene/null_surface_observer.cpp'
--- src/server/scene/null_surface_observer.cpp 2017-02-15 13:36:35 +0000
+++ src/server/scene/null_surface_observer.cpp 2017-03-14 11:00:58 +0000
@@ -41,3 +41,4 @@
41void ms::NullSurfaceObserver::cursor_image_removed() {}41void ms::NullSurfaceObserver::cursor_image_removed() {}
42void ms::NullSurfaceObserver::placed_relative(geometry::Rectangle const& /*placement*/) {}42void ms::NullSurfaceObserver::placed_relative(geometry::Rectangle const& /*placement*/) {}
43void ms::NullSurfaceObserver::input_consumed(MirEvent const* /*event*/) {}43void ms::NullSurfaceObserver::input_consumed(MirEvent const* /*event*/) {}
44void ms::NullSurfaceObserver::start_drag_and_drop(std::vector<uint8_t> const& /*handle*/) {}
4445
=== modified file 'src/server/scene/surface_event_source.cpp'
--- src/server/scene/surface_event_source.cpp 2017-02-15 13:36:35 +0000
+++ src/server/scene/surface_event_source.cpp 2017-03-14 11:00:58 +0000
@@ -101,3 +101,8 @@
101 mev::set_window_id(*ev, id.as_value());101 mev::set_window_id(*ev, id.as_value());
102 event_sink->handle_event(*ev);102 event_sink->handle_event(*ev);
103}103}
104
105void ms::SurfaceEventSource::start_drag_and_drop(std::vector<uint8_t> const& handle)
106{
107 event_sink->handle_event(*mev::make_start_drag_and_drop_event(id, handle));
108}
104109
=== modified file 'src/server/shell/abstract_shell.cpp'
--- src/server/shell/abstract_shell.cpp 2017-03-10 19:47:57 +0000
+++ src/server/shell/abstract_shell.cpp 2017-03-14 11:00:58 +0000
@@ -251,6 +251,14 @@
251 window_manager->handle_raise_surface(session, surface, timestamp);251 window_manager->handle_raise_surface(session, surface, timestamp);
252}252}
253253
254void msh::AbstractShell::request_drag_and_drop(
255 std::shared_ptr<scene::Session> const& session,
256 std::shared_ptr<scene::Surface> const& surface,
257 uint64_t timestamp)
258{
259 window_manager->handle_request_drag_and_drop(session, surface, timestamp);
260}
261
254void msh::AbstractShell::focus_next_session()262void msh::AbstractShell::focus_next_session()
255{263{
256 std::unique_lock<std::mutex> lock(focus_mutex);264 std::unique_lock<std::mutex> lock(focus_mutex);
@@ -401,3 +409,12 @@
401 report->surfaces_raised(surfaces);409 report->surfaces_raised(surfaces);
402}410}
403411
412void msh::AbstractShell::set_drag_and_drop_handle(std::vector<uint8_t> const& handle)
413{
414 input_targeter->set_drag_and_drop_handle(handle);
415}
416
417void msh::AbstractShell::clear_drag_and_drop_handle()
418{
419 input_targeter->clear_drag_and_drop_handle();
420}
404421
=== modified file 'src/server/shell/basic_window_manager.cpp'
--- src/server/shell/basic_window_manager.cpp 2017-01-18 02:29:37 +0000
+++ src/server/shell/basic_window_manager.cpp 2017-03-14 11:00:58 +0000
@@ -135,6 +135,16 @@
135 policy->handle_raise_surface(session, surface);135 policy->handle_raise_surface(session, surface);
136}136}
137137
138void msh::BasicWindowManager::handle_request_drag_and_drop(
139 std::shared_ptr<scene::Session> const& session,
140 std::shared_ptr<scene::Surface> const& surface,
141 uint64_t timestamp)
142{
143 std::lock_guard<decltype(mutex)> lock(mutex);
144 if (timestamp >= last_input_event_timestamp)
145 policy->handle_request_drag_and_drop(session, surface);
146}
147
138int msh::BasicWindowManager::set_surface_attribute(148int msh::BasicWindowManager::set_surface_attribute(
139 std::shared_ptr<scene::Session> const& /*session*/,149 std::shared_ptr<scene::Session> const& /*session*/,
140 std::shared_ptr<scene::Surface> const& surface,150 std::shared_ptr<scene::Surface> const& surface,
@@ -309,3 +319,14 @@
309 }319 }
310 }320 }
311}321}
322
323void mir::shell::BasicWindowManager::set_drag_and_drop_handle(std::vector<uint8_t> const& handle)
324{
325 focus_controller->set_drag_and_drop_handle(handle);
326}
327
328void mir::shell::BasicWindowManager::clear_drag_and_drop_handle()
329{
330 focus_controller->clear_drag_and_drop_handle();
331}
332
312333
=== modified file 'src/server/shell/canonical_window_manager.cpp'
--- src/server/shell/canonical_window_manager.cpp 2017-03-10 19:47:57 +0000
+++ src/server/shell/canonical_window_manager.cpp 2017-03-14 11:00:58 +0000
@@ -24,6 +24,7 @@
24#include "mir/shell/surface_ready_observer.h"24#include "mir/shell/surface_ready_observer.h"
25#include "mir/shell/display_layout.h"25#include "mir/shell/display_layout.h"
2626
27#include <uuid/uuid.h>
27#include <linux/input.h>28#include <linux/input.h>
28#include <csignal>29#include <csignal>
2930
@@ -583,6 +584,18 @@
583 select_active_surface(surface);584 select_active_surface(surface);
584}585}
585586
587void msh::CanonicalWindowManagerPolicy::handle_request_drag_and_drop(
588 std::shared_ptr<ms::Session> const& /*session*/,
589 std::shared_ptr<ms::Surface> const& surface)
590{
591 uuid_t uuid;
592 uuid_generate(uuid);
593 std::vector<uint8_t> const handle{std::begin(uuid), std::end(uuid)};
594
595 surface->start_drag_and_drop(handle);
596 tools->set_drag_and_drop_handle(handle);
597}
598
586bool msh::CanonicalWindowManagerPolicy::handle_keyboard_event(MirKeyboardEvent const* event)599bool msh::CanonicalWindowManagerPolicy::handle_keyboard_event(MirKeyboardEvent const* event)
587{600{
588 auto const action = mir_keyboard_event_action(event);601 auto const action = mir_keyboard_event_action(event);
589602
=== modified file 'src/server/shell/frontend_shell.cpp'
--- src/server/shell/frontend_shell.cpp 2017-01-18 02:29:37 +0000
+++ src/server/shell/frontend_shell.cpp 2017-03-14 11:00:58 +0000
@@ -157,3 +157,13 @@
157 auto const surface = scene_session->surface(surface_id);157 auto const surface = scene_session->surface(surface_id);
158 wrapped->raise_surface(scene_session, surface, timestamp);158 wrapped->raise_surface(scene_session, surface, timestamp);
159}159}
160
161void msh::FrontendShell::request_drag_and_drop(
162 std::shared_ptr<mf::Session> const& session,
163 mf::SurfaceId surface_id,
164 uint64_t timestamp)
165{
166 auto const scene_session = std::dynamic_pointer_cast<ms::Session>(session);
167 auto const surface = scene_session->surface(surface_id);
168 wrapped->request_drag_and_drop(scene_session, surface, timestamp);
169}
160170
=== modified file 'src/server/shell/frontend_shell.h'
--- src/server/shell/frontend_shell.h 2017-01-18 02:29:37 +0000
+++ src/server/shell/frontend_shell.h 2017-03-14 11:00:58 +0000
@@ -91,6 +91,11 @@
91 std::shared_ptr<mf::Session> const& session,91 std::shared_ptr<mf::Session> const& session,
92 mf::SurfaceId surface_id,92 mf::SurfaceId surface_id,
93 uint64_t timestamp) override;93 uint64_t timestamp) override;
94
95 void request_drag_and_drop(
96 std::shared_ptr<mf::Session> const& session,
97 mf::SurfaceId surface_id,
98 uint64_t timestamp) override;
94};99};
95}100}
96}101}
97102
=== modified file 'src/server/shell/shell_wrapper.cpp'
--- src/server/shell/shell_wrapper.cpp 2017-01-18 02:29:37 +0000
+++ src/server/shell/shell_wrapper.cpp 2017-03-14 11:00:58 +0000
@@ -120,6 +120,14 @@
120 wrapped->raise_surface(session, surface, timestamp);120 wrapped->raise_surface(session, surface, timestamp);
121}121}
122122
123void msh::ShellWrapper::request_drag_and_drop(
124 std::shared_ptr<ms::Session> const& session,
125 std::shared_ptr<ms::Surface> const& surface,
126 uint64_t timestamp)
127{
128 wrapped->request_drag_and_drop(session, surface, timestamp);
129}
130
123void msh::ShellWrapper::add_display(geometry::Rectangle const& area)131void msh::ShellWrapper::add_display(geometry::Rectangle const& area)
124{132{
125 wrapped->add_display(area);133 wrapped->add_display(area);
@@ -149,3 +157,13 @@
149{157{
150 return wrapped->raise(surfaces);158 return wrapped->raise(surfaces);
151}159}
160
161void msh::ShellWrapper::set_drag_and_drop_handle(std::vector<uint8_t> const& handle)
162{
163 wrapped->set_drag_and_drop_handle(handle);
164}
165
166void msh::ShellWrapper::clear_drag_and_drop_handle()
167{
168 wrapped->clear_drag_and_drop_handle();
169}
152170
=== modified file 'src/server/shell/system_compositor_window_manager.cpp'
--- src/server/shell/system_compositor_window_manager.cpp 2017-01-18 02:29:37 +0000
+++ src/server/shell/system_compositor_window_manager.cpp 2017-03-14 11:00:58 +0000
@@ -201,3 +201,10 @@
201 uint64_t /*timestamp*/)201 uint64_t /*timestamp*/)
202{202{
203}203}
204
205void msh::SystemCompositorWindowManager::handle_request_drag_and_drop(
206 std::shared_ptr<ms::Session> const& /*session*/,
207 std::shared_ptr<ms::Surface> const& /*surface*/,
208 uint64_t /*timestamp*/)
209{
210}
204211
=== modified file 'src/server/symbols.map'
--- src/server/symbols.map 2017-03-13 08:12:52 +0000
+++ src/server/symbols.map 2017-03-14 11:00:58 +0000
@@ -130,6 +130,7 @@
130 mir::scene::NullSurfaceObserver::reception_mode_set_to*;130 mir::scene::NullSurfaceObserver::reception_mode_set_to*;
131 mir::scene::NullSurfaceObserver::renamed*;131 mir::scene::NullSurfaceObserver::renamed*;
132 mir::scene::NullSurfaceObserver::resized_to*;132 mir::scene::NullSurfaceObserver::resized_to*;
133 mir::scene::NullSurfaceObserver::start_drag_and_drop*;
133 mir::scene::NullSurfaceObserver::transformation_set_to*;134 mir::scene::NullSurfaceObserver::transformation_set_to*;
134 mir::scene::Observer::?Observer*;135 mir::scene::Observer::?Observer*;
135 mir::scene::Observer::Observer*;136 mir::scene::Observer::Observer*;
@@ -294,6 +295,7 @@
294 mir::shell::ShellReport::ShellReport*;295 mir::shell::ShellReport::ShellReport*;
295 mir::shell::ShellWrapper::add_display*;296 mir::shell::ShellWrapper::add_display*;
296 mir::shell::ShellWrapper::add_prompt_provider_for*;297 mir::shell::ShellWrapper::add_prompt_provider_for*;
298 mir::shell::ShellWrapper::clear_drag_and_drop_handle*;
297 mir::shell::ShellWrapper::close_session*;299 mir::shell::ShellWrapper::close_session*;
298 mir::shell::ShellWrapper::create_surface*;300 mir::shell::ShellWrapper::create_surface*;
299 mir::shell::ShellWrapper::destroy_surface*;301 mir::shell::ShellWrapper::destroy_surface*;
@@ -307,9 +309,11 @@
307 mir::shell::ShellWrapper::raise*;309 mir::shell::ShellWrapper::raise*;
308 mir::shell::ShellWrapper::raise_surface*;310 mir::shell::ShellWrapper::raise_surface*;
309 mir::shell::ShellWrapper::remove_display*;311 mir::shell::ShellWrapper::remove_display*;
312 mir::shell::ShellWrapper::request_drag_and_drop*;
310 mir::shell::ShellWrapper::set_focus_to*;313 mir::shell::ShellWrapper::set_focus_to*;
311 mir::shell::ShellWrapper::set_surface_attribute*;314 mir::shell::ShellWrapper::set_surface_attribute*;
312 mir::shell::ShellWrapper::ShellWrapper*;315 mir::shell::ShellWrapper::ShellWrapper*;
316 mir::shell::ShellWrapper::set_drag_and_drop_handle*;
313 mir::shell::ShellWrapper::start_prompt_session_for*;317 mir::shell::ShellWrapper::start_prompt_session_for*;
314 mir::shell::ShellWrapper::stop_prompt_session*;318 mir::shell::ShellWrapper::stop_prompt_session*;
315 mir::shell::ShellWrapper::surface_at*;319 mir::shell::ShellWrapper::surface_at*;
@@ -339,6 +343,7 @@
339 mir::shell::SystemCompositorWindowManager::remove_display*;343 mir::shell::SystemCompositorWindowManager::remove_display*;
340 mir::shell::SystemCompositorWindowManager::remove_session*;344 mir::shell::SystemCompositorWindowManager::remove_session*;
341 mir::shell::SystemCompositorWindowManager::remove_surface*;345 mir::shell::SystemCompositorWindowManager::remove_surface*;
346 mir::shell::SystemCompositorWindowManager::handle_request_drag_and_drop*;
342 mir::shell::SystemCompositorWindowManager::set_surface_attribute*;347 mir::shell::SystemCompositorWindowManager::set_surface_attribute*;
343 mir::shell::SystemCompositorWindowManager::SystemCompositorWindowManager*;348 mir::shell::SystemCompositorWindowManager::SystemCompositorWindowManager*;
344 mir::shell::WindowManager::operator*;349 mir::shell::WindowManager::operator*;
@@ -696,6 +701,7 @@
696 mir::shell::CanonicalWindowManagerPolicy::handle_touch_event*;701 mir::shell::CanonicalWindowManagerPolicy::handle_touch_event*;
697 mir::shell::CanonicalWindowManagerPolicy::handle_pointer_event*;702 mir::shell::CanonicalWindowManagerPolicy::handle_pointer_event*;
698 mir::shell::CanonicalWindowManagerPolicy::handle_raise_surface*;703 mir::shell::CanonicalWindowManagerPolicy::handle_raise_surface*;
704 mir::shell::CanonicalWindowManagerPolicy::handle_request_drag_and_drop*;
699 typeinfo?for?mir::shell::CanonicalWindowManagerPolicy;705 typeinfo?for?mir::shell::CanonicalWindowManagerPolicy;
700 vtable?for?mir::shell::CanonicalWindowManagerPolicy;706 vtable?for?mir::shell::CanonicalWindowManagerPolicy;
701 VTT?for?mir::shell::CanonicalWindowManagerPolicy;707 VTT?for?mir::shell::CanonicalWindowManagerPolicy;
@@ -832,6 +838,7 @@
832 mir::shell::BasicWindowManager::add_session*;838 mir::shell::BasicWindowManager::add_session*;
833 mir::shell::BasicWindowManager::add_surface*;839 mir::shell::BasicWindowManager::add_surface*;
834 mir::shell::BasicWindowManager::BasicWindowManager*;840 mir::shell::BasicWindowManager::BasicWindowManager*;
841 mir::shell::BasicWindowManager::clear_drag_and_drop_handle*;
835 mir::shell::BasicWindowManager::find_session*;842 mir::shell::BasicWindowManager::find_session*;
836 mir::shell::BasicWindowManager::focused_session*;843 mir::shell::BasicWindowManager::focused_session*;
837 mir::shell::BasicWindowManager::focused_surface*;844 mir::shell::BasicWindowManager::focused_surface*;
@@ -840,6 +847,7 @@
840 mir::shell::BasicWindowManager::handle_keyboard_event*;847 mir::shell::BasicWindowManager::handle_keyboard_event*;
841 mir::shell::BasicWindowManager::handle_pointer_event*;848 mir::shell::BasicWindowManager::handle_pointer_event*;
842 mir::shell::BasicWindowManager::handle_raise_surface*;849 mir::shell::BasicWindowManager::handle_raise_surface*;
850 mir::shell::BasicWindowManager::handle_request_drag_and_drop*;
843 mir::shell::BasicWindowManager::handle_touch_event*;851 mir::shell::BasicWindowManager::handle_touch_event*;
844 mir::shell::BasicWindowManager::info_for*;852 mir::shell::BasicWindowManager::info_for*;
845 mir::shell::BasicWindowManager::modify_surface*;853 mir::shell::BasicWindowManager::modify_surface*;
@@ -847,6 +855,7 @@
847 mir::shell::BasicWindowManager::remove_display*;855 mir::shell::BasicWindowManager::remove_display*;
848 mir::shell::BasicWindowManager::remove_session*;856 mir::shell::BasicWindowManager::remove_session*;
849 mir::shell::BasicWindowManager::remove_surface*;857 mir::shell::BasicWindowManager::remove_surface*;
858 mir::shell::BasicWindowManager::set_drag_and_drop_handle*;
850 mir::shell::BasicWindowManager::set_focus_to*;859 mir::shell::BasicWindowManager::set_focus_to*;
851 mir::shell::BasicWindowManager::set_surface_attribute*;860 mir::shell::BasicWindowManager::set_surface_attribute*;
852 mir::shell::BasicWindowManager::surface_at*;861 mir::shell::BasicWindowManager::surface_at*;
@@ -857,6 +866,7 @@
857 virtual?thunk?to?mir::shell::BasicWindowManager::handle_keyboard_event*;866 virtual?thunk?to?mir::shell::BasicWindowManager::handle_keyboard_event*;
858 virtual?thunk?to?mir::shell::BasicWindowManager::handle_pointer_event*;867 virtual?thunk?to?mir::shell::BasicWindowManager::handle_pointer_event*;
859 virtual?thunk?to?mir::shell::BasicWindowManager::handle_raise_surface*;868 virtual?thunk?to?mir::shell::BasicWindowManager::handle_raise_surface*;
869 virtual?thunk?to?mir::shell::BasicWindowManager::handle_request_drag_and_drop*;
860 virtual?thunk?to?mir::shell::BasicWindowManager::handle_touch_event*;870 virtual?thunk?to?mir::shell::BasicWindowManager::handle_touch_event*;
861 virtual?thunk?to?mir::shell::BasicWindowManager::modify_surface*;871 virtual?thunk?to?mir::shell::BasicWindowManager::modify_surface*;
862 virtual?thunk?to?mir::shell::BasicWindowManager::remove_display*;872 virtual?thunk?to?mir::shell::BasicWindowManager::remove_display*;
863873
=== modified file 'tests/acceptance-tests/CMakeLists.txt'
--- tests/acceptance-tests/CMakeLists.txt 2017-03-10 19:47:57 +0000
+++ tests/acceptance-tests/CMakeLists.txt 2017-03-14 11:00:58 +0000
@@ -3,6 +3,8 @@
3set(3set(
4 SOURCES4 SOURCES
55
6 drag_and_drop.cpp
7
6 # Catch double-free bugs by wrapping close() and abort()ing on EBADF8 # Catch double-free bugs by wrapping close() and abort()ing on EBADF
7 strict_close.cpp9 strict_close.cpp
810
911
=== added file 'tests/acceptance-tests/drag_and_drop.cpp'
--- tests/acceptance-tests/drag_and_drop.cpp 1970-01-01 00:00:00 +0000
+++ tests/acceptance-tests/drag_and_drop.cpp 2017-03-14 11:00:58 +0000
@@ -0,0 +1,293 @@
1/*
2 * Copyright © 2017 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 <mir_toolkit/extensions/drag_and_drop.h>
20#include <mir_toolkit/mir_blob.h>
21
22#include <mir/geometry/displacement.h>
23#include <mir/input/input_device_info.h>
24#include <mir/input/device_capability.h>
25#include <mir/shell/shell.h>
26
27#include <mir_test_framework/connected_client_with_a_window.h>
28#include <mir_test_framework/fake_input_device.h>
29#include <mir_test_framework/stub_server_platform_factory.h>
30#include <mir/test/event_factory.h>
31#include <mir/test/signal.h>
32
33#include <gmock/gmock.h>
34#include <gtest/gtest.h>
35
36#include <linux/input.h>
37
38#include <boost/throw_exception.hpp>
39
40using namespace std::chrono_literals;
41using namespace mir::geometry;
42using namespace testing;
43using mir::test::Signal;
44
45namespace
46{
47class Cookie
48{
49public:
50 Cookie() = default;
51 explicit Cookie(MirCookie const* cookie) : self{cookie, deleter} {}
52
53 operator MirCookie const*() const { return self.get(); }
54 auto get() const -> MirCookie const* { return self.get(); }
55
56 void reset() { self.reset(); }
57 void reset(MirCookie const* cookie) { self.reset(cookie, deleter); }
58
59private:
60 static void deleter(MirCookie const* cookie) { mir_cookie_release(cookie); }
61 std::shared_ptr<MirCookie const> self;
62};
63
64void mir_cookie_release(Cookie const&) = delete;
65
66class Blob
67{
68public:
69 Blob() = default;
70 explicit Blob(MirBlob* blob) : self{blob, deleter} {}
71
72 operator MirBlob*() const { return self.get(); }
73 auto get() const -> MirBlob* { return self.get(); }
74
75 void reset() { self.reset(); }
76 void reset(MirBlob* blob) { self.reset(blob, deleter); }
77
78private:
79 static void deleter(MirBlob* blob) { mir_blob_release(blob); }
80 std::shared_ptr<MirBlob> self;
81};
82
83void mir_blob_release(Blob const&) = delete;
84
85struct MouseMoverAndFaker
86{
87 void start_dragging_mouse()
88 {
89 using namespace mir::input::synthesis;
90 fake_mouse->emit_event(a_button_down_event().of_button(BTN_LEFT));
91 }
92
93 void move_mouse(Displacement const& displacement)
94 {
95 using mir::input::synthesis::a_pointer_event;
96 fake_mouse->emit_event(a_pointer_event().with_movement(displacement.dx.as_int(), displacement.dy.as_int()));
97 }
98
99private:
100 std::unique_ptr<mir_test_framework::FakeInputDevice> fake_mouse{
101 mir_test_framework::add_fake_input_device(
102 mir::input::InputDeviceInfo{"mouse", "mouse-uid", mir::input::DeviceCapability::pointer})};
103};
104
105Rectangle const screen_geometry{{0,0}, {800,600}};
106auto const receive_event_timeout = 90s;
107
108struct DragAndDrop : mir_test_framework::ConnectedClientWithAWindow,
109 MouseMoverAndFaker
110{
111 MirDragAndDropV1 const* dnd = nullptr;
112
113 void SetUp() override
114 {
115 initial_display_layout({screen_geometry});
116 mir_test_framework::ConnectedClientWithAWindow::SetUp();
117
118 dnd = mir_drag_and_drop_v1(connection);
119
120 paint_window();
121 mir_window_set_event_handler(window, &window_event_handler, this);
122
123 center_mouse();
124 }
125
126 void TearDown() override
127 {
128 set_window_event_handler([&](MirWindow*, MirEvent const*) {});
129 mir_test_framework::ConnectedClientWithAWindow::TearDown();
130 }
131
132 auto user_initiates_drag() -> Cookie;
133 auto client_requests_drag(Cookie const& cookie) -> Blob;
134 auto handle_from_mouse_move() -> Blob;
135
136private:
137 void center_mouse() { move_mouse(0.5 * as_displacement(screen_geometry.size)); }
138 void paint_window() const { mir_buffer_stream_swap_buffers_sync(mir_window_get_buffer_stream(window)); }
139 void set_window_event_handler(std::function<void(MirWindow* window, MirEvent const* event)> const& handler);
140
141 void invoke_window_event_handler(MirWindow* window, MirEvent const* event)
142 {
143 std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex};
144 window_event_handler_(window, event);
145 }
146
147 std::mutex window_event_handler_mutex;
148 std::function<void(MirWindow* window, MirEvent const* event)> window_event_handler_ =
149 [](MirWindow*, MirEvent const*) {};
150
151 static void window_event_handler(MirWindow* window, MirEvent const* event, void* context);
152};
153
154void DragAndDrop::set_window_event_handler(std::function<void(MirWindow* window, MirEvent const* event)> const& handler)
155{
156 std::lock_guard<decltype(window_event_handler_mutex)> lock{window_event_handler_mutex};
157 window_event_handler_ = handler;
158}
159
160void DragAndDrop::window_event_handler(MirWindow* window, MirEvent const* event, void* context)
161{
162 static_cast<DragAndDrop*>(context)->invoke_window_event_handler(window, event);
163}
164
165auto DragAndDrop::user_initiates_drag() -> Cookie
166{
167 Cookie cookie;
168 Signal have_cookie;
169
170 set_window_event_handler([&](MirWindow*, MirEvent const* event)
171 {
172 if (mir_event_get_type(event) != mir_event_type_input)
173 return;
174
175 auto const input_event = mir_event_get_input_event(event);
176
177 if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer)
178 return;
179
180 auto const pointer_event = mir_input_event_get_pointer_event(input_event);
181
182 if (mir_pointer_event_action(pointer_event) != mir_pointer_action_button_down)
183 return;
184
185 cookie = Cookie{mir_input_event_get_cookie(input_event)};
186 have_cookie.raise();
187 });
188
189 start_dragging_mouse();
190
191 EXPECT_THAT(have_cookie.wait_for(receive_event_timeout), Eq(true));
192
193 return cookie;
194}
195
196auto DragAndDrop::client_requests_drag(Cookie const& cookie) -> Blob
197{
198 Blob blob;
199 Signal initiated;
200
201 set_window_event_handler([&](MirWindow*, MirEvent const* event)
202 {
203 if (mir_event_get_type(event) != mir_event_type_window)
204 return;
205
206 if (!dnd) return;
207
208 blob.reset(dnd->start_drag_and_drop(mir_event_get_window_event(event)));
209
210 if (blob)
211 initiated.raise();
212 });
213
214 EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension";
215
216 if (dnd)
217 dnd->request_drag_and_drop(window, cookie);
218
219 EXPECT_TRUE(initiated.wait_for(receive_event_timeout));
220
221 return blob;
222}
223
224auto DragAndDrop::handle_from_mouse_move() -> Blob
225{
226 Blob blob;
227 Signal have_blob;
228
229 set_window_event_handler([&](MirWindow*, MirEvent const* event)
230 {
231 if (mir_event_get_type(event) != mir_event_type_input)
232 return;
233
234 auto const input_event = mir_event_get_input_event(event);
235
236 if (mir_input_event_get_type(input_event) != mir_input_event_type_pointer)
237 return;
238
239 auto const pointer_event = mir_input_event_get_pointer_event(input_event);
240
241 EXPECT_THAT(dnd, Ne(nullptr)) << "No Drag and Drop extension";
242
243 if (dnd)
244 blob.reset(dnd->pointer_drag_and_drop(pointer_event));
245
246 if (blob)
247 have_blob.raise();
248 });
249
250 move_mouse({1,1});
251
252 EXPECT_TRUE(have_blob.wait_for(receive_event_timeout));
253 return blob;
254}
255
256MATCHER_P(BlobContentEq, p, "")
257{
258 if (!arg || !p)
259 return false;
260 if (mir_blob_size(arg) != mir_blob_size(p))
261 return false;
262 return !memcmp(mir_blob_data(arg), mir_blob_data(p), mir_blob_size(p));
263}
264}
265
266TEST_F(DragAndDrop, when_user_initiates_drag_client_receives_cookie)
267{
268 auto const cookie = user_initiates_drag();
269
270 EXPECT_THAT(cookie.get(), NotNull());
271}
272
273TEST_F(DragAndDrop, when_client_requests_drags_it_receives_handle)
274{
275 auto const cookie = user_initiates_drag();
276 ASSERT_THAT(cookie.get(), NotNull());
277
278 auto const handle = client_requests_drag(cookie);
279
280 EXPECT_THAT(handle.get(), NotNull());
281}
282
283TEST_F(DragAndDrop, during_drag_when_user_moves_mouse_client_receives_handle)
284{
285 auto const cookie = user_initiates_drag();
286 ASSERT_THAT(cookie.get(), NotNull());
287 auto const handle_from_request = client_requests_drag(cookie);
288
289 auto const handle = handle_from_mouse_move();
290
291 EXPECT_THAT(handle.get(), NotNull());
292 EXPECT_THAT(handle.get(), BlobContentEq(handle_from_request.get()));
293}
0294
=== modified file 'tests/acceptance-tests/test_client_cursor_api.cpp'
--- tests/acceptance-tests/test_client_cursor_api.cpp 2017-02-28 08:53:57 +0000
+++ tests/acceptance-tests/test_client_cursor_api.cpp 2017-03-14 11:00:58 +0000
@@ -82,6 +82,7 @@
82 MOCK_METHOD0(cursor_image_removed, void());82 MOCK_METHOD0(cursor_image_removed, void());
83 MOCK_METHOD1(placed_relative, void(geom::Rectangle const& placement));83 MOCK_METHOD1(placed_relative, void(geom::Rectangle const& placement));
84 MOCK_METHOD1(input_consumed, void(MirEvent const*));84 MOCK_METHOD1(input_consumed, void(MirEvent const*));
85 MOCK_METHOD1(start_drag_and_drop, void(std::vector<uint8_t> const& handle));
85};86};
8687
8788
8889
=== modified file 'tests/include/mir/test/doubles/mock_input_targeter.h'
--- tests/include/mir/test/doubles/mock_input_targeter.h 2015-06-18 02:46:16 +0000
+++ tests/include/mir/test/doubles/mock_input_targeter.h 2017-03-14 11:00:58 +0000
@@ -35,6 +35,9 @@
35 virtual ~MockInputTargeter() noexcept(true) {}35 virtual ~MockInputTargeter() noexcept(true) {}
36 MOCK_METHOD1(set_focus, void(std::shared_ptr<input::Surface> const&));36 MOCK_METHOD1(set_focus, void(std::shared_ptr<input::Surface> const&));
37 MOCK_METHOD0(clear_focus, void());37 MOCK_METHOD0(clear_focus, void());
38
39 void set_drag_and_drop_handle(std::vector<uint8_t> const&) override {}
40 void clear_drag_and_drop_handle() override {}
38};41};
3942
40}43}
4144
=== modified file 'tests/include/mir/test/doubles/mock_shell.h'
--- tests/include/mir/test/doubles/mock_shell.h 2017-01-18 02:29:37 +0000
+++ tests/include/mir/test/doubles/mock_shell.h 2017-03-14 11:00:58 +0000
@@ -72,6 +72,9 @@
7272
73 MOCK_METHOD3(raise_surface, void(std::shared_ptr<frontend::Session> const& session,73 MOCK_METHOD3(raise_surface, void(std::shared_ptr<frontend::Session> const& session,
74 frontend::SurfaceId surface_id, uint64_t timestamp));74 frontend::SurfaceId surface_id, uint64_t timestamp));
75
76 MOCK_METHOD3(request_drag_and_drop, void(std::shared_ptr<frontend::Session> const& session,
77 frontend::SurfaceId surface_id, uint64_t timestamp));
75};78};
7679
77}80}
7881
=== modified file 'tests/include/mir/test/doubles/stub_display_server.h'
--- tests/include/mir/test/doubles/stub_display_server.h 2017-02-15 07:38:33 +0000
+++ tests/include/mir/test/doubles/stub_display_server.h 2017-03-14 11:00:58 +0000
@@ -158,6 +158,10 @@
158 mir::protobuf::RaiseRequest const* /*request*/,158 mir::protobuf::RaiseRequest const* /*request*/,
159 mir::protobuf::Void* /*response*/,159 mir::protobuf::Void* /*response*/,
160 google::protobuf::Closure* /*done*/) {}160 google::protobuf::Closure* /*done*/) {}
161 void request_drag_and_drop(
162 mir::protobuf::RequestAuthority const* /*request*/,
163 mir::protobuf::Void* /*response*/,
164 google::protobuf::Closure* /*done*/) {}
161 void apply_input_configuration(165 void apply_input_configuration(
162 mir::protobuf::InputConfigurationRequest const* /*request*/,166 mir::protobuf::InputConfigurationRequest const* /*request*/,
163 mir::protobuf::Void* /*response*/,167 mir::protobuf::Void* /*response*/,
164168
=== modified file 'tests/include/mir/test/doubles/stub_input_targeter.h'
--- tests/include/mir/test/doubles/stub_input_targeter.h 2015-06-18 02:46:16 +0000
+++ tests/include/mir/test/doubles/stub_input_targeter.h 2017-03-14 11:00:58 +0000
@@ -36,6 +36,9 @@
36 void clear_focus()36 void clear_focus()
37 {37 {
38 }38 }
39
40 void set_drag_and_drop_handle(std::vector<uint8_t> const&) override {}
41 void clear_drag_and_drop_handle() override {}
39};42};
4043
41}44}
4245
=== modified file 'tests/include/mir/test/doubles/stub_scene_surface.h'
--- tests/include/mir/test/doubles/stub_scene_surface.h 2017-02-15 14:45:41 +0000
+++ tests/include/mir/test/doubles/stub_scene_surface.h 2017-03-14 11:00:58 +0000
@@ -94,6 +94,7 @@
94 void set_confine_pointer_state(MirPointerConfinementState /*state*/) override {}94 void set_confine_pointer_state(MirPointerConfinementState /*state*/) override {}
95 MirPointerConfinementState confine_pointer_state() const override { return {}; }95 MirPointerConfinementState confine_pointer_state() const override { return {}; }
96 void placed_relative(geometry::Rectangle const& /*placement*/) override {}96 void placed_relative(geometry::Rectangle const& /*placement*/) override {}
97 void start_drag_and_drop(std::vector<uint8_t> const& /*handle*/) override {}
97};98};
9899
99}100}
100101
=== modified file 'tests/mir_test_framework/observant_shell.cpp'
--- tests/mir_test_framework/observant_shell.cpp 2017-01-20 00:01:50 +0000
+++ tests/mir_test_framework/observant_shell.cpp 2017-03-14 11:00:58 +0000
@@ -155,7 +155,26 @@
155void mtf::ObservantShell::raise_surface(155void mtf::ObservantShell::raise_surface(
156 std::shared_ptr<msc::Session> const& session,156 std::shared_ptr<msc::Session> const& session,
157 std::shared_ptr<msc::Surface> const& window,157 std::shared_ptr<msc::Surface> const& window,
158 uint64_t timestamp)
159{
160 return wrapped->raise_surface(session, window, timestamp);
161}
162
163void mtf::ObservantShell::request_drag_and_drop(
164 std::shared_ptr<msc::Session> const& session,
165 std::shared_ptr<msc::Surface> const& window,
158 uint64_t timestamp) 166 uint64_t timestamp)
159{167{
160 return wrapped->raise_surface(session, window, timestamp);168 return wrapped->request_drag_and_drop(session, window, timestamp);
161}169}
170
171void mtf::ObservantShell::set_drag_and_drop_handle(std::vector<uint8_t> const& handle)
172{
173 wrapped->set_drag_and_drop_handle(handle);
174}
175
176void mtf::ObservantShell::clear_drag_and_drop_handle()
177{
178 wrapped->clear_drag_and_drop_handle();
179}
180
162181
=== modified file 'tests/mir_test_framework/stub_surface.cpp'
--- tests/mir_test_framework/stub_surface.cpp 2017-02-15 14:45:41 +0000
+++ tests/mir_test_framework/stub_surface.cpp 2017-03-14 11:00:58 +0000
@@ -198,6 +198,10 @@
198{198{
199}199}
200200
201void mtd::StubSurface::start_drag_and_drop(std::vector<uint8_t> const& /*handle*/)
202{
203}
204
201namespace205namespace
202{206{
203// Ensure we don't accidentally have an abstract class207// Ensure we don't accidentally have an abstract class
204208
=== modified file 'tests/unit-tests/client/test_client_mir_surface.cpp'
--- tests/unit-tests/client/test_client_mir_surface.cpp 2017-03-10 19:47:57 +0000
+++ tests/unit-tests/client/test_client_mir_surface.cpp 2017-03-14 11:00:58 +0000
@@ -215,7 +215,8 @@
215 { mir_window_attrib_focus, mir_window_focus_state_focused },215 { mir_window_attrib_focus, mir_window_focus_state_focused },
216 { mir_window_attrib_dpi, 19 },216 { mir_window_attrib_dpi, 19 },
217 { mir_window_attrib_visibility, mir_window_visibility_exposed },217 { mir_window_attrib_visibility, mir_window_visibility_exposed },
218 { mir_window_attrib_preferred_orientation, mir_orientation_mode_any }218 { mir_window_attrib_preferred_orientation, mir_orientation_mode_any },
219 { mir_window_attrib_drag_and_drop_handle, 0 }
219};220};
220221
221class TestConnectionConfiguration : public mcl::DefaultConnectionConfiguration222class TestConnectionConfiguration : public mcl::DefaultConnectionConfiguration

Subscribers

People subscribed via source and target branches