Mir

Merge lp:~mir-team/mir/unify-keyboard-actions into lp:mir

Proposed by Robert Carr
Status: Merged
Approved by: Robert Carr
Approved revision: no longer in the source branch.
Merged at revision: 2568
Proposed branch: lp:~mir-team/mir/unify-keyboard-actions
Merge into: lp:mir
Prerequisite: lp:~mir-team/mir/unify-event-modifiers
Diff against target: 589 lines (+93/-148)
20 files modified
src/client/events/event_builders.cpp (+1/-20)
src/client/input/android/android_input_lexicon.cpp (+1/-2)
src/client/input/android/event_conversion_helpers.cpp (+32/-0)
src/client/input/input_event.cpp (+2/-16)
src/client/input/xkb_mapper.cpp (+4/-7)
src/client/symbols.map (+2/-0)
src/include/common/mir/events/event_private.h (+1/-8)
src/include/common/mir/input/android/event_conversion_helpers.h (+9/-0)
src/server/input/android/android_input_dispatcher.cpp (+2/-1)
src/server/input/android/input_sender.cpp (+4/-2)
src/server/input/android/input_translator.cpp (+1/-9)
src/server/input/vt_filter.cpp (+1/-1)
tests/acceptance-tests/throwback/test_client_input.cpp (+1/-1)
tests/unit-tests/client/input/test_xkb_mapper.cpp (+17/-38)
tests/unit-tests/input/android/test_android_input_dispatcher.cpp (+2/-3)
tests/unit-tests/input/android/test_android_input_lexicon.cpp (+3/-4)
tests/unit-tests/input/android/test_android_input_sender.cpp (+1/-1)
tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp (+2/-0)
tests/unit-tests/input/android/test_input_translator.cpp (+5/-21)
tests/unit-tests/input/test_input_event.cpp (+2/-14)
To merge this branch: bzr merge lp:~mir-team/mir/unify-keyboard-actions
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andreas Pokorny (community) Approve
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
Kevin DuBois (community) Approve
Review via email: mp+258288@code.launchpad.net

Commit message

Unify keyboard action enums.

The removed mir_key_action_multiple corresponds to a kind of "textual" event which we do not support (as input methods go via another channel).

repeat_count is unified in to mir_keyboard_action_repeat

Description of the change

Unify keyboard action enums.

The removed mir_key_action_multiple corresponds to a kind of "textual" event which we do not support (as input methods go via another channel).

repeat_count is unified in to mir_keyboard_action_repeat

This branch is part of the event cleaning pipeline:

Pluck-low-hanging-event-fruit: Remove unused event members.
Unify-event-modifiers: Consolidate modifier enums (https://code.launchpad.net/~mir-team/mir/unify-event-modifiers/+merge/258218)
Unify-keyboard-actions: Consolidate keyboard action enums and key repeat representation (https://code.launchpad.net/~mir-team/mir/unify-keyboard-actions/+merge/258288)
Remaining-nsec-removal: Remove usage of nsecs_t in event_private.h https://code.launchpad.net/~mir-team/mir/remaining-nsec-removal/+merge/258292
unify-pointer-button: Consolidate pointer button enums
https://code.launchpad.net/~mir-team/mir/unify-pointer-button

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm

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

Looks good.

+ event.key.action == mir_keyboard_action_down)

It would be nice to change (in a future MP) event.key to event.keyboard to better match the new names.

review: Approve
Revision history for this message
Robert Carr (robertcarr) wrote :

Fixed some conflicts and re taed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

114 MirKeyboardAction mir_keyboard_event_action(MirKeyboardEvent const* kev)
115 {
116 auto const& old_kev = old_kev_from_new(kev);
117-
118- switch (old_kev.action)
119- {
120- case mir_key_action_down:
121- if (old_kev.repeat_count != 0)
122- return mir_keyboard_action_repeat;
123- else
124- return mir_keyboard_action_down;
125- case mir_key_action_up:
126- return mir_keyboard_action_up;
127- default:
128- // TODO:? This means we got key_action_multiple which I dont think is
129- // actually emitted yet (and never will be as in the future it would fall under text
130- // event in the new model).
131- return mir_keyboard_action_down;
132- }
133+
134+ return old_kev.action;
135 }

Could be a one liner:

    return old_kev_from_new(kev).action;

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

218+int32_t android_keyboard_action_from_mir(MirKeyboardAction action, int32_t& repeat_count_out);

The name doesn't make it obvious that we have a return value and an out parameter - which, BTW is in the wrong location:

 http://unity.ubuntu.com/mir/cppguide/index.html?showone=Function_Parameter_Ordering#Function_Parameter_Ordering

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote :

>> }
>> Could be a one liner:
>> return old_kev_from_new(kev).action;

Not quite. mir_key_action_multiple does not correspond to mir_keyboard_action_repeat. mir_key_action_multiple is an unused feature from android relating to delivering multiple distinct keys in one event. mir_keyboard_action_repeat corresponds to AKEY_EVENT_ACTION_DOWN and repeatCount > 0.

Revision history for this message
Robert Carr (robertcarr) wrote :

>. The name doesn't make it obvious that we have a return value and an out parameter - which, BTW >> is in the wrong location:

Fixed parameter location.

I don't see how I could make it more obvious that there is an out parameter without repeating myself 3 times in the same line (non const reference, _out postfix...) I've added a comment explaining why MirKeyboardAction needs to be converted to 2 android values though.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

497+ ev.initialize(0, 0, 0, 0, 0, 0, 0, 0, std::chrono::nanoseconds(0), std::chrono::nanoseconds(0));

Yuck!

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

OK

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

> >. The name doesn't make it obvious that we have a return value and an out
> parameter - which, BTW >> is in the wrong location:
>
> Fixed parameter location.
>
> I don't see how I could make it more obvious that there is an out parameter
> without repeating myself 3 times in the same line (non const reference, _out
> postfix...) I've added a comment explaining why MirKeyboardAction needs to be
> converted to 2 android values though.

Well you could return a struct { action, repeat_count }; or a tuple<>

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

+ 489 might not be necessary?

+1 for tuple

lgtm

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/client/events/event_builders.cpp'
2--- src/client/events/event_builders.cpp 2015-05-07 15:00:30 +0000
3+++ src/client/events/event_builders.cpp 2015-05-12 14:00:09 +0000
4@@ -92,23 +92,6 @@
5 return make_event_uptr(e);
6 }
7
8-namespace
9-{
10-MirKeyAction old_action_from_new(MirKeyboardAction action)
11-{
12- switch (action)
13- {
14- case mir_keyboard_action_repeat:
15- case mir_keyboard_action_up:
16- return mir_key_action_up;
17- case mir_keyboard_action_down:
18- return mir_key_action_down;
19- default:
20- BOOST_THROW_EXCEPTION(std::logic_error("Invalid key action"));
21- }
22-}
23-}
24-
25 mir::EventUPtr mev::make_event(MirInputDeviceId device_id, int64_t timestamp,
26 MirKeyboardAction action, xkb_keysym_t key_code,
27 int scan_code, MirInputEventModifiers modifiers)
28@@ -120,9 +103,7 @@
29 auto& kev = e->key;
30 kev.device_id = device_id;
31 kev.event_time = timestamp;
32- kev.action = old_action_from_new(action);
33- if (action == mir_keyboard_action_repeat)
34- kev.repeat_count = 1;
35+ kev.action = action;
36 kev.key_code = key_code;
37 kev.scan_code = scan_code;
38 kev.modifiers = modifiers;
39
40=== modified file 'src/client/input/android/android_input_lexicon.cpp'
41--- src/client/input/android/android_input_lexicon.cpp 2015-05-05 00:15:05 +0000
42+++ src/client/input/android/android_input_lexicon.cpp 2015-05-12 14:00:09 +0000
43@@ -35,11 +35,10 @@
44 mir_event.type = mir_event_type_key;
45 mir_event.key.device_id = android_event->getDeviceId();
46 mir_event.key.source_id = android_event->getSource();
47- mir_event.key.action = static_cast<MirKeyAction>(kev->getAction());
48+ mir_event.key.action = mia::mir_keyboard_action_from_android(kev->getAction(), kev->getRepeatCount());
49 mir_event.key.modifiers = mia::mir_modifiers_from_android(kev->getMetaState());
50 mir_event.key.key_code = kev->getKeyCode();
51 mir_event.key.scan_code = kev->getScanCode();
52- mir_event.key.repeat_count = kev->getRepeatCount();
53 mir_event.key.event_time = kev->getEventTime().count();
54 break;
55 }
56
57=== modified file 'src/client/input/android/event_conversion_helpers.cpp'
58--- src/client/input/android/event_conversion_helpers.cpp 2015-05-05 00:15:05 +0000
59+++ src/client/input/android/event_conversion_helpers.cpp 2015-05-12 14:00:09 +0000
60@@ -68,3 +68,35 @@
61 if (mir_modifiers & mir_input_event_modifier_scroll_lock) ret |= AMETA_SCROLL_LOCK_ON;
62 return ret;
63 }
64+
65+MirKeyboardAction mia::mir_keyboard_action_from_android(int32_t android_action, int32_t repeat_count)
66+{
67+ if (repeat_count > 0)
68+ return mir_keyboard_action_repeat;
69+
70+ switch (android_action)
71+ {
72+ case AKEY_EVENT_ACTION_DOWN:
73+ case AKEY_EVENT_ACTION_MULTIPLE:
74+ return mir_keyboard_action_down;
75+ case AKEY_EVENT_ACTION_UP:
76+ return mir_keyboard_action_up;
77+ default:
78+ return mir_keyboard_action_down;
79+ }
80+}
81+
82+int32_t mia::android_keyboard_action_from_mir(int32_t& repeat_count_out, MirKeyboardAction action)
83+{
84+ repeat_count_out = 0;
85+ switch (action)
86+ {
87+ case mir_keyboard_action_repeat:
88+ repeat_count_out = 1;
89+ case mir_keyboard_action_down:
90+ return AKEY_EVENT_ACTION_DOWN;
91+ case mir_keyboard_action_up:
92+ default:
93+ return AKEY_EVENT_ACTION_UP;
94+ }
95+}
96
97=== modified file 'src/client/input/input_event.cpp'
98--- src/client/input/input_event.cpp 2015-05-05 00:15:05 +0000
99+++ src/client/input/input_event.cpp 2015-05-12 14:00:09 +0000
100@@ -209,22 +209,8 @@
101 MirKeyboardAction mir_keyboard_event_action(MirKeyboardEvent const* kev)
102 {
103 auto const& old_kev = old_kev_from_new(kev);
104-
105- switch (old_kev.action)
106- {
107- case mir_key_action_down:
108- if (old_kev.repeat_count != 0)
109- return mir_keyboard_action_repeat;
110- else
111- return mir_keyboard_action_down;
112- case mir_key_action_up:
113- return mir_keyboard_action_up;
114- default:
115- // TODO:? This means we got key_action_multiple which I dont think is
116- // actually emitted yet (and never will be as in the future it would fall under text
117- // event in the new model).
118- return mir_keyboard_action_down;
119- }
120+
121+ return old_kev.action;
122 }
123
124 xkb_keysym_t mir_keyboard_event_key_code(MirKeyboardEvent const* kev)
125
126=== modified file 'src/client/input/xkb_mapper.cpp'
127--- src/client/input/xkb_mapper.cpp 2015-04-01 19:39:19 +0000
128+++ src/client/input/xkb_mapper.cpp 2015-05-12 14:00:09 +0000
129@@ -90,17 +90,14 @@
130
131 auto &key_ev = ev.key;
132
133- xkb_key_direction direction;
134+ xkb_key_direction direction = XKB_KEY_DOWN;
135
136 bool update_state = true;
137- if (key_ev.action == mir_key_action_up)
138+ if (key_ev.action == mir_keyboard_action_up)
139 direction = XKB_KEY_UP;
140- else if (key_ev.action == mir_key_action_down)
141+ else if (key_ev.action == mir_keyboard_action_down)
142 direction = XKB_KEY_DOWN;
143- else // mir_key_action_multiple does not correspond to a physical keypress
144- update_state = false;
145-
146- if (key_ev.repeat_count > 0)
147+ else if (key_ev.action == mir_keyboard_action_repeat)
148 update_state = false;
149
150 uint32_t xkb_scan_code = to_xkb_scan_code(key_ev.scan_code);
151
152=== modified file 'src/client/symbols.map'
153--- src/client/symbols.map 2015-05-07 07:20:05 +0000
154+++ src/client/symbols.map 2015-05-12 14:00:09 +0000
155@@ -206,6 +206,8 @@
156 mir::input::android::Lexicon::translate*;
157 mir::input::android::android_modifiers_from_mir*;
158 mir::input::android::mir_modifiers_from_android*;
159+ mir::input::android::mir_keyboard_action_from_android*;
160+ mir::input::android::android_keyboard_action_from_mir*;
161 mir::client::DefaultConnectionConfiguration::DefaultConnectionConfiguration*;
162 mir::client::DefaultConnectionConfiguration::the_surface_map*;
163 mir::client::DefaultConnectionConfiguration::the_rpc_channel*;
164
165=== modified file 'src/include/common/mir/events/event_private.h'
166--- src/include/common/mir/events/event_private.h 2015-05-07 07:20:05 +0000
167+++ src/include/common/mir/events/event_private.h 2015-05-12 14:00:09 +0000
168@@ -47,12 +47,6 @@
169 typedef int64_t nsecs_t;
170
171 typedef enum {
172- mir_key_action_down = 0,
173- mir_key_action_up = 1,
174- mir_key_action_multiple = 2
175-} MirKeyAction;
176-
177-typedef enum {
178 mir_motion_action_down = 0,
179 mir_motion_action_up = 1,
180 mir_motion_action_move = 2,
181@@ -91,12 +85,11 @@
182
183 int32_t device_id;
184 int32_t source_id;
185- MirKeyAction action;
186+ MirKeyboardAction action;
187 MirInputEventModifiers modifiers;
188
189 int32_t key_code;
190 int32_t scan_code;
191- int32_t repeat_count;
192
193 nsecs_t event_time;
194 } MirKeyEvent;
195
196=== modified file 'src/include/common/mir/input/android/event_conversion_helpers.h'
197--- src/include/common/mir/input/android/event_conversion_helpers.h 2015-05-05 00:15:05 +0000
198+++ src/include/common/mir/input/android/event_conversion_helpers.h 2015-05-12 14:00:09 +0000
199@@ -29,6 +29,15 @@
200 {
201 MirInputEventModifiers mir_modifiers_from_android(int32_t android_modifiers);
202 int32_t android_modifiers_from_mir(MirInputEventModifiers modifiers);
203+
204+MirKeyboardAction mir_keyboard_action_from_android(int32_t android_action, int32_t repeat_count);
205+
206+// Mir differentiates between mir_keyboard_action_down
207+// and mir_keyboard_action_repeat whereas android encodes
208+// keyrepeats as AKEY_EVENT_ACTION_DOWN and a repeatCount of > 0
209+// Thus when converting from MirKeyboardAction to an android
210+// action we must also fetch a repeat count for the android event.
211+int32_t android_keyboard_action_from_mir(int32_t& repeat_count_out, MirKeyboardAction action);
212 }
213 }
214 }
215
216=== modified file 'src/server/input/android/android_input_dispatcher.cpp'
217--- src/server/input/android/android_input_dispatcher.cpp 2015-05-07 07:20:05 +0000
218+++ src/server/input/android/android_input_dispatcher.cpp 2015-05-12 14:00:09 +0000
219@@ -55,12 +55,13 @@
220 {
221 case mir_event_type_key:
222 {
223+ int32_t ignored_repeat_count = 0;
224 droidinput::NotifyKeyArgs const notify_key_args(
225 std::chrono::nanoseconds(event.key.event_time),
226 event.key.device_id,
227 event.key.source_id,
228 policy_flags,
229- event.key.action,
230+ mia::android_keyboard_action_from_mir(ignored_repeat_count, event.key.action),
231 0, /* flags */
232 event.key.key_code,
233 event.key.scan_code,
234
235=== modified file 'src/server/input/android/input_sender.cpp'
236--- src/server/input/android/input_sender.cpp 2015-05-05 00:15:05 +0000
237+++ src/server/input/android/input_sender.cpp 2015-05-12 14:00:09 +0000
238@@ -237,16 +237,18 @@
239
240 droidinput::status_t mia::InputSender::ActiveTransfer::send_key_event(uint32_t seq, MirKeyEvent const& event)
241 {
242+ int32_t repeat_count = 0;
243+ auto android_action = mia::android_keyboard_action_from_mir(repeat_count, event.action);
244 return publisher.publishKeyEvent(
245 seq,
246 event.device_id,
247 event.source_id,
248- event.action,
249+ android_action,
250 0, /* Flags */
251 event.key_code,
252 event.scan_code,
253 mia::android_modifiers_from_mir(event.modifiers),
254- event.repeat_count,
255+ repeat_count,
256 std::chrono::nanoseconds(event.event_time),
257 std::chrono::nanoseconds(event.event_time)
258 );
259
260=== modified file 'src/server/input/android/input_translator.cpp'
261--- src/server/input/android/input_translator.cpp 2015-05-07 07:20:05 +0000
262+++ src/server/input/android/input_translator.cpp 2015-05-12 14:00:09 +0000
263@@ -29,10 +29,6 @@
264
265 namespace
266 {
267-bool valid_key_event(MirKeyEvent const& key)
268-{
269- return key.action == mir_key_action_up || key.action == mir_key_action_down;
270-}
271 inline int32_t get_index_from_motion_action(int action)
272 {
273 // FIXME: https://bugs.launchpad.net/mir/+bug/1311699
274@@ -131,16 +127,12 @@
275 mir_event.type = mir_event_type_key;
276 mir_event.key.device_id = args->deviceId;
277 mir_event.key.source_id = args->source;
278- mir_event.key.action = static_cast<MirKeyAction>(args->action);
279+ mir_event.key.action = mia::mir_keyboard_action_from_android(args->action, 0 /* repeat_count */);
280 mir_event.key.modifiers = mir_modifiers;
281 mir_event.key.key_code = args->keyCode;
282 mir_event.key.scan_code = args->scanCode;
283- mir_event.key.repeat_count = 0;
284 mir_event.key.event_time = args->eventTime.count();
285
286- if (!valid_key_event(mir_event.key))
287- return;
288-
289 dispatcher->dispatch(mir_event);
290 }
291
292
293=== modified file 'src/server/input/vt_filter.cpp'
294--- src/server/input/vt_filter.cpp 2015-05-05 00:15:05 +0000
295+++ src/server/input/vt_filter.cpp 2015-05-12 14:00:09 +0000
296@@ -38,7 +38,7 @@
297 bool mir::input::VTFilter::handle(MirEvent const& event)
298 {
299 if (event.type == mir_event_type_key &&
300- event.key.action == mir_key_action_down &&
301+ event.key.action == mir_keyboard_action_down &&
302 (event.key.modifiers & mir_input_event_modifier_alt) &&
303 (event.key.modifiers & mir_input_event_modifier_ctrl))
304 {
305
306=== modified file 'tests/acceptance-tests/throwback/test_client_input.cpp'
307--- tests/acceptance-tests/throwback/test_client_input.cpp 2015-04-30 11:36:36 +0000
308+++ tests/acceptance-tests/throwback/test_client_input.cpp 2015-05-12 14:00:09 +0000
309@@ -617,7 +617,7 @@
310 MirEvent key_event;
311 std::memset(&key_event, 0, sizeof key_event);
312 key_event.type = mir_event_type_key;
313- key_event.key.action = mir_key_action_down;
314+ key_event.key.action = mir_keyboard_action_down;
315
316 session->default_surface()->consume(key_event);
317 });
318
319=== modified file 'tests/unit-tests/client/input/test_xkb_mapper.cpp'
320--- tests/unit-tests/client/input/test_xkb_mapper.cpp 2015-04-01 19:39:19 +0000
321+++ tests/unit-tests/client/input/test_xkb_mapper.cpp 2015-05-12 14:00:09 +0000
322@@ -31,25 +31,12 @@
323 namespace
324 {
325
326-static int map_key(mircv::XKBMapper &mapper, MirKeyAction action, int scan_code)
327-{
328- MirEvent ev;
329- ev.type = mir_event_type_key;
330- ev.key.action = action;
331- ev.key.scan_code = scan_code;
332- ev.key.repeat_count = 0;
333-
334- mapper.update_state_and_map_event(ev);
335- return ev.key.key_code;
336-}
337-
338-static int map_repeated_key(mircv::XKBMapper &mapper, MirKeyAction action, int scan_code)
339-{
340- MirEvent ev;
341- ev.type = mir_event_type_key;
342- ev.key.action = action;
343- ev.key.scan_code = scan_code;
344- ev.key.repeat_count = 1;
345+static int map_key(mircv::XKBMapper &mapper, MirKeyboardAction action, int scan_code)
346+{
347+ MirEvent ev;
348+ ev.type = mir_event_type_key;
349+ ev.key.action = action;
350+ ev.key.scan_code = scan_code;
351
352 mapper.update_state_and_map_event(ev);
353 return ev.key.key_code;
354@@ -61,29 +48,21 @@
355 {
356 mircv::XKBMapper mapper;
357
358- EXPECT_EQ(XKB_KEY_4, map_key(mapper, mir_key_action_down, KEY_4));
359- EXPECT_EQ(XKB_KEY_Shift_L, map_key(mapper, mir_key_action_down, KEY_LEFTSHIFT));
360- EXPECT_EQ(XKB_KEY_dollar, map_key(mapper, mir_key_action_down, KEY_4));
361- EXPECT_EQ(XKB_KEY_dollar, map_key(mapper, mir_key_action_up, KEY_4));
362- EXPECT_EQ(XKB_KEY_Shift_L, map_key(mapper, mir_key_action_up, KEY_LEFTSHIFT));
363- EXPECT_EQ(XKB_KEY_4, map_key(mapper, mir_key_action_down, KEY_4));
364-}
365-
366-TEST(XKBMapper, key_action_multiple_does_not_update_modifier_state)
367-{
368- mircv::XKBMapper mapper;
369-
370- EXPECT_EQ(XKB_KEY_Shift_R, map_key(mapper, mir_key_action_multiple, KEY_RIGHTSHIFT));
371- EXPECT_EQ(XKB_KEY_7, map_key(mapper, mir_key_action_down, KEY_7));
372+ EXPECT_EQ(XKB_KEY_4, map_key(mapper, mir_keyboard_action_down, KEY_4));
373+ EXPECT_EQ(XKB_KEY_Shift_L, map_key(mapper, mir_keyboard_action_down, KEY_LEFTSHIFT));
374+ EXPECT_EQ(XKB_KEY_dollar, map_key(mapper, mir_keyboard_action_down, KEY_4));
375+ EXPECT_EQ(XKB_KEY_dollar, map_key(mapper, mir_keyboard_action_up, KEY_4));
376+ EXPECT_EQ(XKB_KEY_Shift_L, map_key(mapper, mir_keyboard_action_up, KEY_LEFTSHIFT));
377+ EXPECT_EQ(XKB_KEY_4, map_key(mapper, mir_keyboard_action_down, KEY_4));
378 }
379
380 TEST(XKBMapper, key_repeats_do_not_recurse_modifier_state)
381 {
382 mircv::XKBMapper mapper;
383
384- EXPECT_EQ(XKB_KEY_Shift_R, map_key(mapper, mir_key_action_down, KEY_RIGHTSHIFT));
385- EXPECT_EQ(XKB_KEY_Shift_R, map_repeated_key(mapper, mir_key_action_down, KEY_RIGHTSHIFT));
386- EXPECT_EQ(XKB_KEY_ampersand, map_key(mapper, mir_key_action_down, KEY_7));
387- EXPECT_EQ(XKB_KEY_Shift_R, map_key(mapper, mir_key_action_up, KEY_RIGHTSHIFT));
388- EXPECT_EQ(XKB_KEY_7, map_key(mapper, mir_key_action_down, KEY_7));
389+ EXPECT_EQ(XKB_KEY_Shift_R, map_key(mapper, mir_keyboard_action_down, KEY_RIGHTSHIFT));
390+ EXPECT_EQ(XKB_KEY_Shift_R, map_key(mapper, mir_keyboard_action_repeat, KEY_RIGHTSHIFT));
391+ EXPECT_EQ(XKB_KEY_ampersand, map_key(mapper, mir_keyboard_action_down, KEY_7));
392+ EXPECT_EQ(XKB_KEY_Shift_R, map_key(mapper, mir_keyboard_action_up, KEY_RIGHTSHIFT));
393+ EXPECT_EQ(XKB_KEY_7, map_key(mapper, mir_keyboard_action_down, KEY_7));
394 }
395
396=== modified file 'tests/unit-tests/input/android/test_android_input_dispatcher.cpp'
397--- tests/unit-tests/input/android/test_android_input_dispatcher.cpp 2015-05-05 00:15:05 +0000
398+++ tests/unit-tests/input/android/test_android_input_dispatcher.cpp 2015-05-12 14:00:09 +0000
399@@ -236,17 +236,16 @@
400 event.key.event_time = 1;
401 event.key.device_id = 2;
402 event.key.source_id = 3;
403- event.key.action = mir_key_action_down;
404+ event.key.action = mir_keyboard_action_down;
405 event.key.scan_code = 4;
406 event.key.key_code = 5;
407- event.key.repeat_count = 0;
408 event.key.modifiers = mir_input_event_modifier_shift;
409
410 droidinput::NotifyKeyArgs expected(std::chrono::nanoseconds(event.key.event_time),
411 event.key.device_id,
412 event.key.source_id,
413 default_policy_flags,
414- event.key.action,
415+ AKEY_EVENT_ACTION_DOWN,
416 0, /* flags */
417 event.key.key_code,
418 event.key.scan_code,
419
420=== modified file 'tests/unit-tests/input/android/test_android_input_lexicon.cpp'
421--- tests/unit-tests/input/android/test_android_input_lexicon.cpp 2015-05-05 00:15:05 +0000
422+++ tests/unit-tests/input/android/test_android_input_lexicon.cpp 2015-05-12 14:00:09 +0000
423@@ -34,12 +34,12 @@
424
425 const int32_t device_id = 1;
426 const int32_t source_id = 2;
427- const int32_t action = 3;
428+ const int32_t action = AKEY_EVENT_ACTION_DOWN;
429 const int32_t flags = 4;
430 const int32_t key_code = 5;
431 const int32_t scan_code = 6;
432 const int32_t meta_state = AMETA_ALT_ON;
433- const int32_t repeat_count = 8;
434+ const int32_t repeat_count = 0;
435 auto const down_time = std::chrono::nanoseconds(9);
436 auto const event_time = std::chrono::nanoseconds(10);
437
438@@ -53,7 +53,7 @@
439 // Common event properties
440 EXPECT_EQ(device_id, mir_ev.key.device_id);
441 EXPECT_EQ(source_id, mir_ev.key.source_id);
442- EXPECT_EQ(action, mir_ev.key.action);
443+ EXPECT_EQ(mir_keyboard_action_down, mir_ev.key.action);
444 EXPECT_EQ(mir_input_event_modifier_alt, mir_ev.key.modifiers);
445
446 auto mir_key_ev = &mir_ev.key;
447@@ -61,7 +61,6 @@
448 EXPECT_EQ(mir_ev.type, mir_event_type_key);
449 EXPECT_EQ(mir_key_ev->key_code, key_code);
450 EXPECT_EQ(mir_key_ev->scan_code, scan_code);
451- EXPECT_EQ(mir_key_ev->repeat_count, repeat_count);
452 EXPECT_EQ(mir_key_ev->event_time, event_time.count());
453
454 delete android_key_ev;
455
456=== modified file 'tests/unit-tests/input/android/test_android_input_sender.cpp'
457--- tests/unit-tests/input/android/test_android_input_sender.cpp 2015-04-01 19:39:19 +0000
458+++ tests/unit-tests/input/android/test_android_input_sender.cpp 2015-05-12 14:00:09 +0000
459@@ -89,7 +89,7 @@
460
461 key_event.type = mir_event_type_key;
462 key_event.key.scan_code = 32;
463- key_event.key.action = mir_key_action_down;
464+ key_event.key.action = mir_keyboard_action_down;
465
466 motion_event.type = mir_event_type_motion;
467 motion_event.motion.pointer_count = 2;
468
469=== modified file 'tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp'
470--- tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp 2015-04-01 19:39:19 +0000
471+++ tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp 2015-05-12 14:00:09 +0000
472@@ -24,6 +24,7 @@
473 #include "mir_test_doubles/mock_event_filter.h"
474
475 #include <androidfw/Input.h>
476+#include <string.h>
477
478 #include <gtest/gtest.h>
479 #include <gmock/gmock.h>
480@@ -37,6 +38,7 @@
481 {
482 using namespace ::testing;
483 droidinput::KeyEvent ev;
484+ ev.initialize(0, 0, 0, 0, 0, 0, 0, 0, std::chrono::nanoseconds(0), std::chrono::nanoseconds(0));
485 mtd::MockEventFilter filter;
486 mia::EventFilterDispatcherPolicy policy(mt::fake_shared(filter), true);
487 uint32_t policy_flags;
488
489=== modified file 'tests/unit-tests/input/android/test_input_translator.cpp'
490--- tests/unit-tests/input/android/test_input_translator.cpp 2015-05-07 07:20:05 +0000
491+++ tests/unit-tests/input/android/test_input_translator.cpp 2015-05-12 14:00:09 +0000
492@@ -102,21 +102,6 @@
493 translator.notifyDeviceReset(&reset);
494 }
495
496-TEST_F(InputTranslator, ignores_invalid_key_events)
497-{
498- using namespace ::testing;
499-
500- EXPECT_CALL(dispatcher, dispatch(_)).Times(0);
501-
502- translator.notifyKey(nullptr);
503-
504- const int32_t invalid_action = 5;
505- droidinput::NotifyKeyArgs key(some_time, device_id, source_id, 0, invalid_action, no_flags,
506- arbitrary_key_code, arbitrary_scan_code, no_modifiers, later_time);
507-
508- translator.notifyKey(&key);
509-}
510-
511 TEST_F(InputTranslator, ignores_invalid_motion_action)
512 {
513 using namespace ::testing;
514@@ -231,9 +216,9 @@
515 EXPECT_CALL(dispatcher, dispatch(mt::KeyDownEvent())).Times(1);
516 EXPECT_CALL(dispatcher, dispatch(mt::KeyUpEvent())).Times(1);
517
518- droidinput::NotifyKeyArgs down(some_time, device_id, source_id, 0, mir_key_action_down,
519+ droidinput::NotifyKeyArgs down(some_time, device_id, source_id, 0, AKEY_EVENT_ACTION_DOWN,
520 no_flags, arbitrary_key_code, arbitrary_scan_code, no_modifiers, later_time);
521- droidinput::NotifyKeyArgs up(some_time, device_id, source_id, 0, mir_key_action_up,
522+ droidinput::NotifyKeyArgs up(some_time, device_id, source_id, 0, AKEY_EVENT_ACTION_UP,
523 no_flags, arbitrary_key_code, arbitrary_scan_code, no_modifiers, later_time);
524
525 translator.notifyKey(&down);
526@@ -248,10 +233,9 @@
527 expected.key.event_time = 1;
528 expected.key.device_id = 2;
529 expected.key.source_id = 3;
530- expected.key.action = mir_key_action_down;
531+ expected.key.action = mir_keyboard_action_down;
532 expected.key.scan_code = 4;
533 expected.key.key_code = 5;
534- expected.key.repeat_count = 0;
535 expected.key.modifiers = mir_input_event_modifier_shift;
536
537 InSequence seq;
538@@ -261,7 +245,7 @@
539 expected.key.device_id,
540 expected.key.source_id,
541 default_policy_flags,
542- expected.key.action,
543+ AKEY_EVENT_ACTION_DOWN,
544 0, /* flags */
545 expected.key.key_code,
546 expected.key.scan_code,
547@@ -341,7 +325,7 @@
548 ).Times(1);
549
550 droidinput::NotifyKeyArgs tester(some_time, device_id, source_id,
551- GetParam().policy_flag, mir_key_action_down,
552+ GetParam().policy_flag, AKEY_EVENT_ACTION_DOWN,
553 no_flags, arbitrary_key_code, arbitrary_scan_code, no_modifiers, later_time);
554
555 translator.notifyKey(&tester);
556
557=== modified file 'tests/unit-tests/input/test_input_event.cpp'
558--- tests/unit-tests/input/test_input_event.cpp 2015-05-05 00:15:05 +0000
559+++ tests/unit-tests/input/test_input_event.cpp 2015-05-12 14:00:09 +0000
560@@ -125,27 +125,15 @@
561 {
562 auto old_ev = a_key_ev();
563
564- old_ev.key.action = mir_key_action_down;
565- old_ev.key.repeat_count = 0;
566+ old_ev.key.action = mir_keyboard_action_down;
567
568 auto new_kev = mir_input_event_get_keyboard_event(mir_event_get_input_event(&old_ev));
569 EXPECT_EQ(mir_keyboard_action_down, mir_keyboard_event_action(new_kev));
570
571- old_ev.key.action = mir_key_action_up;
572+ old_ev.key.action = mir_keyboard_action_up;
573 EXPECT_EQ(mir_keyboard_action_up, mir_keyboard_event_action(new_kev));
574 }
575
576-TEST(KeyInputEventProperties, repeat_action_produced_from_non_zero_repeat_count_in_old_style_event)
577-{
578- auto old_ev = a_key_ev();
579-
580- old_ev.key.action = mir_key_action_down;
581- old_ev.key.repeat_count = 1;
582-
583- auto new_kev = mir_input_event_get_keyboard_event(mir_event_get_input_event(&old_ev));
584- EXPECT_EQ(mir_keyboard_action_repeat, mir_keyboard_event_action(new_kev));
585-}
586-
587 TEST(KeyInputEventProperties, keycode_scancode_and_modifiers_taken_from_old_style_event)
588 {
589 xkb_keysym_t key_code = 171;

Subscribers

People subscribed via source and target branches