swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.33k stars 1.09k forks source link

`input natural_scroll`: New option to only enable for vertical scrolling #8211

Open mrusme opened 2 months ago

mrusme commented 2 months ago

Having become victim to what is dubbed natural scrolling years ago, I have trained my muscle memory into that scrolling behavior. Sway luckily allows me to cope with that using the following configuration:

input "type:pointer" {
  natural_scroll enabled
}

Unfortunately this setting not only inverts the vertical mouse wheel scrolling, but also any horizontal scrolling if available. Contrary to the feature's name, however, that behavior does not feel natural at all -- especially when the horizontal scrolling is performed using a sideways clickable mouse wheel. As a result, pressing the scroll wheel on its left side to the right leads to browser tabs, the text input cursors and scroll bars going all the way to the left.

While I assume that this is how natural scrolling is supposed to work when using an input device with a multi-touch surface, with all mechanical horizontal scrolling methods this feels very off -- at least to me. It would hence be helpful to have a new option for the natural_scroll setting (eg. vertical-only) that would limit the natural scrolling feature to only vertical scrolling.

I would appreciate any thoughts on this!

tarcisioe commented 1 month ago

For what I get from libinput's evdev.c, natural scrolling will always invert both axes. However, there seems to be an internal flag that triggers inverting just the horizontal axis, as can be seen some lines above. Unfortunately, I wasn't able to find an option that triggers that flag, only a model quirk seems to be able to do that.

In any case, there isn't much that can be done in Sway if libinput doesn't provide the right option. You will likely need to request either a configurable option for this there, or see if there is a way to register your device as having the "quirk" that requires it to get the horizontal axis flipped. I don't know how the quirks system works, however, so this may or may not be something a user can easily add or change, you'll need to check.

Edit: it seems you can add quirks locally, however the quirks database is part of libinput and there is no guarantee that what you add will work forever: https://wayland.freedesktop.org/libinput/doc/latest/device-quirks.html. I don't believe your case could be upstreamed, since the device itself works as expected and the axis only needs to be flipped because of natural scrolling being enabled by you. However this can be a temporary workaround for your use case.

mrusme commented 1 month ago

@tarcisioe thank you very much for this in-depth reply, this is super helpful! I understood that there's little Sway can do here, unless libinput will provide an option to make this configurable. I have hence created an issue in libinput: https://gitlab.freedesktop.org/libinput/libinput/-/issues/1019

Let's see what libinput developers think or if they might have another solution to this issue. I'm going to leave this issue open (if nobody minds) until hearing back from the libinput devs.