Mir

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

Proposed by Andreas Pokorny
Status: Merged
Approved by: Daniel van Vugt
Approved revision: 3203
Merged at revision: 3256
Proposed branch: lp:~andreas-pokorny/mir/add-option-to-disable-acceleration
Merge into: lp:mir
Prerequisite: lp:~andreas-pokorny/mir/bump-platform-to-5
Diff against target: 454 lines (+118/-45)
11 files modified
examples/server_example_input_device_config.cpp (+30/-11)
examples/server_example_input_device_config.h (+2/-8)
include/client/mir_toolkit/mir_input_device.h (+15/-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 (+16/-9)
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 (+16/-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 Approve
Daniel van Vugt Approve
Mir CI Bot continuous-integration Approve
Kevin DuBois (community) Approve
Review via email: mp+280593@code.launchpad.net

This proposal supersedes a proposal from 2015-12-14.

Commit message

add an option to select pointer acceleration profile

Allow the selection of one out of three porfiles: diabled, flat, adaptive. The last one is adaptive to the poimter movement, and our previous default behavior.

Description of the change

This MP adds a configuration option to select the cursor acceleration profile for pointing devices. Libinput offers three profiles including one that disables acceleration. Flat and disabled are now also simulated by the fake input devices.

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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

Andreas Pokorny (andreas-pokorny) wrote :

^ needs a newer libinput.. will land with 0.18...

Daniel van Vugt (vanvugt) wrote :

Looking good except:

(1) Dead code needs removing: bool enable_cursor_acceleration{true};

(2) I wonder if we can use more concise and accurate naming than libinput does?...

  MirPointerAccelerationProfile --> MirPointerAcceleration
  mir_pointer_acceleration_profile_none --> mir_pointer_acceleration_none
  mir_pointer_acceleration_profile_flat --> mir_pointer_acceleration_constant (is that accurate?)
  mir_pointer_acceleration_profile_adaptive --> mir_pointer_acceleration_adaptive

review: Needs Fixing
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

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Daniel van Vugt (vanvugt) wrote :

"acceleration" is already a noun so we don't need to call it "acceleration_profile". Drop the "profile" methinks.

Asking people to remember how to spell acceleration is bad enough without adding extra words :)

Andreas Pokorny (andreas-pokorny) wrote :

@duflu: in both the enum and commandline option?

Andreas Pokorny (andreas-pokorny) wrote :

I think in both cases we could leave the profile out..

3196. By Andreas Pokorny on 2015-12-19

AccelerationProfile -> Acceleration

PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3196
http://jenkins.qa.ubuntu.com/job/mir-ci/5900/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5389
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4296
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5342
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/218
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/226
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/226/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/226
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/226/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5339
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5339/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7847
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26275
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/214
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/214/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/71
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26276

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

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

Oh, we need to check and verify that the libinput API is not misusing the word "acceleration" like others do. If they are using the word acceleration accurately, then curiously there is no option to change the pointer speed without also accelerating.

We need to check the libinput source and make sure their terminology is correct before we do the same.

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

Looking at the libinput code and docs, it gives conflicting answers as to what "flat acceleration" means. In the code it kind of looks like "flat acceleration" means "zero acceleration with constant velocity multiplier".

Please check my findings but I think this means LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT is incorrectly named and perhaps in most profiles there is zero acceleration in the physical sense. So more accurate names would be:

  MirPointerAcceleration -> MirPointerSpeed
  mir_pointer_acceleration_none -> mir_pointer_speed_native
  mir_pointer_acceleration_constant -> mir_pointer_speed_constant (with bias 0 same as native?)
  mir_pointer_acceleration_adaptive -> mir_pointer_speed_accelerated

Sorry to be pedantic, but it's libinput that has apparently confused the physics terminology. We should try not to copy their mistakes, if they are mistakes...

review: Needs Fixing
Andreas Pokorny (andreas-pokorny) wrote :

profile flat means that the way the relative movement is interpreted is 'constant' - independent of the current velocity of mouse - or better independent of the most recent measured pointer deltas.

So hmm I think speed_native is ok-ish but mir_pointer_speed_constant seems wrong - since the speed of the cursor will not be constant in that case. And since we used the term acceleration in the other enumeration already I would rather stay in that level of derivative. Or we change both... but what is going on is harder to describe in velocity terms.

Daniel van Vugt (vanvugt) wrote :

Looking at the libinput source, I *think* LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT means a constant multiple (which is configurable) of the velocity of the mouse. So constant multiple of velocity means acceleration introduced by the input stack is always exactly zero. As such, I think it's misleading to call that "acceleration_constant". It's actually a constant speed (when moving at all) with an acceleration of precisely zero, I think.

I'd be inclined to fix up the terminology for Mir rather than copy the common misnomer. But I'd also like more people to review the libinput source and check my assertion is correct.

Andreas Pokorny (andreas-pokorny) wrote :

Ok I see your point. Still speed_constant seems not right. From the users perspective the setting will change the velocity of the movement. So the user will observe an acceleration.

Daniel van Vugt (vanvugt) wrote :

Yes, the user will always observe instantaneous acceleration when velocity changes from zero to non-zero. However pointer acceleration is not about that first event, it's about the second and subsequent events. In the second and subsequent motion events your acceleration is precisely zero if your velocity is constant/flat. So a constant velocity or flat mode should not have "acceleration" in its name.

That all said, a constant velocity multiplier of anything other that one is arguably useless. Less than one and a lot of code will never move the cursor. More than one and you lose pixel accuracy on screen. I guess that's why the libinput code limits the multiplier for flat mode to 2.

Daniel van Vugt (vanvugt) wrote :

(1) Naming needs clarification per above.

Manual testing results:

(2) Surprisingly --mouse-acceleration=none does not fix bug 1528109 but --mouse-acceleration=constant does. Have we misinterpreted the "none" mode? Should it be removed in favour of constant mode with no bias?

(3) The --mouse-acceleration option is missing from some servers (mir_proving_server) so still not helpful to me. I guess it or something like it needs to be promoted up into libmirserver default config at some point.

Andreas Pokorny (andreas-pokorny) wrote :

> (1) Naming needs clarification per above.
>
> Manual testing results:
>
> (2) Surprisingly --mouse-acceleration=none does not fix bug 1528109 but
> --mouse-acceleration=constant does. Have we misinterpreted the "none" mode?
> Should it be removed in favour of constant mode with no bias?

ok will investigate that..

>
> (3) The --mouse-acceleration option is missing from some servers
> (mir_proving_server) so still not helpful to me. I guess it or something like
> it needs to be promoted up into libmirserver default config at some point.

Yeah we should do that. Hmm it would be nicer if we could make the configuration device specific.. The current unique ids are not good enough for that.. thats another story that needs fixing..

Kevin DuBois (kdub) wrote :

+ settings.handedness = left_handed? mir_pointer_handedness_left : mir_pointer_handedness_right;
nit: spacing

lgtm, pending fixing the issues Daniel brought up

Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3196
https://mir-jenkins.ubuntu.com/job/mir-ci/17/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/17/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/17/rebuild

review: Approve (continuous-integration)
Kevin DuBois (kdub) wrote :

> lgtm, pending fixing the issues Daniel brought up
suppose I'll "pre-approve"

review: Approve
Andreas Pokorny (andreas-pokorny) wrote :

Yes this is a bug in libinput. It does not handle the NONE case yet so it falls through to either adaptive high-dpi or low-dpi acceleration.

Andreas Pokorny (andreas-pokorny) wrote :

So it seems none was only intended to indicate that there is no acceleraton filter available. We could remap our enum value to flat and 'speed' zero, or document how to acchieve an unaccelerated setting. I would prefer the second option since it would avoid mapping errors when the current status is read back, and we have to interpret a float value.

3197. By Andreas Pokorny on 2016-01-18

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

Daniel van Vugt (vanvugt) wrote :

(1) constant mode means zero acceleration, so the enum should not have "acceleration" in its name. I'm just trying to be physically accurate. I think we need to either remove the word "acceleration" from the enum or rename "mir_pointer_acceleration_constant" to "mir_pointer_acceleration_none".

(2) Nit: Please try to keep code within 80 columns.

(3) Nit: Unwanted blank line and s/separates/separated/

154 + * function based on the current velocity that usually consists of a two linear
155 + *
156 + * inclines separates by a plateau.

review: Needs Fixing
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

Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3202
https://mir-jenkins.ubuntu.com/job/mir-ci/80/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/80/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/80/rebuild

review: Needs Fixing (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3202
http://jenkins.qa.ubuntu.com/job/mir-ci/6054/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5585
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4492
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5541
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/296
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/378
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/378/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/378
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/378/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5538
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5538/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7998
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26783
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/292
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/292/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/148
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26788

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

review: Approve (continuous-integration)
3203. By Andreas Pokorny on 2016-01-19

fix doxygen comment

Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3203
https://mir-jenkins.ubuntu.com/job/mir-ci/94/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/94/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/94/rebuild

review: Approve (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3203
http://jenkins.qa.ubuntu.com/job/mir-ci/6067/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5600
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4507
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5556
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/304
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/391
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/391/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/391
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/391/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5553
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5553/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8008
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26810
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/300
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/300/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/156
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26813

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

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

Works nicely now: mir_demo_server --vt 1 --mouse-acceleration=none

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/server_example_input_device_config.cpp'
--- examples/server_example_input_device_config.cpp 2015-12-06 23:57:03 +0000
+++ examples/server_example_input_device_config.cpp 2016-01-19 22:31:46 +0000
@@ -31,21 +31,26 @@
3131
32///\example server_example_input_device_config.cpp32///\example server_example_input_device_config.cpp
33/// Demonstrate input device configuration33/// Demonstrate input device configuration
3434namespace
35char const* const me::disable_while_typing_opt = "disable-while-typing";35{
36char const* const me::mouse_cursor_acceleration_bias_opt = "mouse-cursor-acceleration-bias";36char const* const disable_while_typing_opt = "disable-while-typing";
37char const* const me::mouse_scroll_speed_scale_opt = "mouse-scroll-speed-scale";37char const* const mouse_acceleration_opt = "mouse-acceleration";
38char const* const me::touchpad_cursor_acceleration_bias_opt = "touchpad-cursor-acceleration-bias";38char const* const acceleration_none = "none";
39char const* const me::touchpad_scroll_speed_scale_opt = "touchpad-scroll-speed-scale";39char const* const acceleration_adaptive = "adaptive";
40char const* const me::touchpad_scroll_mode_opt = "touchpad-scroll-mode";40char const* const mouse_cursor_acceleration_bias_opt = "mouse-cursor-acceleration-bias";
41char const* const mouse_scroll_speed_scale_opt = "mouse-scroll-speed-scale";
42char const* const touchpad_cursor_acceleration_bias_opt = "touchpad-cursor-acceleration-bias";
43char const* const touchpad_scroll_speed_scale_opt = "touchpad-scroll-speed-scale";
44char const* const touchpad_scroll_mode_opt = "touchpad-scroll-mode";
4145
42char const* const touchpad_scroll_mode_two_finger = "two-finger";46char const* const touchpad_scroll_mode_two_finger = "two-finger";
43char const* const touchpad_scroll_mode_edge = "edge";47char const* const touchpad_scroll_mode_edge = "edge";
4448
45char const* const me::touchpad_click_mode_opt= "touchpad-click-mode";49char const* const touchpad_click_mode_opt= "touchpad-click-mode";
4650
47char const* const touchpad_click_mode_area = "area";51char const* const touchpad_click_mode_area = "area";
48char const* const touchpad_click_mode_finger_count = "finger-count";52char const* const touchpad_click_mode_finger_count = "finger-count";
53}
4954
50void me::add_input_device_configuration_options_to(mir::Server& server)55void me::add_input_device_configuration_options_to(mir::Server& server)
51{56{
@@ -53,14 +58,17 @@
53 server.add_configuration_option(disable_while_typing_opt,58 server.add_configuration_option(disable_while_typing_opt,
54 "Disable touchpad while typing on keyboard configuration [true, false]",59 "Disable touchpad while typing on keyboard configuration [true, false]",
55 false);60 false);
61 server.add_configuration_option(mouse_acceleration_opt,
62 "Select acceleration profile for mice and trackballs [none, adaptive]",
63 acceleration_adaptive);
56 server.add_configuration_option(mouse_cursor_acceleration_bias_opt,64 server.add_configuration_option(mouse_cursor_acceleration_bias_opt,
57 "Bias to the acceleration curve within the range [-1.0, 1.0] for mice",65 "Constant factor (+1) to velocity or bias to the acceleration curve within the range [-1.0, 1.0] for mice",
58 0.0);66 0.0);
59 server.add_configuration_option(mouse_scroll_speed_scale_opt,67 server.add_configuration_option(mouse_scroll_speed_scale_opt,
60 "Scales mice scroll events, use negative values for natural scrolling",68 "Scales mice scroll events, use negative values for natural scrolling",
61 1.0);69 1.0);
62 server.add_configuration_option(touchpad_cursor_acceleration_bias_opt,70 server.add_configuration_option(touchpad_cursor_acceleration_bias_opt,
63 "Bias to the acceleration curve within the range [-1.0, 1.0] for touchpads",71 "Constant factor (+1) to velocity or bias to the acceleration curve within the range [-1.0, 1.0] for touchpads",
64 0.0);72 0.0);
65 server.add_configuration_option(touchpad_scroll_speed_scale_opt,73 server.add_configuration_option(touchpad_scroll_speed_scale_opt,
66 "Scales touchpad scroll events, use negative values for natural scrolling",74 "Scales touchpad scroll events, use negative values for natural scrolling",
@@ -93,6 +101,13 @@
93 return mir_touchpad_scroll_mode_none;101 return mir_touchpad_scroll_mode_none;
94 };102 };
95103
104 auto to_profile = [](std::string const& val)
105 {
106 if (val == acceleration_none)
107 return mir_pointer_acceleration_none;
108 return mir_pointer_acceleration_adaptive;
109 };
110
96 auto convert_to_click_mode = [](std::string const& val)111 auto convert_to_click_mode = [](std::string const& val)
97 {112 {
98 if (val == touchpad_click_mode_finger_count)113 if (val == touchpad_click_mode_finger_count)
@@ -107,6 +122,7 @@
107 auto const options = server.get_options();122 auto const options = server.get_options();
108 auto const input_config = std::make_shared<me::InputDeviceConfig>(123 auto const input_config = std::make_shared<me::InputDeviceConfig>(
109 options->get<bool>(disable_while_typing_opt),124 options->get<bool>(disable_while_typing_opt),
125 to_profile(options->get<std::string>(mouse_acceleration_opt)),
110 clamp_to_range(options->get<double>(mouse_cursor_acceleration_bias_opt)),126 clamp_to_range(options->get<double>(mouse_cursor_acceleration_bias_opt)),
111 options->get<double>(mouse_scroll_speed_scale_opt),127 options->get<double>(mouse_scroll_speed_scale_opt),
112 clamp_to_range(options->get<double>(touchpad_cursor_acceleration_bias_opt)),128 clamp_to_range(options->get<double>(touchpad_cursor_acceleration_bias_opt)),
@@ -122,13 +138,15 @@
122/// Demonstrate how to implement an InputDeviceObserver that identifies and configures input devices.138/// Demonstrate how to implement an InputDeviceObserver that identifies and configures input devices.
123139
124me::InputDeviceConfig::InputDeviceConfig(bool disable_while_typing,140me::InputDeviceConfig::InputDeviceConfig(bool disable_while_typing,
141 MirPointerAcceleration mouse_profile,
125 double mouse_cursor_acceleration_bias,142 double mouse_cursor_acceleration_bias,
126 double mouse_scroll_speed_scale,143 double mouse_scroll_speed_scale,
127 double touchpad_cursor_acceleration_bias,144 double touchpad_cursor_acceleration_bias,
128 double touchpad_scroll_speed_scale,145 double touchpad_scroll_speed_scale,
129 MirTouchpadClickModes click_mode,146 MirTouchpadClickModes click_mode,
130 MirTouchpadClickModes scroll_mode)147 MirTouchpadClickModes scroll_mode)
131 : disable_while_typing(disable_while_typing), mouse_cursor_acceleration_bias(mouse_cursor_acceleration_bias),148 : disable_while_typing(disable_while_typing), mouse_profile{mouse_profile},
149 mouse_cursor_acceleration_bias(mouse_cursor_acceleration_bias),
132 mouse_scroll_speed_scale(mouse_scroll_speed_scale),150 mouse_scroll_speed_scale(mouse_scroll_speed_scale),
133 touchpad_cursor_acceleration_bias(touchpad_cursor_acceleration_bias),151 touchpad_cursor_acceleration_bias(touchpad_cursor_acceleration_bias),
134 touchpad_scroll_speed_scale(touchpad_scroll_speed_scale), click_mode(click_mode), scroll_mode(scroll_mode)152 touchpad_scroll_speed_scale(touchpad_scroll_speed_scale), click_mode(click_mode), scroll_mode(scroll_mode)
@@ -154,6 +172,7 @@
154 else if (contains(device->capabilities(), mi::DeviceCapability::pointer))172 else if (contains(device->capabilities(), mi::DeviceCapability::pointer))
155 {173 {
156 mi::PointerConfiguration pointer_config( device->pointer_configuration().value() );174 mi::PointerConfiguration pointer_config( device->pointer_configuration().value() );
175 pointer_config.acceleration = mouse_profile;
157 pointer_config.cursor_acceleration_bias = mouse_cursor_acceleration_bias;176 pointer_config.cursor_acceleration_bias = mouse_cursor_acceleration_bias;
158 pointer_config.vertical_scroll_scale = mouse_scroll_speed_scale;177 pointer_config.vertical_scroll_scale = mouse_scroll_speed_scale;
159 pointer_config.horizontal_scroll_scale = mouse_scroll_speed_scale;178 pointer_config.horizontal_scroll_scale = mouse_scroll_speed_scale;
160179
=== modified file 'examples/server_example_input_device_config.h'
--- examples/server_example_input_device_config.h 2015-12-06 23:57:03 +0000
+++ examples/server_example_input_device_config.h 2016-01-19 22:31:46 +0000
@@ -33,20 +33,13 @@
3333
34namespace examples34namespace examples
35{35{
36extern char const* const disable_while_typing_opt;
37extern char const* const mouse_cursor_acceleration_bias_opt;
38extern char const* const mouse_scroll_speed_scale_opt;
39extern char const* const touchpad_cursor_acceleration_bias_opt;
40extern char const* const touchpad_scroll_speed_scale_opt;
41extern char const* const touchpad_click_mode_opt;
42extern char const* const touchpad_scroll_mode_opt;
43
44void add_input_device_configuration_options_to(Server& server);36void add_input_device_configuration_options_to(Server& server);
4537
46class InputDeviceConfig : public mir::input::InputDeviceObserver38class InputDeviceConfig : public mir::input::InputDeviceObserver
47{39{
48public:40public:
49 InputDeviceConfig(bool disable_while_typing,41 InputDeviceConfig(bool disable_while_typing,
42 MirPointerAcceleration mouse_profile,
50 double mouse_cursor_acceleration_bias,43 double mouse_cursor_acceleration_bias,
51 double mouse_scroll_speed_scale,44 double mouse_scroll_speed_scale,
52 double touchpad_cursor_acceleration_bias,45 double touchpad_cursor_acceleration_bias,
@@ -59,6 +52,7 @@
59 void changes_complete() override {}52 void changes_complete() override {}
60private:53private:
61 bool disable_while_typing;54 bool disable_while_typing;
55 MirPointerAcceleration mouse_profile;
62 double mouse_cursor_acceleration_bias;56 double mouse_cursor_acceleration_bias;
63 double mouse_scroll_speed_scale;57 double mouse_scroll_speed_scale;
64 double touchpad_cursor_acceleration_bias;58 double touchpad_cursor_acceleration_bias;
6559
=== modified file 'include/client/mir_toolkit/mir_input_device.h'
--- include/client/mir_toolkit/mir_input_device.h 2015-10-26 03:33:22 +0000
+++ include/client/mir_toolkit/mir_input_device.h 2016-01-19 22:31:46 +0000
@@ -32,6 +32,21 @@
32 mir_pointer_handedness_left = 132 mir_pointer_handedness_left = 1
33} MirPointerHandedness;33} MirPointerHandedness;
3434
35/**
36 * MirPointerAcceleration describes the way pointer movement is filtered:
37 * - mir_pointer_acceleration_none: (acceleration bias + 1.0) is applied as
38 * a factor to the current velocity of the pointer. So a bias of 0 to results
39 * to no change of velocity.
40 * - mir_pointer_acceleration_adaptive: acceleration bias selects an
41 * acceleration function based on the current velocity that usually consists
42 * of two linear inclines separated by a plateau.
43 */
44typedef enum MirPointerAcceleration
45{
46 mir_pointer_acceleration_none = 1,
47 mir_pointer_acceleration_adaptive = 2
48} MirPointerAcceleration;
49
35typedef enum MirTouchpadClickMode50typedef enum MirTouchpadClickMode
36{51{
37 mir_touchpad_click_mode_none = 0,52 mir_touchpad_click_mode_none = 0,
3853
=== modified file 'include/platform/mir/input/pointer_settings.h'
--- include/platform/mir/input/pointer_settings.h 2015-10-26 03:33:22 +0000
+++ include/platform/mir/input/pointer_settings.h 2016-01-19 22:31:46 +0000
@@ -43,6 +43,10 @@
43 */43 */
44 double cursor_acceleration_bias{0.0};44 double cursor_acceleration_bias{0.0};
45 /**45 /**
46 * Acceleration profile
47 */
48 MirPointerAcceleration acceleration{mir_pointer_acceleration_adaptive};
49 /**
46 * Scale horizontal scrolling linearly50 * Scale horizontal scrolling linearly
47 */51 */
48 double horizontal_scroll_scale{1.0};52 double horizontal_scroll_scale{1.0};
4953
=== modified file 'include/server/mir/input/pointer_configuration.h'
--- include/server/mir/input/pointer_configuration.h 2015-11-04 16:30:42 +0000
+++ include/server/mir/input/pointer_configuration.h 2016-01-19 22:31:46 +0000
@@ -33,10 +33,11 @@
33{33{
34 PointerConfiguration() {}34 PointerConfiguration() {}
3535
36 PointerConfiguration(MirPointerHandedness handedness, double acceleration_bias, double horizontal_scroll_scale,36 PointerConfiguration(MirPointerHandedness handedness, MirPointerAcceleration acceleration, double acceleration_bias,
37 double vertical_scroll_scale)37 double horizontal_scroll_scale, double vertical_scroll_scale)
38 : handedness{handedness}, cursor_acceleration_bias{acceleration_bias},38 : handedness{handedness}, acceleration{acceleration},
39 horizontal_scroll_scale{horizontal_scroll_scale}, vertical_scroll_scale{vertical_scroll_scale}39 cursor_acceleration_bias{acceleration_bias}, horizontal_scroll_scale{horizontal_scroll_scale},
40 vertical_scroll_scale{vertical_scroll_scale}
40 {41 {
41 }42 }
4243
@@ -47,6 +48,11 @@
47 MirPointerHandedness handedness{mir_pointer_handedness_right};48 MirPointerHandedness handedness{mir_pointer_handedness_right};
4849
49 /*!50 /*!
51 * Configure cursor acceleration profile
52 */
53 MirPointerAcceleration acceleration{mir_pointer_acceleration_adaptive};
54
55 /*!
50 * Configures the intensity of the cursor acceleration. Values within the range of [-1, 1] are allowed.56 * Configures the intensity of the cursor acceleration. Values within the range of [-1, 1] are allowed.
51 * - 0: default acceleration57 * - 0: default acceleration
52 * - [-1, 0): reduced acceleration58 * - [-1, 0): reduced acceleration
5359
=== modified file 'src/platforms/evdev/libinput_device.cpp'
--- src/platforms/evdev/libinput_device.cpp 2016-01-07 11:55:03 +0000
+++ src/platforms/evdev/libinput_device.cpp 2016-01-19 22:31:46 +0000
@@ -167,9 +167,8 @@
167167
168 report->received_event_from_kernel(time.count(), EV_REL, 0, 0);168 report->received_event_from_kernel(time.count(), EV_REL, 0, 0);
169169
170 mir::geometry::Displacement const movement{170 mir::geometry::Displacement const movement{libinput_event_pointer_get_dx(pointer),
171 libinput_event_pointer_get_dx(pointer),171 libinput_event_pointer_get_dy(pointer)};
172 libinput_event_pointer_get_dy(pointer)};
173172
174 return builder->pointer_event(time, action, button_state, hscroll_value, vscroll_value, movement.dx.as_float(),173 return builder->pointer_event(time, action, button_state, hscroll_value, vscroll_value, movement.dx.as_float(),
175 movement.dy.as_float());174 movement.dy.as_float());
@@ -336,15 +335,18 @@
336 if (!contains(info.capabilities, mi::DeviceCapability::pointer))335 if (!contains(info.capabilities, mi::DeviceCapability::pointer))
337 return {};336 return {};
338337
339 auto dev = device();
340 auto accel_bias = libinput_device_config_accel_get_speed(dev);
341 auto left_handed = (libinput_device_config_left_handed_get(dev) == 1);
342
343 mi::PointerSettings settings;338 mi::PointerSettings settings;
344 settings.cursor_acceleration_bias = accel_bias;339 auto dev = device();
340 auto const left_handed = (libinput_device_config_left_handed_get(dev) == 1);
341 settings.handedness = left_handed? mir_pointer_handedness_left : mir_pointer_handedness_right;
342 if (libinput_device_config_accel_get_profile(dev) == LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT)
343 settings.acceleration = mir_pointer_acceleration_none;
344 else
345 settings.acceleration = mir_pointer_acceleration_adaptive;
346
347 settings.cursor_acceleration_bias = libinput_device_config_accel_get_speed(dev);
345 settings.vertical_scroll_scale = vertical_scroll_scale;348 settings.vertical_scroll_scale = vertical_scroll_scale;
346 settings.horizontal_scroll_scale = horizontal_scroll_scale;349 settings.horizontal_scroll_scale = horizontal_scroll_scale;
347 settings.handedness = left_handed? mir_pointer_handedness_left : mir_pointer_handedness_right;
348 return settings;350 return settings;
349}351}
350352
@@ -354,10 +356,15 @@
354 return;356 return;
355357
356 auto dev = device();358 auto dev = device();
359
360 auto accel_profile = settings.acceleration == mir_pointer_acceleration_adaptive ?
361 LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE :
362 LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
357 libinput_device_config_accel_set_speed(dev, settings.cursor_acceleration_bias);363 libinput_device_config_accel_set_speed(dev, settings.cursor_acceleration_bias);
358 libinput_device_config_left_handed_set(dev, mir_pointer_handedness_left == settings.handedness);364 libinput_device_config_left_handed_set(dev, mir_pointer_handedness_left == settings.handedness);
359 vertical_scroll_scale = settings.vertical_scroll_scale;365 vertical_scroll_scale = settings.vertical_scroll_scale;
360 horizontal_scroll_scale = settings.horizontal_scroll_scale;366 horizontal_scroll_scale = settings.horizontal_scroll_scale;
367 libinput_device_config_accel_set_profile(dev, accel_profile);
361}368}
362369
363mir::optional_value<mi::TouchpadSettings> mie::LibInputDevice::get_touchpad_settings() const370mir::optional_value<mi::TouchpadSettings> mie::LibInputDevice::get_touchpad_settings() const
364371
=== modified file 'src/server/input/default_device.cpp'
--- src/server/input/default_device.cpp 2015-11-04 19:47:19 +0000
+++ src/server/input/default_device.cpp 2016-01-19 22:31:46 +0000
@@ -62,8 +62,9 @@
6262
63 auto const& settings = pointer.value();63 auto const& settings = pointer.value();
6464
65 return PointerConfiguration(settings.handedness, settings.cursor_acceleration_bias,65 return PointerConfiguration(settings.handedness, settings.acceleration,
66 settings.horizontal_scroll_scale, settings.vertical_scroll_scale);66 settings.cursor_acceleration_bias, settings.horizontal_scroll_scale,
67 settings.vertical_scroll_scale);
67}68}
6869
69mir::optional_value<mi::TouchpadConfiguration> mi::DefaultDevice::touchpad_configuration() const70mir::optional_value<mi::TouchpadConfiguration> mi::DefaultDevice::touchpad_configuration() const
@@ -88,6 +89,7 @@
8889
89 PointerSettings settings;90 PointerSettings settings;
90 settings.handedness = conf.handedness;91 settings.handedness = conf.handedness;
92 settings.acceleration = conf.acceleration;
91 settings.cursor_acceleration_bias = conf.cursor_acceleration_bias;93 settings.cursor_acceleration_bias = conf.cursor_acceleration_bias;
92 settings.vertical_scroll_scale = conf.vertical_scroll_scale;94 settings.vertical_scroll_scale = conf.vertical_scroll_scale;
93 settings.horizontal_scroll_scale = conf.horizontal_scroll_scale;95 settings.horizontal_scroll_scale = conf.horizontal_scroll_scale;
9496
=== modified file 'tests/include/mir/test/doubles/mock_libinput.h'
--- tests/include/mir/test/doubles/mock_libinput.h 2016-01-07 11:55:03 +0000
+++ tests/include/mir/test/doubles/mock_libinput.h 2016-01-19 22:31:46 +0000
@@ -121,6 +121,8 @@
121 MOCK_METHOD2(libinput_device_config_accel_set_speed, libinput_config_status(libinput_device*, double speed));121 MOCK_METHOD2(libinput_device_config_accel_set_speed, libinput_config_status(libinput_device*, double speed));
122 MOCK_METHOD1(libinput_device_config_accel_get_speed, double(libinput_device*));122 MOCK_METHOD1(libinput_device_config_accel_get_speed, double(libinput_device*));
123 MOCK_METHOD1(libinput_device_config_accel_get_default_speed, double(libinput_device*));123 MOCK_METHOD1(libinput_device_config_accel_get_default_speed, double(libinput_device*));
124 MOCK_METHOD2(libinput_device_config_accel_set_profile, libinput_config_status(libinput_device*, libinput_config_accel_profile));
125 MOCK_METHOD1(libinput_device_config_accel_get_profile, libinput_config_accel_profile(libinput_device*));
124 MOCK_METHOD1(libinput_device_config_scroll_has_natural_scroll, int(libinput_device*));126 MOCK_METHOD1(libinput_device_config_scroll_has_natural_scroll, int(libinput_device*));
125 MOCK_METHOD2(libinput_device_config_scroll_set_natural_scroll_enabled, libinput_config_status(libinput_device*, int enable));127 MOCK_METHOD2(libinput_device_config_scroll_set_natural_scroll_enabled, libinput_config_status(libinput_device*, int enable));
126 MOCK_METHOD1(libinput_device_config_scroll_get_natural_scroll_enabled, int(libinput_device*));128 MOCK_METHOD1(libinput_device_config_scroll_get_natural_scroll_enabled, int(libinput_device*));
127129
=== modified file 'tests/mir_test_doubles/mock_libinput.cpp'
--- tests/mir_test_doubles/mock_libinput.cpp 2016-01-07 11:55:03 +0000
+++ tests/mir_test_doubles/mock_libinput.cpp 2016-01-19 22:31:46 +0000
@@ -51,6 +51,8 @@
51 .WillByDefault(Return(LIBINPUT_CONFIG_STATUS_SUCCESS));51 .WillByDefault(Return(LIBINPUT_CONFIG_STATUS_SUCCESS));
52 ON_CALL(*this, libinput_device_config_middle_emulation_set_enabled(_, _))52 ON_CALL(*this, libinput_device_config_middle_emulation_set_enabled(_, _))
53 .WillByDefault(Return(LIBINPUT_CONFIG_STATUS_SUCCESS));53 .WillByDefault(Return(LIBINPUT_CONFIG_STATUS_SUCCESS));
54 ON_CALL(*this, libinput_device_config_accel_set_profile(_, _))
55 .WillByDefault(Return(LIBINPUT_CONFIG_STATUS_SUCCESS));
54}56}
5557
56void mtd::MockLibInput::wake()58void mtd::MockLibInput::wake()
@@ -458,6 +460,16 @@
458 return global_libinput->libinput_device_config_accel_get_default_speed(device);460 return global_libinput->libinput_device_config_accel_get_default_speed(device);
459}461}
460462
463libinput_config_status libinput_device_config_accel_set_profile(libinput_device* dev, libinput_config_accel_profile profile)
464{
465 return global_libinput->libinput_device_config_accel_set_profile(dev, profile);
466}
467
468libinput_config_accel_profile libinput_device_config_accel_get_profile(libinput_device* dev)
469{
470 return global_libinput->libinput_device_config_accel_get_profile(dev);
471}
472
461int libinput_device_config_scroll_has_natural_scroll(libinput_device *device)473int libinput_device_config_scroll_has_natural_scroll(libinput_device *device)
462{474{
463 return global_libinput->libinput_device_config_scroll_has_natural_scroll(device);475 return global_libinput->libinput_device_config_scroll_has_natural_scroll(device);
464476
=== modified file 'tests/mir_test_framework/fake_input_device_impl.cpp'
--- tests/mir_test_framework/fake_input_device_impl.cpp 2015-11-25 20:26:59 +0000
+++ tests/mir_test_framework/fake_input_device_impl.cpp 2016-01-19 22:31:46 +0000
@@ -90,6 +90,9 @@
90 std::shared_ptr<mir::dispatch::Dispatchable> const& dispatchable)90 std::shared_ptr<mir::dispatch::Dispatchable> const& dispatchable)
91 : info(info), queue{dispatchable}, buttons{0}91 : info(info), queue{dispatchable}, buttons{0}
92{92{
93 // the default setup results in a direct mapping of input velocity to output velocity.
94 settings.acceleration = mir_pointer_acceleration_none;
95 settings.cursor_acceleration_bias = 0.0;
93}96}
9497
95void mtf::FakeInputDeviceImpl::InputDevice::synthesize_events(synthesis::KeyParameters const& key_params)98void mtf::FakeInputDeviceImpl::InputDevice::synthesize_events(synthesis::KeyParameters const& key_params)
@@ -151,9 +154,9 @@
151 // constant scaling is used here to simplify checking for the154 // constant scaling is used here to simplify checking for the
152 // expected results. Default settings of the device lead to no155 // expected results. Default settings of the device lead to no
153 // scaling at all.156 // scaling at all.
154 auto acceleration = (settings.cursor_acceleration_bias + 1.0);157 auto const acceleration = settings.cursor_acceleration_bias + 1.0;
155 auto rel_x = pointer.rel_x * acceleration;158 auto const rel_x = pointer.rel_x * acceleration;
156 auto rel_y = pointer.rel_y * acceleration;159 auto const rel_y = pointer.rel_y * acceleration;
157160
158 auto pointer_event = builder->pointer_event(event_time,161 auto pointer_event = builder->pointer_event(event_time,
159 mir_pointer_action_motion,162 mir_pointer_action_motion,
@@ -213,7 +216,7 @@
213 if (!contains(info.capabilities, mi::DeviceCapability::pointer))216 if (!contains(info.capabilities, mi::DeviceCapability::pointer))
214 return ret;217 return ret;
215218
216 ret = mi::PointerSettings();219 ret = settings;
217 return ret;220 return ret;
218}221}
219222
220223
=== modified file 'tests/unit-tests/input/evdev/test_libinput_device.cpp'
--- tests/unit-tests/input/evdev/test_libinput_device.cpp 2016-01-07 11:55:03 +0000
+++ tests/unit-tests/input/evdev/test_libinput_device.cpp 2016-01-19 22:31:46 +0000
@@ -208,12 +208,16 @@
208 return device_path;208 return device_path;
209 }209 }
210210
211 void setup_pointer_configuration(libinput_device* dev, double accel_speed, MirPointerHandedness handedness)211 void setup_pointer_configuration(libinput_device* dev, double accel_speed, MirPointerHandedness handedness, MirPointerAcceleration profile)
212 {212 {
213 ON_CALL(mock_libinput, libinput_device_config_accel_get_speed(dev))213 ON_CALL(mock_libinput, libinput_device_config_accel_get_speed(dev))
214 .WillByDefault(Return(accel_speed));214 .WillByDefault(Return(accel_speed));
215 ON_CALL(mock_libinput, libinput_device_config_left_handed_get(dev))215 ON_CALL(mock_libinput, libinput_device_config_left_handed_get(dev))
216 .WillByDefault(Return(handedness == mir_pointer_handedness_left));216 .WillByDefault(Return(handedness == mir_pointer_handedness_left));
217 ON_CALL(mock_libinput, libinput_device_config_accel_get_profile(dev))
218 .WillByDefault(Return((profile == mir_pointer_acceleration_none) ?
219 LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT :
220 LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE));
217 }221 }
218222
219 void setup_touchpad_configuration(libinput_device* dev,223 void setup_touchpad_configuration(libinput_device* dev,
@@ -779,7 +783,7 @@
779783
780TEST_F(LibInputDeviceOnMouse, reads_pointer_settings_from_libinput)784TEST_F(LibInputDeviceOnMouse, reads_pointer_settings_from_libinput)
781{785{
782 setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right);786 setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right, mir_pointer_acceleration_none);
783 auto optional_settings = mouse.get_pointer_settings();787 auto optional_settings = mouse.get_pointer_settings();
784788
785 EXPECT_THAT(optional_settings.is_set(), Eq(true));789 EXPECT_THAT(optional_settings.is_set(), Eq(true));
@@ -789,8 +793,9 @@
789 EXPECT_THAT(ptr_settings.cursor_acceleration_bias, Eq(1.0));793 EXPECT_THAT(ptr_settings.cursor_acceleration_bias, Eq(1.0));
790 EXPECT_THAT(ptr_settings.horizontal_scroll_scale, Eq(1.0));794 EXPECT_THAT(ptr_settings.horizontal_scroll_scale, Eq(1.0));
791 EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0));795 EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0));
796 EXPECT_THAT(ptr_settings.acceleration, Eq(mir_pointer_acceleration_none));
792797
793 setup_pointer_configuration(mouse.device(), 0.0, mir_pointer_handedness_left);798 setup_pointer_configuration(mouse.device(), 0.0, mir_pointer_handedness_left, mir_pointer_acceleration_adaptive);
794 optional_settings = mouse.get_pointer_settings();799 optional_settings = mouse.get_pointer_settings();
795800
796 EXPECT_THAT(optional_settings.is_set(), Eq(true));801 EXPECT_THAT(optional_settings.is_set(), Eq(true));
@@ -800,23 +805,27 @@
800 EXPECT_THAT(ptr_settings.cursor_acceleration_bias, Eq(0.0));805 EXPECT_THAT(ptr_settings.cursor_acceleration_bias, Eq(0.0));
801 EXPECT_THAT(ptr_settings.horizontal_scroll_scale, Eq(1.0));806 EXPECT_THAT(ptr_settings.horizontal_scroll_scale, Eq(1.0));
802 EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0));807 EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0));
808 EXPECT_THAT(ptr_settings.acceleration, Eq(mir_pointer_acceleration_adaptive));
803}809}
804810
805TEST_F(LibInputDeviceOnMouse, applies_pointer_settings)811TEST_F(LibInputDeviceOnMouse, applies_pointer_settings)
806{812{
807 setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right);813 setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right, mir_pointer_acceleration_adaptive);
808 mi::PointerSettings settings(mouse.get_pointer_settings().value());814 mi::PointerSettings settings(mouse.get_pointer_settings().value());
809 settings.cursor_acceleration_bias = 1.1;815 settings.cursor_acceleration_bias = 1.1;
810 settings.handedness = mir_pointer_handedness_left;816 settings.handedness = mir_pointer_handedness_left;
817 settings.acceleration = mir_pointer_acceleration_none;
811818
812 EXPECT_CALL(mock_libinput,libinput_device_config_accel_set_speed(mouse.device(), 1.1)).Times(1);819 EXPECT_CALL(mock_libinput, libinput_device_config_accel_set_speed(mouse.device(), 1.1)).Times(1);
813 EXPECT_CALL(mock_libinput,libinput_device_config_left_handed_set(mouse.device(), true)).Times(1);820 EXPECT_CALL(mock_libinput, libinput_device_config_accel_set_profile(mouse.device(), LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT)).Times(1);
821 EXPECT_CALL(mock_libinput, libinput_device_config_left_handed_set(mouse.device(), true)).Times(1);
814822
815 mouse.apply_settings(settings);823 mouse.apply_settings(settings);
816}824}
817825
818TEST_F(LibInputDeviceOnLaptopKeyboardAndMouse, denies_pointer_settings_on_keyboards)826TEST_F(LibInputDeviceOnLaptopKeyboardAndMouse, denies_pointer_settings_on_keyboards)
819{827{
828 setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right, mir_pointer_acceleration_adaptive);
820 auto settings_from_mouse = mouse.get_pointer_settings();829 auto settings_from_mouse = mouse.get_pointer_settings();
821830
822 EXPECT_CALL(mock_libinput,libinput_device_config_accel_set_speed(_, _)).Times(0);831 EXPECT_CALL(mock_libinput,libinput_device_config_accel_set_speed(_, _)).Times(0);
@@ -834,7 +843,7 @@
834 EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, 3.0f)));843 EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, 3.0f)));
835 EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_hscroll, -10.0f)));844 EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_hscroll, -10.0f)));
836845
837 setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right);846 setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right, mir_pointer_acceleration_none);
838 mi::PointerSettings settings(mouse.get_pointer_settings().value());847 mi::PointerSettings settings(mouse.get_pointer_settings().value());
839 settings.vertical_scroll_scale = -1.0;848 settings.vertical_scroll_scale = -1.0;
840 settings.horizontal_scroll_scale = 5.0;849 settings.horizontal_scroll_scale = 5.0;

Subscribers

People subscribed via source and target branches