Merge lp:~mir-team/mir/unify-event-modifiers into lp:mir
- unify-event-modifiers
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Robert Carr |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2546 |
Proposed branch: | lp:~mir-team/mir/unify-event-modifiers |
Merge into: | lp:mir |
Prerequisite: | lp:~mir-team/mir/pluck-low-hanging-event-fruit |
Diff against target: |
764 lines (+171/-166) 17 files modified
playground/demo-shell/window_manager.cpp (+14/-14) src/client/events/event_builders.cpp (+3/-46) src/client/input/android/CMakeLists.txt (+1/-0) src/client/input/android/android_input_lexicon.cpp (+3/-2) src/client/input/android/event_conversion_helpers.cpp (+70/-0) src/client/input/input_event.cpp (+3/-52) src/client/symbols.map (+2/-0) src/include/common/mir/events/event_private.h (+2/-23) src/include/common/mir/input/android/event_conversion_helpers.h (+36/-0) src/server/input/android/android_input_dispatcher.cpp (+3/-2) src/server/input/android/input_sender.cpp (+3/-2) src/server/input/android/input_translator.cpp (+15/-8) src/server/input/vt_filter.cpp (+2/-2) tests/unit-tests/input/android/test_android_input_dispatcher.cpp (+4/-4) tests/unit-tests/input/android/test_android_input_lexicon.cpp (+2/-4) tests/unit-tests/input/android/test_input_translator.cpp (+2/-2) tests/unit-tests/input/test_input_event.cpp (+6/-5) |
To merge this branch: | bzr merge lp:~mir-team/mir/unify-event-modifiers |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandros Frantzis (community) | Approve | ||
Kevin DuBois (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+258218@code.launchpad.net |
Commit message
Remove the legacy event modifier enum.
Description of the change
Remove the legacy event modifier enum.
This branch is part of the event cleaning pipeline:
Pluck-low-
Unify-event-
Unify-keyboard-
Remaining-
unify-pointer-
https:/
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:2543
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Kevin DuBois (kdub) wrote : | # |
side note: If playground/
lgtm
Alan Griffiths (alan-griffiths) wrote : | # |
585+ if (mir_modifiers != mir_input_
586+ mir_modifiers &= ~mir_input_
if (mir_modifiers != mir_input_
mir_modifiers &= ~mir_input_
or
if (mir_modifiers | ~mir_input_
mir_modifiers &= ~mir_input_
Alexandros Frantzis (afrantzis) wrote : | # |
Looks good.
I think that mir_input_
Robert Carr (robertcarr) wrote : | # |
>> I think that mir_input_
>> use unintuitive, but that's another discussion.
Yeah you may be right. It was originally an intentional decision with the idea that 0 was reserved for an out of band/invalid state. Practically though I made an error in the original assembly of the branch (fixed before submission don't worry ;))...I'm not sure if it was just because of confusion with the android flags or this interface really is hard to use though.
Preview Diff
1 | === modified file 'playground/demo-shell/window_manager.cpp' |
2 | --- playground/demo-shell/window_manager.cpp 2015-04-16 18:50:58 +0000 |
3 | +++ playground/demo-shell/window_manager.cpp 2015-05-05 05:53:22 +0000 |
4 | @@ -209,7 +209,7 @@ |
5 | if (event.key.type == mir_event_type_key && |
6 | event.key.action == mir_key_action_down) |
7 | { |
8 | - if (event.key.modifiers & mir_key_modifier_alt && |
9 | + if (event.key.modifiers & mir_input_event_modifier_alt && |
10 | event.key.scan_code == KEY_TAB) // TODO: Use keycode once we support keymapping on the server side |
11 | { |
12 | focus_controller->focus_next_session(); |
13 | @@ -217,7 +217,7 @@ |
14 | focus_controller->raise({surface}); |
15 | return true; |
16 | } |
17 | - else if (event.key.modifiers & mir_key_modifier_alt && |
18 | + else if (event.key.modifiers & mir_input_event_modifier_alt && |
19 | event.key.scan_code == KEY_GRAVE) |
20 | { |
21 | if (auto const prev = focus_controller->focused_surface()) |
22 | @@ -229,7 +229,7 @@ |
23 | } |
24 | return true; |
25 | } |
26 | - else if (event.key.modifiers & mir_key_modifier_alt && |
27 | + else if (event.key.modifiers & mir_input_event_modifier_alt && |
28 | event.key.scan_code == KEY_F4) |
29 | { |
30 | auto const surf = focus_controller->focused_surface(); |
31 | @@ -237,7 +237,7 @@ |
32 | surf->request_client_surface_close(); |
33 | return true; |
34 | } |
35 | - else if ((event.key.modifiers & mir_key_modifier_alt && |
36 | + else if ((event.key.modifiers & mir_input_event_modifier_alt && |
37 | event.key.scan_code == KEY_P) || |
38 | (event.key.scan_code == KEY_POWER)) |
39 | { |
40 | @@ -258,15 +258,15 @@ |
41 | compositor->start(); |
42 | return true; |
43 | } |
44 | - else if ((event.key.modifiers & mir_key_modifier_alt) && |
45 | - (event.key.modifiers & mir_key_modifier_ctrl) && |
46 | + else if ((event.key.modifiers & mir_input_event_modifier_alt) && |
47 | + (event.key.modifiers & mir_input_event_modifier_ctrl) && |
48 | (event.key.scan_code == KEY_ESC)) |
49 | { |
50 | std::abort(); |
51 | return true; |
52 | } |
53 | - else if ((event.key.modifiers & mir_key_modifier_alt) && |
54 | - (event.key.modifiers & mir_key_modifier_ctrl) && |
55 | + else if ((event.key.modifiers & mir_input_event_modifier_alt) && |
56 | + (event.key.modifiers & mir_input_event_modifier_ctrl) && |
57 | (event.key.scan_code == KEY_L) && |
58 | focus_controller) |
59 | { |
60 | @@ -276,8 +276,8 @@ |
61 | app->set_lifecycle_state(mir_lifecycle_state_will_suspend); |
62 | } |
63 | } |
64 | - else if ((event.key.modifiers & mir_key_modifier_alt) && |
65 | - (event.key.modifiers & mir_key_modifier_ctrl)) |
66 | + else if ((event.key.modifiers & mir_input_event_modifier_alt) && |
67 | + (event.key.modifiers & mir_input_event_modifier_ctrl)) |
68 | { |
69 | MirOrientation orientation = mir_orientation_normal; |
70 | bool rotating = true; |
71 | @@ -366,13 +366,13 @@ |
72 | compositor->start(); |
73 | return true; |
74 | } |
75 | - else if (event.key.modifiers & mir_key_modifier_meta && |
76 | + else if (event.key.modifiers & mir_input_event_modifier_meta && |
77 | event.key.scan_code == KEY_N) |
78 | { |
79 | toggle(inverse); |
80 | return true; |
81 | } |
82 | - else if (event.key.modifiers & mir_key_modifier_meta && |
83 | + else if (event.key.modifiers & mir_input_event_modifier_meta && |
84 | event.key.scan_code == KEY_C) |
85 | { |
86 | toggle(contrast); |
87 | @@ -389,7 +389,7 @@ |
88 | |
89 | float new_zoom_mag = 0.0f; // zero means unchanged |
90 | |
91 | - if (event.motion.modifiers & mir_key_modifier_meta && |
92 | + if (event.motion.modifiers & mir_input_event_modifier_meta && |
93 | action == mir_motion_action_scroll) |
94 | { |
95 | zoom_exponent += event.motion.pointer_coordinates[0].vscroll; |
96 | @@ -421,7 +421,7 @@ |
97 | |
98 | auto const surf = focus_controller->focused_surface(); |
99 | if (surf && |
100 | - (event.motion.modifiers & mir_key_modifier_alt || |
101 | + (event.motion.modifiers & mir_input_event_modifier_alt || |
102 | fingers >= 3)) |
103 | { |
104 | geometry::Displacement pinch_dir; |
105 | |
106 | === modified file 'src/client/events/event_builders.cpp' |
107 | --- src/client/events/event_builders.cpp 2015-05-05 05:53:22 +0000 |
108 | +++ src/client/events/event_builders.cpp 2015-05-05 05:53:22 +0000 |
109 | @@ -107,49 +107,6 @@ |
110 | BOOST_THROW_EXCEPTION(std::logic_error("Invalid key action")); |
111 | } |
112 | } |
113 | -MirKeyModifier old_modifiers_from_new(MirInputEventModifiers modifiers) |
114 | -{ |
115 | - int old_modifiers = mir_key_modifier_none; |
116 | - |
117 | - if (modifiers & mir_input_event_modifier_none) |
118 | - old_modifiers |= mir_key_modifier_none; |
119 | - if (modifiers & mir_input_event_modifier_alt) |
120 | - old_modifiers |= mir_key_modifier_alt; |
121 | - if (modifiers & mir_input_event_modifier_alt_left) |
122 | - old_modifiers |= mir_key_modifier_alt_left; |
123 | - if (modifiers & mir_input_event_modifier_alt_right) |
124 | - old_modifiers |= mir_key_modifier_alt_right; |
125 | - if (modifiers & mir_input_event_modifier_shift) |
126 | - old_modifiers |= mir_key_modifier_shift; |
127 | - if (modifiers & mir_input_event_modifier_shift_left) |
128 | - old_modifiers |= mir_key_modifier_shift_left; |
129 | - if (modifiers & mir_input_event_modifier_shift_right) |
130 | - old_modifiers |= mir_key_modifier_shift_right; |
131 | - if (modifiers & mir_input_event_modifier_sym) |
132 | - old_modifiers |= mir_key_modifier_sym; |
133 | - if (modifiers & mir_input_event_modifier_function) |
134 | - old_modifiers |= mir_key_modifier_function; |
135 | - if (modifiers & mir_input_event_modifier_ctrl) |
136 | - old_modifiers |= mir_key_modifier_ctrl; |
137 | - if (modifiers & mir_input_event_modifier_ctrl_left) |
138 | - old_modifiers |= mir_key_modifier_ctrl_left; |
139 | - if (modifiers & mir_input_event_modifier_ctrl_right) |
140 | - old_modifiers |= mir_key_modifier_ctrl_right; |
141 | - if (modifiers & mir_input_event_modifier_meta) |
142 | - old_modifiers |= mir_key_modifier_meta; |
143 | - if (modifiers & mir_input_event_modifier_meta_left) |
144 | - old_modifiers |= mir_key_modifier_meta_left; |
145 | - if (modifiers & mir_input_event_modifier_meta_right) |
146 | - old_modifiers |= mir_key_modifier_meta_right; |
147 | - if (modifiers & mir_input_event_modifier_caps_lock) |
148 | - old_modifiers |= mir_key_modifier_caps_lock; |
149 | - if (modifiers & mir_input_event_modifier_num_lock) |
150 | - old_modifiers |= mir_key_modifier_num_lock; |
151 | - if (modifiers & mir_input_event_modifier_scroll_lock) |
152 | - old_modifiers |= mir_key_modifier_scroll_lock; |
153 | - |
154 | - return static_cast<MirKeyModifier>(old_modifiers); |
155 | -} |
156 | } |
157 | |
158 | mir::EventUPtr mev::make_event(MirInputDeviceId device_id, int64_t timestamp, |
159 | @@ -168,7 +125,7 @@ |
160 | kev.repeat_count = 1; |
161 | kev.key_code = key_code; |
162 | kev.scan_code = scan_code; |
163 | - kev.modifiers = old_modifiers_from_new(modifiers); |
164 | + kev.modifiers = modifiers; |
165 | |
166 | return make_event_uptr(e); |
167 | } |
168 | @@ -214,7 +171,7 @@ |
169 | auto& mev = e->motion; |
170 | mev.device_id = device_id; |
171 | mev.event_time = timestamp; |
172 | - mev.modifiers = old_modifiers_from_new(modifiers); |
173 | + mev.modifiers = modifiers; |
174 | mev.action = mir_motion_action_move; |
175 | mev.source_id = AINPUT_SOURCE_TOUCHSCREEN; |
176 | |
177 | @@ -314,7 +271,7 @@ |
178 | auto& mev = e->motion; |
179 | mev.device_id = device_id; |
180 | mev.event_time = timestamp; |
181 | - mev.modifiers = old_modifiers_from_new(modifiers); |
182 | + mev.modifiers = modifiers; |
183 | mev.action = old_action_from_pointer_action(action); |
184 | mev.source_id = AINPUT_SOURCE_MOUSE; |
185 | |
186 | |
187 | === modified file 'src/client/input/android/CMakeLists.txt' |
188 | --- src/client/input/android/CMakeLists.txt 2015-03-31 02:35:42 +0000 |
189 | +++ src/client/input/android/CMakeLists.txt 2015-05-05 05:53:22 +0000 |
190 | @@ -19,6 +19,7 @@ |
191 | ${CMAKE_CURRENT_SOURCE_DIR}/android_input_lexicon.cpp |
192 | ${CMAKE_CURRENT_SOURCE_DIR}/android_input_receiver.cpp |
193 | ${CMAKE_CURRENT_SOURCE_DIR}/android_input_platform.cpp |
194 | + ${CMAKE_CURRENT_SOURCE_DIR}/event_conversion_helpers.cpp |
195 | ) |
196 | |
197 | set(ANDROID_SHARED_INPUT_SOURCES ${ANDROID_SHARED_INPUT_SOURCES} PARENT_SCOPE) |
198 | |
199 | === modified file 'src/client/input/android/android_input_lexicon.cpp' |
200 | --- src/client/input/android/android_input_lexicon.cpp 2015-05-05 05:53:22 +0000 |
201 | +++ src/client/input/android/android_input_lexicon.cpp 2015-05-05 05:53:22 +0000 |
202 | @@ -18,6 +18,7 @@ |
203 | */ |
204 | |
205 | #include "mir/input/android/android_input_lexicon.h" |
206 | +#include "mir/input/android/event_conversion_helpers.h" |
207 | #include "mir/events/event_private.h" |
208 | |
209 | #include <androidfw/Input.h> |
210 | @@ -35,7 +36,7 @@ |
211 | mir_event.key.device_id = android_event->getDeviceId(); |
212 | mir_event.key.source_id = android_event->getSource(); |
213 | mir_event.key.action = static_cast<MirKeyAction>(kev->getAction()); |
214 | - mir_event.key.modifiers = kev->getMetaState(); |
215 | + mir_event.key.modifiers = mia::mir_modifiers_from_android(kev->getMetaState()); |
216 | mir_event.key.key_code = kev->getKeyCode(); |
217 | mir_event.key.scan_code = kev->getScanCode(); |
218 | mir_event.key.repeat_count = kev->getRepeatCount(); |
219 | @@ -49,7 +50,7 @@ |
220 | mir_event.motion.device_id = android_event->getDeviceId(); |
221 | mir_event.motion.source_id = android_event->getSource(); |
222 | mir_event.motion.action = mev->getAction(); |
223 | - mir_event.motion.modifiers = mev->getMetaState(); |
224 | + mir_event.motion.modifiers = mia::mir_modifiers_from_android(mev->getMetaState()); |
225 | mir_event.motion.button_state = static_cast<MirMotionButton>(mev->getButtonState()); |
226 | mir_event.motion.event_time = mev->getEventTime().count(); |
227 | mir_event.motion.pointer_count = mev->getPointerCount(); |
228 | |
229 | === added file 'src/client/input/android/event_conversion_helpers.cpp' |
230 | --- src/client/input/android/event_conversion_helpers.cpp 1970-01-01 00:00:00 +0000 |
231 | +++ src/client/input/android/event_conversion_helpers.cpp 2015-05-05 05:53:22 +0000 |
232 | @@ -0,0 +1,70 @@ |
233 | +/* |
234 | + * Copyright © 2015 Canonical Ltd. |
235 | + * |
236 | + * This program is free software: you can redistribute it and/or modify it |
237 | + * under the terms of the GNU Lesser General Public License version 3, |
238 | + * as published by the Free Software Foundation. |
239 | + * |
240 | + * This program is distributed in the hope that it will be useful, |
241 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
242 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
243 | + * GNU Lesser General Public License for more details. |
244 | + * |
245 | + * You should have received a copy of the GNU Lesser General Public License |
246 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
247 | + * |
248 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
249 | + */ |
250 | + |
251 | +#include "mir/input/android/event_conversion_helpers.h" |
252 | + |
253 | +#include <androidfw/Input.h> |
254 | + |
255 | +namespace mia = mir::input::android; |
256 | + |
257 | +MirInputEventModifiers mia::mir_modifiers_from_android(int32_t android_modifiers) |
258 | +{ |
259 | + MirInputEventModifiers ret = 0; |
260 | + if (android_modifiers == 0) ret |= mir_input_event_modifier_none; |
261 | + if (android_modifiers & AMETA_ALT_ON) ret |= mir_input_event_modifier_alt; |
262 | + if (android_modifiers & AMETA_ALT_LEFT_ON) ret |= mir_input_event_modifier_alt_left; |
263 | + if (android_modifiers & AMETA_ALT_RIGHT_ON) ret |= mir_input_event_modifier_alt_right; |
264 | + if (android_modifiers & AMETA_SHIFT_ON) ret |= mir_input_event_modifier_shift; |
265 | + if (android_modifiers & AMETA_SHIFT_LEFT_ON) ret |= mir_input_event_modifier_shift_left; |
266 | + if (android_modifiers & AMETA_SHIFT_RIGHT_ON) ret |= mir_input_event_modifier_shift_right; |
267 | + if (android_modifiers & AMETA_SYM_ON) ret |= mir_input_event_modifier_sym; |
268 | + if (android_modifiers & AMETA_FUNCTION_ON) ret |= mir_input_event_modifier_function; |
269 | + if (android_modifiers & AMETA_CTRL_ON) ret |= mir_input_event_modifier_ctrl; |
270 | + if (android_modifiers & AMETA_CTRL_LEFT_ON) ret |= mir_input_event_modifier_ctrl_left; |
271 | + if (android_modifiers & AMETA_CTRL_RIGHT_ON) ret |= mir_input_event_modifier_ctrl_right; |
272 | + if (android_modifiers & AMETA_META_ON) ret |= mir_input_event_modifier_meta; |
273 | + if (android_modifiers & AMETA_META_LEFT_ON) ret |= mir_input_event_modifier_meta_left; |
274 | + if (android_modifiers & AMETA_META_RIGHT_ON) ret |= mir_input_event_modifier_meta_right; |
275 | + if (android_modifiers & AMETA_CAPS_LOCK_ON) ret |= mir_input_event_modifier_caps_lock; |
276 | + if (android_modifiers & AMETA_NUM_LOCK_ON) ret |= mir_input_event_modifier_num_lock; |
277 | + if (android_modifiers & AMETA_SCROLL_LOCK_ON) ret |= mir_input_event_modifier_scroll_lock; |
278 | + return ret; |
279 | +} |
280 | + |
281 | +int32_t mia::android_modifiers_from_mir(MirInputEventModifiers mir_modifiers) |
282 | +{ |
283 | + int32_t ret = AMETA_NONE; |
284 | + if (mir_modifiers & mir_input_event_modifier_alt) ret |= AMETA_ALT_ON; |
285 | + if (mir_modifiers & mir_input_event_modifier_alt_left) ret |= AMETA_ALT_LEFT_ON; |
286 | + if (mir_modifiers & mir_input_event_modifier_alt_right) ret |= AMETA_ALT_RIGHT_ON; |
287 | + if (mir_modifiers & mir_input_event_modifier_shift) ret |= AMETA_SHIFT_ON; |
288 | + if (mir_modifiers & mir_input_event_modifier_shift_left) ret |= AMETA_SHIFT_LEFT_ON; |
289 | + if (mir_modifiers & mir_input_event_modifier_shift_right) ret |= AMETA_SHIFT_RIGHT_ON; |
290 | + if (mir_modifiers & mir_input_event_modifier_sym) ret |= AMETA_SYM_ON; |
291 | + if (mir_modifiers & mir_input_event_modifier_function) ret |= AMETA_FUNCTION_ON; |
292 | + if (mir_modifiers & mir_input_event_modifier_ctrl) ret |= AMETA_CTRL_ON; |
293 | + if (mir_modifiers & mir_input_event_modifier_ctrl_left) ret |= AMETA_CTRL_LEFT_ON; |
294 | + if (mir_modifiers & mir_input_event_modifier_ctrl_right) ret |= AMETA_CTRL_RIGHT_ON; |
295 | + if (mir_modifiers & mir_input_event_modifier_meta) ret |= AMETA_META_ON; |
296 | + if (mir_modifiers & mir_input_event_modifier_meta_left) ret |= AMETA_META_LEFT_ON; |
297 | + if (mir_modifiers & mir_input_event_modifier_meta_right) ret |= AMETA_META_RIGHT_ON; |
298 | + if (mir_modifiers & mir_input_event_modifier_caps_lock) ret |= AMETA_CAPS_LOCK_ON; |
299 | + if (mir_modifiers & mir_input_event_modifier_num_lock) ret |= AMETA_NUM_LOCK_ON; |
300 | + if (mir_modifiers & mir_input_event_modifier_scroll_lock) ret |= AMETA_SCROLL_LOCK_ON; |
301 | + return ret; |
302 | +} |
303 | |
304 | === modified file 'src/client/input/input_event.cpp' |
305 | --- src/client/input/input_event.cpp 2015-04-01 19:39:19 +0000 |
306 | +++ src/client/input/input_event.cpp 2015-05-05 05:53:22 +0000 |
307 | @@ -239,66 +239,17 @@ |
308 | return old_kev.scan_code; |
309 | } |
310 | |
311 | -namespace |
312 | -{ |
313 | -MirInputEventModifiers old_modifiers_to_new(unsigned int old_modifier) |
314 | -{ |
315 | - MirInputEventModifiers modifier = 0; |
316 | - |
317 | - if (old_modifier & mir_key_modifier_none) |
318 | - modifier |= mir_input_event_modifier_none; |
319 | - if (old_modifier & mir_key_modifier_alt) |
320 | - modifier |= mir_input_event_modifier_alt; |
321 | - if (old_modifier & mir_key_modifier_alt_left) |
322 | - modifier |= mir_input_event_modifier_alt_left; |
323 | - if (old_modifier & mir_key_modifier_alt_right) |
324 | - modifier |= mir_input_event_modifier_alt_right; |
325 | - if (old_modifier & mir_key_modifier_shift) |
326 | - modifier |= mir_input_event_modifier_shift; |
327 | - if (old_modifier & mir_key_modifier_shift_left) |
328 | - modifier |= mir_input_event_modifier_shift_left; |
329 | - if (old_modifier & mir_key_modifier_shift_right) |
330 | - modifier |= mir_input_event_modifier_shift_right; |
331 | - if (old_modifier & mir_key_modifier_sym) |
332 | - modifier |= mir_input_event_modifier_sym; |
333 | - if (old_modifier & mir_key_modifier_function) |
334 | - modifier |= mir_input_event_modifier_function; |
335 | - if (old_modifier & mir_key_modifier_ctrl) |
336 | - modifier |= mir_input_event_modifier_ctrl; |
337 | - if (old_modifier & mir_key_modifier_ctrl_left) |
338 | - modifier |= mir_input_event_modifier_ctrl_left; |
339 | - if (old_modifier & mir_key_modifier_ctrl_right) |
340 | - modifier |= mir_input_event_modifier_ctrl_right; |
341 | - if (old_modifier & mir_key_modifier_meta) |
342 | - modifier |= mir_input_event_modifier_meta; |
343 | - if (old_modifier & mir_key_modifier_meta_left) |
344 | - modifier |= mir_input_event_modifier_meta_left; |
345 | - if (old_modifier & mir_key_modifier_meta_right) |
346 | - modifier |= mir_input_event_modifier_meta_right; |
347 | - if (old_modifier & mir_key_modifier_caps_lock) |
348 | - modifier |= mir_input_event_modifier_caps_lock; |
349 | - if (old_modifier & mir_key_modifier_num_lock) |
350 | - modifier |= mir_input_event_modifier_num_lock; |
351 | - if (old_modifier & mir_key_modifier_scroll_lock) |
352 | - modifier |= mir_input_event_modifier_scroll_lock; |
353 | - |
354 | - if (modifier) |
355 | - return modifier; |
356 | - return mir_input_event_modifier_none; |
357 | -} |
358 | -} |
359 | - |
360 | MirInputEventModifiers mir_keyboard_event_modifiers(MirKeyboardEvent const* kev) |
361 | { |
362 | auto const& old_kev = old_kev_from_new(kev); |
363 | - return old_modifiers_to_new(old_kev.modifiers); |
364 | + return old_kev.modifiers; |
365 | } |
366 | /* Touch event accessors */ |
367 | |
368 | MirInputEventModifiers mir_touch_event_modifiers(MirTouchEvent const* tev) |
369 | { |
370 | auto const& old_mev = old_mev_from_new(tev); |
371 | - return old_modifiers_to_new(old_mev.modifiers); |
372 | + return old_mev.modifiers; |
373 | } |
374 | |
375 | MirTouchEvent const* mir_input_event_get_touch_event(MirInputEvent const* ev) |
376 | @@ -453,7 +404,7 @@ |
377 | MirInputEventModifiers mir_pointer_event_modifiers(MirPointerEvent const* pev) |
378 | { |
379 | auto const& old_mev = old_mev_from_new(pev); |
380 | - return old_modifiers_to_new(old_mev.modifiers); |
381 | + return old_mev.modifiers; |
382 | } |
383 | |
384 | MirPointerAction mir_pointer_event_action(MirPointerEvent const* pev) |
385 | |
386 | === modified file 'src/client/symbols.map' |
387 | --- src/client/symbols.map 2015-04-30 17:41:03 +0000 |
388 | +++ src/client/symbols.map 2015-05-05 05:53:22 +0000 |
389 | @@ -200,6 +200,8 @@ |
390 | mir::events::make_event*; |
391 | mir::events::add_touch*; |
392 | mir::input::android::Lexicon::translate*; |
393 | + mir::input::android::android_modifiers_from_mir*; |
394 | + mir::input::android::mir_modifiers_from_android*; |
395 | mir::client::DefaultConnectionConfiguration::DefaultConnectionConfiguration*; |
396 | mir::client::DefaultConnectionConfiguration::the_surface_map*; |
397 | mir::client::DefaultConnectionConfiguration::the_rpc_channel*; |
398 | |
399 | === modified file 'src/include/common/mir/events/event_private.h' |
400 | --- src/include/common/mir/events/event_private.h 2015-05-05 05:53:22 +0000 |
401 | +++ src/include/common/mir/events/event_private.h 2015-05-05 05:53:22 +0000 |
402 | @@ -51,27 +51,6 @@ |
403 | } MirKeyAction; |
404 | |
405 | typedef enum { |
406 | - mir_key_modifier_none = 0, |
407 | - mir_key_modifier_alt = 0x02, |
408 | - mir_key_modifier_alt_left = 0x10, |
409 | - mir_key_modifier_alt_right = 0x20, |
410 | - mir_key_modifier_shift = 0x01, |
411 | - mir_key_modifier_shift_left = 0x40, |
412 | - mir_key_modifier_shift_right = 0x80, |
413 | - mir_key_modifier_sym = 0x04, |
414 | - mir_key_modifier_function = 0x08, |
415 | - mir_key_modifier_ctrl = 0x1000, |
416 | - mir_key_modifier_ctrl_left = 0x2000, |
417 | - mir_key_modifier_ctrl_right = 0x4000, |
418 | - mir_key_modifier_meta = 0x10000, |
419 | - mir_key_modifier_meta_left = 0x20000, |
420 | - mir_key_modifier_meta_right = 0x40000, |
421 | - mir_key_modifier_caps_lock = 0x100000, |
422 | - mir_key_modifier_num_lock = 0x200000, |
423 | - mir_key_modifier_scroll_lock = 0x400000 |
424 | -} MirKeyModifier; |
425 | - |
426 | -typedef enum { |
427 | mir_motion_action_down = 0, |
428 | mir_motion_action_up = 1, |
429 | mir_motion_action_move = 2, |
430 | @@ -111,7 +90,7 @@ |
431 | int32_t device_id; |
432 | int32_t source_id; |
433 | MirKeyAction action; |
434 | - unsigned int modifiers; |
435 | + MirInputEventModifiers modifiers; |
436 | |
437 | int32_t key_code; |
438 | int32_t scan_code; |
439 | @@ -150,7 +129,7 @@ |
440 | * this way for now until we can drop SF/Hybris support in QtUbuntu. |
441 | */ |
442 | int action; |
443 | - unsigned int modifiers; |
444 | + MirInputEventModifiers modifiers; |
445 | |
446 | MirMotionButton button_state; |
447 | nsecs_t event_time; |
448 | |
449 | === added file 'src/include/common/mir/input/android/event_conversion_helpers.h' |
450 | --- src/include/common/mir/input/android/event_conversion_helpers.h 1970-01-01 00:00:00 +0000 |
451 | +++ src/include/common/mir/input/android/event_conversion_helpers.h 2015-05-05 05:53:22 +0000 |
452 | @@ -0,0 +1,36 @@ |
453 | +/* |
454 | + * Copyright © 2015 Canonical Ltd. |
455 | + * |
456 | + * This program is free software: you can redistribute it and/or modify it |
457 | + * under the terms of the GNU Lesser General Public License version 3, |
458 | + * as published by the Free Software Foundation. |
459 | + * |
460 | + * This program is distributed in the hope that it will be useful, |
461 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
462 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
463 | + * GNU Lesser General Public License for more details. |
464 | + * |
465 | + * You should have received a copy of the GNU Lesser General Public License |
466 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
467 | + * |
468 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
469 | + */ |
470 | + |
471 | +#ifndef MIR_INPUT_EVENT_CONVERSION_HELPERS_H_ |
472 | +#define MIR_INPUT_EVENT_CONVERSION_HELPERS_H_ |
473 | + |
474 | +#include "mir_toolkit/event.h" |
475 | + |
476 | +namespace mir |
477 | +{ |
478 | +namespace input |
479 | +{ |
480 | +namespace android |
481 | +{ |
482 | +MirInputEventModifiers mir_modifiers_from_android(int32_t android_modifiers); |
483 | +int32_t android_modifiers_from_mir(MirInputEventModifiers modifiers); |
484 | +} |
485 | +} |
486 | +} |
487 | + |
488 | +#endif // MIR_INPUT_EVENT_CONVERSION_HELPERS_H_ |
489 | |
490 | === modified file 'src/server/input/android/android_input_dispatcher.cpp' |
491 | --- src/server/input/android/android_input_dispatcher.cpp 2015-05-05 05:53:22 +0000 |
492 | +++ src/server/input/android/android_input_dispatcher.cpp 2015-05-05 05:53:22 +0000 |
493 | @@ -21,6 +21,7 @@ |
494 | #include "android_input_constants.h" |
495 | #include "android_input_thread.h" |
496 | |
497 | +#include "mir/input/android/event_conversion_helpers.h" |
498 | #include "mir/events/event_private.h" |
499 | |
500 | #include <InputListener.h> // NotifyArgs |
501 | @@ -75,7 +76,7 @@ |
502 | 0, /* flags */ |
503 | event.key.key_code, |
504 | event.key.scan_code, |
505 | - event.key.modifiers, |
506 | + mia::android_modifiers_from_mir(event.key.modifiers), |
507 | std::chrono::nanoseconds(event.key.event_time)); |
508 | |
509 | dispatcher->notifyKey(¬ify_key_args); |
510 | @@ -111,7 +112,7 @@ |
511 | policy_flags, |
512 | event.motion.action, |
513 | 0, /* flags */ |
514 | - event.motion.modifiers, |
515 | + mia::android_modifiers_from_mir(event.motion.modifiers), |
516 | event.motion.button_state, |
517 | 0, /* edge_flags */ |
518 | event.motion.pointer_count, |
519 | |
520 | === modified file 'src/server/input/android/input_sender.cpp' |
521 | --- src/server/input/android/input_sender.cpp 2015-05-05 05:53:22 +0000 |
522 | +++ src/server/input/android/input_sender.cpp 2015-05-05 05:53:22 +0000 |
523 | @@ -21,6 +21,7 @@ |
524 | #include "input_sender.h" |
525 | #include "input_send_entry.h" |
526 | |
527 | +#include "mir/input/android/event_conversion_helpers.h" |
528 | #include "mir/input/input_send_observer.h" |
529 | #include "mir/input/input_channel.h" |
530 | #include "mir/input/input_report.h" |
531 | @@ -244,7 +245,7 @@ |
532 | 0, /* Flags */ |
533 | event.key_code, |
534 | event.scan_code, |
535 | - event.modifiers, |
536 | + mia::android_modifiers_from_mir(event.modifiers), |
537 | event.repeat_count, |
538 | std::chrono::nanoseconds(event.event_time), |
539 | std::chrono::nanoseconds(event.event_time) |
540 | @@ -284,7 +285,7 @@ |
541 | event.action, |
542 | 0, /* flags */ |
543 | 0, /* edge flags */ |
544 | - static_cast<int32_t>(event.modifiers), |
545 | + mia::android_modifiers_from_mir(event.modifiers), |
546 | static_cast<int32_t>(event.button_state), |
547 | 0.0f, // event.x_offset, |
548 | 0.0f, // event.y_offset, |
549 | |
550 | === modified file 'src/server/input/android/input_translator.cpp' |
551 | --- src/server/input/android/input_translator.cpp 2015-05-05 05:53:22 +0000 |
552 | +++ src/server/input/android/input_translator.cpp 2015-05-05 05:53:22 +0000 |
553 | @@ -18,6 +18,7 @@ |
554 | |
555 | #include "input_translator.h" |
556 | |
557 | +#include "mir/input/android/event_conversion_helpers.h" |
558 | #include "mir/events/event_private.h" |
559 | |
560 | #include "androidfw/Input.h" |
561 | @@ -100,25 +101,31 @@ |
562 | if (!args) |
563 | return; |
564 | uint32_t policy_flags = args->policyFlags; |
565 | - int32_t modifiers = args->metaState; |
566 | + MirInputEventModifiers mir_modifiers = mia::mir_modifiers_from_android(args->metaState); |
567 | |
568 | if (policy_flags & droidinput::POLICY_FLAG_ALT) |
569 | - modifiers |= mir_key_modifier_alt | mir_key_modifier_alt_left; |
570 | + mir_modifiers |= mir_input_event_modifier_alt | mir_input_event_modifier_alt_left; |
571 | if (policy_flags & droidinput::POLICY_FLAG_ALT_GR) |
572 | - modifiers |= mir_key_modifier_alt | mir_key_modifier_alt_right; |
573 | + mir_modifiers |= mir_input_event_modifier_alt | mir_input_event_modifier_alt_right; |
574 | if (policy_flags & droidinput::POLICY_FLAG_SHIFT) |
575 | - modifiers |= mir_key_modifier_shift | mir_key_modifier_shift_left; |
576 | + mir_modifiers |= mir_input_event_modifier_shift | mir_input_event_modifier_shift_left; |
577 | if (policy_flags & droidinput::POLICY_FLAG_CAPS_LOCK) |
578 | - modifiers |= mir_key_modifier_caps_lock; |
579 | + mir_modifiers |= mir_input_event_modifier_caps_lock; |
580 | if (policy_flags & droidinput::POLICY_FLAG_FUNCTION) |
581 | - modifiers |= mir_key_modifier_function; |
582 | + mir_modifiers |= mir_input_event_modifier_function; |
583 | + |
584 | + // If we've added a modifier to none we have to remove the none flag. |
585 | + if (mir_modifiers != mir_input_event_modifier_none && mir_modifiers & mir_input_event_modifier_none) |
586 | + { |
587 | + mir_modifiers &= ~mir_input_event_modifier_none; |
588 | + } |
589 | |
590 | MirEvent mir_event; |
591 | mir_event.type = mir_event_type_key; |
592 | mir_event.key.device_id = args->deviceId; |
593 | mir_event.key.source_id = args->source; |
594 | mir_event.key.action = static_cast<MirKeyAction>(args->action); |
595 | - mir_event.key.modifiers = modifiers; |
596 | + mir_event.key.modifiers = mir_modifiers; |
597 | mir_event.key.key_code = args->keyCode; |
598 | mir_event.key.scan_code = args->scanCode; |
599 | mir_event.key.repeat_count = 0; |
600 | @@ -140,7 +147,7 @@ |
601 | mir_event.motion.device_id = args->deviceId; |
602 | mir_event.motion.source_id = args->source; |
603 | mir_event.motion.action = args->action; |
604 | - mir_event.motion.modifiers = args->metaState; |
605 | + mir_event.motion.modifiers = mia::mir_modifiers_from_android(args->metaState); |
606 | mir_event.motion.button_state = static_cast<MirMotionButton>(args->buttonState); |
607 | mir_event.motion.event_time = args->eventTime.count(); |
608 | mir_event.motion.pointer_count = args->pointerCount; |
609 | |
610 | === modified file 'src/server/input/vt_filter.cpp' |
611 | --- src/server/input/vt_filter.cpp 2015-04-01 19:39:19 +0000 |
612 | +++ src/server/input/vt_filter.cpp 2015-05-05 05:53:22 +0000 |
613 | @@ -39,8 +39,8 @@ |
614 | { |
615 | if (event.type == mir_event_type_key && |
616 | event.key.action == mir_key_action_down && |
617 | - (event.key.modifiers & mir_key_modifier_alt) && |
618 | - (event.key.modifiers & mir_key_modifier_ctrl)) |
619 | + (event.key.modifiers & mir_input_event_modifier_alt) && |
620 | + (event.key.modifiers & mir_input_event_modifier_ctrl)) |
621 | { |
622 | switch (event.key.scan_code) |
623 | { |
624 | |
625 | === modified file 'tests/unit-tests/input/android/test_android_input_dispatcher.cpp' |
626 | --- tests/unit-tests/input/android/test_android_input_dispatcher.cpp 2015-05-05 05:53:22 +0000 |
627 | +++ tests/unit-tests/input/android/test_android_input_dispatcher.cpp 2015-05-05 05:53:22 +0000 |
628 | @@ -179,7 +179,7 @@ |
629 | event.motion.device_id = 3; |
630 | event.motion.source_id = 4; |
631 | event.motion.action = mir_motion_action_scroll; |
632 | - event.motion.modifiers = 6; |
633 | + event.motion.modifiers = mir_input_event_modifier_shift, |
634 | event.motion.button_state = |
635 | static_cast<MirMotionButton>(mir_motion_button_forward | mir_motion_button_secondary); |
636 | |
637 | @@ -214,7 +214,7 @@ |
638 | default_policy_flags, |
639 | event.motion.action, |
640 | 0, /* flags */ |
641 | - event.motion.modifiers, |
642 | + AMETA_SHIFT_ON, |
643 | event.motion.button_state, |
644 | 0, /* edge_flags */ |
645 | event.motion.pointer_count, |
646 | @@ -240,7 +240,7 @@ |
647 | event.key.scan_code = 4; |
648 | event.key.key_code = 5; |
649 | event.key.repeat_count = 0; |
650 | - event.key.modifiers = 7; |
651 | + event.key.modifiers = mir_input_event_modifier_shift; |
652 | |
653 | droidinput::NotifyKeyArgs expected(std::chrono::nanoseconds(event.key.event_time), |
654 | event.key.device_id, |
655 | @@ -250,7 +250,7 @@ |
656 | 0, /* flags */ |
657 | event.key.key_code, |
658 | event.key.scan_code, |
659 | - event.key.modifiers, |
660 | + AMETA_SHIFT_ON, |
661 | std::chrono::nanoseconds(event.key.event_time)); |
662 | |
663 | EXPECT_CALL(*dispatcher, notifyKey(KeyArgsMatches(expected))); |
664 | |
665 | === modified file 'tests/unit-tests/input/android/test_android_input_lexicon.cpp' |
666 | --- tests/unit-tests/input/android/test_android_input_lexicon.cpp 2015-05-05 05:53:22 +0000 |
667 | +++ tests/unit-tests/input/android/test_android_input_lexicon.cpp 2015-05-05 05:53:22 +0000 |
668 | @@ -38,7 +38,7 @@ |
669 | const int32_t flags = 4; |
670 | const int32_t key_code = 5; |
671 | const int32_t scan_code = 6; |
672 | - const int32_t meta_state = 7; |
673 | + const int32_t meta_state = AMETA_ALT_ON; |
674 | const int32_t repeat_count = 8; |
675 | auto const down_time = std::chrono::nanoseconds(9); |
676 | auto const event_time = std::chrono::nanoseconds(10); |
677 | @@ -54,7 +54,7 @@ |
678 | EXPECT_EQ(device_id, mir_ev.key.device_id); |
679 | EXPECT_EQ(source_id, mir_ev.key.source_id); |
680 | EXPECT_EQ(action, mir_ev.key.action); |
681 | - EXPECT_EQ((unsigned int)meta_state, mir_ev.key.modifiers); |
682 | + EXPECT_EQ(mir_input_event_modifier_alt, mir_ev.key.modifiers); |
683 | |
684 | auto mir_key_ev = &mir_ev.key; |
685 | // Key event specific properties |
686 | @@ -129,7 +129,6 @@ |
687 | EXPECT_EQ(device_id, mir_ev.motion.device_id); |
688 | EXPECT_EQ(source_id, mir_ev.motion.source_id); |
689 | EXPECT_EQ(action, mir_ev.motion.action); |
690 | - EXPECT_EQ((unsigned int)meta_state, mir_ev.motion.modifiers); |
691 | |
692 | // Motion event specific properties |
693 | EXPECT_EQ(mir_ev.type, mir_event_type_motion); |
694 | @@ -237,7 +236,6 @@ |
695 | EXPECT_EQ(device_id, mir_ev.motion.device_id); |
696 | EXPECT_EQ(source_id, mir_ev.motion.source_id); |
697 | EXPECT_EQ(action, mir_ev.motion.action); |
698 | - EXPECT_EQ((unsigned int)meta_state, mir_ev.motion.modifiers); |
699 | |
700 | // Motion event specific properties |
701 | EXPECT_EQ(mir_ev.type, mir_event_type_motion); |
702 | |
703 | === modified file 'tests/unit-tests/input/android/test_input_translator.cpp' |
704 | --- tests/unit-tests/input/android/test_input_translator.cpp 2015-05-05 05:53:22 +0000 |
705 | +++ tests/unit-tests/input/android/test_input_translator.cpp 2015-05-05 05:53:22 +0000 |
706 | @@ -252,7 +252,7 @@ |
707 | expected.key.scan_code = 4; |
708 | expected.key.key_code = 5; |
709 | expected.key.repeat_count = 0; |
710 | - expected.key.modifiers = 7; |
711 | + expected.key.modifiers = mir_input_event_modifier_shift; |
712 | |
713 | InSequence seq; |
714 | EXPECT_CALL(dispatcher, dispatch(mt::MirKeyEventMatches(expected))).Times(1); |
715 | @@ -265,7 +265,7 @@ |
716 | 0, /* flags */ |
717 | expected.key.key_code, |
718 | expected.key.scan_code, |
719 | - expected.key.modifiers, |
720 | + AMETA_SHIFT_ON, |
721 | std::chrono::nanoseconds(expected.key.event_time)); |
722 | |
723 | translator.notifyKey(¬ified); |
724 | |
725 | === modified file 'tests/unit-tests/input/test_input_event.cpp' |
726 | --- tests/unit-tests/input/test_input_event.cpp 2015-04-01 19:39:19 +0000 |
727 | +++ tests/unit-tests/input/test_input_event.cpp 2015-05-05 05:53:22 +0000 |
728 | @@ -150,17 +150,17 @@ |
729 | { |
730 | xkb_keysym_t key_code = 171; |
731 | int scan_code = 31; |
732 | - MirKeyModifier old_modifiers = mir_key_modifier_shift; |
733 | + MirInputEventModifiers modifiers = mir_input_event_modifier_shift; |
734 | |
735 | auto old_ev = a_key_ev(); |
736 | old_ev.key.key_code = key_code; |
737 | old_ev.key.scan_code = scan_code; |
738 | - old_ev.key.modifiers = old_modifiers; |
739 | + old_ev.key.modifiers = modifiers; |
740 | |
741 | auto new_kev = mir_input_event_get_keyboard_event(mir_event_get_input_event(&old_ev)); |
742 | EXPECT_EQ(key_code, mir_keyboard_event_key_code(new_kev)); |
743 | EXPECT_EQ(scan_code, mir_keyboard_event_scan_code(new_kev)); |
744 | - EXPECT_EQ(mir_input_event_modifier_shift, mir_keyboard_event_modifiers(new_kev)); |
745 | + EXPECT_EQ(modifiers, mir_keyboard_event_modifiers(new_kev)); |
746 | } |
747 | |
748 | TEST(TouchEventProperties, touch_count_taken_from_pointer_count) |
749 | @@ -296,12 +296,13 @@ |
750 | |
751 | TEST(PointerInputEventProperties, modifiers_taken_from_old_style_ev) |
752 | { |
753 | + MirInputEventModifiers modifiers = mir_input_event_modifier_shift; |
754 | auto old_ev = a_motion_ev(AINPUT_SOURCE_MOUSE); |
755 | - old_ev.motion.modifiers = mir_key_modifier_shift; |
756 | + old_ev.motion.modifiers = modifiers; |
757 | |
758 | auto pointer_event = |
759 | mir_input_event_get_pointer_event(mir_event_get_input_event(&old_ev)); |
760 | - EXPECT_EQ(mir_input_event_modifier_shift, mir_pointer_event_modifiers(pointer_event)); |
761 | + EXPECT_EQ(modifiers, mir_pointer_event_modifiers(pointer_event)); |
762 | } |
763 | |
764 | namespace |
FAILED: Continuous integration, rev:2542 jenkins. qa.ubuntu. com/job/ mir-ci/ 3698/ jenkins. qa.ubuntu. com/job/ mir-android- vivid-i386- build/2293/ console jenkins. qa.ubuntu. com/job/ mir-clang- vivid-amd64- build/2292 jenkins. qa.ubuntu. com/job/ mir-mediumtests -vivid- touch/2241/ console jenkins. qa.ubuntu. com/job/ mir-vivid- amd64-ci/ 1695/console jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- vivid-armhf/ 2241/console
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/mir- ci/3698/ rebuild
http://