Mir

Merge lp:~mir-team/mir/remaining-nsec-removal into lp:mir

Proposed by Robert Carr
Status: Merged
Approved by: Robert Carr
Approved revision: no longer in the source branch.
Merged at revision: 2569
Proposed branch: lp:~mir-team/mir/remaining-nsec-removal
Merge into: lp:mir
Prerequisite: lp:~mir-team/mir/unify-keyboard-actions
Diff against target: 594 lines (+64/-61)
21 files modified
include/client/mir/events/event_builders.h (+4/-3)
src/client/events/event_builders.cpp (+3/-3)
src/client/input/android/android_input_lexicon.cpp (+2/-2)
src/client/input/input_event.cpp (+2/-2)
src/include/common/mir/events/event_private.h (+3/-4)
src/server/input/android/android_input_dispatcher.cpp (+2/-2)
src/server/input/android/input_sender.cpp (+4/-4)
src/server/input/android/input_translator.cpp (+2/-2)
tests/acceptance-tests/test_surface_modifications.cpp (+2/-4)
tests/acceptance-tests/test_surface_placement.cpp (+2/-2)
tests/mir_test_framework/fake_input_device_impl.cpp (+9/-8)
tests/unit-tests/frontend/test_event_sender.cpp (+1/-1)
tests/unit-tests/input/android/test_android_input_dispatcher.cpp (+4/-4)
tests/unit-tests/input/android/test_android_input_lexicon.cpp (+3/-3)
tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp (+5/-0)
tests/unit-tests/input/android/test_input_translator.cpp (+4/-4)
tests/unit-tests/input/test_default_input_device_hub.cpp (+2/-2)
tests/unit-tests/input/test_event_builders.cpp (+1/-1)
tests/unit-tests/input/test_event_filter_chain.cpp (+1/-1)
tests/unit-tests/input/test_input_event.cpp (+3/-3)
tests/unit-tests/scene/test_abstract_shell.cpp (+5/-6)
To merge this branch: bzr merge lp:~mir-team/mir/remaining-nsec-removal
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Robert Carr (community) Approve
Daniel van Vugt Needs Fixing
Alexandros Frantzis (community) Approve
Kevin DuBois (community) Approve
Review via email: mp+258292@code.launchpad.net

Commit message

Eliminate remaining usage of nsecs_t type in event_private.h.

Description of the change

Eliminate remaining usage of nsecs_t type in event_private.h.

Part of the event cleaning pipeline to reduce conflicts
https://code.launchpad.net/~mir-team/mir/unify-keyboard-actions/+merge/258288

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
Kevin DuBois (kdub) wrote :

240+ std::chrono::nanoseconds const timestamp = std::chrono::nanoseconds(39);
(also 209, 303, 374)
Could use:
auto const timestamps = 39ns;
(although, after writing "using std::literals::chrono_literals;", doesn't save a lot of typing!)

lgtm with or without chrono_literals.

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

Looks good, apart from the CI failure:

[ RUN ] EventFilterDispatcherPolicy.offers_key_events_to_filter
==12700== Conditional jump or move depends on uninitialised value(s)
==12700== at 0x1524A57: mir::input::android::mir_keyboard_action_from_android(int, int) (event_conversion_helpers.cpp:74)
==12700== by 0x152275A: mir::input::android::Lexicon::translate(android::InputEvent const*, MirEvent&) (android_input_lexicon.cpp:38)
==12700== by 0x1439049: mir::input::android::EventFilterDispatcherPolicy::filterInputEvent(android::InputEvent const*, unsigned int) (event_filter_dispatcher_policy.cpp:58)
==12700== by 0x117A645: EventFilterDispatcherPolicy_offers_key_events_to_filter_Test::TestBody() (test_event_filter_input_dispatcher_policy.cpp:54)
==12700== by 0x1699491: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /tmp/buildd/mir-0.13.0bzr2545pkg0vivid1722/obj-x86_64-linux-gnu/bin/.mir_unit_tests-uninstalled)
==12700== by 0x1694166: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /tmp/buildd/mir-0.13.0bzr2545pkg0vivid1722/obj-x86_64-linux-gnu/bin/.mir_unit_tests-uninstalled)
==12700== by 0x1679DD2: testing::Test::Run() (in /tmp/buildd/mir-0.13.0bzr2545pkg0vivid1722/obj-x86_64-linux-gnu/bin/.mir_unit_tests-uninstalled)
==12700== by 0x167A670: testing::TestInfo::Run() (in /tmp/buildd/mir-0.13.0bzr2545pkg0vivid1722/obj-x86_64-linux-gnu/bin/.mir_unit_tests-uninstalled)
==12700== by 0x167AD79: testing::TestCase::Run() (in /tmp/buildd/mir-0.13.0bzr2545pkg0vivid1722/obj-x86_64-linux-gnu/bin/.mir_unit_tests-uninstalled)
==12700== by 0x1681C4B: testing::internal::UnitTestImpl::RunAllTests() (in /tmp/buildd/mir-0.13.0bzr2545pkg0vivid1722/obj-x86_64-linux-gnu/bin/.mir_unit_tests-uninstalled)
==12700== by 0x169AA5C: bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (in /tmp/buildd/mir-0.13.0bzr2545pkg0vivid1722/obj-x86_64-linux-gnu/bin/.mir_unit_tests-uninstalled)
==12700== by 0x1694FFE: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (in /tmp/buildd/mir-0.13.0bzr2545pkg0vivid1722/obj-x86_64-linux-gnu/bin/.mir_unit_tests-uninstalled)
==12700==
[ OK ] EventFilterDispatcherPolicy.offers_key_events_to_filter (43 ms)

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

(0) Replacing nsecs_t with std::chrono is actually a step backwards. The former requires simpler (integer) logic to work with (nicer to read), generates fewer bytes of code, generates slightly faster code, compiles quicker, and makes us less divergent from the upstream Android input code. That all said most of the change landed some time ago so that battle is mostly lost...

(1) This is a client ABI break because some downstreams actually use build_event :P
+++ include/client/mir/events/event_builders.h

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

(we don't have ABI checking automated on proposals to trunk yet)

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

>> (1) This is a client ABI break because some downstreams actually use build_event :P

Haha whoops got overzealous. will fix in morning.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> Haha whoops got overzealous. will fix in morning.

We are planning to break client ABI in this release, so it's fine (and I would argue, recommended) to break it a bit more if we feel that the changes will improve our interfaces.

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

Yeah forgot that API/ABI was breaking anyway.

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

Fixed conflicts and retaed

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

The client ABI break is still there. Do you mean we intend to break the client ABI in series 0.14?

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

(1) ABI break:
16 -EventUPtr make_event(MirInputDeviceId device_id, int64_t timestamp,
17 +EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
...

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

> The client ABI break is still there. Do you mean we intend to break the client ABI in series 0.14?

That's the plan.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Alright. Any client ABI break needs discussion and planning though. Because we need to make sure it's (a) necessary; and (b) breaking everything we'll need to break for the foreseeable future.

Still needs fixing because either you're missing the ABI bump in this branch, or (more ideally) we should undo the break and add comments instead, then discuss the next client ABI break in detail next week.

Remember a client ABI break affects a lot more projects than a server ABI break.

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

> Alright. Any client ABI break needs discussion and planning though.

I'm not sure why it didn't get communicated to you but breaking ABI was discussed before branching 0.13.0 (which discussion led to -r 2532 happening before the branch) and again before landing -r 2545 (which was the first ABI breaking change).

> Because we
> need to make sure it's (a) necessary; and (b) breaking everything we'll need
> to break for the foreseeable future.

Agreed. And the thinking is that the beginning of the Wily cycle is a good time for this.

> Still needs fixing because either you're missing the ABI bump in this branch,
> or (more ideally) we should undo the break and add comments instead, then
> discuss the next client ABI break in detail next week.

We are missing an ABI bump MP, but we've landed those separately on many occasions.

> Remember a client ABI break affects a lot more projects than a server ABI
> break.

We can review how we intend to handle this next week.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
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
Robert Carr (robertcarr) :
review: Approve
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
1=== modified file 'include/client/mir/events/event_builders.h'
2--- include/client/mir/events/event_builders.h 2015-04-01 19:39:19 +0000
3+++ include/client/mir/events/event_builders.h 2015-05-12 14:01:11 +0000
4@@ -27,6 +27,7 @@
5 #include <memory>
6 #include <vector>
7 #include <functional>
8+#include <chrono>
9
10 namespace mir
11 {
12@@ -48,19 +49,19 @@
13 EventUPtr make_event(frontend::SurfaceId const& surface_id, xkb_rule_names const& names);
14
15 // Key event
16-EventUPtr make_event(MirInputDeviceId device_id, int64_t timestamp,
17+EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
18 MirKeyboardAction action, xkb_keysym_t key_code,
19 int scan_code, MirInputEventModifiers modifiers);
20
21 // Touch event
22-EventUPtr make_event(MirInputDeviceId device_id, int64_t timestamp,
23+EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
24 MirInputEventModifiers modifiers);
25 void add_touch(MirEvent &event, MirTouchId touch_id, MirTouchAction action,
26 MirTouchTooltype tooltype, float x_axis_value, float y_axis_value,
27 float pressure_value, float touch_major_value, float touch_minor_value, float size_value);
28
29 // Pointer event
30-EventUPtr make_event(MirInputDeviceId device_id, int64_t timestamp,
31+EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
32 MirInputEventModifiers modifiers, MirPointerAction action,
33 std::vector<MirPointerButton> const& buttons_pressed,
34 float x_axis_value, float y_axis_value,
35
36=== modified file 'src/client/events/event_builders.cpp'
37--- src/client/events/event_builders.cpp 2015-05-12 14:01:11 +0000
38+++ src/client/events/event_builders.cpp 2015-05-12 14:01:11 +0000
39@@ -92,7 +92,7 @@
40 return make_event_uptr(e);
41 }
42
43-mir::EventUPtr mev::make_event(MirInputDeviceId device_id, int64_t timestamp,
44+mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
45 MirKeyboardAction action, xkb_keysym_t key_code,
46 int scan_code, MirInputEventModifiers modifiers)
47 {
48@@ -142,7 +142,7 @@
49 };
50 }
51
52-mir::EventUPtr mev::make_event(MirInputDeviceId device_id, int64_t timestamp,
53+mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
54 MirInputEventModifiers modifiers)
55 {
56 MirEvent *e = new MirEvent;
57@@ -251,7 +251,7 @@
58 }
59 }
60
61-mir::EventUPtr mev::make_event(MirInputDeviceId device_id, int64_t timestamp,
62+mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
63 MirInputEventModifiers modifiers, MirPointerAction action,
64 std::vector<MirPointerButton> const& buttons_pressed,
65 float x_axis_value, float y_axis_value,
66
67=== modified file 'src/client/input/android/android_input_lexicon.cpp'
68--- src/client/input/android/android_input_lexicon.cpp 2015-05-12 14:01:11 +0000
69+++ src/client/input/android/android_input_lexicon.cpp 2015-05-12 14:01:11 +0000
70@@ -39,7 +39,7 @@
71 mir_event.key.modifiers = mia::mir_modifiers_from_android(kev->getMetaState());
72 mir_event.key.key_code = kev->getKeyCode();
73 mir_event.key.scan_code = kev->getScanCode();
74- mir_event.key.event_time = kev->getEventTime().count();
75+ mir_event.key.event_time = kev->getEventTime();
76 break;
77 }
78 case AINPUT_EVENT_TYPE_MOTION:
79@@ -51,7 +51,7 @@
80 mir_event.motion.action = mev->getAction();
81 mir_event.motion.modifiers = mia::mir_modifiers_from_android(mev->getMetaState());
82 mir_event.motion.button_state = static_cast<MirMotionButton>(mev->getButtonState());
83- mir_event.motion.event_time = mev->getEventTime().count();
84+ mir_event.motion.event_time = mev->getEventTime();
85 mir_event.motion.pointer_count = mev->getPointerCount();
86 for(unsigned int i = 0; i < mev->getPointerCount(); i++)
87 {
88
89=== modified file 'src/client/input/input_event.cpp'
90--- src/client/input/input_event.cpp 2015-05-12 14:01:11 +0000
91+++ src/client/input/input_event.cpp 2015-05-12 14:01:11 +0000
92@@ -184,9 +184,9 @@
93 switch (old_ev->type)
94 {
95 case mir_event_type_motion:
96- return old_ev->motion.event_time;
97+ return old_ev->motion.event_time.count();
98 case mir_event_type_key:
99- return old_ev->key.event_time;
100+ return old_ev->key.event_time.count();
101 default:
102 abort();
103 }
104
105=== modified file 'src/include/common/mir/events/event_private.h'
106--- src/include/common/mir/events/event_private.h 2015-05-12 14:01:11 +0000
107+++ src/include/common/mir/events/event_private.h 2015-05-12 14:01:11 +0000
108@@ -31,6 +31,7 @@
109 #include "mir_toolkit/common.h"
110
111 #include <xkbcommon/xkbcommon.h>
112+#include <chrono>
113
114 #include <chrono>
115
116@@ -44,8 +45,6 @@
117 /* TODO: To the moon. */
118 #define MIR_INPUT_EVENT_MAX_POINTER_COUNT 16
119
120-typedef int64_t nsecs_t;
121-
122 typedef enum {
123 mir_motion_action_down = 0,
124 mir_motion_action_up = 1,
125@@ -91,7 +90,7 @@
126 int32_t key_code;
127 int32_t scan_code;
128
129- nsecs_t event_time;
130+ std::chrono::nanoseconds event_time;
131 } MirKeyEvent;
132
133 typedef struct
134@@ -127,7 +126,7 @@
135 MirInputEventModifiers modifiers;
136
137 MirMotionButton button_state;
138- nsecs_t event_time;
139+ std::chrono::nanoseconds event_time;
140
141 size_t pointer_count;
142 MirMotionPointer pointer_coordinates[MIR_INPUT_EVENT_MAX_POINTER_COUNT];
143
144=== modified file 'src/server/input/android/android_input_dispatcher.cpp'
145--- src/server/input/android/android_input_dispatcher.cpp 2015-05-12 14:01:11 +0000
146+++ src/server/input/android/android_input_dispatcher.cpp 2015-05-12 14:01:11 +0000
147@@ -66,7 +66,7 @@
148 event.key.key_code,
149 event.key.scan_code,
150 mia::android_modifiers_from_mir(event.key.modifiers),
151- std::chrono::nanoseconds(event.key.event_time));
152+ event.key.event_time);
153
154 dispatcher->notifyKey(&notify_key_args);
155
156@@ -108,7 +108,7 @@
157 pointer_properties.data(),
158 pointer_coords.data(),
159 0, 0, /* unused x/y precision */
160- std::chrono::nanoseconds(event.motion.event_time));
161+ event.motion.event_time);
162
163 dispatcher->notifyMotion(&notify_motion_args);
164
165
166=== modified file 'src/server/input/android/input_sender.cpp'
167--- src/server/input/android/input_sender.cpp 2015-05-12 14:01:11 +0000
168+++ src/server/input/android/input_sender.cpp 2015-05-12 14:01:11 +0000
169@@ -249,8 +249,8 @@
170 event.scan_code,
171 mia::android_modifiers_from_mir(event.modifiers),
172 repeat_count,
173- std::chrono::nanoseconds(event.event_time),
174- std::chrono::nanoseconds(event.event_time)
175+ event.event_time,
176+ event.event_time
177 );
178 }
179
180@@ -292,8 +292,8 @@
181 0.0f, // event.x_offset,
182 0.0f, // event.y_offset,
183 0, 0, /* unused x/y precision */
184- std::chrono::nanoseconds(event.event_time),
185- std::chrono::nanoseconds(event.event_time),
186+ event.event_time,
187+ event.event_time,
188 event.pointer_count,
189 properties,
190 coords
191
192=== modified file 'src/server/input/android/input_translator.cpp'
193--- src/server/input/android/input_translator.cpp 2015-05-12 14:01:11 +0000
194+++ src/server/input/android/input_translator.cpp 2015-05-12 14:01:11 +0000
195@@ -131,7 +131,7 @@
196 mir_event.key.modifiers = mir_modifiers;
197 mir_event.key.key_code = args->keyCode;
198 mir_event.key.scan_code = args->scanCode;
199- mir_event.key.event_time = args->eventTime.count();
200+ mir_event.key.event_time = args->eventTime;
201
202 dispatcher->dispatch(mir_event);
203 }
204@@ -148,7 +148,7 @@
205 mir_event.motion.action = args->action;
206 mir_event.motion.modifiers = mia::mir_modifiers_from_android(args->metaState);
207 mir_event.motion.button_state = static_cast<MirMotionButton>(args->buttonState);
208- mir_event.motion.event_time = args->eventTime.count();
209+ mir_event.motion.event_time = args->eventTime;
210 mir_event.motion.pointer_count = args->pointerCount;
211 for(unsigned int i = 0; i < args->pointerCount; i++)
212 {
213
214=== modified file 'tests/acceptance-tests/test_surface_modifications.cpp'
215--- tests/acceptance-tests/test_surface_modifications.cpp 2015-04-30 19:27:13 +0000
216+++ tests/acceptance-tests/test_surface_modifications.cpp 2015-05-12 14:01:11 +0000
217@@ -92,8 +92,6 @@
218
219 void generate_alt_click_at(Point const& click_position)
220 {
221- MirInputDeviceId const device_id{7};
222- int64_t const timestamp{39};
223 auto const modifiers = mir_input_event_modifier_alt;
224 std::vector<MirPointerButton> depressed_buttons{mir_pointer_button_tertiary};
225
226@@ -111,8 +109,6 @@
227
228 void generate_alt_move_to(Point const& drag_position)
229 {
230- MirInputDeviceId const device_id{7};
231- int64_t const timestamp{39};
232 auto const modifiers = mir_input_event_modifier_alt;
233 std::vector<MirPointerButton> depressed_buttons{mir_pointer_button_tertiary};
234
235@@ -156,6 +152,8 @@
236 mir_surface_spec_release(spec);
237 }
238
239+ MirInputDeviceId const device_id = MirInputDeviceId(7);
240+ std::chrono::nanoseconds const timestamp = std::chrono::nanoseconds(39);
241 MockSurfaceObserver surface_observer;
242 std::weak_ptr<ms::Surface> shell_surface;
243 };
244
245=== modified file 'tests/acceptance-tests/test_surface_placement.cpp'
246--- tests/acceptance-tests/test_surface_placement.cpp 2015-04-17 13:39:36 +0000
247+++ tests/acceptance-tests/test_surface_placement.cpp 2015-05-12 14:01:11 +0000
248@@ -119,7 +119,7 @@
249 auto const click_position = display.top_left + 0.5*as_displacement(display.size);
250
251 MirInputDeviceId const device_id{7};
252- int64_t const timestamp{39};
253+
254 auto const modifiers = mir_input_event_modifier_none;
255 std::vector<MirPointerButton> depressed_buttons{mir_pointer_button_primary};
256
257@@ -129,7 +129,7 @@
258 auto const vscroll_value = 0.0;
259 auto const action = mir_pointer_action_button_down;
260
261- auto const click_event = mev::make_event(device_id, timestamp, modifiers,
262+ auto const click_event = mev::make_event(device_id, std::chrono::nanoseconds(1), modifiers,
263 action, depressed_buttons, x_axis_value, y_axis_value, hscroll_value, vscroll_value);
264
265 server.the_shell()->handle(*click_event);
266
267=== modified file 'tests/mir_test_framework/fake_input_device_impl.cpp'
268--- tests/mir_test_framework/fake_input_device_impl.cpp 2015-05-04 07:28:06 +0000
269+++ tests/mir_test_framework/fake_input_device_impl.cpp 2015-05-12 14:01:11 +0000
270@@ -151,8 +151,9 @@
271 void mtf::FakeInputDeviceImpl::InputDevice::synthesize_events(synthesis::KeyParameters const& key_params)
272 {
273 xkb_keysym_t key_code = 0;
274- int64_t event_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
275- std::chrono::system_clock::now().time_since_epoch()).count();
276+
277+ auto event_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
278+ std::chrono::system_clock::now().time_since_epoch());
279
280 auto input_action =
281 (key_params.action == synthesis::EventAction::Down) ? mir_keyboard_action_down : mir_keyboard_action_up;
282@@ -173,8 +174,8 @@
283
284 void mtf::FakeInputDeviceImpl::InputDevice::synthesize_events(synthesis::ButtonParameters const& button)
285 {
286- int64_t event_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
287- std::chrono::system_clock::now().time_since_epoch()).count();
288+ auto event_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
289+ std::chrono::system_clock::now().time_since_epoch());
290 auto action = update_buttons(button.action, to_pointer_button(button.button));
291 auto event_modifiers = expand_modifier(modifiers);
292 auto button_event = mir::events::make_event(device_id_unknown,
293@@ -211,8 +212,8 @@
294 if (!sink)
295 BOOST_THROW_EXCEPTION(std::runtime_error("Device is not started."));
296
297- int64_t event_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
298- std::chrono::system_clock::now().time_since_epoch()).count();
299+ auto event_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
300+ std::chrono::system_clock::now().time_since_epoch());
301 auto event_modifiers = expand_modifier(modifiers);
302 update_position(pointer.rel_x, pointer.rel_y);
303 auto pointer_event = mir::events::make_event(device_id_unknown,
304@@ -239,8 +240,8 @@
305 if (!sink)
306 BOOST_THROW_EXCEPTION(std::runtime_error("Device is not started."));
307
308- int64_t event_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
309- std::chrono::system_clock::now().time_since_epoch()).count();
310+ auto event_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
311+ std::chrono::system_clock::now().time_since_epoch());
312 auto event_modifiers = expand_modifier(modifiers);
313
314 auto touch_event = mir::events::make_event(device_id_unknown, event_time, event_modifiers);
315
316=== modified file 'tests/unit-tests/frontend/test_event_sender.cpp'
317--- tests/unit-tests/frontend/test_event_sender.cpp 2015-03-31 02:35:42 +0000
318+++ tests/unit-tests/frontend/test_event_sender.cpp 2015-05-12 14:01:11 +0000
319@@ -94,7 +94,7 @@
320 {
321 using namespace testing;
322
323- auto ev = mev::make_event(MirInputDeviceId(), 0, MirKeyboardAction(),
324+ auto ev = mev::make_event(MirInputDeviceId(), std::chrono::nanoseconds(0), MirKeyboardAction(),
325 0, 0, MirInputEventModifiers());
326
327 EXPECT_CALL(mock_msg_sender, send(_, _, _))
328
329=== modified file 'tests/unit-tests/input/android/test_android_input_dispatcher.cpp'
330--- tests/unit-tests/input/android/test_android_input_dispatcher.cpp 2015-05-12 14:01:11 +0000
331+++ tests/unit-tests/input/android/test_android_input_dispatcher.cpp 2015-05-12 14:01:11 +0000
332@@ -175,7 +175,7 @@
333 MirEvent event;
334 event.type = mir_event_type_motion;
335 event.motion.pointer_count = 1;
336- event.motion.event_time = 2;
337+ event.motion.event_time = std::chrono::nanoseconds(2);
338 event.motion.device_id = 3;
339 event.motion.source_id = 4;
340 event.motion.action = mir_motion_action_scroll;
341@@ -208,7 +208,7 @@
342 expected_properties[0].id = pointer.id;
343 expected_properties[0].toolType = pointer.tool_type;
344
345- droidinput::NotifyMotionArgs expected(std::chrono::nanoseconds(event.motion.event_time),
346+ droidinput::NotifyMotionArgs expected(event.motion.event_time,
347 event.motion.device_id,
348 event.motion.source_id,
349 default_policy_flags,
350@@ -233,7 +233,7 @@
351 using namespace ::testing;
352 MirEvent event;
353 event.type = mir_event_type_key;
354- event.key.event_time = 1;
355+ event.key.event_time = std::chrono::nanoseconds(1);
356 event.key.device_id = 2;
357 event.key.source_id = 3;
358 event.key.action = mir_keyboard_action_down;
359@@ -250,7 +250,7 @@
360 event.key.key_code,
361 event.key.scan_code,
362 AMETA_SHIFT_ON,
363- std::chrono::nanoseconds(event.key.event_time));
364+ event.key.event_time);
365
366 EXPECT_CALL(*dispatcher, notifyKey(KeyArgsMatches(expected)));
367
368
369=== modified file 'tests/unit-tests/input/android/test_android_input_lexicon.cpp'
370--- tests/unit-tests/input/android/test_android_input_lexicon.cpp 2015-05-12 14:01:11 +0000
371+++ tests/unit-tests/input/android/test_android_input_lexicon.cpp 2015-05-12 14:01:11 +0000
372@@ -61,7 +61,7 @@
373 EXPECT_EQ(mir_ev.type, mir_event_type_key);
374 EXPECT_EQ(mir_key_ev->key_code, key_code);
375 EXPECT_EQ(mir_key_ev->scan_code, scan_code);
376- EXPECT_EQ(mir_key_ev->event_time, event_time.count());
377+ EXPECT_EQ(mir_key_ev->event_time, event_time);
378
379 delete android_key_ev;
380 }
381@@ -135,7 +135,7 @@
382 auto mir_motion_ev = &mir_ev.motion;
383
384 EXPECT_EQ(mir_motion_ev->button_state, button_state);
385- EXPECT_EQ(mir_motion_ev->event_time, event_time.count());
386+ EXPECT_EQ(mir_motion_ev->event_time, event_time);
387
388 EXPECT_EQ(mir_motion_ev->pointer_count, pointer_count);
389
390@@ -242,7 +242,7 @@
391 auto mir_motion_ev = &mir_ev.motion;
392
393 EXPECT_EQ(mir_motion_ev->button_state, button_state);
394- EXPECT_EQ(mir_motion_ev->event_time, event_time.count());
395+ EXPECT_EQ(mir_motion_ev->event_time, event_time);
396 EXPECT_EQ(mir_motion_ev->pointer_count, pointer_count);
397
398 auto pointer = &mir_motion_ev->pointer_coordinates[0];
399
400=== modified file 'tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp'
401--- tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp 2015-05-12 14:01:11 +0000
402+++ tests/unit-tests/input/android/test_event_filter_input_dispatcher_policy.cpp 2015-05-12 14:01:11 +0000
403@@ -43,6 +43,11 @@
404 mia::EventFilterDispatcherPolicy policy(mt::fake_shared(filter), true);
405 uint32_t policy_flags;
406
407+ ev.initialize(0, 0, 0, 0, 0, 0, 0, 0,
408+ std::chrono::nanoseconds(0),
409+ std::chrono::nanoseconds(0));
410+
411+
412 EXPECT_CALL(filter, handle(_)).Times(1).WillOnce(Return(false));
413
414 // The policy filters ALL key events before queuing
415
416=== modified file 'tests/unit-tests/input/android/test_input_translator.cpp'
417--- tests/unit-tests/input/android/test_input_translator.cpp 2015-05-12 14:01:11 +0000
418+++ tests/unit-tests/input/android/test_input_translator.cpp 2015-05-12 14:01:11 +0000
419@@ -230,7 +230,7 @@
420 using namespace ::testing;
421 MirEvent expected;
422 expected.type = mir_event_type_key;
423- expected.key.event_time = 1;
424+ expected.key.event_time = std::chrono::nanoseconds(1);
425 expected.key.device_id = 2;
426 expected.key.source_id = 3;
427 expected.key.action = mir_keyboard_action_down;
428@@ -250,7 +250,7 @@
429 expected.key.key_code,
430 expected.key.scan_code,
431 AMETA_SHIFT_ON,
432- std::chrono::nanoseconds(expected.key.event_time));
433+ expected.key.event_time);
434
435 translator.notifyKey(&notified);
436 }
437@@ -261,7 +261,7 @@
438 MirEvent expected;
439 expected.type = mir_event_type_motion;
440 expected.motion.pointer_count = 1;
441- expected.motion.event_time = 2;
442+ expected.motion.event_time = std::chrono::nanoseconds(2);
443 expected.motion.device_id = 3;
444 expected.motion.source_id = 4;
445 expected.motion.action = mir_motion_action_scroll;
446@@ -309,7 +309,7 @@
447 properties,
448 coords,
449 0, 0, /* unused x/y precision */
450- std::chrono::nanoseconds(expected.motion.event_time));
451+ expected.motion.event_time);
452
453 translator.notifyMotion(&notified);
454 }
455
456=== modified file 'tests/unit-tests/input/test_default_input_device_hub.cpp'
457--- tests/unit-tests/input/test_default_input_device_hub.cpp 2015-04-14 11:08:21 +0000
458+++ tests/unit-tests/input/test_default_input_device_hub.cpp 2015-05-12 14:01:11 +0000
459@@ -100,6 +100,8 @@
460 Nice<MockInputDevice> another_device;
461 Nice<MockInputDevice> third_device;
462
463+ std::chrono::nanoseconds arbitrary_timestamp;
464+
465 InputDeviceHubTest()
466 {
467 using namespace testing;
468@@ -241,7 +243,6 @@
469 TEST_F(InputDeviceHubTest, input_sink_posts_events_to_input_dispatcher)
470 {
471 using namespace ::testing;
472- int64_t arbitrary_timestamp = 0;
473 int64_t unset_input_device_id = 0;
474 auto event = mir::events::make_event(unset_input_device_id, arbitrary_timestamp, mir_keyboard_action_down, 0, KEY_A, mir_input_event_modifier_none);
475
476@@ -266,7 +267,6 @@
477 TEST_F(InputDeviceHubTest, forwards_touch_spots_to_visualizer)
478 {
479 using namespace ::testing;
480- int64_t arbitrary_timestamp = 0;
481 auto touch_event_1 = mir::events::make_event(0, arbitrary_timestamp, mir_input_event_modifier_none);
482 mir::events::add_touch(*touch_event_1, 0, mir_touch_action_down, mir_touch_tooltype_finger,
483 21.0f, 34.0f, 50.0f, 15.0f, 5.0f, 4.0f);
484
485=== modified file 'tests/unit-tests/input/test_event_builders.cpp'
486--- tests/unit-tests/input/test_event_builders.cpp 2015-05-04 10:00:26 +0000
487+++ tests/unit-tests/input/test_event_builders.cpp 2015-05-12 14:01:11 +0000
488@@ -28,7 +28,7 @@
489 struct InputEventBuilder : public testing::Test
490 {
491 MirInputDeviceId const device_id = 7;
492- int64_t const timestamp = 39;
493+ std::chrono::nanoseconds const timestamp = std::chrono::nanoseconds(39);
494 MirInputEventModifiers const modifiers = mir_input_event_modifier_meta;
495 };
496 }
497
498=== modified file 'tests/unit-tests/input/test_event_filter_chain.cpp'
499--- tests/unit-tests/input/test_event_filter_chain.cpp 2015-04-01 19:39:19 +0000
500+++ tests/unit-tests/input/test_event_filter_chain.cpp 2015-05-12 14:01:11 +0000
501@@ -40,7 +40,7 @@
502
503 struct EventFilterChain : public ::testing::Test
504 {
505- mir::EventUPtr const event = mir::events::make_event(MirInputDeviceId(), 0,
506+ mir::EventUPtr const event = mir::events::make_event(MirInputDeviceId(), std::chrono::nanoseconds(0),
507 MirKeyboardAction(), xkb_keysym_t(), 0, MirInputEventModifiers());
508 };
509 }
510
511=== modified file 'tests/unit-tests/input/test_input_event.cpp'
512--- tests/unit-tests/input/test_input_event.cpp 2015-05-12 14:01:11 +0000
513+++ tests/unit-tests/input/test_input_event.cpp 2015-05-12 14:01:11 +0000
514@@ -108,16 +108,16 @@
515
516 TEST(CommonInputEventProperties, event_time_taken_from_old_style_event)
517 {
518- int64_t event_time_1 = 79, event_time_2 = 83;
519+ std::chrono::nanoseconds event_time_1{79}, event_time_2{83};
520 auto old_ev = a_motion_ev();
521
522 old_ev.motion.event_time = event_time_1;
523- EXPECT_EQ(event_time_1, mir_input_event_get_event_time(
524+ EXPECT_EQ(event_time_1.count(), mir_input_event_get_event_time(
525 mir_event_get_input_event(&old_ev)));
526
527 old_ev.type = mir_event_type_key;
528 old_ev.key.event_time = event_time_2;
529- EXPECT_EQ(event_time_2, mir_input_event_get_event_time(
530+ EXPECT_EQ(event_time_2.count(), mir_input_event_get_event_time(
531 mir_event_get_input_event(&old_ev)));
532 }
533
534
535=== modified file 'tests/unit-tests/scene/test_abstract_shell.cpp'
536--- tests/unit-tests/scene/test_abstract_shell.cpp 2015-05-04 18:18:36 +0000
537+++ tests/unit-tests/scene/test_abstract_shell.cpp 2015-05-12 14:01:11 +0000
538@@ -132,6 +132,8 @@
539 ON_CALL(surface_factory, create_surface(_,_))
540 .WillByDefault(Return(mt::fake_shared(mock_surface)));
541 }
542+
543+ std::chrono::nanoseconds const event_timestamp = std::chrono::nanoseconds(0);
544 };
545 }
546
547@@ -239,7 +241,6 @@
548
549 TEST_F(AbstractShell, key_input_events_are_handled_by_window_manager)
550 {
551- int64_t const timestamp{0};
552 MirKeyboardAction const action{mir_keyboard_action_down};
553 xkb_keysym_t const key_code{0};
554 int const scan_code{0};
555@@ -247,7 +248,7 @@
556
557 auto const event = mir::events::make_event(
558 mir_input_event_type_key,
559- timestamp,
560+ event_timestamp,
561 action,
562 key_code,
563 scan_code,
564@@ -263,12 +264,11 @@
565
566 TEST_F(AbstractShell, touch_input_events_are_handled_by_window_manager)
567 {
568- int64_t const timestamp{0};
569 MirInputEventModifiers const modifiers{mir_input_event_modifier_none};
570
571 auto const event = mir::events::make_event(
572 mir_input_event_type_touch,
573- timestamp,
574+ event_timestamp,
575 modifiers);
576
577 EXPECT_CALL(*wm, handle_touch_event(_))
578@@ -281,7 +281,6 @@
579
580 TEST_F(AbstractShell, pointer_input_events_are_handled_by_window_manager)
581 {
582- int64_t const timestamp{0};
583 MirInputEventModifiers const modifiers{mir_input_event_modifier_none};
584 MirPointerAction const action{mir_pointer_action_button_down};
585 std::vector<MirPointerButton> const buttons_pressed{mir_pointer_button_primary};
586@@ -292,7 +291,7 @@
587
588 auto const event = mir::events::make_event(
589 mir_input_event_type_pointer,
590- timestamp,
591+ event_timestamp,
592 modifiers,
593 action,
594 buttons_pressed,

Subscribers

People subscribed via source and target branches