Merge lp:~andreas-pokorny/mir/use-one-cursor-position-per-seat into lp:mir
- use-one-cursor-position-per-seat
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Andreas Pokorny |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3125 |
Proposed branch: | lp:~andreas-pokorny/mir/use-one-cursor-position-per-seat |
Merge into: | lp:mir |
Diff against target: |
658 lines (+139/-110) 17 files modified
include/client/mir/events/event_builders.h (+2/-0) include/platform/mir/input/event_builder.h (+2/-2) include/platform/mir/input/input_sink.h (+0/-5) src/client/events/event_builders.cpp (+11/-0) src/client/symbols.map (+1/-0) src/platforms/evdev/libinput_device.cpp (+7/-14) src/platforms/mesa/server/x11/input/input_device.h (+2/-0) src/platforms/mesa/server/x11/input/input_platform.cpp (+8/-10) src/server/input/default_event_builder.cpp (+3/-2) src/server/input/default_event_builder.h (+2/-2) src/server/input/default_input_device_hub.cpp (+4/-6) src/server/input/default_input_device_hub.h (+0/-1) src/server/input/seat.cpp (+18/-5) src/server/input/seat.h (+7/-1) tests/mir_test_framework/fake_input_device_impl.cpp (+0/-11) tests/unit-tests/input/evdev/test_libinput_device.cpp (+13/-26) tests/unit-tests/input/test_default_input_device_hub.cpp (+59/-25) |
To merge this branch: | bzr merge lp:~andreas-pokorny/mir/use-one-cursor-position-per-seat |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Kevin DuBois (community) | Approve | ||
Alberto Aguirre (community) | Approve | ||
Review via email: mp+277843@code.launchpad.net |
Commit message
Unify the cursor position within a seat
This move changes the responsibility to track the cursor position out of the platforms to the mir::input::Seat. This reduces the EventBuilder interface and removes the InputSink:
The fixes cursor jumps when switching between mouse and keyboard.
Description of the change
Yet another ABI breaking change to EventBuilder. This time it moves the responsibility of controlling the cursor position to the 'Seat'. Now the relative changes of multiple pointing devices contribute to the same cursor position.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3104
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
None: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3105
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3106
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3107
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'include/client/mir/events/event_builders.h' |
2 | --- include/client/mir/events/event_builders.h 2015-11-04 07:43:28 +0000 |
3 | +++ include/client/mir/events/event_builders.h 2015-11-19 12:36:51 +0000 |
4 | @@ -22,6 +22,7 @@ |
5 | #include "mir_toolkit/event.h" |
6 | |
7 | #include "mir/geometry/size.h" |
8 | +#include "mir/geometry/point.h" |
9 | #include "mir/frontend/surface_id.h" |
10 | |
11 | #include <memory> |
12 | @@ -60,6 +61,7 @@ |
13 | int scan_code, MirInputEventModifiers modifiers); |
14 | |
15 | void set_modifier(MirEvent& event, MirInputEventModifiers modifiers); |
16 | +void set_cursor_position(MirEvent& event, mir::geometry::Point const& pos); |
17 | |
18 | // Deprecated version without mac |
19 | EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp, |
20 | |
21 | === modified file 'include/platform/mir/input/event_builder.h' |
22 | --- include/platform/mir/input/event_builder.h 2015-11-04 07:43:28 +0000 |
23 | +++ include/platform/mir/input/event_builder.h 2015-11-19 12:36:51 +0000 |
24 | @@ -46,8 +46,8 @@ |
25 | float touch_minor_value, float size_value) = 0; |
26 | |
27 | virtual EventUPtr pointer_event(Timestamp timestamp, MirPointerAction action, MirPointerButtons buttons_pressed, |
28 | - float x_axis_value, float y_axis_value, float hscroll_value, float vscroll_value, |
29 | - float relative_x_value, float relative_y_value) = 0; |
30 | + float hscroll_value, float vscroll_value, float relative_x_value, |
31 | + float relative_y_value) = 0; |
32 | |
33 | virtual EventUPtr configuration_event(Timestamp timestamp, MirInputConfigurationAction action) = 0; |
34 | |
35 | |
36 | === modified file 'include/platform/mir/input/input_sink.h' |
37 | --- include/platform/mir/input/input_sink.h 2015-06-17 05:20:42 +0000 |
38 | +++ include/platform/mir/input/input_sink.h 2015-11-19 12:36:51 +0000 |
39 | @@ -34,11 +34,6 @@ |
40 | InputSink() = default; |
41 | virtual ~InputSink() = default; |
42 | virtual void handle_input(MirEvent& event) = 0; |
43 | - /** |
44 | - * Confine position of a pointer |
45 | - */ |
46 | - virtual void confine_pointer(mir::geometry::Point& position) = 0; |
47 | - |
48 | /**! |
49 | * Obtain the bounding rectangle of the destination area for this input sink |
50 | */ |
51 | |
52 | === modified file 'src/client/events/event_builders.cpp' |
53 | --- src/client/events/event_builders.cpp 2015-11-04 07:43:28 +0000 |
54 | +++ src/client/events/event_builders.cpp 2015-11-19 12:36:51 +0000 |
55 | @@ -189,6 +189,17 @@ |
56 | } |
57 | } |
58 | |
59 | +void mev::set_cursor_position(MirEvent& event, mir::geometry::Point const& pos) |
60 | +{ |
61 | + if (event.type != mir_event_type_motion && |
62 | + event.motion.source_id != AINPUT_SOURCE_MOUSE && |
63 | + event.motion.pointer_count == 1) |
64 | + BOOST_THROW_EXCEPTION(std::invalid_argument("Cursor position is only valid for pointer events.")); |
65 | + |
66 | + event.motion.pointer_coordinates[0].x = pos.x.as_float(); |
67 | + event.motion.pointer_coordinates[0].y = pos.y.as_float(); |
68 | +} |
69 | + |
70 | // Deprecated version without mac |
71 | mir::EventUPtr mev::make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp, |
72 | MirKeyboardAction action, xkb_keysym_t key_code, |
73 | |
74 | === modified file 'src/client/symbols.map' |
75 | --- src/client/symbols.map 2015-11-04 07:43:28 +0000 |
76 | +++ src/client/symbols.map 2015-11-19 12:36:51 +0000 |
77 | @@ -250,6 +250,7 @@ |
78 | global: |
79 | extern "C++" { |
80 | mir::events::set_modifier*; |
81 | + mir::events::set_cursor_position*; |
82 | }; |
83 | } MIR_CLIENT_DETAIL_9; |
84 | |
85 | |
86 | === modified file 'src/platforms/evdev/libinput_device.cpp' |
87 | --- src/platforms/evdev/libinput_device.cpp 2015-11-19 04:54:42 +0000 |
88 | +++ src/platforms/evdev/libinput_device.cpp 2015-11-19 12:36:51 +0000 |
89 | @@ -163,8 +163,7 @@ |
90 | else |
91 | button_state = MirPointerButton(button_state & ~uint32_t(pointer_button)); |
92 | |
93 | - return builder->pointer_event(time, action, button_state, pointer_pos.x.as_float(), pointer_pos.y.as_float(), |
94 | - hscroll_value, vscroll_value, relative_x_value, relative_y_value); |
95 | + return builder->pointer_event(time, action, button_state, hscroll_value, vscroll_value, relative_x_value, relative_y_value); |
96 | } |
97 | |
98 | mir::EventUPtr mie::LibInputDevice::convert_motion_event(libinput_event_pointer* pointer) |
99 | @@ -179,12 +178,9 @@ |
100 | mir::geometry::Displacement const movement{ |
101 | libinput_event_pointer_get_dx(pointer), |
102 | libinput_event_pointer_get_dy(pointer)}; |
103 | - pointer_pos = pointer_pos + movement; |
104 | - |
105 | - sink->confine_pointer(pointer_pos); |
106 | - |
107 | - return builder->pointer_event(time, action, button_state, pointer_pos.x.as_float(), pointer_pos.y.as_float(), |
108 | - hscroll_value, vscroll_value, movement.dx.as_float(), movement.dy.as_float()); |
109 | + |
110 | + return builder->pointer_event(time, action, button_state, hscroll_value, vscroll_value, movement.dx.as_float(), |
111 | + movement.dy.as_float()); |
112 | } |
113 | |
114 | mir::EventUPtr mie::LibInputDevice::convert_absolute_motion_event(libinput_event_pointer* pointer) |
115 | @@ -205,10 +201,7 @@ |
116 | libinput_event_pointer_get_absolute_y_transformed(pointer, height)}; |
117 | auto const movement = pointer_pos - old_pointer_pos; |
118 | |
119 | - sink->confine_pointer(pointer_pos); |
120 | - |
121 | - return builder->pointer_event(time, action, button_state, pointer_pos.x.as_float(), pointer_pos.y.as_float(), |
122 | - hscroll_value, vscroll_value, movement.dx.as_float(), movement.dy.as_float()); |
123 | + return builder->pointer_event(time, action, button_state, hscroll_value, vscroll_value, movement.dx.as_float(), movement.dy.as_float()); |
124 | } |
125 | |
126 | mir::EventUPtr mie::LibInputDevice::convert_axis_event(libinput_event_pointer* pointer) |
127 | @@ -227,8 +220,8 @@ |
128 | : 0.0f; |
129 | |
130 | report->received_event_from_kernel(time.count(), EV_REL, 0, 0); |
131 | - return builder->pointer_event(time, action, button_state, pointer_pos.x.as_float(), pointer_pos.y.as_float(), |
132 | - hscroll_value, vscroll_value, relative_x_value, relative_y_value); |
133 | + return builder->pointer_event(time, action, button_state, hscroll_value, vscroll_value, relative_x_value, |
134 | + relative_y_value); |
135 | } |
136 | |
137 | MirEvent& mie::LibInputDevice::get_accumulated_touch_event(std::chrono::nanoseconds timestamp) |
138 | |
139 | === modified file 'src/platforms/mesa/server/x11/input/input_device.h' |
140 | --- src/platforms/mesa/server/x11/input/input_device.h 2015-11-03 15:54:51 +0000 |
141 | +++ src/platforms/mesa/server/x11/input/input_device.h 2015-11-19 12:36:51 +0000 |
142 | @@ -21,6 +21,7 @@ |
143 | |
144 | #include "mir/input/input_device.h" |
145 | #include "mir/input/input_device_info.h" |
146 | +#include "mir/geometry/point.h" |
147 | #include "mir/optional_value.h" |
148 | |
149 | namespace mir |
150 | @@ -48,6 +49,7 @@ |
151 | |
152 | InputSink* sink{nullptr}; |
153 | EventBuilder* builder{nullptr}; |
154 | + geometry::Point pointer_pos; |
155 | private: |
156 | InputDeviceInfo info; |
157 | }; |
158 | |
159 | === modified file 'src/platforms/mesa/server/x11/input/input_platform.cpp' |
160 | --- src/platforms/mesa/server/x11/input/input_platform.cpp 2015-11-04 07:43:28 +0000 |
161 | +++ src/platforms/mesa/server/x11/input/input_platform.cpp 2015-11-19 12:36:51 +0000 |
162 | @@ -205,8 +205,6 @@ |
163 | event_time, |
164 | mir_pointer_action_motion, |
165 | 0, |
166 | - xbev.x, |
167 | - xbev.y, |
168 | 0.0f, |
169 | (xbev.button == Button4) ? 1.0f : -1.0f, |
170 | 0.0f, |
171 | @@ -216,6 +214,10 @@ |
172 | } |
173 | else |
174 | { |
175 | + auto const old_pointer_pos = core_pointer->pointer_pos; |
176 | + core_pointer->pointer_pos = geometry::Point{xbev.x, xbev.y}; |
177 | + auto const movement = core_pointer->pointer_pos - old_pointer_pos; |
178 | + |
179 | core_pointer->sink->handle_input( |
180 | *core_pointer->builder->pointer_event( |
181 | event_time, |
182 | @@ -223,12 +225,10 @@ |
183 | mir_pointer_action_button_down : |
184 | mir_pointer_action_button_up, |
185 | buttons_pressed, |
186 | - xbev.x, |
187 | - xbev.y, |
188 | - 0.0f, |
189 | - 0.0f, |
190 | - 0.0f, |
191 | - 0.0f |
192 | + 0.0f, |
193 | + 0.0f, |
194 | + movement.dx.as_float(), |
195 | + movement.dy.as_float() |
196 | ) |
197 | ); |
198 | } |
199 | @@ -275,8 +275,6 @@ |
200 | event_time, |
201 | mir_pointer_action_motion, |
202 | buttons_pressed, |
203 | - xmev.x, |
204 | - xmev.y, |
205 | 0.0f, |
206 | 0.0f, |
207 | 0.0f, |
208 | |
209 | === modified file 'src/server/input/default_event_builder.cpp' |
210 | --- src/server/input/default_event_builder.cpp 2015-11-04 07:43:28 +0000 |
211 | +++ src/server/input/default_event_builder.cpp 2015-11-19 12:36:51 +0000 |
212 | @@ -60,10 +60,11 @@ |
213 | } |
214 | |
215 | mir::EventUPtr mi::DefaultEventBuilder::pointer_event(Timestamp timestamp, MirPointerAction action, |
216 | - MirPointerButtons buttons_pressed, float x_axis_value, |
217 | - float y_axis_value, float hscroll_value, float vscroll_value, |
218 | + MirPointerButtons buttons_pressed, float hscroll_value, float vscroll_value, |
219 | float relative_x_value, float relative_y_value) |
220 | { |
221 | + const float x_axis_value = 0; |
222 | + const float y_axis_value = 0; |
223 | uint64_t mac = 0; |
224 | if (action == mir_pointer_action_button_up || action == mir_pointer_action_button_down) |
225 | mac = cookie_factory->timestamp_to_cookie(timestamp.count()).mac; |
226 | |
227 | === modified file 'src/server/input/default_event_builder.h' |
228 | --- src/server/input/default_event_builder.h 2015-11-04 07:43:28 +0000 |
229 | +++ src/server/input/default_event_builder.h 2015-11-19 12:36:51 +0000 |
230 | @@ -45,8 +45,8 @@ |
231 | float touch_minor_value, float size_value) override; |
232 | |
233 | EventUPtr pointer_event(Timestamp timestamp, MirPointerAction action, MirPointerButtons buttons_pressed, |
234 | - float x_axis_value, float y_axis_value, float hscroll_value, float vscroll_value, |
235 | - float relative_x_value, float relative_y_value) override; |
236 | + float hscroll_value, float vscroll_value, float relative_x_value, |
237 | + float relative_y_value) override; |
238 | |
239 | EventUPtr configuration_event(Timestamp timestamp, MirInputConfigurationAction action) override; |
240 | |
241 | |
242 | === modified file 'src/server/input/default_input_device_hub.cpp' |
243 | --- src/server/input/default_input_device_hub.cpp 2015-11-04 15:42:43 +0000 |
244 | +++ src/server/input/default_input_device_hub.cpp 2015-11-19 12:36:51 +0000 |
245 | @@ -56,7 +56,7 @@ |
246 | device_queue(std::make_shared<dispatch::ActionQueue>()), |
247 | input_region(input_region), |
248 | cookie_factory(cookie_factory), |
249 | - seat(touch_visualizer, cursor_listener), |
250 | + seat(touch_visualizer, cursor_listener, input_region), |
251 | device_id_generator{0} |
252 | { |
253 | input_dispatchable->add_watch(device_queue); |
254 | @@ -175,6 +175,9 @@ |
255 | else |
256 | mev::set_modifier(event, seat->event_modifier()); |
257 | |
258 | + if (mir_input_event_type_pointer == mir_input_event_get_type(input_event)) |
259 | + mev::set_cursor_position(event, seat->cursor_position()); |
260 | + |
261 | dispatcher->dispatch(event); |
262 | } |
263 | |
264 | @@ -193,11 +196,6 @@ |
265 | device->stop(); |
266 | } |
267 | |
268 | -void mi::DefaultInputDeviceHub::RegisteredDevice::confine_pointer(mir::geometry::Point& position) |
269 | -{ |
270 | - hub->input_region->confine(position); |
271 | -} |
272 | - |
273 | mir::geometry::Rectangle mi::DefaultInputDeviceHub::RegisteredDevice::bounding_rectangle() const |
274 | { |
275 | // TODO touchscreens only need the bounding rectangle of one output |
276 | |
277 | === modified file 'src/server/input/default_input_device_hub.h' |
278 | --- src/server/input/default_input_device_hub.h 2015-11-04 15:42:43 +0000 |
279 | +++ src/server/input/default_input_device_hub.h 2015-11-19 12:36:51 +0000 |
280 | @@ -99,7 +99,6 @@ |
281 | DefaultInputDeviceHub* hub, |
282 | Seat* seat); |
283 | void handle_input(MirEvent& event) override; |
284 | - void confine_pointer(mir::geometry::Point& position) override; |
285 | mir::geometry::Rectangle bounding_rectangle() const override; |
286 | bool device_matches(std::shared_ptr<InputDevice> const& dev) const; |
287 | void start(); |
288 | |
289 | === modified file 'src/server/input/seat.cpp' |
290 | --- src/server/input/seat.cpp 2015-10-19 10:00:22 +0000 |
291 | +++ src/server/input/seat.cpp 2015-11-19 12:36:51 +0000 |
292 | @@ -20,6 +20,8 @@ |
293 | #include "seat.h" |
294 | #include "mir/input/device.h" |
295 | #include "mir/input/cursor_listener.h" |
296 | +#include "mir/input/input_region.h" |
297 | +#include "mir/geometry/displacement.h" |
298 | |
299 | #include "input_modifier_utils.h" |
300 | |
301 | @@ -31,8 +33,9 @@ |
302 | namespace mi = mir::input; |
303 | |
304 | mi::Seat::Seat(std::shared_ptr<TouchVisualizer> const& touch_visualizer, |
305 | - std::shared_ptr<CursorListener> const& cursor_listener) |
306 | - : touch_visualizer{touch_visualizer}, cursor_listener{cursor_listener}, modifier{0} |
307 | + std::shared_ptr<CursorListener> const& cursor_listener, |
308 | + std::shared_ptr<InputRegion> const& input_region) |
309 | + : touch_visualizer{touch_visualizer}, cursor_listener{cursor_listener}, input_region{input_region}, modifier{0} |
310 | { |
311 | } |
312 | |
313 | @@ -153,9 +156,19 @@ |
314 | }); |
315 | } |
316 | |
317 | +mir::geometry::Point mi::Seat::cursor_position() const |
318 | +{ |
319 | + return cursor_pos; |
320 | +} |
321 | + |
322 | void mi::Seat::update_cursor(MirPointerEvent const* event) |
323 | { |
324 | - cursor_listener->cursor_moved_to(mir_pointer_event_axis_value(event, mir_pointer_axis_x), |
325 | - mir_pointer_event_axis_value(event, mir_pointer_axis_y)); |
326 | + mir::geometry::Displacement movement{ |
327 | + mir_pointer_event_axis_value(event, mir_pointer_axis_relative_x), |
328 | + mir_pointer_event_axis_value(event, mir_pointer_axis_relative_y), |
329 | + }; |
330 | + cursor_pos = cursor_pos + movement; |
331 | + input_region->confine(cursor_pos); |
332 | + |
333 | + cursor_listener->cursor_moved_to(cursor_pos.x.as_float(), cursor_pos.y.as_float()); |
334 | } |
335 | - |
336 | |
337 | === modified file 'src/server/input/seat.h' |
338 | --- src/server/input/seat.h 2015-10-19 10:00:22 +0000 |
339 | +++ src/server/input/seat.h 2015-11-19 12:36:51 +0000 |
340 | @@ -21,6 +21,7 @@ |
341 | #define MIR_INPUT_DEFAULT_SEAT_H_ |
342 | |
343 | #include "mir/input/touch_visualizer.h" |
344 | +#include "mir/geometry/point.h" |
345 | #include "mir_toolkit/event.h" |
346 | #include <unordered_map> |
347 | #include <memory> |
348 | @@ -30,6 +31,7 @@ |
349 | namespace input |
350 | { |
351 | class CursorListener; |
352 | +class InputRegion; |
353 | |
354 | /* |
355 | * The seat bundles a group of devices. A cursor position, input event modifiers and the visible touch spots are properties |
356 | @@ -38,13 +40,15 @@ |
357 | class Seat |
358 | { |
359 | public: |
360 | - Seat(std::shared_ptr<TouchVisualizer> const& touch_visualizer, std::shared_ptr<CursorListener> const& cursor_listener); |
361 | + Seat(std::shared_ptr<TouchVisualizer> const& touch_visualizer, |
362 | + std::shared_ptr<CursorListener> const& cursor_listener, std::shared_ptr<InputRegion> const& input_region); |
363 | void add_device(MirInputDeviceId); |
364 | void remove_device(MirInputDeviceId); |
365 | |
366 | MirInputEventModifiers event_modifier() const; |
367 | MirInputEventModifiers event_modifier(MirInputDeviceId) const; |
368 | void update_seat_properties(MirInputEvent const* event); |
369 | + geometry::Point cursor_position() const; |
370 | private: |
371 | void update_cursor(MirPointerEvent const* event); |
372 | void update_spots(); |
373 | @@ -52,6 +56,7 @@ |
374 | |
375 | std::shared_ptr<TouchVisualizer> const touch_visualizer; |
376 | std::shared_ptr<CursorListener> const cursor_listener; |
377 | + std::shared_ptr<InputRegion> const input_region; |
378 | |
379 | struct DeviceData |
380 | { |
381 | @@ -63,6 +68,7 @@ |
382 | std::vector<TouchVisualizer::Spot> spots; |
383 | }; |
384 | |
385 | + mir::geometry::Point cursor_pos; |
386 | MirInputEventModifiers modifier; |
387 | std::unordered_map<MirInputDeviceId, DeviceData> device_data; |
388 | std::vector<TouchVisualizer::Spot> spots; |
389 | |
390 | === modified file 'tests/mir_test_framework/fake_input_device_impl.cpp' |
391 | --- tests/mir_test_framework/fake_input_device_impl.cpp 2015-11-19 04:54:42 +0000 |
392 | +++ tests/mir_test_framework/fake_input_device_impl.cpp 2015-11-19 12:36:51 +0000 |
393 | @@ -117,8 +117,6 @@ |
394 | auto button_event = builder->pointer_event(event_time, |
395 | action, |
396 | buttons, |
397 | - pos.x.as_float(), |
398 | - pos.y.as_float(), |
399 | scroll.x.as_float(), |
400 | scroll.y.as_float(), |
401 | 0.0f, |
402 | @@ -157,12 +155,9 @@ |
403 | auto rel_x = pointer.rel_x * acceleration; |
404 | auto rel_y = pointer.rel_y * acceleration; |
405 | |
406 | - update_position(rel_x, rel_y); |
407 | auto pointer_event = builder->pointer_event(event_time, |
408 | mir_pointer_action_motion, |
409 | buttons, |
410 | - pos.x.as_float(), |
411 | - pos.y.as_float(), |
412 | scroll.x.as_float(), |
413 | scroll.y.as_float(), |
414 | rel_x, |
415 | @@ -171,12 +166,6 @@ |
416 | sink->handle_input(*pointer_event); |
417 | } |
418 | |
419 | -void mtf::FakeInputDeviceImpl::InputDevice::update_position(int rel_x, int rel_y) |
420 | -{ |
421 | - pos = pos + mir::geometry::Displacement{rel_x, rel_y}; |
422 | - sink->confine_pointer(pos); |
423 | -} |
424 | - |
425 | void mtf::FakeInputDeviceImpl::InputDevice::synthesize_events(synthesis::TouchParameters const& touch) |
426 | { |
427 | if (!sink) |
428 | |
429 | === modified file 'tests/unit-tests/input/evdev/test_libinput_device.cpp' |
430 | --- tests/unit-tests/input/evdev/test_libinput_device.cpp 2015-11-19 04:54:42 +0000 |
431 | +++ tests/unit-tests/input/evdev/test_libinput_device.cpp 2015-11-19 12:36:51 +0000 |
432 | @@ -96,11 +96,11 @@ |
433 | return builder.add_touch(event, id, action, tooltype, x, y, major, minor, |
434 | pressure, size); |
435 | })); |
436 | - ON_CALL(*this, pointer_event(_, _, _, _, _, _, _, _, _)) |
437 | - .WillByDefault(Invoke([this](Timestamp time, MirPointerAction action, MirPointerButtons buttons, float x, |
438 | - float y, float hscroll, float vscroll, float relative_x, float relative_y) |
439 | + ON_CALL(*this, pointer_event(_, _, _, _, _, _, _)) |
440 | + .WillByDefault(Invoke([this](Timestamp time, MirPointerAction action, MirPointerButtons buttons, |
441 | + float hscroll, float vscroll, float relative_x, float relative_y) |
442 | { |
443 | - return builder.pointer_event(time, action, buttons, x, y, hscroll, vscroll, |
444 | + return builder.pointer_event(time, action, buttons, hscroll, vscroll, |
445 | relative_x, relative_y); |
446 | })); |
447 | ON_CALL(*this, configuration_event(_,_)) |
448 | @@ -115,9 +115,8 @@ |
449 | MOCK_METHOD1(touch_event, mir::EventUPtr(Timestamp)); |
450 | MOCK_METHOD10(add_touch, void(MirEvent&, MirTouchId, MirTouchAction, MirTouchTooltype, float, float, float, float, |
451 | float, float)); |
452 | - |
453 | - MOCK_METHOD9(pointer_event, mir::EventUPtr(Timestamp, MirPointerAction, MirPointerButtons, float, float, float, |
454 | - float, float, float)); |
455 | + MOCK_METHOD7(pointer_event, |
456 | + mir::EventUPtr(Timestamp, MirPointerAction, MirPointerButtons, float, float, float, float)); |
457 | MOCK_METHOD2(configuration_event, mir::EventUPtr(Timestamp, MirInputConfigurationAction)); |
458 | }; |
459 | |
460 | @@ -549,28 +548,16 @@ |
461 | setup_absolute_pointer_event(fake_event_1, event_time_1, x1, y1); |
462 | setup_absolute_pointer_event(fake_event_2, event_time_2, x2, y2); |
463 | |
464 | - EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithPosition(x1, y1))); |
465 | + EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithDiff(x1, y1))); |
466 | EXPECT_CALL(mock_sink, |
467 | - handle_input(AllOf(mt::PointerEventWithPosition(x2, y2), mt::PointerEventWithDiff(x2 - x1, y2 - y1)))); |
468 | + handle_input(mt::PointerEventWithDiff(x2 - x1, y2 - y1))); |
469 | |
470 | mouse.start(&mock_sink, &mock_builder); |
471 | mouse.process_event(fake_event_1); |
472 | mouse.process_event(fake_event_2); |
473 | } |
474 | |
475 | -TEST_F(LibInputDeviceOnMouse, process_event_provides_relative_coordinates) |
476 | -{ |
477 | - float x = -5; |
478 | - float y = 20; |
479 | - setup_pointer_event(fake_event_1, event_time_1, x, y); |
480 | - |
481 | - EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithDiff(x,y))); |
482 | - |
483 | - mouse.start(&mock_sink, &mock_builder); |
484 | - mouse.process_event(fake_event_1); |
485 | -} |
486 | - |
487 | -TEST_F(LibInputDeviceOnMouse, process_event_accumulates_pointer_movement) |
488 | +TEST_F(LibInputDeviceOnMouse, process_event_motion_events_with_relative_changes) |
489 | { |
490 | float x1 = 15, x2 = 23; |
491 | float y1 = 17, y2 = 21; |
492 | @@ -578,8 +565,8 @@ |
493 | setup_pointer_event(fake_event_1, event_time_1, x1, y1); |
494 | setup_pointer_event(fake_event_2, event_time_2, x2, y2); |
495 | |
496 | - EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithPosition(x1,y1))); |
497 | - EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithPosition(x1+x2,y1+y2))); |
498 | + EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithDiff(x1,y1))); |
499 | + EXPECT_CALL(mock_sink, handle_input(mt::PointerEventWithDiff(x2,y2))); |
500 | |
501 | mouse.start(&mock_sink, &mock_builder); |
502 | mouse.process_event(fake_event_1); |
503 | @@ -618,10 +605,10 @@ |
504 | InSequence seq; |
505 | // expect two scroll events.. |
506 | EXPECT_CALL(mock_builder, |
507 | - pointer_event(time_stamp_1, mir_pointer_action_motion, 0, 0.0f, 0.0f, 0.0f, 20.0f, 0.0f, 0.0f)); |
508 | + pointer_event(time_stamp_1, mir_pointer_action_motion, 0, 0.0f, 20.0f, 0.0f, 0.0f)); |
509 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, 20.0f))); |
510 | EXPECT_CALL(mock_builder, |
511 | - pointer_event(time_stamp_2, mir_pointer_action_motion, 0, 0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f)); |
512 | + pointer_event(time_stamp_2, mir_pointer_action_motion, 0, 5.0f, 0.0f, 0.0f, 0.0f)); |
513 | EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_hscroll, 5.0f))); |
514 | |
515 | mouse.start(&mock_sink, &mock_builder); |
516 | |
517 | === modified file 'tests/unit-tests/input/test_default_input_device_hub.cpp' |
518 | --- tests/unit-tests/input/test_default_input_device_hub.cpp 2015-11-04 15:42:43 +0000 |
519 | +++ tests/unit-tests/input/test_default_input_device_hub.cpp 2015-11-19 12:36:51 +0000 |
520 | @@ -340,22 +340,22 @@ |
521 | TEST_F(InputDeviceHubTest, tracks_pointer_position) |
522 | { |
523 | geom::Point first{10,10}, second{20,20}, third{10,30}; |
524 | - EXPECT_CALL(mock_region,confine(first)); |
525 | - EXPECT_CALL(mock_region,confine(second)); |
526 | - EXPECT_CALL(mock_region,confine(third)); |
527 | + EXPECT_CALL(mock_region, confine(first)); |
528 | + EXPECT_CALL(mock_region, confine(second)); |
529 | + EXPECT_CALL(mock_region, confine(third)); |
530 | |
531 | mi::InputSink* sink; |
532 | mi::EventBuilder* builder; |
533 | capture_input_sink(device, sink, builder); |
534 | |
535 | hub.add_device(mt::fake_shared(device)); |
536 | - |
537 | - geom::Point pos = first; |
538 | - sink->confine_pointer(pos); |
539 | - pos = second; |
540 | - sink->confine_pointer(pos); |
541 | - pos = third; |
542 | - sink->confine_pointer(pos); |
543 | + observer_loop.trigger_server_actions(); |
544 | + sink->handle_input( |
545 | + *builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 0.0f, 0.0f, 10.0f, 10.0f)); |
546 | + sink->handle_input( |
547 | + *builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 0.0f, 0.0f, 10.0f, 10.0f)); |
548 | + sink->handle_input( |
549 | + *builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 0.0f, 0.0f, -10.0f, 10.0f)); |
550 | } |
551 | |
552 | TEST_F(InputDeviceHubTest, confines_pointer_movement) |
553 | @@ -364,34 +364,34 @@ |
554 | |
555 | ON_CALL(mock_region,confine(_)) |
556 | .WillByDefault(SetArgReferee<0>(confined_pos)); |
557 | + EXPECT_CALL(mock_cursor_listener, cursor_moved_to(confined_pos.x.as_int(), confined_pos.y.as_int())).Times(2); |
558 | |
559 | mi::InputSink* sink; |
560 | mi::EventBuilder* builder; |
561 | capture_input_sink(device, sink, builder); |
562 | hub.add_device(mt::fake_shared(device)); |
563 | - |
564 | - geom::Point pos1{10,20}; |
565 | - sink->confine_pointer(pos1); |
566 | - |
567 | - geom::Point pos2{20,30}; |
568 | - sink->confine_pointer(pos2); |
569 | - |
570 | - EXPECT_THAT(pos1, Eq(confined_pos)); |
571 | - EXPECT_THAT(pos2, Eq(confined_pos)); |
572 | + observer_loop.trigger_server_actions(); |
573 | + |
574 | + sink->handle_input( |
575 | + *builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 0.0f, 0.0f, 10.0f, 20.0f)); |
576 | + sink->handle_input( |
577 | + *builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 0.0f, 0.0f, 10.0f, 10.0f)); |
578 | } |
579 | |
580 | TEST_F(InputDeviceHubTest, forwards_pointer_updates_to_cursor_listener) |
581 | { |
582 | - auto x = 12.2f, y = 14.3f; |
583 | + using namespace ::testing; |
584 | + |
585 | + auto move_x = 12.0f, move_y = 14.0f; |
586 | |
587 | mi::InputSink* sink; |
588 | mi::EventBuilder* builder; |
589 | capture_input_sink(device, sink, builder); |
590 | hub.add_device(mt::fake_shared(device)); |
591 | |
592 | - auto event = builder->pointer_event(0ns, mir_pointer_action_motion, 0, x, y, 0.0f, 0.0f, 0.0f, 0.0f); |
593 | + auto event = builder->pointer_event(0ns, mir_pointer_action_motion, 0, 0.0f, 0.0f, move_x, move_y); |
594 | |
595 | - EXPECT_CALL(mock_cursor_listener, cursor_moved_to(x, y)).Times(1); |
596 | + EXPECT_CALL(mock_cursor_listener, cursor_moved_to(move_x, move_y)).Times(1); |
597 | |
598 | sink->handle_input(*event); |
599 | } |
600 | @@ -490,7 +490,7 @@ |
601 | auto key = |
602 | key_event_builder->key_event(arbitrary_timestamp, mir_keyboard_action_down, 0, KEY_RIGHTALT); |
603 | auto motion = |
604 | - mouse_event_builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 12, 40, 0, 0, 12, 40); |
605 | + mouse_event_builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 0, 0, 12, 40); |
606 | |
607 | EXPECT_CALL(mock_dispatcher, dispatch(mt::KeyWithModifiers(r_alt_modifier))); |
608 | EXPECT_CALL(mock_dispatcher, dispatch(mt::PointerEventWithModifiers(r_alt_modifier))); |
609 | @@ -543,9 +543,9 @@ |
610 | auto ctrl_up = key_event_builder_2->key_event(arbitrary_timestamp, mir_keyboard_action_up, 0, KEY_LEFTCTRL); |
611 | |
612 | auto motion_1 = |
613 | - mouse_event_builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 12, 40, 0, 0, 12, 40); |
614 | + mouse_event_builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 0, 0, 12, 40); |
615 | auto motion_2 = |
616 | - mouse_event_builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 30, 50, 0, 0, 18, 10); |
617 | + mouse_event_builder->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 0, 0, 18, 10); |
618 | |
619 | EXPECT_CALL(mock_dispatcher, dispatch(mt::KeyWithModifiers(r_alt_modifier))); |
620 | EXPECT_CALL(mock_dispatcher, dispatch(mt::KeyWithModifiers(l_ctrl_modifier))); |
621 | @@ -561,3 +561,37 @@ |
622 | |
623 | EXPECT_THAT(key_handle_1->id(), Ne(key_handle_2->id())); |
624 | } |
625 | + |
626 | +TEST_F(InputDeviceHubTest, tracks_a_single_cursor_position_from_multiple_pointing_devices) |
627 | +{ |
628 | + using namespace ::testing; |
629 | + |
630 | + mi::InputSink* mouse_sink_1; |
631 | + mi::EventBuilder* mouse_event_builder_1; |
632 | + mi::InputSink* mouse_sink_2; |
633 | + mi::EventBuilder* mouse_event_builder_2; |
634 | + |
635 | + capture_input_sink(device, mouse_sink_1, mouse_event_builder_1); |
636 | + capture_input_sink(another_device, mouse_sink_2, mouse_event_builder_2); |
637 | + |
638 | + hub.add_device(mt::fake_shared(device)); |
639 | + hub.add_device(mt::fake_shared(another_device)); |
640 | + |
641 | + observer_loop.trigger_server_actions(); |
642 | + |
643 | + auto motion_1 = |
644 | + mouse_event_builder_1->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 0, 0, 23, 20); |
645 | + auto motion_2 = |
646 | + mouse_event_builder_2->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 0, 0, 18, -10); |
647 | + auto motion_3 = |
648 | + mouse_event_builder_2->pointer_event(arbitrary_timestamp, mir_pointer_action_motion, 0, 0, 0, 2, 10); |
649 | + |
650 | + EXPECT_CALL(mock_cursor_listener, cursor_moved_to(23, 20)); |
651 | + EXPECT_CALL(mock_cursor_listener, cursor_moved_to(41, 10)); |
652 | + EXPECT_CALL(mock_cursor_listener, cursor_moved_to(43, 20)); |
653 | + |
654 | + mouse_sink_1->handle_input(*motion_1); |
655 | + mouse_sink_2->handle_input(*motion_2); |
656 | + mouse_sink_1->handle_input(*motion_3); |
657 | + |
658 | +} |
Looks good other than L332