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
Diff against target: 441 lines (+90/-81)
14 files modified
debian/control (+2/-2)
debian/libmircommon7.install (+1/-1)
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/CMakeLists.txt (+1/-1)
src/common/events/input_device_state_event.cpp (+2/-2)
src/common/symbols.map (+15/-48)
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
Mir CI Bot continuous-integration Approve
Andreas Pokorny (community) Needs Resubmitting
Review via email: mp+306532@code.launchpad.net

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

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 :

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 :

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 :

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

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

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 :

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)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2016-09-12 11:49:12 +0000
3+++ debian/control 2016-09-23 17:21:20 +0000
4@@ -101,7 +101,7 @@
5 Architecture: linux-any
6 Multi-Arch: same
7 Pre-Depends: ${misc:Pre-Depends}
8-Depends: libmircommon6 (= ${binary:Version}),
9+Depends: libmircommon7 (= ${binary:Version}),
10 libprotobuf-dev (>= 2.4.1),
11 libxkbcommon-dev,
12 ${misc:Depends},
13@@ -290,7 +290,7 @@
14 .
15 Contains a tool for checking the graphics components of android devices.
16
17-Package: libmircommon6
18+Package: libmircommon7
19 Section: libs
20 Architecture: linux-any
21 Multi-Arch: same
22
23=== renamed file 'debian/libmircommon6.install' => 'debian/libmircommon7.install'
24--- debian/libmircommon6.install 2016-06-27 18:09:48 +0000
25+++ debian/libmircommon7.install 2016-09-23 17:21:20 +0000
26@@ -1,1 +1,1 @@
27-usr/lib/*/libmircommon.so.6
28+usr/lib/*/libmircommon.so.7
29
30=== modified file 'include/client/mir_toolkit/events/input_device_state_event.h'
31--- include/client/mir_toolkit/events/input_device_state_event.h 2016-06-02 15:07:12 +0000
32+++ include/client/mir_toolkit/events/input_device_state_event.h 2016-09-23 17:21:20 +0000
33@@ -100,13 +100,27 @@
34 * Retrieve an array of pressed keys on the device identified by the \a index.
35 * The keys are encoded as scan codes.
36 *
37+ * \deprecated Use mir_input_device_state_event_device_pressed_keys_for_index() instead
38 * \param[in] ev The input device state event
39 * \param[in] index The index of the input device
40- * \return An array of pressed keys
41+ * \return a NULL pointer
42 */
43+__attribute__ ((deprecated))
44 uint32_t const* mir_input_device_state_event_device_pressed_keys(
45 MirInputDeviceStateEvent const* ev, uint32_t index);
46
47+/*
48+ * Retrieve a pressed key on the device identified by the \a index.
49+ * The key is encoded as a scan code.
50+ *
51+ * \param[in] ev The input device state event
52+ * \param[in] index The index of the input device
53+ * \param[in] pressed_index The index of the pressed key
54+ * \return The pressed key at index pressed_index
55+ */
56+uint32_t mir_input_device_state_event_device_pressed_keys_for_index(
57+ MirInputDeviceStateEvent const* ev, uint32_t index, uint32_t pressed_index);
58+
59 /**
60 * Retrieve the size of scan code array of the device identified by the \a index.
61 *
62
63=== modified file 'include/test/mir/test/event_matchers.h'
64--- include/test/mir/test/event_matchers.h 2016-07-04 12:17:44 +0000
65+++ include/test/mir/test/event_matchers.h 2016-09-23 17:21:20 +0000
66@@ -527,8 +527,14 @@
67 if (num_required_keys != key_count)
68 continue;
69
70- auto pressed_keys = mir_input_device_state_event_device_pressed_keys(device_state, index);
71- if (!std::equal(it_keys, end_keys, pressed_keys))
72+ std::vector<uint32_t> pressed_keys;
73+ for (uint32_t i = 0; i < key_count; i++)
74+ {
75+ pressed_keys.push_back(
76+ mir_input_device_state_event_device_pressed_keys_for_index(device_state, index, i));
77+ }
78+
79+ if (!std::equal(it_keys, end_keys, std::begin(pressed_keys)))
80 continue;
81 return true;
82 }
83
84=== modified file 'src/client/event.cpp'
85--- src/client/event.cpp 2016-09-19 04:16:15 +0000
86+++ src/client/event.cpp 2016-09-23 17:21:20 +0000
87@@ -321,11 +321,19 @@
88 return ev->device_id(index);
89 }
90
91-uint32_t const* mir_input_device_state_event_device_pressed_keys(MirInputDeviceStateEvent const* ev, uint32_t index)
92+// Function is deprecated, and no one is currently using it.
93+uint32_t const* mir_input_device_state_event_device_pressed_keys(MirInputDeviceStateEvent const* /*ev*/, uint32_t /*index*/)
94+{
95+ return nullptr;
96+}
97+
98+uint32_t mir_input_device_state_event_device_pressed_keys_for_index(MirInputDeviceStateEvent const* ev,
99+ uint32_t index,
100+ uint32_t pressed_index)
101 {
102 expect_event_type(ev, mir_event_type_input_device_state);
103 expect_index_in_range(ev->device_count(), index);
104- return ev->device_pressed_keys(index);
105+ return ev->device_pressed_keys_for_index(index, pressed_index);
106 }
107
108 uint32_t mir_input_device_state_event_device_pressed_keys_count(MirInputDeviceStateEvent const* ev, uint32_t index)
109
110=== modified file 'src/client/event_printer.cpp'
111--- src/client/event_printer.cpp 2016-09-19 04:16:15 +0000
112+++ src/client/event_printer.cpp 2016-09-23 17:21:20 +0000
113@@ -348,11 +348,11 @@
114 out << mir_input_device_state_event_device_id(&event, index)
115 << " btns=" << mir_input_device_state_event_device_pointer_buttons(&event, index)
116 << " pressed=(";
117- auto keys = mir_input_device_state_event_device_pressed_keys(&event, index);
118- for (size_t count_keys = mir_input_device_state_event_device_pressed_keys_count(&event, index), i = 0; i != count_keys; ++i)
119+ auto key_count = mir_input_device_state_event_device_pressed_keys_count(&event, index);
120+ for (uint32_t i = 0; i < key_count; i++)
121 {
122- out << static_cast<uint32_t>(keys[i]);
123- if (i + 1 < count_keys)
124+ out << mir_input_device_state_event_device_pressed_keys_for_index(&event, index, i);
125+ if (i + 1 < key_count)
126 out << ", ";
127 }
128 out << ")";
129
130=== modified file 'src/client/symbols.map'
131--- src/client/symbols.map 2016-09-19 09:05:08 +0000
132+++ src/client/symbols.map 2016-09-23 17:21:20 +0000
133@@ -432,5 +432,6 @@
134 mir_surface_placement_get_relative_position;
135 mir_display_output_type_name;
136 mir_output_type_name;
137+ mir_input_device_state_event_device_pressed_keys_for_index;
138 } MIR_CLIENT_0.24;
139
140
141=== modified file 'src/common/CMakeLists.txt'
142--- src/common/CMakeLists.txt 2016-09-19 04:16:15 +0000
143+++ src/common/CMakeLists.txt 2016-09-23 17:21:20 +0000
144@@ -37,7 +37,7 @@
145 PARENT_SCOPE)
146
147 # TODO we need a place to manage ABI and related versioning but use this as placeholder
148-set(MIRCOMMON_ABI 6)
149+set(MIRCOMMON_ABI 7)
150 set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)
151
152 add_library(mircommon SHARED
153
154=== modified file 'src/common/events/input_device_state_event.cpp'
155--- src/common/events/input_device_state_event.cpp 2016-05-26 20:59:38 +0000
156+++ src/common/events/input_device_state_event.cpp 2016-09-23 17:21:20 +0000
157@@ -98,9 +98,9 @@
158 return devices[index].id;
159 }
160
161-uint32_t const* MirInputDeviceStateEvent::device_pressed_keys(size_t index) const
162+uint32_t MirInputDeviceStateEvent::device_pressed_keys_for_index(size_t index, size_t pressed_index) const
163 {
164- return devices[index].pressed_keys.data();
165+ return devices[index].pressed_keys[pressed_index];
166 }
167
168 uint32_t MirInputDeviceStateEvent::device_pressed_keys_count(size_t index) const
169
170=== modified file 'src/common/symbols.map'
171--- src/common/symbols.map 2016-09-19 04:16:15 +0000
172+++ src/common/symbols.map 2016-09-23 17:21:20 +0000
173@@ -1,5 +1,8 @@
174-MIR_COMMON_5 {
175+MIR_COMMON_0.25 {
176 global:
177+ __android_log_assert;
178+ __android_log_print;
179+ systemTime;
180 extern "C++" {
181 # The following symbols come from running a script over the generated docs. Vis:
182 # ../tools/process_doxygen_xml.py doc/xml/*.xml | grep "^mircommon public" | sed "s/mircommon public: / /" | sort
183@@ -111,7 +114,6 @@
184 mir::default_server_socket;
185 mir::libraries_for_path*;
186 mir::logging::input_timestamp*;
187- mir::logging::log*;
188 mir::logging::SharedLibraryProberReport::SharedLibraryProberReport*;
189 mir::RecursiveReadLock::?RecursiveReadLock*;
190 mir::RecursiveReadLock::RecursiveReadLock*;
191@@ -139,16 +141,8 @@
192
193 mir::SignalBlocker::SignalBlocker*;
194 mir::SignalBlocker::?SignalBlocker*;
195- };
196-};
197
198-MIR_COMMON_5.1 { # New functions in Mir 0.16
199- global:
200- __android_log_assert;
201- __android_log_print;
202- systemTime;
203- toMillisecondTimeoutDelay;
204- extern "C++" {
205+# New functions in Mir 0.16
206 android::InputChannel::InputChannel*;
207 android::InputChannel::openInputFdPair*;
208 android::InputConsumer::consume*;
209@@ -170,10 +164,8 @@
210 android::IntSet::remove*;
211 android::KeyEvent::initialize*;
212 android::MotionEvent::getAxisValue*;
213- android::MotionEvent::getAxisValue*;
214 android::MotionEvent::getHistoricalAxisValue*;
215 android::MotionEvent::getRawAxisValue*;
216- android::MotionEvent::getRawAxisValue*;
217 android::PointerCoords::copyFrom*;
218 android::PointerCoords::getAxisValue*;
219 android::PointerCoords::operator*;
220@@ -191,37 +183,21 @@
221 mir::write_to_log;
222 typeinfo?for?android::RefBase;
223 vtable?for?android::IntSet;
224- mir::dispatch::ReadableFd::ReadableFd*;
225- mir::dispatch::ReadableFd::?ReadableFd*;
226- mir::dispatch::ReadableFd::watch_fd*;
227- mir::dispatch::ReadableFd::dispatch*;
228- mir::dispatch::ReadableFd::relevant_events*;
229+ vtable?for?mir::dispatch::ReadableFd;
230+ mir::dispatch::ReadableFd*;
231 mir::logger::Logger::log*;
232- };
233- local: *;
234-} MIR_COMMON_5;
235
236-MIR_COMMON_5v19 { # New functions in Mir 0.19.0
237- global:
238- extern "C++" {
239+# New functions in Mir 0.19.0
240 typeinfo?for?mir::logging::SharedLibraryProberReport;
241 typeinfo?for?mir::time::SteadyClock;
242 typeinfo?for?android::InputChannel;
243 typeinfo?for?mir::logging::DumbConsoleLogger;
244 mir::detail::libname_impl*;
245- };
246-} MIR_COMMON_5.1;
247
248-MIR_COMMON_0.19.1 { # New functions in Mir 0.19.1
249- global:
250- extern "C++" {
251+# New functions in Mir 0.19.1
252 mir::select_libraries_for_path*;
253- };
254-} MIR_COMMON_5v19; # <- Note Mir 0.19.0 used the wrong syntax
255
256-MIR_COMMON_0.22 {
257- global:
258- extern "C++" {
259+# New functions in Mir 0.22
260 MirEvent::to_surface*;
261 MirEvent::to_resize*;
262 MirEvent::to_orientation*;
263@@ -351,12 +327,8 @@
264 MirPromptSessionEvent::MirPromptSessionEvent*;
265 MirPromptSessionEvent::new_state*;
266 MirPromptSessionEvent::set_new_state*;
267- };
268-} MIR_COMMON_0.19.1;
269
270-MIR_COMMON_0.24 {
271- global:
272- extern "C++" {
273+# New functions in Mir 0.24
274 android::InputPublisher::publishEventBuffer*;
275 MirEvent::to_input_device_state*;
276 MirInputDeviceStateEvent::MirInputDeviceStateEvent*;
277@@ -366,7 +338,6 @@
278 MirInputDeviceStateEvent::device_count*;
279 MirInputDeviceStateEvent::device_id*;
280 MirInputDeviceStateEvent::device_pointer_buttons*;
281- MirInputDeviceStateEvent::device_pressed_keys*;
282 MirInputDeviceStateEvent::device_pressed_keys_count*;
283 MirInputDeviceStateEvent::modifiers*;
284 MirInputDeviceStateEvent::pointer_axis*;
285@@ -382,19 +353,15 @@
286 android::MotionEvent::initialize*;
287 mir::dispatch::epoll_to_fd_event*;
288 mir::dispatch::fd_event_to_epoll*;
289- mir::dispatch::ReadableFd*;
290- vtable?for?mir::dispatch::ReadableFd;
291- };
292-} MIR_COMMON_0.22;
293
294-MIR_COMMON_0.25 {
295- global:
296- extern "C++" {
297+# New functions in Mir 0.25
298 MirSurfacePlacementEvent::MirSurfacePlacementEvent*;
299 MirSurfacePlacementEvent::id*;
300 MirSurfacePlacementEvent::set_id*;
301 MirSurfacePlacementEvent::placement*;
302 MirSurfacePlacementEvent::set_placement*;
303+ MirInputDeviceStateEvent::device_pressed_keys_for_index*;
304 mir::output_type_name*;
305 };
306-} MIR_COMMON_0.24;
307+ local: *;
308+};
309
310=== modified file 'src/include/common/mir/events/input_device_state_event.h'
311--- src/include/common/mir/events/input_device_state_event.h 2016-05-26 20:59:38 +0000
312+++ src/include/common/mir/events/input_device_state_event.h 2016-09-23 17:21:20 +0000
313@@ -43,7 +43,7 @@
314 uint32_t device_count() const;
315 MirInputDeviceId device_id(size_t index) const;
316 MirPointerButtons device_pointer_buttons(size_t index) const;
317- uint32_t const* device_pressed_keys(size_t index) const;
318+ uint32_t device_pressed_keys_for_index(size_t index, size_t pressed_index) const;
319 uint32_t device_pressed_keys_count(size_t index) const;
320
321 static mir::EventUPtr deserialize(std::string const& bytes);
322
323=== modified file 'src/server/graphics/nested/input_platform.cpp'
324--- src/server/graphics/nested/input_platform.cpp 2016-09-01 12:28:46 +0000
325+++ src/server/graphics/nested/input_platform.cpp 2016-09-23 17:21:20 +0000
326@@ -247,9 +247,13 @@
327 {
328 auto dest = it->second->destination;
329 auto key_count = mir_input_device_state_event_device_pressed_keys_count(device_state, index);
330- auto const* scan_codes = mir_input_device_state_event_device_pressed_keys(device_state, index);
331+ std::vector<uint32_t> scan_codes;
332+ for (uint32_t i = 0; i < key_count; i++)
333+ {
334+ scan_codes.push_back(mir_input_device_state_event_device_pressed_keys_for_index(device_state, index, i));
335+ }
336
337- dest->key_state({scan_codes, scan_codes + key_count});
338+ dest->key_state(scan_codes);
339 dest->pointer_state(
340 mir_input_device_state_event_device_pointer_buttons(device_state, index));
341 }
342
343=== modified file 'tests/unit-tests/input/android/test_android_input_sender.cpp'
344--- tests/unit-tests/input/android/test_android_input_sender.cpp 2016-06-07 21:10:34 +0000
345+++ tests/unit-tests/input/android/test_android_input_sender.cpp 2016-09-23 17:21:20 +0000
346@@ -503,7 +503,8 @@
347 const auto timestamp = std::chrono::nanoseconds(10);
348 register_surface();
349 std::vector<mir::events::InputDeviceState> states;
350- states.push_back({MirInputDeviceId{23}, {50, 60, 80}, 0});
351+ std::vector<uint32_t> const pressed_keys = {50, 60, 80};
352+ states.push_back({MirInputDeviceId{23}, pressed_keys, 0});
353 states.push_back({MirInputDeviceId{21}, {}, mir_pointer_button_primary});
354
355 auto device_state = mir::events::make_event(timestamp, mir_pointer_button_primary, mir_input_event_modifier_caps_lock,
356@@ -520,12 +521,13 @@
357 EXPECT_THAT(mir_input_device_state_event_time(input_device_state), Eq(timestamp.count()));
358 EXPECT_THAT(mir_input_device_state_event_modifiers(input_device_state), Eq(mir_input_event_modifier_caps_lock));
359 EXPECT_THAT(mir_input_device_state_event_device_count(input_device_state), Eq(2));
360-
361 EXPECT_THAT(mir_input_device_state_event_device_id(input_device_state, 0), Eq(MirInputDeviceId{23}));
362- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_count(input_device_state, 0), Eq(3));
363- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(input_device_state, 0)[0], Eq(50));
364- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(input_device_state, 0)[1], Eq(60));
365- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(input_device_state, 0)[2], Eq(80));
366+ auto keys_count = mir_input_device_state_event_device_pressed_keys_count(input_device_state, 0);
367+ EXPECT_THAT(keys_count, Eq(3));
368+ for (uint32_t i = 0; i < keys_count; i++)
369+ {
370+ EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_for_index(input_device_state, 0, i), Eq(pressed_keys[i]));
371+ }
372 EXPECT_THAT(mir_input_device_state_event_device_pointer_buttons(input_device_state, 0), 0);
373
374 EXPECT_THAT(mir_input_device_state_event_device_id(input_device_state, 1), Eq(MirInputDeviceId{21}));
375
376=== modified file 'tests/unit-tests/input/test_event_builders.cpp'
377--- tests/unit-tests/input/test_event_builders.cpp 2016-05-26 20:59:38 +0000
378+++ tests/unit-tests/input/test_event_builders.cpp 2016-09-23 17:21:20 +0000
379@@ -189,12 +189,13 @@
380 auto const pos_y = 53.2f;
381 auto const button_state = mir_pointer_button_primary|mir_pointer_button_secondary;
382 auto const modifiers = mir_input_event_modifier_ctrl_right | mir_input_event_modifier_ctrl;
383+ std::vector<uint32_t> const pressed_keys = {KEY_LEFTALT, KEY_M};
384 auto ev = mev::make_event(timestamp,
385 button_state,
386 modifiers,
387 pos_x,
388 pos_y,
389- {mev::InputDeviceState{MirInputDeviceId{3}, {KEY_LEFTALT, KEY_M}, 0},
390+ {mev::InputDeviceState{MirInputDeviceId{3}, pressed_keys, 0},
391 mev::InputDeviceState{MirInputDeviceId{2}, {}, button_state}});
392
393 EXPECT_THAT(mir_event_get_type(ev.get()), Eq(mir_event_type_input_device_state));
394@@ -208,9 +209,12 @@
395 EXPECT_THAT(mir_input_device_state_event_device_count(ids_event), Eq(2));
396
397 EXPECT_THAT(mir_input_device_state_event_device_id(ids_event, 0), Eq(MirInputDeviceId{3}));
398- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_count(ids_event, 0), Eq(2));
399- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(ids_event, 0)[0], Eq(KEY_LEFTALT));
400- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(ids_event, 0)[1], Eq(KEY_M));
401+ auto const pressed_keys_count = mir_input_device_state_event_device_pressed_keys_count(ids_event, 0);
402+ EXPECT_THAT(pressed_keys_count, Eq(2));
403+ for (uint32_t i = 0; i < pressed_keys_count; i++)
404+ {
405+ EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_for_index(ids_event, 0, i), Eq(pressed_keys[i]));
406+ }
407 EXPECT_THAT(mir_input_device_state_event_device_pointer_buttons(ids_event, 0), Eq(0));
408
409 EXPECT_THAT(mir_input_device_state_event_device_id(ids_event, 1), Eq(MirInputDeviceId{2}));
410@@ -252,6 +256,7 @@
411 auto const pos_y = 0.0f;
412 auto const button_state = mir_pointer_button_primary | mir_pointer_button_secondary;
413 auto const modifiers = mir_input_event_modifier_none;
414+ std::vector<uint32_t> const pressed_keys = {KEY_RIGHTALT, KEY_LEFTSHIFT, KEY_Q};
415 auto ev = mev::make_event(timestamp,
416 button_state,
417 modifiers,
418@@ -259,7 +264,7 @@
419 pos_y,
420 {mev::InputDeviceState{MirInputDeviceId{0}, {}, mir_pointer_button_primary},
421 mev::InputDeviceState{MirInputDeviceId{2}, {}, mir_pointer_button_secondary},
422- mev::InputDeviceState{MirInputDeviceId{3}, {KEY_RIGHTALT, KEY_LEFTSHIFT, KEY_Q}, 0}});
423+ mev::InputDeviceState{MirInputDeviceId{3}, pressed_keys, 0}});
424
425 auto encoded = MirEvent::serialize(ev.get());
426
427@@ -269,8 +274,10 @@
428 auto ids_event = mir_event_get_input_device_state_event(deserialzed_event.get());
429
430 EXPECT_THAT(mir_input_device_state_event_device_count(ids_event), Eq(3));
431- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_count(ids_event, 2), Eq(3));
432- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(ids_event, 2)[0], Eq(KEY_RIGHTALT));
433- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(ids_event, 2)[1], Eq(KEY_LEFTSHIFT));
434- EXPECT_THAT(mir_input_device_state_event_device_pressed_keys(ids_event, 2)[2], Eq(KEY_Q));
435+ auto pressed_keys_count = mir_input_device_state_event_device_pressed_keys_count(ids_event, 2);
436+ EXPECT_THAT(pressed_keys_count, Eq(3));
437+ for (uint32_t i = 0; i < pressed_keys_count; i++)
438+ {
439+ EXPECT_THAT(mir_input_device_state_event_device_pressed_keys_for_index(ids_event, 2, i), Eq(pressed_keys[i]));
440+ }
441 }

Subscribers

People subscribed via source and target branches