Mir

Merge lp:~andreas-pokorny/mir/add-option-to-disable-acceleration into lp:mir

Proposed by Andreas Pokorny
Status: Superseded
Proposed branch: lp:~andreas-pokorny/mir/add-option-to-disable-acceleration
Merge into: lp:mir
Diff against target: 459 lines (+124/-43)
12 files modified
examples/server_example_input_device_config.cpp (+31/-9)
examples/server_example_input_device_config.h (+2/-8)
include/client/mir_toolkit/mir_input_device.h (+7/-0)
include/platform/mir/input/pointer_settings.h (+4/-0)
include/server/mir/input/pointer_configuration.h (+10/-4)
src/platforms/evdev/libinput_device.cpp (+26/-9)
src/platforms/evdev/libinput_device.h (+1/-0)
src/server/input/default_device.cpp (+4/-2)
tests/include/mir/test/doubles/mock_libinput.h (+2/-0)
tests/mir_test_doubles/mock_libinput.cpp (+12/-0)
tests/mir_test_framework/fake_input_device_impl.cpp (+7/-4)
tests/unit-tests/input/evdev/test_libinput_device.cpp (+18/-7)
To merge this branch: bzr merge lp:~andreas-pokorny/mir/add-option-to-disable-acceleration
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Daniel van Vugt Needs Fixing
Review via email: mp+280523@code.launchpad.net

This proposal has been superseded by a proposal from 2015-12-15.

Commit message

add an option to disable pointer acceleration

This is a makeshift for unknown high dpi / high freq mice. This breaks input platform abi

Description of the change

This MP adds a configuration option to disable cursor acceleration for pointing devices. The option is used in a new program option in example servers - and there restricted to mice.

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3192
http://jenkins.qa.ubuntu.com/job/mir-ci/5847/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5309
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4215
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5258
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/157/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/175
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/175/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/175
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/175/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5258
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5258/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7778
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26049
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/155
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/155/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/14/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26052

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/5847/rebuild

review: Approve (continuous-integration)
Daniel van Vugt (vanvugt) wrote :

Thanks for putting the time into this. I suspect this is slightly the wrong approach though:

+ bool enable_cursor_acceleration{true};

would be better replaced by an enum that matches enum libinput_config_accel_profile:

http://wayland.freedesktop.org/libinput/doc/latest/libinput_8h.html#ad63796972347f318b180e322e35cee79

So we could set it as LIBINPUT_CONFIG_ACCEL_PROFILE_NONE (or FLAT or ADAPTIVE) instead of enable_cursor_acceleration=false.

review: Needs Fixing
Daniel van Vugt (vanvugt) wrote :

And therefore we would end up calling libinput_device_config_accel_set_profile:
http://wayland.freedesktop.org/libinput/doc/latest/group__config.html#ga6e72a6214840d76c8a43d3753c1d549d

Andreas Pokorny (andreas-pokorny) wrote :

Agreed. I guess that would turn that into a more permanent solution.

3193. By Andreas Pokorny on 2015-12-15

Add support for acceleration profiles.

Libinput offers different strategies to accelerate or not accelerate relative movement. This configuration is now exposed via PointerConfiguration.

3194. By Andreas Pokorny on 2015-12-17

review findings first round

3195. By Andreas Pokorny on 2015-12-17

also change example option naming

3196. By Andreas Pokorny on 2015-12-19

AccelerationProfile -> Acceleration

3197. By Andreas Pokorny on 2016-01-18

remove the none setting and instead document the usage of 'constant' acceleration

3198. By Andreas Pokorny on 2016-01-19

back to 80 chars in documentation.

3199. By Andreas Pokorny on 2016-01-19

Switch back to _none

3200. By Andreas Pokorny on 2016-01-19

merge mir

3201. By Andreas Pokorny on 2016-01-19

merge lp:mir

3202. By Andreas Pokorny on 2016-01-19

Fix documentation about acceleration settings and fake input devices

3203. By Andreas Pokorny on 2016-01-19

fix doxygen comment

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/server_example_input_device_config.cpp'
2--- examples/server_example_input_device_config.cpp 2015-12-06 23:57:03 +0000
3+++ examples/server_example_input_device_config.cpp 2015-12-15 13:25:30 +0000
4@@ -31,21 +31,27 @@
5
6 ///\example server_example_input_device_config.cpp
7 /// Demonstrate input device configuration
8-
9-char const* const me::disable_while_typing_opt = "disable-while-typing";
10-char const* const me::mouse_cursor_acceleration_bias_opt = "mouse-cursor-acceleration-bias";
11-char const* const me::mouse_scroll_speed_scale_opt = "mouse-scroll-speed-scale";
12-char const* const me::touchpad_cursor_acceleration_bias_opt = "touchpad-cursor-acceleration-bias";
13-char const* const me::touchpad_scroll_speed_scale_opt = "touchpad-scroll-speed-scale";
14-char const* const me::touchpad_scroll_mode_opt = "touchpad-scroll-mode";
15+namespace
16+{
17+char const* const disable_while_typing_opt = "disable-while-typing";
18+char const* const mouse_acceleration_profile_opt = "mouse-acceleration-profile";
19+char const* const acceleration_profile_none = "none";
20+char const* const acceleration_profile_flat = "flat";
21+char const* const acceleration_profile_adaptive = "adaptive";
22+char const* const mouse_cursor_acceleration_bias_opt = "mouse-cursor-acceleration-bias";
23+char const* const mouse_scroll_speed_scale_opt = "mouse-scroll-speed-scale";
24+char const* const touchpad_cursor_acceleration_bias_opt = "touchpad-cursor-acceleration-bias";
25+char const* const touchpad_scroll_speed_scale_opt = "touchpad-scroll-speed-scale";
26+char const* const touchpad_scroll_mode_opt = "touchpad-scroll-mode";
27
28 char const* const touchpad_scroll_mode_two_finger = "two-finger";
29 char const* const touchpad_scroll_mode_edge = "edge";
30
31-char const* const me::touchpad_click_mode_opt= "touchpad-click-mode";
32+char const* const touchpad_click_mode_opt= "touchpad-click-mode";
33
34 char const* const touchpad_click_mode_area = "area";
35 char const* const touchpad_click_mode_finger_count = "finger-count";
36+}
37
38 void me::add_input_device_configuration_options_to(mir::Server& server)
39 {
40@@ -53,6 +59,9 @@
41 server.add_configuration_option(disable_while_typing_opt,
42 "Disable touchpad while typing on keyboard configuration [true, false]",
43 false);
44+ server.add_configuration_option(mouse_acceleration_profile_opt,
45+ "Select acceleration profile for mice and trackballs [none, flat, adaptive]",
46+ acceleration_profile_adaptive);
47 server.add_configuration_option(mouse_cursor_acceleration_bias_opt,
48 "Bias to the acceleration curve within the range [-1.0, 1.0] for mice",
49 0.0);
50@@ -93,6 +102,15 @@
51 return mir_touchpad_scroll_mode_none;
52 };
53
54+ auto to_profile = [](std::string const& val)
55+ {
56+ if (val == acceleration_profile_flat)
57+ return mir_pointer_acceleration_profile_flat;
58+ if (val == acceleration_profile_none)
59+ return mir_pointer_acceleration_profile_none;
60+ return mir_pointer_acceleration_profile_adaptive;
61+ };
62+
63 auto convert_to_click_mode = [](std::string const& val)
64 {
65 if (val == touchpad_click_mode_finger_count)
66@@ -107,6 +125,7 @@
67 auto const options = server.get_options();
68 auto const input_config = std::make_shared<me::InputDeviceConfig>(
69 options->get<bool>(disable_while_typing_opt),
70+ to_profile(options->get<std::string>(mouse_acceleration_profile_opt)),
71 clamp_to_range(options->get<double>(mouse_cursor_acceleration_bias_opt)),
72 options->get<double>(mouse_scroll_speed_scale_opt),
73 clamp_to_range(options->get<double>(touchpad_cursor_acceleration_bias_opt)),
74@@ -122,13 +141,15 @@
75 /// Demonstrate how to implement an InputDeviceObserver that identifies and configures input devices.
76
77 me::InputDeviceConfig::InputDeviceConfig(bool disable_while_typing,
78+ MirPointerAccelerationProfile mouse_profile,
79 double mouse_cursor_acceleration_bias,
80 double mouse_scroll_speed_scale,
81 double touchpad_cursor_acceleration_bias,
82 double touchpad_scroll_speed_scale,
83 MirTouchpadClickModes click_mode,
84 MirTouchpadClickModes scroll_mode)
85- : disable_while_typing(disable_while_typing), mouse_cursor_acceleration_bias(mouse_cursor_acceleration_bias),
86+ : disable_while_typing(disable_while_typing), mouse_profile{mouse_profile},
87+ mouse_cursor_acceleration_bias(mouse_cursor_acceleration_bias),
88 mouse_scroll_speed_scale(mouse_scroll_speed_scale),
89 touchpad_cursor_acceleration_bias(touchpad_cursor_acceleration_bias),
90 touchpad_scroll_speed_scale(touchpad_scroll_speed_scale), click_mode(click_mode), scroll_mode(scroll_mode)
91@@ -154,6 +175,7 @@
92 else if (contains(device->capabilities(), mi::DeviceCapability::pointer))
93 {
94 mi::PointerConfiguration pointer_config( device->pointer_configuration().value() );
95+ pointer_config.acceleration_profile = mouse_profile;
96 pointer_config.cursor_acceleration_bias = mouse_cursor_acceleration_bias;
97 pointer_config.vertical_scroll_scale = mouse_scroll_speed_scale;
98 pointer_config.horizontal_scroll_scale = mouse_scroll_speed_scale;
99
100=== modified file 'examples/server_example_input_device_config.h'
101--- examples/server_example_input_device_config.h 2015-12-06 23:57:03 +0000
102+++ examples/server_example_input_device_config.h 2015-12-15 13:25:30 +0000
103@@ -33,20 +33,13 @@
104
105 namespace examples
106 {
107-extern char const* const disable_while_typing_opt;
108-extern char const* const mouse_cursor_acceleration_bias_opt;
109-extern char const* const mouse_scroll_speed_scale_opt;
110-extern char const* const touchpad_cursor_acceleration_bias_opt;
111-extern char const* const touchpad_scroll_speed_scale_opt;
112-extern char const* const touchpad_click_mode_opt;
113-extern char const* const touchpad_scroll_mode_opt;
114-
115 void add_input_device_configuration_options_to(Server& server);
116
117 class InputDeviceConfig : public mir::input::InputDeviceObserver
118 {
119 public:
120 InputDeviceConfig(bool disable_while_typing,
121+ MirPointerAccelerationProfile mouse_profile,
122 double mouse_cursor_acceleration_bias,
123 double mouse_scroll_speed_scale,
124 double touchpad_cursor_acceleration_bias,
125@@ -59,6 +52,7 @@
126 void changes_complete() override {}
127 private:
128 bool disable_while_typing;
129+ MirPointerAccelerationProfile mouse_profile;
130 double mouse_cursor_acceleration_bias;
131 double mouse_scroll_speed_scale;
132 double touchpad_cursor_acceleration_bias;
133
134=== modified file 'include/client/mir_toolkit/mir_input_device.h'
135--- include/client/mir_toolkit/mir_input_device.h 2015-10-26 03:33:22 +0000
136+++ include/client/mir_toolkit/mir_input_device.h 2015-12-15 13:25:30 +0000
137@@ -32,6 +32,13 @@
138 mir_pointer_handedness_left = 1
139 } MirPointerHandedness;
140
141+typedef enum MirPointerAccelerationProfile
142+{
143+ mir_pointer_acceleration_profile_none = 0,
144+ mir_pointer_acceleration_profile_flat = 1,
145+ mir_pointer_acceleration_profile_adaptive = 2
146+} MirPointerAccelerationProfile;
147+
148 typedef enum MirTouchpadClickMode
149 {
150 mir_touchpad_click_mode_none = 0,
151
152=== modified file 'include/platform/mir/input/pointer_settings.h'
153--- include/platform/mir/input/pointer_settings.h 2015-10-26 03:33:22 +0000
154+++ include/platform/mir/input/pointer_settings.h 2015-12-15 13:25:30 +0000
155@@ -43,6 +43,10 @@
156 */
157 double cursor_acceleration_bias{0.0};
158 /**
159+ * Acceleration profile
160+ */
161+ MirPointerAccelerationProfile acceleration_profile{mir_pointer_acceleration_profile_adaptive};
162+ /**
163 * Scale horizontal scrolling linearly
164 */
165 double horizontal_scroll_scale{1.0};
166
167=== modified file 'include/server/mir/input/pointer_configuration.h'
168--- include/server/mir/input/pointer_configuration.h 2015-11-04 16:30:42 +0000
169+++ include/server/mir/input/pointer_configuration.h 2015-12-15 13:25:30 +0000
170@@ -33,10 +33,11 @@
171 {
172 PointerConfiguration() {}
173
174- PointerConfiguration(MirPointerHandedness handedness, double acceleration_bias, double horizontal_scroll_scale,
175- double vertical_scroll_scale)
176- : handedness{handedness}, cursor_acceleration_bias{acceleration_bias},
177- horizontal_scroll_scale{horizontal_scroll_scale}, vertical_scroll_scale{vertical_scroll_scale}
178+ PointerConfiguration(MirPointerHandedness handedness, MirPointerAccelerationProfile acceleration_profile, double acceleration_bias,
179+ double horizontal_scroll_scale, double vertical_scroll_scale)
180+ : handedness{handedness}, acceleration_profile{acceleration_profile},
181+ cursor_acceleration_bias{acceleration_bias}, horizontal_scroll_scale{horizontal_scroll_scale},
182+ vertical_scroll_scale{vertical_scroll_scale}
183 {
184 }
185
186@@ -47,6 +48,11 @@
187 MirPointerHandedness handedness{mir_pointer_handedness_right};
188
189 /*!
190+ * Configure cursor acceleration profile
191+ */
192+ MirPointerAccelerationProfile acceleration_profile{mir_pointer_acceleration_profile_adaptive};
193+
194+ /*!
195 * Configures the intensity of the cursor acceleration. Values within the range of [-1, 1] are allowed.
196 * - 0: default acceleration
197 * - [-1, 0): reduced acceleration
198
199=== modified file 'src/platforms/evdev/libinput_device.cpp'
200--- src/platforms/evdev/libinput_device.cpp 2015-12-07 01:13:18 +0000
201+++ src/platforms/evdev/libinput_device.cpp 2015-12-15 13:25:30 +0000
202@@ -167,9 +167,8 @@
203
204 report->received_event_from_kernel(time.count(), EV_REL, 0, 0);
205
206- mir::geometry::Displacement const movement{
207- libinput_event_pointer_get_dx(pointer),
208- libinput_event_pointer_get_dy(pointer)};
209+ mir::geometry::Displacement const movement{libinput_event_pointer_get_dx(pointer),
210+ libinput_event_pointer_get_dy(pointer)};
211
212 return builder->pointer_event(time, action, button_state, hscroll_value, vscroll_value, movement.dx.as_float(),
213 movement.dy.as_float());
214@@ -336,15 +335,26 @@
215 if (!contains(info.capabilities, mi::DeviceCapability::pointer))
216 return {};
217
218- auto dev = device();
219- auto accel_bias = libinput_device_config_accel_get_speed(dev);
220- auto left_handed = (libinput_device_config_left_handed_get(dev) == 1);
221-
222 mi::PointerSettings settings;
223- settings.cursor_acceleration_bias = accel_bias;
224+ auto dev = device();
225+ auto const left_handed = (libinput_device_config_left_handed_get(dev) == 1);
226+ settings.handedness = left_handed? mir_pointer_handedness_left : mir_pointer_handedness_right;
227+ switch(libinput_device_config_accel_get_profile(dev))
228+ {
229+ case LIBINPUT_CONFIG_ACCEL_PROFILE_NONE:
230+ settings.acceleration_profile = mir_pointer_acceleration_profile_none;
231+ break;
232+ case LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT:
233+ settings.acceleration_profile = mir_pointer_acceleration_profile_flat;
234+ break;
235+ case LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE:
236+ settings.acceleration_profile = mir_pointer_acceleration_profile_adaptive;
237+ break;
238+ }
239+
240+ settings.cursor_acceleration_bias = libinput_device_config_accel_get_speed(dev);
241 settings.vertical_scroll_scale = vertical_scroll_scale;
242 settings.horizontal_scroll_scale = horizontal_scroll_scale;
243- settings.handedness = left_handed? mir_pointer_handedness_left : mir_pointer_handedness_right;
244 return settings;
245 }
246
247@@ -358,6 +368,13 @@
248 libinput_device_config_left_handed_set(dev, mir_pointer_handedness_left == settings.handedness);
249 vertical_scroll_scale = settings.vertical_scroll_scale;
250 horizontal_scroll_scale = settings.horizontal_scroll_scale;
251+ libinput_device_config_accel_set_profile(
252+ dev,
253+ (settings.acceleration_profile == mir_pointer_acceleration_profile_none) ?
254+ LIBINPUT_CONFIG_ACCEL_PROFILE_NONE :
255+ (settings.acceleration_profile == mir_pointer_acceleration_profile_flat) ?
256+ LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT :
257+ LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
258 }
259
260 mir::optional_value<mi::TouchpadSettings> mie::LibInputDevice::get_touchpad_settings() const
261
262=== modified file 'src/platforms/evdev/libinput_device.h'
263--- src/platforms/evdev/libinput_device.h 2015-11-30 16:34:46 +0000
264+++ src/platforms/evdev/libinput_device.h 2015-12-15 13:25:30 +0000
265@@ -88,6 +88,7 @@
266 InputDeviceInfo info;
267 mir::geometry::Point pointer_pos;
268 MirPointerButtons button_state;
269+ bool enable_cursor_acceleration{true};
270 double vertical_scroll_scale{1.0};
271 double horizontal_scroll_scale{1.0};
272
273
274=== modified file 'src/server/input/default_device.cpp'
275--- src/server/input/default_device.cpp 2015-11-04 19:47:19 +0000
276+++ src/server/input/default_device.cpp 2015-12-15 13:25:30 +0000
277@@ -62,8 +62,9 @@
278
279 auto const& settings = pointer.value();
280
281- return PointerConfiguration(settings.handedness, settings.cursor_acceleration_bias,
282- settings.horizontal_scroll_scale, settings.vertical_scroll_scale);
283+ return PointerConfiguration(settings.handedness, settings.acceleration_profile,
284+ settings.cursor_acceleration_bias, settings.horizontal_scroll_scale,
285+ settings.vertical_scroll_scale);
286 }
287
288 mir::optional_value<mi::TouchpadConfiguration> mi::DefaultDevice::touchpad_configuration() const
289@@ -88,6 +89,7 @@
290
291 PointerSettings settings;
292 settings.handedness = conf.handedness;
293+ settings.acceleration_profile = conf.acceleration_profile;
294 settings.cursor_acceleration_bias = conf.cursor_acceleration_bias;
295 settings.vertical_scroll_scale = conf.vertical_scroll_scale;
296 settings.horizontal_scroll_scale = conf.horizontal_scroll_scale;
297
298=== modified file 'tests/include/mir/test/doubles/mock_libinput.h'
299--- tests/include/mir/test/doubles/mock_libinput.h 2015-12-07 01:13:18 +0000
300+++ tests/include/mir/test/doubles/mock_libinput.h 2015-12-15 13:25:30 +0000
301@@ -121,6 +121,8 @@
302 MOCK_METHOD2(libinput_device_config_accel_set_speed, libinput_config_status(libinput_device*, double speed));
303 MOCK_METHOD1(libinput_device_config_accel_get_speed, double(libinput_device*));
304 MOCK_METHOD1(libinput_device_config_accel_get_default_speed, double(libinput_device*));
305+ MOCK_METHOD2(libinput_device_config_accel_set_profile, libinput_config_status(libinput_device*, libinput_config_accel_profile));
306+ MOCK_METHOD1(libinput_device_config_accel_get_profile, libinput_config_accel_profile(libinput_device*));
307 MOCK_METHOD1(libinput_device_config_scroll_has_natural_scroll, int(libinput_device*));
308 MOCK_METHOD2(libinput_device_config_scroll_set_natural_scroll_enabled, libinput_config_status(libinput_device*, int enable));
309 MOCK_METHOD1(libinput_device_config_scroll_get_natural_scroll_enabled, int(libinput_device*));
310
311=== modified file 'tests/mir_test_doubles/mock_libinput.cpp'
312--- tests/mir_test_doubles/mock_libinput.cpp 2015-12-07 01:13:18 +0000
313+++ tests/mir_test_doubles/mock_libinput.cpp 2015-12-15 13:25:30 +0000
314@@ -51,6 +51,8 @@
315 .WillByDefault(Return(LIBINPUT_CONFIG_STATUS_SUCCESS));
316 ON_CALL(*this, libinput_device_config_middle_emulation_set_enabled(_, _))
317 .WillByDefault(Return(LIBINPUT_CONFIG_STATUS_SUCCESS));
318+ ON_CALL(*this, libinput_device_config_accel_set_profile(_, _))
319+ .WillByDefault(Return(LIBINPUT_CONFIG_STATUS_SUCCESS));
320 }
321
322 void mtd::MockLibInput::wake()
323@@ -458,6 +460,16 @@
324 return global_libinput->libinput_device_config_accel_get_default_speed(device);
325 }
326
327+libinput_config_status libinput_device_config_accel_set_profile(libinput_device* dev, libinput_config_accel_profile profile)
328+{
329+ return global_libinput->libinput_device_config_accel_set_profile(dev, profile);
330+}
331+
332+libinput_config_accel_profile libinput_device_config_accel_get_profile(libinput_device* dev)
333+{
334+ return global_libinput->libinput_device_config_accel_get_profile(dev);
335+}
336+
337 int libinput_device_config_scroll_has_natural_scroll(libinput_device *device)
338 {
339 return global_libinput->libinput_device_config_scroll_has_natural_scroll(device);
340
341=== modified file 'tests/mir_test_framework/fake_input_device_impl.cpp'
342--- tests/mir_test_framework/fake_input_device_impl.cpp 2015-11-25 20:26:59 +0000
343+++ tests/mir_test_framework/fake_input_device_impl.cpp 2015-12-15 13:25:30 +0000
344@@ -90,6 +90,7 @@
345 std::shared_ptr<mir::dispatch::Dispatchable> const& dispatchable)
346 : info(info), queue{dispatchable}, buttons{0}
347 {
348+ settings.acceleration_profile = mir_pointer_acceleration_profile_none;
349 }
350
351 void mtf::FakeInputDeviceImpl::InputDevice::synthesize_events(synthesis::KeyParameters const& key_params)
352@@ -151,9 +152,11 @@
353 // constant scaling is used here to simplify checking for the
354 // expected results. Default settings of the device lead to no
355 // scaling at all.
356- auto acceleration = (settings.cursor_acceleration_bias + 1.0);
357- auto rel_x = pointer.rel_x * acceleration;
358- auto rel_y = pointer.rel_y * acceleration;
359+ auto const acceleration = settings.acceleration_profile == mir_pointer_acceleration_profile_flat ?
360+ (settings.cursor_acceleration_bias + 1.0) :
361+ 1.0;
362+ auto const rel_x = pointer.rel_x * acceleration;
363+ auto const rel_y = pointer.rel_y * acceleration;
364
365 auto pointer_event = builder->pointer_event(event_time,
366 mir_pointer_action_motion,
367@@ -213,7 +216,7 @@
368 if (!contains(info.capabilities, mi::DeviceCapability::pointer))
369 return ret;
370
371- ret = mi::PointerSettings();
372+ ret = settings;
373 return ret;
374 }
375
376
377=== modified file 'tests/unit-tests/input/evdev/test_libinput_device.cpp'
378--- tests/unit-tests/input/evdev/test_libinput_device.cpp 2015-12-07 01:13:18 +0000
379+++ tests/unit-tests/input/evdev/test_libinput_device.cpp 2015-12-15 13:25:30 +0000
380@@ -208,12 +208,18 @@
381 return device_path;
382 }
383
384- void setup_pointer_configuration(libinput_device* dev, double accel_speed, MirPointerHandedness handedness)
385+ void setup_pointer_configuration(libinput_device* dev, double accel_speed, MirPointerHandedness handedness, MirPointerAccelerationProfile profile)
386 {
387 ON_CALL(mock_libinput, libinput_device_config_accel_get_speed(dev))
388 .WillByDefault(Return(accel_speed));
389 ON_CALL(mock_libinput, libinput_device_config_left_handed_get(dev))
390 .WillByDefault(Return(handedness == mir_pointer_handedness_left));
391+ ON_CALL(mock_libinput, libinput_device_config_accel_get_profile(dev))
392+ .WillByDefault(Return((profile == mir_pointer_acceleration_profile_flat) ?
393+ LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT :
394+ (profile == mir_pointer_acceleration_profile_none) ?
395+ LIBINPUT_CONFIG_ACCEL_PROFILE_NONE :
396+ LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE));
397 }
398
399 void setup_touchpad_configuration(libinput_device* dev,
400@@ -779,7 +785,7 @@
401
402 TEST_F(LibInputDeviceOnMouse, reads_pointer_settings_from_libinput)
403 {
404- setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right);
405+ setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right, mir_pointer_acceleration_profile_flat);
406 auto optional_settings = mouse.get_pointer_settings();
407
408 EXPECT_THAT(optional_settings.is_set(), Eq(true));
409@@ -789,8 +795,9 @@
410 EXPECT_THAT(ptr_settings.cursor_acceleration_bias, Eq(1.0));
411 EXPECT_THAT(ptr_settings.horizontal_scroll_scale, Eq(1.0));
412 EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0));
413+ EXPECT_THAT(ptr_settings.acceleration_profile, Eq(mir_pointer_acceleration_profile_flat));
414
415- setup_pointer_configuration(mouse.device(), 0.0, mir_pointer_handedness_left);
416+ setup_pointer_configuration(mouse.device(), 0.0, mir_pointer_handedness_left, mir_pointer_acceleration_profile_adaptive);
417 optional_settings = mouse.get_pointer_settings();
418
419 EXPECT_THAT(optional_settings.is_set(), Eq(true));
420@@ -800,23 +807,27 @@
421 EXPECT_THAT(ptr_settings.cursor_acceleration_bias, Eq(0.0));
422 EXPECT_THAT(ptr_settings.horizontal_scroll_scale, Eq(1.0));
423 EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0));
424+ EXPECT_THAT(ptr_settings.acceleration_profile, Eq(mir_pointer_acceleration_profile_adaptive));
425 }
426
427 TEST_F(LibInputDeviceOnMouse, applies_pointer_settings)
428 {
429- setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right);
430+ setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right, mir_pointer_acceleration_profile_none);
431 mi::PointerSettings settings(mouse.get_pointer_settings().value());
432 settings.cursor_acceleration_bias = 1.1;
433 settings.handedness = mir_pointer_handedness_left;
434+ settings.acceleration_profile = mir_pointer_acceleration_profile_flat;
435
436- EXPECT_CALL(mock_libinput,libinput_device_config_accel_set_speed(mouse.device(), 1.1)).Times(1);
437- EXPECT_CALL(mock_libinput,libinput_device_config_left_handed_set(mouse.device(), true)).Times(1);
438+ EXPECT_CALL(mock_libinput, libinput_device_config_accel_set_speed(mouse.device(), 1.1)).Times(1);
439+ EXPECT_CALL(mock_libinput, libinput_device_config_accel_set_profile(mouse.device(), LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT)).Times(1);
440+ EXPECT_CALL(mock_libinput, libinput_device_config_left_handed_set(mouse.device(), true)).Times(1);
441
442 mouse.apply_settings(settings);
443 }
444
445 TEST_F(LibInputDeviceOnLaptopKeyboardAndMouse, denies_pointer_settings_on_keyboards)
446 {
447+ setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right, mir_pointer_acceleration_profile_none);
448 auto settings_from_mouse = mouse.get_pointer_settings();
449
450 EXPECT_CALL(mock_libinput,libinput_device_config_accel_set_speed(_, _)).Times(0);
451@@ -834,7 +845,7 @@
452 EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, 3.0f)));
453 EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_hscroll, -10.0f)));
454
455- setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right);
456+ setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right, mir_pointer_acceleration_profile_flat);
457 mi::PointerSettings settings(mouse.get_pointer_settings().value());
458 settings.vertical_scroll_scale = -1.0;
459 settings.horizontal_scroll_scale = 5.0;

Subscribers

People subscribed via source and target branches