Mir

Merge lp:~raof/mir/wayland-touch-support into lp:mir

Proposed by Chris Halse Rogers on 2017-09-26
Status: Merged
Merged at revision: 4272
Proposed branch: lp:~raof/mir/wayland-touch-support
Merge into: lp:mir
Prerequisite: lp:~raof/mir/wayland-clients-close-their-sessions-on-quit
Diff against target: 106 lines (+78/-3)
1 file modified
src/server/frontend/wayland/wayland_connector.cpp (+78/-3)
To merge this branch: bzr merge lp:~raof/mir/wayland-touch-support
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Needs Fixing on 2017-09-27
Alan Griffiths 2017-09-26 Approve on 2017-09-26
Review via email: mp+331368@code.launchpad.net

Commit message

Wayland: Implement touch support.

This is mostly complete - it does not support touchpoint shape/size, but we only expose wl_seat v5 (as that's the version supported by Xenial's wayland) and the size/shape protocol was added in v6 anyway.

Fixes: https://bugs.launchpad.net/mir/+bug/1718732

To post a comment you must log in.
Alan Griffiths (alan-griffiths) wrote :

$ bzr diff
=== modified file 'src/server/frontend/wayland/wayland_connector.cpp'
--- src/server/frontend/wayland/wayland_connector.cpp 2017-09-26 20:56:19 +0000
+++ src/server/frontend/wayland/wayland_connector.cpp 2017-09-26 21:24:57 +0000
@@ -1055,7 +1055,8 @@
         std::shared_ptr<mir::Executor> const& executor)
         : Touch(client, parent, id),
           executor{executor},
- on_destroy{on_destroy}
+ on_destroy{on_destroy},
+ destroyed{std::make_shared<bool>(false)}
     {
     }

review: Needs Fixing
lp:~raof/mir/wayland-touch-support updated on 2017-09-26
4280. By Chris Halse Rogers on 2017-09-26

Wayland: Actually initialise WlTouch's “destroyed” shared_ptr<>

Alan Griffiths (alan-griffiths) wrote :

LGTM

review: Approve
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:4280
https://mir-jenkins.ubuntu.com/job/mir-ci/3696/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/5068/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/5304
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/5292
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/5292
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/5292
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/5112
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/5112/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/5112/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/5112
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/5112/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/5112/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/5112
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/5112/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/5112
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/5112/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/5112
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/5112/artifact/output/*zip*/output.zip
    ABORTED: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/5112/console

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

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/frontend/wayland/wayland_connector.cpp'
2--- src/server/frontend/wayland/wayland_connector.cpp 2017-09-26 21:34:45 +0000
3+++ src/server/frontend/wayland/wayland_connector.cpp 2017-09-26 21:34:45 +0000
4@@ -1055,7 +1055,8 @@
5 std::shared_ptr<mir::Executor> const& executor)
6 : Touch(client, parent, id),
7 executor{executor},
8- on_destroy{on_destroy}
9+ on_destroy{on_destroy},
10+ destroyed{std::make_shared<bool>(false)}
11 {
12 }
13
14@@ -1065,8 +1066,81 @@
15 *destroyed = true;
16 }
17
18- void handle_event(MirInputEvent const* /*event*/, wl_resource* /*target*/)
19+ void handle_event(MirInputEvent const* event, wl_resource* target)
20 {
21+ executor->spawn(run_unless(
22+ destroyed,
23+ [ev = mcl::Event{mir_input_event_get_event(event)}, target = target, this]()
24+ {
25+ auto const input_ev = mir_event_get_input_event(ev);
26+ auto const touch_ev = mir_input_event_get_touch_event(input_ev);
27+
28+ for (auto i = 0u; i < mir_touch_event_point_count(touch_ev); ++i)
29+ {
30+ auto const touch_id = mir_touch_event_id(touch_ev, i);
31+ auto const action = mir_touch_event_action(touch_ev, i);
32+ auto const x = mir_touch_event_axis_value(
33+ touch_ev,
34+ i,
35+ mir_touch_axis_x);
36+ auto const y = mir_touch_event_axis_value(
37+ touch_ev,
38+ i,
39+ mir_touch_axis_y);
40+
41+ switch (action)
42+ {
43+ case mir_touch_action_down:
44+ wl_touch_send_down(
45+ resource,
46+ wl_display_get_serial(wl_client_get_display(client)),
47+ mir_input_event_get_event_time(input_ev) / 1000,
48+ target,
49+ touch_id,
50+ wl_fixed_from_double(x),
51+ wl_fixed_from_double(y));
52+ break;
53+ case mir_touch_action_up:
54+ wl_touch_send_up(
55+ resource,
56+ wl_display_get_serial(wl_client_get_display(client)),
57+ mir_input_event_get_event_time(input_ev) / 1000,
58+ touch_id);
59+ break;
60+ case mir_touch_action_change:
61+ wl_touch_send_motion(
62+ resource,
63+ mir_input_event_get_event_time(input_ev) / 1000,
64+ touch_id,
65+ wl_fixed_from_double(x),
66+ wl_fixed_from_double(y));
67+ break;
68+ case mir_touch_actions:
69+ /*
70+ * We should never receive an event with this action set;
71+ * the only way would be if a *new* action has been added
72+ * to the enum, and this hasn't been updated.
73+ *
74+ * There's nothing to do here, but don't use default: so
75+ * that the compiler will warn if a new enum value is added.
76+ */
77+ break;
78+ }
79+ }
80+
81+ if (mir_touch_event_point_count(touch_ev) > 0)
82+ {
83+ /*
84+ * This is mostly paranoia; I assume we won't actually be called
85+ * with an empty touch event.
86+ *
87+ * Regardless, the Wayland protocol requires that there be at least
88+ * one event sent before we send the ending frame, so make that explicit.
89+ */
90+ wl_touch_send_frame(resource);
91+ }
92+ }
93+ ));
94 }
95
96 // Touch interface
97@@ -1189,7 +1263,8 @@
98 wl_seat_send_capabilities(
99 resource,
100 WL_SEAT_CAPABILITY_POINTER |
101- WL_SEAT_CAPABILITY_KEYBOARD);
102+ WL_SEAT_CAPABILITY_KEYBOARD |
103+ WL_SEAT_CAPABILITY_TOUCH);
104 wl_seat_send_name(
105 resource,
106 "seat0");

Subscribers

People subscribed via source and target branches