Mir

Merge lp:~brandontschaefer/mir/deprecate-input-device-api into lp:mir

Proposed by Brandon Schaefer
Status: Superseded
Proposed branch: lp:~brandontschaefer/mir/deprecate-input-device-api
Merge into: lp:mir
Prerequisite: lp:~vanvugt/mir/common7
Diff against target: 280 lines (+72/-30)
11 files modified
include/client/mir_toolkit/events/input_device_state_event.h (+15/-1)
include/test/mir/test/event_matchers.h (+8/-2)
src/client/event.cpp (+10/-2)
src/client/event_printer.cpp (+4/-4)
src/client/symbols.map (+1/-0)
src/common/events/input_device_state_event.cpp (+2/-2)
src/common/symbols.map (+1/-1)
src/include/common/mir/events/input_device_state_event.h (+1/-1)
src/server/graphics/nested/input_platform.cpp (+6/-2)
tests/unit-tests/input/android/test_android_input_sender.cpp (+8/-6)
tests/unit-tests/input/test_event_builders.cpp (+16/-9)
To merge this branch: bzr merge lp:~brandontschaefer/mir/deprecate-input-device-api
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) Needs Fixing
Alan Griffiths Needs Fixing
Andreas Pokorny (community) Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+306656@code.launchpad.net

This proposal supersedes a proposal from 2016-09-22.

This proposal has been superseded by a proposal from 2016-09-29.

Commit message

Deprecate mir_input_device_state_event_device_pressed_keys for mir_input_device_state_event_device_pressed_keys_for_index

Description of the change

Deprecate

uint32_t const* mir_input_device_state_event_device_pressed_keys

to

uint32_t mir_input_device_state_event_device_pressed_keys_for_index

Issue:
The original one would return a non opaque pointer to a memory location in MirEvent* making it harder to change the underlying structure.

For example moving to capntproto it doesnt allow returning raw pointers from its memory pool. This means we cannot return the uint32_t* required with out extra hacking.

This function was just released in 0.24, and talking with anpok it has not been used. He would be the one using it for qt/gtk.

Since it has not been used, it'll just be easier to return a nullptr vs maintain behaviour that would require extra hacks in capnproto to preserve a uint32_t* for the lifetime of the MirEvent.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:3713
https://mir-jenkins.ubuntu.com/job/mir-ci/1790/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/2240/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2303
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2294
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2294
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2294
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2268/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2268
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2268/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2268
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2268/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/2268
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2268/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/2268
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2268/artifact/output/*zip*/output.zip

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote : Posted in a previous version of this proposal

PASSED: Continuous integration, rev:3715
https://mir-jenkins.ubuntu.com/job/mir-ci/1792/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2242
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2305
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2296
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2296
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2296
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2270
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2270/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/2270
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2270/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2270
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2270/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/2270
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2270/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/2270
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2270/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal

ok..
the old api is not used yet - other than internally.

review: Approve
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal

ok this is breaking the mircommon ABI.. so you would have to have the mircommon7 MP as a prereq.

review: Needs Resubmitting
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote : Posted in a previous version of this proposal

PASSED: Continuous integration, rev:3716
https://mir-jenkins.ubuntu.com/job/mir-ci/1803/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2253
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2316
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2307
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2307
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2307
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2281
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2281/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/2281
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2281/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2281
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2281/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/2281
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2281/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/2281
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2281/artifact/output/*zip*/output.zip

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

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

PASSED: Continuous integration, rev:3716
https://mir-jenkins.ubuntu.com/job/mir-ci/1804/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2254
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2317
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2308
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2308
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2308
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2282
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2282/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/2282
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2282/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2282
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2282/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/2282
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2282/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/2282
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2282/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

lgtm

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

Deprecated functions are still, in principle, supported and working.

If the function is unusable then we shouldn't be deprecating it, we should be *removing* it. (The description claims we can get away with this.)

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Note the prerequisite branch to this is still contentious, so a blocker.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> Deprecated functions are still, in principle, supported and working.
>
> If the function is unusable then we shouldn't be deprecating it, we should be *removing* it. (The description claims we can get away with this.)

+1

Changing the function to return a nullptr is still an ABI break, and an insidious one at that. If we are going to silently break ABI anyway, we should go all the way and remove the function completely.

review: Needs Fixing
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Talking with anpok this function is used (somewhere?). Ill have to talk to him again about it, but just returning a nullptr shouldnt be an ABI break? All the sizes are the same... though unexpected behaviour changes (bad).

Im fine with removing this function but wouldnt this be something we've not broken in a long time?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/client/mir_toolkit/events/input_device_state_event.h'
2--- include/client/mir_toolkit/events/input_device_state_event.h 2016-06-02 15:07:12 +0000
3+++ include/client/mir_toolkit/events/input_device_state_event.h 2016-09-29 18:19:03 +0000
4@@ -100,13 +100,27 @@
5 * Retrieve an array of pressed keys on the device identified by the \a index.
6 * The keys are encoded as scan codes.
7 *
8+ * \deprecated Use mir_input_device_state_event_device_pressed_keys_for_index() instead
9 * \param[in] ev The input device state event
10 * \param[in] index The index of the input device
11- * \return An array of pressed keys
12+ * \return a NULL pointer
13 */
14+__attribute__ ((deprecated))
15 uint32_t const* mir_input_device_state_event_device_pressed_keys(
16 MirInputDeviceStateEvent const* ev, uint32_t index);
17
18+/*
19+ * Retrieve a pressed key on the device identified by the \a index.
20+ * The key is encoded as a scan code.
21+ *
22+ * \param[in] ev The input device state event
23+ * \param[in] index The index of the input device
24+ * \param[in] pressed_index The index of the pressed key
25+ * \return The pressed key at index pressed_index
26+ */
27+uint32_t mir_input_device_state_event_device_pressed_keys_for_index(
28+ MirInputDeviceStateEvent const* ev, uint32_t index, uint32_t pressed_index);
29+
30 /**
31 * Retrieve the size of scan code array of the device identified by the \a index.
32 *
33
34=== modified file 'include/test/mir/test/event_matchers.h'
35--- include/test/mir/test/event_matchers.h 2016-07-04 12:17:44 +0000
36+++ include/test/mir/test/event_matchers.h 2016-09-29 18:19:03 +0000
37@@ -527,8 +527,14 @@
38 if (num_required_keys != key_count)
39 continue;
40
41- auto pressed_keys = mir_input_device_state_event_device_pressed_keys(device_state, index);
42- if (!std::equal(it_keys, end_keys, pressed_keys))
43+ std::vector<uint32_t> pressed_keys;
44+ for (uint32_t i = 0; i < key_count; i++)
45+ {
46+ pressed_keys.push_back(
47+ mir_input_device_state_event_device_pressed_keys_for_index(device_state, index, i));
48+ }
49+
50+ if (!std::equal(it_keys, end_keys, std::begin(pressed_keys)))
51 continue;
52 return true;
53 }
54
55=== modified file 'src/client/event.cpp'
56--- src/client/event.cpp 2016-09-19 04:16:15 +0000
57+++ src/client/event.cpp 2016-09-29 18:19:03 +0000
58@@ -321,11 +321,19 @@
59 return ev->device_id(index);
60 }
61
62-uint32_t const* mir_input_device_state_event_device_pressed_keys(MirInputDeviceStateEvent const* ev, uint32_t index)
63+// Function is deprecated, and no one is currently using it.
64+uint32_t const* mir_input_device_state_event_device_pressed_keys(MirInputDeviceStateEvent const* /*ev*/, uint32_t /*index*/)
65+{
66+ return nullptr;
67+}
68+
69+uint32_t mir_input_device_state_event_device_pressed_keys_for_index(MirInputDeviceStateEvent const* ev,
70+ uint32_t index,
71+ uint32_t pressed_index)
72 {
73 expect_event_type(ev, mir_event_type_input_device_state);
74 expect_index_in_range(ev->device_count(), index);
75- return ev->device_pressed_keys(index);
76+ return ev->device_pressed_keys_for_index(index, pressed_index);
77 }
78
79 uint32_t mir_input_device_state_event_device_pressed_keys_count(MirInputDeviceStateEvent const* ev, uint32_t index)
80
81=== modified file 'src/client/event_printer.cpp'
82--- src/client/event_printer.cpp 2016-09-19 04:16:15 +0000
83+++ src/client/event_printer.cpp 2016-09-29 18:19:03 +0000
84@@ -348,11 +348,11 @@
85 out << mir_input_device_state_event_device_id(&event, index)
86 << " btns=" << mir_input_device_state_event_device_pointer_buttons(&event, index)
87 << " pressed=(";
88- auto keys = mir_input_device_state_event_device_pressed_keys(&event, index);
89- for (size_t count_keys = mir_input_device_state_event_device_pressed_keys_count(&event, index), i = 0; i != count_keys; ++i)
90+ auto key_count = mir_input_device_state_event_device_pressed_keys_count(&event, index);
91+ for (uint32_t i = 0; i < key_count; i++)
92 {
93- out << static_cast<uint32_t>(keys[i]);
94- if (i + 1 < count_keys)
95+ out << mir_input_device_state_event_device_pressed_keys_for_index(&event, index, i);
96+ if (i + 1 < key_count)
97 out << ", ";
98 }
99 out << ")";
100
101=== modified file 'src/client/symbols.map'
102--- src/client/symbols.map 2016-09-29 12:26:11 +0000
103+++ src/client/symbols.map 2016-09-29 18:19:03 +0000
104@@ -433,6 +433,7 @@
105 mir_surface_placement_get_relative_position;
106 mir_display_output_type_name;
107 mir_output_type_name;
108+ mir_input_device_state_event_device_pressed_keys_for_index;
109 } MIR_CLIENT_0.24;
110
111 MIR_CLIENT_DETAIL_0.26 {
112
113=== modified file 'src/common/events/input_device_state_event.cpp'
114--- src/common/events/input_device_state_event.cpp 2016-05-26 20:59:38 +0000
115+++ src/common/events/input_device_state_event.cpp 2016-09-29 18:19:03 +0000
116@@ -98,9 +98,9 @@
117 return devices[index].id;
118 }
119
120-uint32_t const* MirInputDeviceStateEvent::device_pressed_keys(size_t index) const
121+uint32_t MirInputDeviceStateEvent::device_pressed_keys_for_index(size_t index, size_t pressed_index) const
122 {
123- return devices[index].pressed_keys.data();
124+ return devices[index].pressed_keys[pressed_index];
125 }
126
127 uint32_t MirInputDeviceStateEvent::device_pressed_keys_count(size_t index) const
128
129=== modified file 'src/common/symbols.map'
130--- src/common/symbols.map 2016-09-27 08:57:34 +0000
131+++ src/common/symbols.map 2016-09-29 18:19:03 +0000
132@@ -363,7 +363,6 @@
133 MirInputDeviceStateEvent::device_count*;
134 MirInputDeviceStateEvent::device_id*;
135 MirInputDeviceStateEvent::device_pointer_buttons*;
136- MirInputDeviceStateEvent::device_pressed_keys*;
137 MirInputDeviceStateEvent::device_pressed_keys_count*;
138 MirInputDeviceStateEvent::modifiers*;
139 MirInputDeviceStateEvent::pointer_axis*;
140@@ -401,6 +400,7 @@
141 MirSurfacePlacementEvent::set_id*;
142 MirSurfacePlacementEvent::placement*;
143 MirSurfacePlacementEvent::set_placement*;
144+ MirInputDeviceStateEvent::device_pressed_keys_for_index*;
145 mir::output_type_name*;
146 };
147 } MIR_COMMON_0.24;
148
149=== modified file 'src/include/common/mir/events/input_device_state_event.h'
150--- src/include/common/mir/events/input_device_state_event.h 2016-05-26 20:59:38 +0000
151+++ src/include/common/mir/events/input_device_state_event.h 2016-09-29 18:19:03 +0000
152@@ -43,7 +43,7 @@
153 uint32_t device_count() const;
154 MirInputDeviceId device_id(size_t index) const;
155 MirPointerButtons device_pointer_buttons(size_t index) const;
156- uint32_t const* device_pressed_keys(size_t index) const;
157+ uint32_t device_pressed_keys_for_index(size_t index, size_t pressed_index) const;
158 uint32_t device_pressed_keys_count(size_t index) const;
159
160 static mir::EventUPtr deserialize(std::string const& bytes);
161
162=== modified file 'src/server/graphics/nested/input_platform.cpp'
163--- src/server/graphics/nested/input_platform.cpp 2016-09-01 12:28:46 +0000
164+++ src/server/graphics/nested/input_platform.cpp 2016-09-29 18:19:03 +0000
165@@ -247,9 +247,13 @@
166 {
167 auto dest = it->second->destination;
168 auto key_count = mir_input_device_state_event_device_pressed_keys_count(device_state, index);
169- auto const* scan_codes = mir_input_device_state_event_device_pressed_keys(device_state, index);
170+ std::vector<uint32_t> scan_codes;
171+ for (uint32_t i = 0; i < key_count; i++)
172+ {
173+ scan_codes.push_back(mir_input_device_state_event_device_pressed_keys_for_index(device_state, index, i));
174+ }
175
176- dest->key_state({scan_codes, scan_codes + key_count});
177+ dest->key_state(scan_codes);
178 dest->pointer_state(
179 mir_input_device_state_event_device_pointer_buttons(device_state, index));
180 }
181
182=== modified file 'tests/unit-tests/input/android/test_android_input_sender.cpp'
183--- tests/unit-tests/input/android/test_android_input_sender.cpp 2016-06-07 21:10:34 +0000
184+++ tests/unit-tests/input/android/test_android_input_sender.cpp 2016-09-29 18:19:03 +0000
185@@ -503,7 +503,8 @@
186 const auto timestamp = std::chrono::nanoseconds(10);
187 register_surface();
188 std::vector<mir::events::InputDeviceState> states;
189- states.push_back({MirInputDeviceId{23}, {50, 60, 80}, 0});
190+ std::vector<uint32_t> const pressed_keys = {50, 60, 80};
191+ states.push_back({MirInputDeviceId{23}, pressed_keys, 0});
192 states.push_back({MirInputDeviceId{21}, {}, mir_pointer_button_primary});
193
194 auto device_state = mir::events::make_event(timestamp, mir_pointer_button_primary, mir_input_event_modifier_caps_lock,
195@@ -520,12 +521,13 @@
196 EXPECT_THAT(mir_input_device_state_event_time(input_device_state), Eq(timestamp.count()));
197 EXPECT_THAT(mir_input_device_state_event_modifiers(input_device_state), Eq(mir_input_event_modifier_caps_lock));
198 EXPECT_THAT(mir_input_device_state_event_device_count(input_device_state), Eq(2));
199-
200 EXPECT_THAT(mir_input_device_state_event_device_id(input_device_state, 0), Eq(MirInputDeviceId{23}));
201- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_count(input_device_state, 0), Eq(3));
202- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(input_device_state, 0)[0], Eq(50));
203- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(input_device_state, 0)[1], Eq(60));
204- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(input_device_state, 0)[2], Eq(80));
205+ auto keys_count = mir_input_device_state_event_device_pressed_keys_count(input_device_state, 0);
206+ EXPECT_THAT(keys_count, Eq(3));
207+ for (uint32_t i = 0; i < keys_count; i++)
208+ {
209+ EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_for_index(input_device_state, 0, i), Eq(pressed_keys[i]));
210+ }
211 EXPECT_THAT(mir_input_device_state_event_device_pointer_buttons(input_device_state, 0), 0);
212
213 EXPECT_THAT(mir_input_device_state_event_device_id(input_device_state, 1), Eq(MirInputDeviceId{21}));
214
215=== modified file 'tests/unit-tests/input/test_event_builders.cpp'
216--- tests/unit-tests/input/test_event_builders.cpp 2016-05-26 20:59:38 +0000
217+++ tests/unit-tests/input/test_event_builders.cpp 2016-09-29 18:19:03 +0000
218@@ -189,12 +189,13 @@
219 auto const pos_y = 53.2f;
220 auto const button_state = mir_pointer_button_primary|mir_pointer_button_secondary;
221 auto const modifiers = mir_input_event_modifier_ctrl_right | mir_input_event_modifier_ctrl;
222+ std::vector<uint32_t> const pressed_keys = {KEY_LEFTALT, KEY_M};
223 auto ev = mev::make_event(timestamp,
224 button_state,
225 modifiers,
226 pos_x,
227 pos_y,
228- {mev::InputDeviceState{MirInputDeviceId{3}, {KEY_LEFTALT, KEY_M}, 0},
229+ {mev::InputDeviceState{MirInputDeviceId{3}, pressed_keys, 0},
230 mev::InputDeviceState{MirInputDeviceId{2}, {}, button_state}});
231
232 EXPECT_THAT(mir_event_get_type(ev.get()), Eq(mir_event_type_input_device_state));
233@@ -208,9 +209,12 @@
234 EXPECT_THAT(mir_input_device_state_event_device_count(ids_event), Eq(2));
235
236 EXPECT_THAT(mir_input_device_state_event_device_id(ids_event, 0), Eq(MirInputDeviceId{3}));
237- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_count(ids_event, 0), Eq(2));
238- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(ids_event, 0)[0], Eq(KEY_LEFTALT));
239- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(ids_event, 0)[1], Eq(KEY_M));
240+ auto const pressed_keys_count = mir_input_device_state_event_device_pressed_keys_count(ids_event, 0);
241+ EXPECT_THAT(pressed_keys_count, Eq(2));
242+ for (uint32_t i = 0; i < pressed_keys_count; i++)
243+ {
244+ EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_for_index(ids_event, 0, i), Eq(pressed_keys[i]));
245+ }
246 EXPECT_THAT(mir_input_device_state_event_device_pointer_buttons(ids_event, 0), Eq(0));
247
248 EXPECT_THAT(mir_input_device_state_event_device_id(ids_event, 1), Eq(MirInputDeviceId{2}));
249@@ -252,6 +256,7 @@
250 auto const pos_y = 0.0f;
251 auto const button_state = mir_pointer_button_primary | mir_pointer_button_secondary;
252 auto const modifiers = mir_input_event_modifier_none;
253+ std::vector<uint32_t> const pressed_keys = {KEY_RIGHTALT, KEY_LEFTSHIFT, KEY_Q};
254 auto ev = mev::make_event(timestamp,
255 button_state,
256 modifiers,
257@@ -259,7 +264,7 @@
258 pos_y,
259 {mev::InputDeviceState{MirInputDeviceId{0}, {}, mir_pointer_button_primary},
260 mev::InputDeviceState{MirInputDeviceId{2}, {}, mir_pointer_button_secondary},
261- mev::InputDeviceState{MirInputDeviceId{3}, {KEY_RIGHTALT, KEY_LEFTSHIFT, KEY_Q}, 0}});
262+ mev::InputDeviceState{MirInputDeviceId{3}, pressed_keys, 0}});
263
264 auto encoded = MirEvent::serialize(ev.get());
265
266@@ -269,8 +274,10 @@
267 auto ids_event = mir_event_get_input_device_state_event(deserialzed_event.get());
268
269 EXPECT_THAT(mir_input_device_state_event_device_count(ids_event), Eq(3));
270- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_count(ids_event, 2), Eq(3));
271- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(ids_event, 2)[0], Eq(KEY_RIGHTALT));
272- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(ids_event, 2)[1], Eq(KEY_LEFTSHIFT));
273- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(ids_event, 2)[2], Eq(KEY_Q));
274+ auto pressed_keys_count = mir_input_device_state_event_device_pressed_keys_count(ids_event, 2);
275+ EXPECT_THAT(pressed_keys_count, Eq(3));
276+ for (uint32_t i = 0; i < pressed_keys_count; i++)
277+ {
278+ EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_for_index(ids_event, 2, i), Eq(pressed_keys[i]));
279+ }
280 }

Subscribers

People subscribed via source and target branches