Mir

Merge lp:~mir-team/mir/unify-pointer-button into lp:mir

Proposed by Robert Carr
Status: Merged
Approved by: Robert Carr
Approved revision: no longer in the source branch.
Merged at revision: 2589
Proposed branch: lp:~mir-team/mir/unify-pointer-button
Merge into: lp:mir
Prerequisite: lp:~andreas-pokorny/mir/connect-cursor-listener-to-input-device-hub
Diff against target: 778 lines (+190/-114)
25 files modified
include/client/mir/events/event_builders.h (+1/-2)
include/client/mir_toolkit/events/input/pointer_event.h (+15/-5)
src/client/events/event_builders.cpp (+19/-30)
src/client/input/android/android_input_lexicon.cpp (+1/-1)
src/client/input/android/event_conversion_helpers.cpp (+34/-0)
src/client/input/input_event.cpp (+11/-5)
src/client/symbols.map (+3/-0)
src/include/common/mir/events/event_private.h (+1/-9)
src/include/common/mir/input/android/event_conversion_helpers.h (+3/-1)
src/server/input/android/android_input_dispatcher.cpp (+1/-1)
src/server/input/android/input_sender.cpp (+1/-1)
src/server/input/android/input_translator.cpp (+1/-1)
tests/acceptance-tests/test_client_input.cpp (+43/-0)
tests/acceptance-tests/test_surface_modifications.cpp (+2/-4)
tests/acceptance-tests/test_surface_placement.cpp (+1/-1)
tests/include/mir_test/event_matchers.h (+26/-25)
tests/mir_test_framework/fake_input_device_impl.cpp (+3/-3)
tests/mir_test_framework/fake_input_device_impl.h (+1/-3)
tests/unit-tests/input/android/test_android_input_dispatcher.cpp (+5/-4)
tests/unit-tests/input/android/test_android_input_lexicon.cpp (+2/-5)
tests/unit-tests/input/android/test_input_translator.cpp (+2/-3)
tests/unit-tests/input/test_default_input_device_hub.cpp (+3/-3)
tests/unit-tests/input/test_event_builders.cpp (+2/-4)
tests/unit-tests/input/test_input_event.cpp (+8/-2)
tests/unit-tests/scene/test_abstract_shell.cpp (+1/-1)
To merge this branch: bzr merge lp:~mir-team/mir/unify-pointer-button
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alberto Aguirre (community) Approve
Alan Griffiths Approve
Daniel van Vugt Pending
Alexandros Frantzis Pending
Andreas Pokorny Pending
Kevin DuBois Pending
Review via email: mp+259148@code.launchpad.net

This proposal supersedes a proposal from 2015-05-05.

Commit message

Unify the pointer button enumerations.

Description of the change

Unify the pointer button enums. The new style event buttons are not using a mask so as to allow for extensibility so there is some churn in the change of the internal representation.

Resubmit to depend on connect-cursor-listener-to-input-device-hub to enhanced testing

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 : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal

> The new style event buttons are not using a mask so as to allow for extensibility so there
> is some churn in the change of the internal representation.

How is having a mask reduce extensibility? Do you mean running out of bits?

190+ bool button_state[mir_pointer_button_forward + 1];

This will break if we add a new member to the enum (although we will probably catch the issue at compile time). In any case, it's best to introduce a mir_pointer_button_count (or similar) value, and actually make it a policy to have such a member in all suitable enums.

Needs info/fixing

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote : Posted in a previous version of this proposal

Added mir_pointer_button_Count...good call...tbh I dont like this solution that much but I'm concerned about the extensibility with flags (e.g. running out of bits). In particular what if devices have buttons only available through some sort of mir_input_device_list_buttons_ API (e.g. they don't correspond to forward/back...)? ON the other hand I guess this device wouldn't be a pointer...maybe flags are fine...I'd like to get another opinion! RAOF?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Seems self-consistent.

But I'm a little concerned that other APIs treat buttons as bitmasks (e.g. "143+ android_state |= AMOTION_EVENT_BUTTON_PRIMARY;"). Apart from not matching expectations are we really sure we know better?

review: Needs Information
Revision history for this message
Robert Carr (robertcarr) wrote : Posted in a previous version of this proposal

I've thought through my concerns that related to nto storing buttons as a flag. Primarly I was worried about exotic devices and allocating button indices for them and potentially running out of flag values. I suppose if anything though such devices would not be pointers and only available throuhg the raw input API so I'm not concerned. Updated branch to use flag...required more client ABI break :)

Revision history for this message
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal

nonblocking comment:
The bitmask seems okay for now, plenty of unused bits left.

needs-info
77+ mev.button_state[mir_pointer_button_tertiary] = true;

Since this appears private now, could we have something more like:
mev.button_state[mir_pointer_button_tertiary] = pressed;
It took a bit of reading of the struct to figure out what was going on in the present form.

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal

ok looks good apart from the merge conflict

Revision history for this message
Andreas Pokorny (andreas-pokorny) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

(0) MirPointerButton: Definitely a client ABI break now, so we must remember to bump to libmirclient9 ASAP (Alan is working on it but blocked by CI annoyances).

(1) I guess this isn't well tested yet because there's a logic error (should be "&="):
365 - buttons.erase(remove(begin(buttons), end(buttons), button));
366 + buttons |= ~button;

review: Needs Fixing
Revision history for this message
Alexandros Frantzis (afrantzis) wrote : Posted in a previous version of this proposal

Besides Daniel's "Needs Fixing", looks good.

Nit:

239-

Why remove the line?

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Agree with Daniel about test coverage and Alexandros about whitespace.

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

Good catch that the fake input device wasn't properly tested. Real devices worked though! Merged connect-cursor-listener-to-input-device-hub in order to write a test to make this possible.

Added said test (see diff: presses and releases all buttons)

Discovered another issue: If we omit mir_motion_action_down (gesture start) for a second button down instead of mir_motion_action_pointer_down the "conflicting action" codepath in android::InputDispatcher::findFocusedWindowTargetsLocked and the event gets converted to a motion event. Corrected this with some refactoring to the event builders.

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
Alan Griffiths (alan-griffiths) wrote :

=== modified file '3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp'

Are the changes to this file anything to do with merging the pointer types?

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

Removed extra changes

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

229 + auto const& old_mev = old_mev_from_new(pev);
230 + return old_mev.buttons;

There still seems little point in naming the reference. (C.f. return old_mev_from_new(pev).buttons;)

review: Approve
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM

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

(2) This could be simplified with a while loop with bitshift each time, but not a blocking issue:
90 +int count_buttons(MirPointerButtons buttons)

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) :
review: Approve (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) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/client/mir/events/event_builders.h'
--- include/client/mir/events/event_builders.h 2015-05-13 06:23:25 +0000
+++ include/client/mir/events/event_builders.h 2015-05-20 14:14:47 +0000
@@ -25,7 +25,6 @@
25#include "mir/frontend/surface_id.h"25#include "mir/frontend/surface_id.h"
2626
27#include <memory>27#include <memory>
28#include <vector>
29#include <functional>28#include <functional>
30#include <chrono>29#include <chrono>
3130
@@ -63,7 +62,7 @@
63// Pointer event62// Pointer event
64EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,63EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
65 MirInputEventModifiers modifiers, MirPointerAction action,64 MirInputEventModifiers modifiers, MirPointerAction action,
66 std::vector<MirPointerButton> const& buttons_pressed,65 MirPointerButtons buttons_pressed,
67 float x_axis_value, float y_axis_value,66 float x_axis_value, float y_axis_value,
68 float hscroll_value, float vscroll_value);67 float hscroll_value, float vscroll_value);
69}68}
7069
=== modified file 'include/client/mir_toolkit/events/input/pointer_event.h'
--- include/client/mir_toolkit/events/input/pointer_event.h 2015-03-31 02:35:42 +0000
+++ include/client/mir_toolkit/events/input/pointer_event.h 2015-05-20 14:14:47 +0000
@@ -68,12 +68,13 @@
68 * Identifiers for pointer buttons68 * Identifiers for pointer buttons
69 */69 */
70typedef enum {70typedef enum {
71 mir_pointer_button_primary = 1,71 mir_pointer_button_primary = 1 << 0,
72 mir_pointer_button_secondary = 2,72 mir_pointer_button_secondary = 1 << 1,
73 mir_pointer_button_tertiary = 3,73 mir_pointer_button_tertiary = 1 << 2,
74 mir_pointer_button_back = 4,74 mir_pointer_button_back = 1 << 3,
75 mir_pointer_button_forward = 575 mir_pointer_button_forward = 1 << 4
76} MirPointerButton;76} MirPointerButton;
77typedef unsigned int MirPointerButtons;
7778
78/**79/**
79 * Retrieve the modifier keys pressed when the pointer action occured.80 * Retrieve the modifier keys pressed when the pointer action occured.
@@ -103,6 +104,15 @@
103 MirPointerButton button);104 MirPointerButton button);
104105
105/**106/**
107 * Retreive the pointer button state as a masked set of values.
108 *
109 * \param [in] event The pointer event
110 *
111 * \return The button state
112 */
113MirPointerButtons mir_pointer_event_buttons(MirPointerEvent const* event);
114
115/**
106 * Retrieve the axis value reported by a given pointer event.116 * Retrieve the axis value reported by a given pointer event.
107 *117 *
108 * \param [in] event The pointer event118 * \param [in] event The pointer event
109119
=== modified file 'src/client/events/event_builders.cpp'
--- src/client/events/event_builders.cpp 2015-05-19 14:02:31 +0000
+++ src/client/events/event_builders.cpp 2015-05-20 14:14:47 +0000
@@ -231,29 +231,40 @@
231231
232namespace232namespace
233{233{
234MirMotionAction old_action_from_pointer_action(MirPointerAction action, MirMotionButton button_state)234MirMotionAction old_action_from_pointer_action(MirPointerAction action, int buttons_pressed)
235{235{
236 switch (action)236 switch (action)
237 {237 {
238 case mir_pointer_action_button_up:238 case mir_pointer_action_button_up:
239 return mir_motion_action_up;239 return buttons_pressed == 0 ? mir_motion_action_up : mir_motion_action_pointer_up;
240 case mir_pointer_action_button_down:240 case mir_pointer_action_button_down:
241 return mir_motion_action_down;241 return buttons_pressed == 1 ? mir_motion_action_down : mir_motion_action_pointer_down;
242 case mir_pointer_action_enter:242 case mir_pointer_action_enter:
243 return mir_motion_action_hover_enter;243 return mir_motion_action_hover_enter;
244 case mir_pointer_action_leave:244 case mir_pointer_action_leave:
245 return mir_motion_action_hover_exit;245 return mir_motion_action_hover_exit;
246 case mir_pointer_action_motion:246 case mir_pointer_action_motion:
247 return button_state ? mir_motion_action_move : mir_motion_action_hover_move;247 return buttons_pressed ? mir_motion_action_move : mir_motion_action_hover_move;
248 default:248 default:
249 BOOST_THROW_EXCEPTION(std::logic_error("Invalid pointer action"));249 BOOST_THROW_EXCEPTION(std::logic_error("Invalid pointer action"));
250 }250 }
251}251}
252int count_buttons(MirPointerButtons buttons)
253{
254 int ret = 0;
255 if (buttons & mir_pointer_button_primary) ret++;
256 if (buttons & mir_pointer_button_secondary) ret++;
257 if (buttons & mir_pointer_button_tertiary) ret++;
258 if (buttons & mir_pointer_button_forward) ret++;
259 if (buttons & mir_pointer_button_back) ret++;
260
261 return ret;
262}
252}263}
253264
254mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,265mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
255 MirInputEventModifiers modifiers, MirPointerAction action,266 MirInputEventModifiers modifiers, MirPointerAction action,
256 std::vector<MirPointerButton> const& buttons_pressed,267 MirPointerButtons buttons_pressed,
257 float x_axis_value, float y_axis_value,268 float x_axis_value, float y_axis_value,
258 float hscroll_value, float vscroll_value)269 float hscroll_value, float vscroll_value)
259{270{
@@ -266,31 +277,9 @@
266 mev.event_time = timestamp;277 mev.event_time = timestamp;
267 mev.modifiers = modifiers;278 mev.modifiers = modifiers;
268 mev.source_id = AINPUT_SOURCE_MOUSE;279 mev.source_id = AINPUT_SOURCE_MOUSE;
269280 mev.buttons = buttons_pressed;
270 int button_state = 0;281
271 for (auto button : buttons_pressed)282 mev.action = old_action_from_pointer_action(action, count_buttons(buttons_pressed));
272 {
273 switch (button)
274 {
275 case mir_pointer_button_primary:
276 button_state |= mir_motion_button_primary;
277 break;
278 case mir_pointer_button_secondary:
279 button_state |= mir_motion_button_secondary;
280 break;
281 case mir_pointer_button_tertiary:
282 button_state |= mir_motion_button_tertiary;
283 break;
284 case mir_pointer_button_back:
285 button_state |= mir_motion_button_back;
286 break;
287 case mir_pointer_button_forward:
288 button_state |= mir_motion_button_forward;
289 break;
290 }
291 }
292 mev.button_state = static_cast<MirMotionButton>(button_state);
293 mev.action = old_action_from_pointer_action(action, mev.button_state);
294283
295 mev.pointer_count = 1;284 mev.pointer_count = 1;
296 auto& pc = mev.pointer_coordinates[0];285 auto& pc = mev.pointer_coordinates[0];
297286
=== modified file 'src/client/input/android/android_input_lexicon.cpp'
--- src/client/input/android/android_input_lexicon.cpp 2015-05-13 06:23:25 +0000
+++ src/client/input/android/android_input_lexicon.cpp 2015-05-20 14:14:47 +0000
@@ -50,7 +50,7 @@
50 mir_event.motion.source_id = android_event->getSource();50 mir_event.motion.source_id = android_event->getSource();
51 mir_event.motion.action = mev->getAction();51 mir_event.motion.action = mev->getAction();
52 mir_event.motion.modifiers = mia::mir_modifiers_from_android(mev->getMetaState());52 mir_event.motion.modifiers = mia::mir_modifiers_from_android(mev->getMetaState());
53 mir_event.motion.button_state = static_cast<MirMotionButton>(mev->getButtonState());53 mir_event.motion.buttons = mia::mir_pointer_buttons_from_android(mev->getButtonState());
54 mir_event.motion.event_time = mev->getEventTime();54 mir_event.motion.event_time = mev->getEventTime();
55 mir_event.motion.pointer_count = mev->getPointerCount();55 mir_event.motion.pointer_count = mev->getPointerCount();
56 for(unsigned int i = 0; i < mev->getPointerCount(); i++)56 for(unsigned int i = 0; i < mev->getPointerCount(); i++)
5757
=== modified file 'src/client/input/android/event_conversion_helpers.cpp'
--- src/client/input/android/event_conversion_helpers.cpp 2015-05-13 06:23:25 +0000
+++ src/client/input/android/event_conversion_helpers.cpp 2015-05-20 14:14:47 +0000
@@ -100,3 +100,37 @@
100 return AKEY_EVENT_ACTION_UP;100 return AKEY_EVENT_ACTION_UP;
101 }101 }
102}102}
103
104MirPointerButtons mia::mir_pointer_buttons_from_android(int32_t android_state)
105{
106 MirPointerButtons buttons = 0;
107
108 if (android_state & AMOTION_EVENT_BUTTON_PRIMARY)
109 buttons |= mir_pointer_button_primary;
110 if (android_state & AMOTION_EVENT_BUTTON_SECONDARY)
111 buttons |= mir_pointer_button_secondary;
112 if (android_state & AMOTION_EVENT_BUTTON_TERTIARY)
113 buttons |= mir_pointer_button_tertiary;
114 if (android_state & AMOTION_EVENT_BUTTON_BACK)
115 buttons |= mir_pointer_button_back;
116 if (android_state & AMOTION_EVENT_BUTTON_FORWARD)
117 buttons |= mir_pointer_button_forward;
118
119 return buttons;
120}
121
122int32_t mia::android_pointer_buttons_from_mir(MirPointerButtons buttons)
123{
124 int32_t android_state = 0;
125 if (buttons & mir_pointer_button_primary)
126 android_state |= AMOTION_EVENT_BUTTON_PRIMARY;
127 if (buttons & mir_pointer_button_secondary)
128 android_state |= AMOTION_EVENT_BUTTON_SECONDARY;
129 if (buttons & mir_pointer_button_tertiary)
130 android_state |= AMOTION_EVENT_BUTTON_TERTIARY;
131 if (buttons & mir_pointer_button_back)
132 android_state |= AMOTION_EVENT_BUTTON_BACK;
133 if (buttons & mir_pointer_button_forward)
134 android_state |= AMOTION_EVENT_BUTTON_FORWARD;
135 return android_state;
136}
103137
=== modified file 'src/client/input/input_event.cpp'
--- src/client/input/input_event.cpp 2015-05-13 06:23:25 +0000
+++ src/client/input/input_event.cpp 2015-05-20 14:14:47 +0000
@@ -424,20 +424,26 @@
424 switch (button)424 switch (button)
425 {425 {
426 case mir_pointer_button_primary:426 case mir_pointer_button_primary:
427 return old_mev.button_state & mir_motion_button_primary;427 return old_mev.buttons & mir_pointer_button_primary;
428 case mir_pointer_button_secondary:428 case mir_pointer_button_secondary:
429 return old_mev.button_state & mir_motion_button_secondary;429 return old_mev.buttons & mir_pointer_button_secondary;
430 case mir_pointer_button_tertiary:430 case mir_pointer_button_tertiary:
431 return old_mev.button_state & mir_motion_button_tertiary;431 return old_mev.buttons & mir_pointer_button_tertiary;
432 case mir_pointer_button_back:432 case mir_pointer_button_back:
433 return old_mev.button_state & mir_motion_button_back;433 return old_mev.buttons & mir_pointer_button_back;
434 case mir_pointer_button_forward:434 case mir_pointer_button_forward:
435 return old_mev.button_state & mir_motion_button_forward;435 return old_mev.buttons & mir_pointer_button_forward;
436 default:436 default:
437 return false;437 return false;
438 }438 }
439}439}
440440
441MirPointerButtons mir_pointer_event_buttons(MirPointerEvent const* pev)
442{
443 auto const& old_mev = old_mev_from_new(pev);
444 return old_mev.buttons;
445}
446
441float mir_pointer_event_axis_value(MirPointerEvent const* pev, MirPointerAxis axis)447float mir_pointer_event_axis_value(MirPointerEvent const* pev, MirPointerAxis axis)
442{448{
443 auto const& old_mev = old_mev_from_new(pev);449 auto const& old_mev = old_mev_from_new(pev);
444450
=== modified file 'src/client/symbols.map'
--- src/client/symbols.map 2015-05-13 06:23:25 +0000
+++ src/client/symbols.map 2015-05-20 14:14:47 +0000
@@ -196,6 +196,7 @@
196 mir_buffer_stream_release;196 mir_buffer_stream_release;
197 mir_buffer_stream_release_sync;197 mir_buffer_stream_release_sync;
198 mir_buffer_stream_is_valid;198 mir_buffer_stream_is_valid;
199 mir_pointer_event_buttons; # Move to 8.5
199} MIR_CLIENT_8.3;200} MIR_CLIENT_8.3;
200201
201MIR_CLIENT_DETAIL_8 {202MIR_CLIENT_DETAIL_8 {
@@ -208,6 +209,8 @@
208 mir::input::android::mir_modifiers_from_android*;209 mir::input::android::mir_modifiers_from_android*;
209 mir::input::android::mir_keyboard_action_from_android*;210 mir::input::android::mir_keyboard_action_from_android*;
210 mir::input::android::android_keyboard_action_from_mir*;211 mir::input::android::android_keyboard_action_from_mir*;
212 mir::input::android::mir_pointer_buttons_from_android*;
213 mir::input::android::android_pointer_buttons_from_mir*;
211 mir::client::DefaultConnectionConfiguration::DefaultConnectionConfiguration*;214 mir::client::DefaultConnectionConfiguration::DefaultConnectionConfiguration*;
212 mir::client::DefaultConnectionConfiguration::the_surface_map*;215 mir::client::DefaultConnectionConfiguration::the_surface_map*;
213 mir::client::DefaultConnectionConfiguration::the_rpc_channel*;216 mir::client::DefaultConnectionConfiguration::the_rpc_channel*;
214217
=== modified file 'src/include/common/mir/events/event_private.h'
--- src/include/common/mir/events/event_private.h 2015-05-13 06:23:25 +0000
+++ src/include/common/mir/events/event_private.h 2015-05-20 14:14:47 +0000
@@ -60,14 +60,6 @@
60} MirMotionAction;60} MirMotionAction;
6161
62typedef enum {62typedef enum {
63 mir_motion_button_primary = 1 << 0,
64 mir_motion_button_secondary = 1 << 1,
65 mir_motion_button_tertiary = 1 << 2,
66 mir_motion_button_back = 1 << 3,
67 mir_motion_button_forward = 1 << 4
68} MirMotionButton;
69
70typedef enum {
71 mir_motion_tool_type_unknown = 0,63 mir_motion_tool_type_unknown = 0,
72 mir_motion_tool_type_finger = 1,64 mir_motion_tool_type_finger = 1,
73 mir_motion_tool_type_stylus = 2,65 mir_motion_tool_type_stylus = 2,
@@ -125,7 +117,7 @@
125 int action;117 int action;
126 MirInputEventModifiers modifiers;118 MirInputEventModifiers modifiers;
127119
128 MirMotionButton button_state;120 MirPointerButtons buttons;
129 std::chrono::nanoseconds event_time;121 std::chrono::nanoseconds event_time;
130122
131 size_t pointer_count;123 size_t pointer_count;
132124
=== modified file 'src/include/common/mir/input/android/event_conversion_helpers.h'
--- src/include/common/mir/input/android/event_conversion_helpers.h 2015-05-13 06:23:25 +0000
+++ src/include/common/mir/input/android/event_conversion_helpers.h 2015-05-20 14:14:47 +0000
@@ -31,13 +31,15 @@
31int32_t android_modifiers_from_mir(MirInputEventModifiers modifiers);31int32_t android_modifiers_from_mir(MirInputEventModifiers modifiers);
3232
33MirKeyboardAction mir_keyboard_action_from_android(int32_t android_action, int32_t repeat_count);33MirKeyboardAction mir_keyboard_action_from_android(int32_t android_action, int32_t repeat_count);
34
35// Mir differentiates between mir_keyboard_action_down34// Mir differentiates between mir_keyboard_action_down
36// and mir_keyboard_action_repeat whereas android encodes35// and mir_keyboard_action_repeat whereas android encodes
37// keyrepeats as AKEY_EVENT_ACTION_DOWN and a repeatCount of > 036// keyrepeats as AKEY_EVENT_ACTION_DOWN and a repeatCount of > 0
38// Thus when converting from MirKeyboardAction to an android37// Thus when converting from MirKeyboardAction to an android
39// action we must also fetch a repeat count for the android event.38// action we must also fetch a repeat count for the android event.
40int32_t android_keyboard_action_from_mir(int32_t& repeat_count_out, MirKeyboardAction action);39int32_t android_keyboard_action_from_mir(int32_t& repeat_count_out, MirKeyboardAction action);
40
41MirPointerButtons mir_pointer_buttons_from_android(int32_t android_state);
42int32_t android_pointer_buttons_from_mir(MirPointerButtons buttons);
41}43}
42}44}
43}45}
4446
=== modified file 'src/server/input/android/android_input_dispatcher.cpp'
--- src/server/input/android/android_input_dispatcher.cpp 2015-05-13 06:23:25 +0000
+++ src/server/input/android/android_input_dispatcher.cpp 2015-05-20 14:14:47 +0000
@@ -102,7 +102,7 @@
102 event.motion.action,102 event.motion.action,
103 0, /* flags */103 0, /* flags */
104 mia::android_modifiers_from_mir(event.motion.modifiers),104 mia::android_modifiers_from_mir(event.motion.modifiers),
105 event.motion.button_state,105 mia::android_pointer_buttons_from_mir(event.motion.buttons),
106 0, /* edge_flags */106 0, /* edge_flags */
107 event.motion.pointer_count,107 event.motion.pointer_count,
108 pointer_properties.data(),108 pointer_properties.data(),
109109
=== modified file 'src/server/input/android/input_sender.cpp'
--- src/server/input/android/input_sender.cpp 2015-05-13 06:23:25 +0000
+++ src/server/input/android/input_sender.cpp 2015-05-20 14:14:47 +0000
@@ -288,7 +288,7 @@
288 0, /* flags */288 0, /* flags */
289 0, /* edge flags */289 0, /* edge flags */
290 mia::android_modifiers_from_mir(event.modifiers),290 mia::android_modifiers_from_mir(event.modifiers),
291 static_cast<int32_t>(event.button_state),291 mia::android_pointer_buttons_from_mir(event.buttons),
292 0.0f, // event.x_offset,292 0.0f, // event.x_offset,
293 0.0f, // event.y_offset,293 0.0f, // event.y_offset,
294 0, 0, /* unused x/y precision */294 0, 0, /* unused x/y precision */
295295
=== modified file 'src/server/input/android/input_translator.cpp'
--- src/server/input/android/input_translator.cpp 2015-05-13 06:23:25 +0000
+++ src/server/input/android/input_translator.cpp 2015-05-20 14:14:47 +0000
@@ -147,7 +147,7 @@
147 mir_event.motion.source_id = args->source;147 mir_event.motion.source_id = args->source;
148 mir_event.motion.action = args->action;148 mir_event.motion.action = args->action;
149 mir_event.motion.modifiers = mia::mir_modifiers_from_android(args->metaState);149 mir_event.motion.modifiers = mia::mir_modifiers_from_android(args->metaState);
150 mir_event.motion.button_state = static_cast<MirMotionButton>(args->buttonState);150 mir_event.motion.buttons = mia::mir_pointer_buttons_from_android(args->buttonState);
151 mir_event.motion.event_time = args->eventTime;151 mir_event.motion.event_time = args->eventTime;
152 mir_event.motion.pointer_count = args->pointerCount;152 mir_event.motion.pointer_count = args->pointerCount;
153 for(unsigned int i = 0; i < args->pointerCount; i++)153 for(unsigned int i = 0; i < args->pointerCount; i++)
154154
=== modified file 'tests/acceptance-tests/test_client_input.cpp'
--- tests/acceptance-tests/test_client_input.cpp 2015-05-19 14:02:31 +0000
+++ tests/acceptance-tests/test_client_input.cpp 2015-05-20 14:14:47 +0000
@@ -242,6 +242,49 @@
242 first_client.all_events_received.wait_for_at_most_seconds(10);242 first_client.all_events_received.wait_for_at_most_seconds(10);
243}243}
244244
245TEST_F(TestClientInput, clients_receive_many_button_events_inside_window)
246{
247 Client first_client(new_connection(), first);
248 // The cursor starts at (0, 0).
249
250 InSequence seq;
251 auto expect_buttons = [&](MirPointerButtons b) {
252 EXPECT_CALL(first_client, handle_input(mt::ButtonsDown(0, 0, b)));
253 };
254
255 MirPointerButtons buttons = mir_pointer_button_primary;
256 expect_buttons(buttons);
257 expect_buttons(buttons |= mir_pointer_button_secondary);
258 expect_buttons(buttons |= mir_pointer_button_tertiary);
259 expect_buttons(buttons |= mir_pointer_button_forward);
260 expect_buttons(buttons |= mir_pointer_button_back);
261 expect_buttons(buttons &= ~mir_pointer_button_back);
262 expect_buttons(buttons &= ~mir_pointer_button_forward);
263 expect_buttons(buttons &= ~mir_pointer_button_tertiary);
264 expect_buttons(buttons &= ~mir_pointer_button_secondary);
265 EXPECT_CALL(first_client, handle_input(mt::ButtonsDown(0, 0, 0))).WillOnce(
266 mt::WakeUp(&first_client.all_events_received));
267
268 auto press_button = [&](int button) {
269 fake_mouse->emit_event(mis::a_button_down_event().of_button(button).with_action(mis::EventAction::Down));
270 };
271 auto release_button = [&](int button) {
272 fake_mouse->emit_event(mis::a_button_up_event().of_button(button).with_action(mis::EventAction::Up));
273 };
274 press_button(BTN_LEFT);
275 press_button(BTN_RIGHT);
276 press_button(BTN_MIDDLE);
277 press_button(BTN_FORWARD);
278 press_button(BTN_BACK);
279 release_button(BTN_BACK);
280 release_button(BTN_FORWARD);
281 release_button(BTN_MIDDLE);
282 release_button(BTN_RIGHT);
283 release_button(BTN_LEFT);
284
285 first_client.all_events_received.wait_for_at_most_seconds(10);
286}
287
245TEST_F(TestClientInput, multiple_clients_receive_pointer_inside_windows)288TEST_F(TestClientInput, multiple_clients_receive_pointer_inside_windows)
246{289{
247 int const screen_width = screen_geometry.size.width.as_int();290 int const screen_width = screen_geometry.size.width.as_int();
248291
=== modified file 'tests/acceptance-tests/test_surface_modifications.cpp'
--- tests/acceptance-tests/test_surface_modifications.cpp 2015-05-13 06:23:25 +0000
+++ tests/acceptance-tests/test_surface_modifications.cpp 2015-05-20 14:14:47 +0000
@@ -93,7 +93,6 @@
93 void generate_alt_click_at(Point const& click_position)93 void generate_alt_click_at(Point const& click_position)
94 {94 {
95 auto const modifiers = mir_input_event_modifier_alt;95 auto const modifiers = mir_input_event_modifier_alt;
96 std::vector<MirPointerButton> depressed_buttons{mir_pointer_button_tertiary};
9796
98 auto const x_axis_value = click_position.x.as_float();97 auto const x_axis_value = click_position.x.as_float();
99 auto const y_axis_value = click_position.y.as_float();98 auto const y_axis_value = click_position.y.as_float();
@@ -102,7 +101,7 @@
102 auto const action = mir_pointer_action_button_down;101 auto const action = mir_pointer_action_button_down;
103102
104 auto const click_event = mev::make_event(device_id, timestamp, modifiers,103 auto const click_event = mev::make_event(device_id, timestamp, modifiers,
105 action, depressed_buttons, x_axis_value, y_axis_value, hscroll_value, vscroll_value);104 action, mir_pointer_button_tertiary, x_axis_value, y_axis_value, hscroll_value, vscroll_value);
106105
107 server.the_shell()->handle(*click_event);106 server.the_shell()->handle(*click_event);
108 }107 }
@@ -110,7 +109,6 @@
110 void generate_alt_move_to(Point const& drag_position)109 void generate_alt_move_to(Point const& drag_position)
111 {110 {
112 auto const modifiers = mir_input_event_modifier_alt;111 auto const modifiers = mir_input_event_modifier_alt;
113 std::vector<MirPointerButton> depressed_buttons{mir_pointer_button_tertiary};
114112
115 auto const x_axis_value = drag_position.x.as_float();113 auto const x_axis_value = drag_position.x.as_float();
116 auto const y_axis_value = drag_position.y.as_float();114 auto const y_axis_value = drag_position.y.as_float();
@@ -119,7 +117,7 @@
119 auto const action = mir_pointer_action_motion;117 auto const action = mir_pointer_action_motion;
120118
121 auto const drag_event = mev::make_event(device_id, timestamp, modifiers,119 auto const drag_event = mev::make_event(device_id, timestamp, modifiers,
122 action, depressed_buttons, x_axis_value, y_axis_value, hscroll_value, vscroll_value);120 action, mir_pointer_button_tertiary, x_axis_value, y_axis_value, hscroll_value, vscroll_value);
123121
124 server.the_shell()->handle(*drag_event);122 server.the_shell()->handle(*drag_event);
125 }123 }
126124
=== modified file 'tests/acceptance-tests/test_surface_placement.cpp'
--- tests/acceptance-tests/test_surface_placement.cpp 2015-05-13 06:23:25 +0000
+++ tests/acceptance-tests/test_surface_placement.cpp 2015-05-20 14:14:47 +0000
@@ -121,7 +121,7 @@
121 MirInputDeviceId const device_id{7};121 MirInputDeviceId const device_id{7};
122122
123 auto const modifiers = mir_input_event_modifier_none;123 auto const modifiers = mir_input_event_modifier_none;
124 std::vector<MirPointerButton> depressed_buttons{mir_pointer_button_primary};124 auto const depressed_buttons = mir_pointer_button_primary;
125125
126 auto const x_axis_value = click_position.x.as_float();126 auto const x_axis_value = click_position.x.as_float();
127 auto const y_axis_value = click_position.y.as_float();127 auto const y_axis_value = click_position.y.as_float();
128128
=== modified file 'tests/include/mir_test/event_matchers.h'
--- tests/include/mir_test/event_matchers.h 2015-05-19 14:02:31 +0000
+++ tests/include/mir_test/event_matchers.h 2015-05-20 14:14:47 +0000
@@ -135,10 +135,9 @@
135 return false;135 return false;
136 136
137 if(mir_keyboard_event_modifiers(kev) != modifiers)137 if(mir_keyboard_event_modifiers(kev) != modifiers)
138 {138 {
139 printf("modifiers: %d vs expected %d \n", mir_keyboard_event_modifiers(kev), modifiers);
140 return false;139 return false;
141 }140 }
142 141
143 return true;142 return true;
144}143}
@@ -229,36 +228,38 @@
229 return false;228 return false;
230}229}
231230
231inline bool button_event_matches(MirPointerEvent const* pev, float x, float y, MirPointerAction action, MirPointerButtons button_state,
232 bool check_action = true)
233{
234 if (pev == nullptr)
235 return false;
236 if (check_action && mir_pointer_event_action(pev) != action)
237 return false;
238 if (mir_pointer_event_buttons(pev) != button_state)
239 return false;
240 if (mir_pointer_event_axis_value(pev, mir_pointer_axis_x) != x)
241 return false;
242 if (mir_pointer_event_axis_value(pev, mir_pointer_axis_y) != y)
243 return false;
244 return true;
245}
246
232MATCHER_P2(ButtonDownEvent, x, y, "")247MATCHER_P2(ButtonDownEvent, x, y, "")
233{248{
234 auto pev = maybe_pointer_event(to_address(arg));249 auto pev = maybe_pointer_event(to_address(arg));
235 if (pev == nullptr)250 return button_event_matches(pev, x, y, mir_pointer_action_button_down, mir_pointer_button_primary);
236 return false;
237 if (mir_pointer_event_action(pev) != mir_pointer_action_button_down)
238 return false;
239 if (mir_pointer_event_button_state(pev, mir_pointer_button_primary) == false)
240 return false;
241 if (mir_pointer_event_axis_value(pev, mir_pointer_axis_x) != x)
242 return false;
243 if (mir_pointer_event_axis_value(pev, mir_pointer_axis_y) != y)
244 return false;
245 return true;
246}251}
247252
248MATCHER_P2(ButtonUpEvent, x, y, "")253MATCHER_P2(ButtonUpEvent, x, y, "")
249{254{
250 auto pev = maybe_pointer_event(to_address(arg));255 auto pev = maybe_pointer_event(to_address(arg));
251 if (pev == nullptr)256 return button_event_matches(pev, x, y, mir_pointer_action_button_up, 0);
252 return false;257}
253 if (mir_pointer_event_action(pev) != mir_pointer_action_button_up)258
254 return false;259MATCHER_P3(ButtonsDown, x, y, buttons, "")
255 if (mir_pointer_event_button_state(pev, mir_pointer_button_primary) == true)260{
256 return false;261 auto pev = maybe_pointer_event(to_address(arg));
257 if (mir_pointer_event_axis_value(pev, mir_pointer_axis_x) != x)262 return button_event_matches(pev, x, y, mir_pointer_action_button_down, buttons, false);
258 return false;
259 if (mir_pointer_event_axis_value(pev, mir_pointer_axis_y) != y)
260 return false;
261 return true;
262}263}
263264
264MATCHER_P2(TouchEvent, x, y, "")265MATCHER_P2(TouchEvent, x, y, "")
265266
=== modified file 'tests/mir_test_framework/fake_input_device_impl.cpp'
--- tests/mir_test_framework/fake_input_device_impl.cpp 2015-05-19 14:02:31 +0000
+++ tests/mir_test_framework/fake_input_device_impl.cpp 2015-05-20 14:14:47 +0000
@@ -144,7 +144,7 @@
144144
145mtf::FakeInputDeviceImpl::InputDevice::InputDevice(mi::InputDeviceInfo const& info,145mtf::FakeInputDeviceImpl::InputDevice::InputDevice(mi::InputDeviceInfo const& info,
146 std::shared_ptr<mir::dispatch::Dispatchable> const& dispatchable)146 std::shared_ptr<mir::dispatch::Dispatchable> const& dispatchable)
147 : info(info), queue{dispatchable}147 : info(info), queue{dispatchable}, buttons{0}
148{148{
149}149}
150150
@@ -197,12 +197,12 @@
197{197{
198 if (action == synthesis::EventAction::Down)198 if (action == synthesis::EventAction::Down)
199 {199 {
200 buttons.push_back(button);200 buttons |= button;
201 return mir_pointer_action_button_down;201 return mir_pointer_action_button_down;
202 }202 }
203 else203 else
204 {204 {
205 buttons.erase(remove(begin(buttons), end(buttons), button));205 buttons &= ~button;
206 return mir_pointer_action_button_up;206 return mir_pointer_action_button_up;
207 }207 }
208}208}
209209
=== modified file 'tests/mir_test_framework/fake_input_device_impl.h'
--- tests/mir_test_framework/fake_input_device_impl.h 2015-05-19 14:02:31 +0000
+++ tests/mir_test_framework/fake_input_device_impl.h 2015-05-20 14:14:47 +0000
@@ -25,8 +25,6 @@
25#include "mir/input/input_device_info.h"25#include "mir/input/input_device_info.h"
26#include "mir/geometry/point.h"26#include "mir/geometry/point.h"
2727
28#include <vector>
29
30namespace mir28namespace mir
31{29{
32namespace dispatch30namespace dispatch
@@ -76,7 +74,7 @@
76 std::shared_ptr<mir::dispatch::Dispatchable> const queue;74 std::shared_ptr<mir::dispatch::Dispatchable> const queue;
77 uint32_t modifiers{0};75 uint32_t modifiers{0};
78 mir::geometry::Point pos, scroll;76 mir::geometry::Point pos, scroll;
79 std::vector<MirPointerButton> buttons;77 MirPointerButtons buttons;
80 };78 };
81 std::shared_ptr<mir::dispatch::ActionQueue> queue;79 std::shared_ptr<mir::dispatch::ActionQueue> queue;
82 std::shared_ptr<InputDevice> device;80 std::shared_ptr<InputDevice> device;
8381
=== modified file 'tests/unit-tests/input/android/test_android_input_dispatcher.cpp'
--- tests/unit-tests/input/android/test_android_input_dispatcher.cpp 2015-05-13 06:23:25 +0000
+++ tests/unit-tests/input/android/test_android_input_dispatcher.cpp 2015-05-20 14:14:47 +0000
@@ -173,15 +173,16 @@
173 std::memset(expected_coords, 0, sizeof(expected_coords));173 std::memset(expected_coords, 0, sizeof(expected_coords));
174 std::memset(expected_properties, 0, sizeof(expected_properties));174 std::memset(expected_properties, 0, sizeof(expected_properties));
175 MirEvent event;175 MirEvent event;
176 std::memset(&event, 0, sizeof(event));
177
176 event.type = mir_event_type_motion;178 event.type = mir_event_type_motion;
177 event.motion.pointer_count = 1;179 event.motion.pointer_count = 1;
178 event.motion.event_time = std::chrono::nanoseconds(2);180 event.motion.event_time = std::chrono::nanoseconds(2);
179 event.motion.device_id = 3;181 event.motion.device_id = 3;
180 event.motion.source_id = 4;182 event.motion.source_id = 4;
181 event.motion.action = mir_motion_action_scroll;183 event.motion.action = mir_motion_action_scroll;
182 event.motion.modifiers = mir_input_event_modifier_shift,184 event.motion.modifiers = mir_input_event_modifier_shift;
183 event.motion.button_state =185 event.motion.buttons = mir_pointer_button_forward | mir_pointer_button_secondary;
184 static_cast<MirMotionButton>(mir_motion_button_forward | mir_motion_button_secondary);
185186
186 auto & pointer = event.motion.pointer_coordinates[0];187 auto & pointer = event.motion.pointer_coordinates[0];
187 pointer.id = 1;188 pointer.id = 1;
@@ -215,7 +216,7 @@
215 event.motion.action,216 event.motion.action,
216 0, /* flags */217 0, /* flags */
217 AMETA_SHIFT_ON,218 AMETA_SHIFT_ON,
218 event.motion.button_state,219 AMOTION_EVENT_BUTTON_FORWARD | AMOTION_EVENT_BUTTON_SECONDARY,
219 0, /* edge_flags */220 0, /* edge_flags */
220 event.motion.pointer_count,221 event.motion.pointer_count,
221 expected_properties,222 expected_properties,
222223
=== modified file 'tests/unit-tests/input/android/test_android_input_lexicon.cpp'
--- tests/unit-tests/input/android/test_android_input_lexicon.cpp 2015-05-13 06:23:25 +0000
+++ tests/unit-tests/input/android/test_android_input_lexicon.cpp 2015-05-20 14:14:47 +0000
@@ -78,7 +78,7 @@
78 const int32_t flags = 4;78 const int32_t flags = 4;
79 const int32_t edge_flags = 5;79 const int32_t edge_flags = 5;
80 const int32_t meta_state = 6;80 const int32_t meta_state = 6;
81 const int32_t button_state = 7;81 const int32_t button_state = 0;
82 const float x_offset = 8;82 const float x_offset = 8;
83 const float y_offset = 9;83 const float y_offset = 9;
84 const float x_precision = 10;84 const float x_precision = 10;
@@ -134,7 +134,6 @@
134134
135 auto mir_motion_ev = &mir_ev.motion;135 auto mir_motion_ev = &mir_ev.motion;
136136
137 EXPECT_EQ(mir_motion_ev->button_state, button_state);
138 EXPECT_EQ(mir_motion_ev->event_time, event_time);137 EXPECT_EQ(mir_motion_ev->event_time, event_time);
139138
140 EXPECT_EQ(mir_motion_ev->pointer_count, pointer_count);139 EXPECT_EQ(mir_motion_ev->pointer_count, pointer_count);
@@ -170,7 +169,6 @@
170 const int32_t flags = 4;169 const int32_t flags = 4;
171 const int32_t edge_flags = 5;170 const int32_t edge_flags = 5;
172 const int32_t meta_state = 6;171 const int32_t meta_state = 6;
173 const int32_t button_state = 7;
174 const float x_offset = 8;172 const float x_offset = 8;
175 const float y_offset = 9;173 const float y_offset = 9;
176 const float x_precision = 10;174 const float x_precision = 10;
@@ -223,7 +221,7 @@
223 }221 }
224222
225 android_motion_ev->initialize(device_id, source_id, action, flags,223 android_motion_ev->initialize(device_id, source_id, action, flags,
226 edge_flags, meta_state, button_state,224 edge_flags, meta_state, 0,
227 x_offset, y_offset, x_precision, y_precision,225 x_offset, y_offset, x_precision, y_precision,
228 down_time, event_time, pointer_count,226 down_time, event_time, pointer_count,
229 pointer_properties, pointer_coords);227 pointer_properties, pointer_coords);
@@ -241,7 +239,6 @@
241239
242 auto mir_motion_ev = &mir_ev.motion;240 auto mir_motion_ev = &mir_ev.motion;
243241
244 EXPECT_EQ(mir_motion_ev->button_state, button_state);
245 EXPECT_EQ(mir_motion_ev->event_time, event_time);242 EXPECT_EQ(mir_motion_ev->event_time, event_time);
246 EXPECT_EQ(mir_motion_ev->pointer_count, pointer_count);243 EXPECT_EQ(mir_motion_ev->pointer_count, pointer_count);
247244
248245
=== modified file 'tests/unit-tests/input/android/test_input_translator.cpp'
--- tests/unit-tests/input/android/test_input_translator.cpp 2015-05-13 06:23:25 +0000
+++ tests/unit-tests/input/android/test_input_translator.cpp 2015-05-20 14:14:47 +0000
@@ -266,8 +266,7 @@
266 expected.motion.source_id = 4;266 expected.motion.source_id = 4;
267 expected.motion.action = mir_motion_action_scroll;267 expected.motion.action = mir_motion_action_scroll;
268 expected.motion.modifiers = 6;268 expected.motion.modifiers = 6;
269 expected.motion.button_state =269 expected.motion.buttons = mir_pointer_button_forward | mir_pointer_button_secondary;
270 static_cast<MirMotionButton>(mir_motion_button_forward | mir_motion_button_secondary);
271270
272 auto & pointer = expected.motion.pointer_coordinates[0];271 auto & pointer = expected.motion.pointer_coordinates[0];
273 pointer.id = 1;272 pointer.id = 1;
@@ -303,7 +302,7 @@
303 expected.motion.action,302 expected.motion.action,
304 0, /* flags */303 0, /* flags */
305 expected.motion.modifiers,304 expected.motion.modifiers,
306 expected.motion.button_state,305 AMOTION_EVENT_BUTTON_FORWARD | AMOTION_EVENT_BUTTON_SECONDARY,
307 0, /* edge flags */306 0, /* edge flags */
308 expected.motion.pointer_count,307 expected.motion.pointer_count,
309 properties,308 properties,
310309
=== modified file 'tests/unit-tests/input/test_default_input_device_hub.cpp'
--- tests/unit-tests/input/test_default_input_device_hub.cpp 2015-05-19 14:28:28 +0000
+++ tests/unit-tests/input/test_default_input_device_hub.cpp 2015-05-20 14:14:47 +0000
@@ -368,9 +368,9 @@
368 using namespace ::testing;368 using namespace ::testing;
369369
370 auto x = 12.2f, y = 14.3f;370 auto x = 12.2f, y = 14.3f;
371 std::vector<MirPointerButton> none_pressed;371
372 auto event = mir::events::make_event(0, 0ns, mir_input_event_modifier_none, mir_pointer_action_motion, none_pressed,372 auto event = mir::events::make_event(0, 0ns, mir_input_event_modifier_none, mir_pointer_action_motion, 0,
373 x, y, 0.0f, 0.0f);373 x, y, 0.0f, 0.0f);
374374
375 EXPECT_CALL(mock_cursor_listener, cursor_moved_to(x, y)).Times(1);375 EXPECT_CALL(mock_cursor_listener, cursor_moved_to(x, y)).Times(1);
376376
377377
=== modified file 'tests/unit-tests/input/test_event_builders.cpp'
--- tests/unit-tests/input/test_event_builders.cpp 2015-05-19 14:02:31 +0000
+++ tests/unit-tests/input/test_event_builders.cpp 2015-05-20 14:14:47 +0000
@@ -99,8 +99,7 @@
99TEST_F(InputEventBuilder, makes_valid_pointer_event)99TEST_F(InputEventBuilder, makes_valid_pointer_event)
100{100{
101 MirPointerAction action = mir_pointer_action_enter;101 MirPointerAction action = mir_pointer_action_enter;
102 std::vector<MirPointerButton> depressed_buttons = 102 auto depressed_buttons = mir_pointer_button_back | mir_pointer_button_tertiary;
103 {mir_pointer_button_back, mir_pointer_button_tertiary};
104 float x_axis_value = 3.9, y_axis_value = 7.4, hscroll_value = .9, vscroll_value = .3;103 float x_axis_value = 3.9, y_axis_value = 7.4, hscroll_value = .9, vscroll_value = .3;
105 auto ev = mev::make_event(device_id, timestamp, modifiers, 104 auto ev = mev::make_event(device_id, timestamp, modifiers,
106 action, depressed_buttons, x_axis_value, y_axis_value, hscroll_value, vscroll_value);105 action, depressed_buttons, x_axis_value, y_axis_value, hscroll_value, vscroll_value);
@@ -162,11 +161,10 @@
162161
163TEST_F(InputEventBuilder, map_to_hover_if_no_button_pressed)162TEST_F(InputEventBuilder, map_to_hover_if_no_button_pressed)
164{163{
165 std::vector<MirPointerButton> no_pressed_buttons;
166 float x_axis_value = 3.9, y_axis_value = 7.4, hscroll_value = .9, vscroll_value = .3;164 float x_axis_value = 3.9, y_axis_value = 7.4, hscroll_value = .9, vscroll_value = .3;
167 MirPointerAction action = mir_pointer_action_motion;165 MirPointerAction action = mir_pointer_action_motion;
168 auto ev = mev::make_event(device_id, timestamp, modifiers,166 auto ev = mev::make_event(device_id, timestamp, modifiers,
169 action, no_pressed_buttons, x_axis_value, y_axis_value, hscroll_value, vscroll_value);167 action, 0, x_axis_value, y_axis_value, hscroll_value, vscroll_value);
170 auto e = ev.get();168 auto e = ev.get();
171169
172 auto ie = mir_event_get_input_event(e);170 auto ie = mir_event_get_input_event(e);
173171
=== modified file 'tests/unit-tests/input/test_input_event.cpp'
--- tests/unit-tests/input/test_input_event.cpp 2015-05-13 06:23:25 +0000
+++ tests/unit-tests/input/test_input_event.cpp 2015-05-20 14:14:47 +0000
@@ -61,15 +61,21 @@
61MirEvent a_key_ev()61MirEvent a_key_ev()
62{62{
63 MirEvent key_ev;63 MirEvent key_ev;
64 memset(&key_ev, 0, sizeof(key_ev));
65
64 key_ev.type = mir_event_type_key;66 key_ev.type = mir_event_type_key;
67
65 return key_ev;68 return key_ev;
66}69}
6770
68MirEvent a_motion_ev(int device_class = AINPUT_SOURCE_UNKNOWN)71MirEvent a_motion_ev(int device_class = AINPUT_SOURCE_UNKNOWN)
69{72{
70 MirEvent motion_ev;73 MirEvent motion_ev;
74 memset(&motion_ev, 0, sizeof(motion_ev));
75
71 motion_ev.type = mir_event_type_motion;76 motion_ev.type = mir_event_type_motion;
72 motion_ev.motion.source_id = device_class;77 motion_ev.motion.source_id = device_class;
78
73 return motion_ev;79 return motion_ev;
74}80}
7581
@@ -350,13 +356,13 @@
350{356{
351 auto old_ev = a_motion_ev(AINPUT_SOURCE_MOUSE);357 auto old_ev = a_motion_ev(AINPUT_SOURCE_MOUSE);
352358
353 old_ev.motion.button_state = mir_motion_button_primary;359 old_ev.motion.buttons = mir_pointer_button_primary;
354 auto pev = mir_input_event_get_pointer_event(mir_event_get_input_event(&old_ev));360 auto pev = mir_input_event_get_pointer_event(mir_event_get_input_event(&old_ev));
355 361
356 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_primary));362 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_primary));
357 EXPECT_FALSE(mir_pointer_event_button_state(pev, mir_pointer_button_secondary));363 EXPECT_FALSE(mir_pointer_event_button_state(pev, mir_pointer_button_secondary));
358364
359 old_ev.motion.button_state = static_cast<MirMotionButton>(old_ev.motion.button_state | (mir_motion_button_secondary));365 old_ev.motion.buttons |= mir_pointer_button_secondary;
360366
361 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_primary));367 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_primary));
362 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_secondary));368 EXPECT_TRUE(mir_pointer_event_button_state(pev, mir_pointer_button_secondary));
363369
=== modified file 'tests/unit-tests/scene/test_abstract_shell.cpp'
--- tests/unit-tests/scene/test_abstract_shell.cpp 2015-05-13 06:23:25 +0000
+++ tests/unit-tests/scene/test_abstract_shell.cpp 2015-05-20 14:14:47 +0000
@@ -283,7 +283,7 @@
283{283{
284 MirInputEventModifiers const modifiers{mir_input_event_modifier_none};284 MirInputEventModifiers const modifiers{mir_input_event_modifier_none};
285 MirPointerAction const action{mir_pointer_action_button_down};285 MirPointerAction const action{mir_pointer_action_button_down};
286 std::vector<MirPointerButton> const buttons_pressed{mir_pointer_button_primary};286 auto const buttons_pressed = mir_pointer_button_primary;
287 float const x_axis_value{0.0};287 float const x_axis_value{0.0};
288 float const y_axis_value{0.0};288 float const y_axis_value{0.0};
289 float const hscroll_value{0.0};289 float const hscroll_value{0.0};

Subscribers

People subscribed via source and target branches